title: “Lavaan School Study Regression”
author: “Levi Brackman”
date: “November 12, 2016”
output: html_document
Loading required package: lavaan
This is lavaan 0.5-20
lavaan is BETA software! Please report any bugs.
 
###############################################################################
This is semTools 0.4-12
All users of R (or SEM) are invited to submit functions or ideas for functions.
###############################################################################

Attaching package: 'dplyr'
The following objects are masked from 'package:plyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Attaching package: 'purrr'
The following objects are masked from 'package:dplyr':

    contains, order_by
The following object is masked from 'package:plyr':

    compact

Read-in the dataset

Read in pre and post data from Cranbrook

setwd("/Users/levibrackman/Documents/stats_march_2016/Schools Study")
CranReddam<-read.csv("Three_Group_Means_W-Dummy_July_15_2016.csv")
dim(CranReddam)
## [1] 221  49
library(dplyr)
#View(CranReddam)

# Correlations with significance levels
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
## 
##     combine, src, summarize
## The following objects are masked from 'package:plyr':
## 
##     is.discrete, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, round.POSIXt, trunc.POSIXt, units
require(Rcmdr)
## Loading required package: Rcmdr
## Loading required package: splines
## Loading required package: RcmdrMisc
## Loading required package: car
## 
## Attaching package: 'car'
## The following object is masked from 'package:purrr':
## 
##     some
## The following object is masked from 'package:dplyr':
## 
##     recode
## Loading required package: sandwich
## 
## Attaching package: 'RcmdrMisc'
## The following object is masked from 'package:Hmisc':
## 
##     Dotplot
## The following object is masked from 'package:semTools':
## 
##     reliability
## The Commander GUI is launched only in interactive sessions
#options(scipen=999)


#Creat interaction effect veriable for each group
#View(CranReddam)
#names(CranReddam)

#indProd(CranReddam, "MLQ_1", "GROUP1")

#############################################
####     Creating a function to make the ### 
####     interaction terms               ###
############################################

#meanallinteraction<- function(dataset, inter, veriable1, group){
#part1<-noquote(paste0(dataset, "$", "GROUP", inter, collapse = "")) 
#part2<-noquote(paste0("scale","(",dataset, "$", veriable1,")", collapse = ""))
#part3<- noquote(paste0(dataset, "$", group, collapse = ""))
#final<-noquote(paste0(part1,"<-", part2,"*",part3, collapse = ""))
#final
#}

         
#meanallinteraction("CranReddam", "APSI_FG_1", "APSI_FG_1", "GROUP1")
#meanallinteraction("CranReddam", "APSI_FN_1", "APSI_FN_1", "GROUP1")

#meanallinteraction("CranReddam", "SelfEsteem_1", "SelfEsteem_1", "GROUP1")

#meanallinteraction("CranReddam", "MLQP_1", "MLQ_1", "GROUP1")
#meanallinteraction("CranReddam", "MLQS_1", "MLQS_1", "GROUP1")
#meanallinteraction("CranReddam", "PERMA_Happy", "PERMA_Happy_1", "GROUP1")
#meanallinteraction("CranReddam", "PERMA_Lonely", "PERMA_Lonely_1", "GROUP1")
#meanallinteraction("CranReddam", "GRIT", "GRIT_1", "GROUP1")
#meanallinteraction("CranReddam", "Res", "Res_1", "GROUP1")
#meanallinteraction("CranReddam", "APSI", "PurposeAPSI_1", "GROUP1")
#meanallinteraction("CranReddam", "PWB", "PurposePWB_1", "GROUP1")
#meanallinteraction("CranReddam", "Optimism", "Optimism_1", "GROUP1")
#meanallinteraction("CranReddam", "LS", "LifeSatisfaction_1", "GROUP1")
#meanallinteraction("CranReddam", "LET", "LifeEngagement_1", "GROUP1")
#meanallinteraction("CranReddam", "PermaEngagement", "Engagement_1", "GROUP1")
#meanallinteraction("CranReddam", "Rrealtionships", "Relationships_1", "GROUP1")
#meanallinteraction("CranReddam", "Nagative", "Negative_1", "GROUP1")
#meanallinteraction("CranReddam", "Acheivement", "Acheivement_1", "GROUP1")
#meanallinteraction("CranReddam", "Positive", "Positive_1", "GROUP1")
#meanallinteraction("CranReddam", "NewPurpose", "NewPurpose_1", "GROUP1")

##Interaction terms


 
CranReddam$GROUPMLQ_1<-scale(CranReddam$MLQ_1) 
CranReddam$GROUPMLQ_2<-scale(CranReddam$MLQ_1) 

CranReddam<-indProd(CranReddam, "APSI_FG_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "APSI_FN_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)

CranReddam<-indProd(CranReddam, "MLQ_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "MLQS_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "Happiness_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "Grit_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "PurposeAPSI_No36_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "PurposePWB_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)

CranReddam<-indProd(CranReddam, "Optimism_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "LifeSatisfaction_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "LifeEngagement_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "NewPurpose_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "EnglishSC_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "MathSC_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "SciencSC_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "GeneralAcademic_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "SelfEsteem_1", "GROUP2", match = TRUE, meanC = TRUE, doubleMC = FALSE)


CranReddam<-indProd(CranReddam, "APSI_FG_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "APSI_FN_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "SelfEsteem_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)

CranReddam<-indProd(CranReddam, "MLQ_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "MLQS_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "Happiness_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "Grit_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "PurposeAPSI_No36_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "PurposePWB_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)

CranReddam<-indProd(CranReddam, "Optimism_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "LifeSatisfaction_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "LifeEngagement_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "NewPurpose_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "EnglishSC_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "MathSC_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "SciencSC_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)
CranReddam<-indProd(CranReddam, "GeneralAcademic_1", "GROUP1", match = TRUE, meanC = TRUE, doubleMC = FALSE)


#Scale ther rest
CranReddam$SCALED_1_APSI_FN<-scale(CranReddam$APSI_FN_1)

CranReddam$SCALED_1_APSI_FG<-scale(CranReddam$APSI_FG_1)
CranReddam$SCALED_1_SelfEsteem<-scale(CranReddam$SelfEsteem_1)
CranReddam$SCALED_1_MLQP<-scale(CranReddam$MLQ_1) 
CranReddam$SCALED_1_MLQS<-scale(CranReddam$MLQS_1) 
CranReddam$SCALED_1_Happy<-scale(CranReddam$Happiness_1) 
CranReddam$SCALED_1_Res<-scale(CranReddam$Grit_1) 
CranReddam$SCALED_1_APSI<-scale(CranReddam$PurposeAPSI_No36_1) 
CranReddam$SCALED_1_PWB<-scale(CranReddam$PurposePWB_1) 
CranReddam$SCALED_1_Optimism<-scale(CranReddam$Optimism_1) 
CranReddam$SCALED_1_LS<-scale(CranReddam$LifeSatisfaction_1) 
CranReddam$SCALED_1_LET<-scale(CranReddam$LifeEngagement_1) 
CranReddam$SCALED_1_EnglishSC<-scale(CranReddam$EnglishSC_1) 
CranReddam$SCALED_1_SciencSC<-scale(CranReddam$SciencSC_1) 
CranReddam$SCALED_1_MathSC<-scale(CranReddam$MathSC_1) 
CranReddam$SCALED_1_EnglishSC<-scale(CranReddam$EnglishSC_1) 
CranReddam$SCALED_1_GeneralAcademic<-scale(CranReddam$GeneralAcademic_1) 
CranReddam$SCALED_1_NewPurpose<-scale(CranReddam$NewPurpose_1) 
#Scale 2
CranReddam$SCALED_2_APSI_FN<-scale(CranReddam$APSI_FN_2)
CranReddam$SCALED_2_APSI_FG<-scale(CranReddam$APSI_FG_2)
CranReddam$SCALED_2_SelfEsteem<-scale(CranReddam$SelfEsteem_2)
CranReddam$SCALED_2_MLQP<-scale(CranReddam$MLQ_2) 
CranReddam$SCALED_2_MLQS<-scale(CranReddam$MLQS_2) 
CranReddam$SCALED_2_Happy<-scale(CranReddam$Happiness_2) 
CranReddam$SCALED_2_Res<-scale(CranReddam$Grit_2) 
CranReddam$SCALED_2_APSI<-scale(CranReddam$PurposeAPSI_No36_2) 
CranReddam$SCALED_2_PWB<-scale(CranReddam$PurposePWB_2) 
CranReddam$SCALED_2_Optimism<-scale(CranReddam$Optimism_2) 
CranReddam$SCALED_2_LS<-scale(CranReddam$LifeSatisfaction_2) 
CranReddam$SCALED_2_LET<-scale(CranReddam$LifeEngagement_2) 
CranReddam$SCALED_2_EnglishSC<-scale(CranReddam$EnglishSC_2) 
CranReddam$SCALED_2_SciencSC<-scale(CranReddam$SciencSC_2) 
CranReddam$SCALED_2_MathSC<-scale(CranReddam$MathSC_2) 
CranReddam$SCALED_2_EnglishSC<-scale(CranReddam$EnglishSC_2) 
CranReddam$SCALED_2_GeneralAcademic<-scale(CranReddam$GeneralAcademic_2) 
CranReddam$SCALED_2_NewPurpose<-scale(CranReddam$NewPurpose_2)


library(tibble)
## 
## Attaching package: 'tibble'
## The following object is masked from 'package:dplyr':
## 
##     tbl_df
library(tidyr)
#View(CranReddam)

You can also embed plots, for example:

Functions for tables and interactions

#Coefficient Table Function

FitTableYouth<-function(fitname, interactionterm1, interactionterm2, current_scale_name, new_scale_name){
  #Function to round numbers in a df
  round_df<-function(df, num){nums<-map_lgl(df, is.numeric);df[,nums]<-round(df[,nums],num);(df)}
  lolollol<-(parameterEstimates(fitname)) 
  lolollol<-round_df(lolollol, 2)
lolollol$CI<-paste(lolollol$ci.lower, lolollol$ci.upper, sep = ", ")
    lolollol<-select(lolollol, rhs, est, se, z, pvalue, CI)
    lolollol<-slice(lolollol, c(22, 1:5))
    lolollol<-rename(lolollol, Item = rhs, β = est, SE = se, p = pvalue, "90% CI" = CI)
  lolollol[1,1] <- sprintf('Intercept', lolollol[1,1])
  lolollol[,1]<-gsub("SCALED_1_", "", lolollol[,1])
  lolollol[,1]<-gsub("SCALED_2_", "", lolollol[,1])
  lolollol[,1]<-gsub(interactionterm1, "Interaction w/ Group 1", lolollol[,1])
  lolollol[,1]<-gsub(interactionterm2, "Interaction w/ Group 2", lolollol[,1])
  lolollol[,1]<-gsub(current_scale_name, new_scale_name, lolollol[,1])
  lolollol
}



#Interaction Plot Function

PlotInterYouth<-function(fitname, PlotTitle){
fit<-(parameterEstimates(fitname)) 
Treat=1
Control=0
Group0 <-fit[22,4]
Group1<- fit[1,4]
Group2<- fit[2,4]
T1 = fit[3,4]
interaction1 = fit[4,4]
interaction2 = fit[5,4]
TreatHighT2 =  Group0 + T1*1 + Group2*Treat + interaction2*1*Treat
TreatMediumT2 =  Group0 + T1*0 + Group2*Treat + interaction2*0*Treat
TreatLowT2 =  Group0 + T1*-1 + Group2*Treat + interaction2*-1*Treat
ControlHighT2 =  Group0 + T1*1 + Group2*Control + interaction2*1*Control
ControlMediumT2 =  Group0 + T1*0 + Group2*Control + interaction2*0*Control
ControlLowT2 =  Group0 + T1*-1 + Group2*Control + interaction2*-1*Control
#Group 1
RedTreatHighT2 =  Group0 + T1*1 + Group1 + interaction1*1
RedTreatMediumT2 =  Group0 + T1*0 + Group1 + interaction1*0
RedTreatT2 =  Group0 + T1*-1 + Group1 + interaction1*-1
Treat_T2 = c(TreatLowT2, TreatMediumT2, TreatHighT2)
Control_T2 = c(ControlLowT2, ControlMediumT2, ControlHighT2)
RedTreat  = c(RedTreatT2, RedTreatMediumT2, RedTreatHighT2)
levels = c("-1","0","1")
fdsd<-data.frame(levels, Treat_T2,Control_T2, RedTreat)
Plot1<-ggplot(fdsd, aes(levels)) + 
  geom_line(aes(levels, Treat_T2, group = 1,  colour = "Treatment 2 (Cran)")) + 
  geom_line(aes(levels, Control_T2, group = 1,  colour = "Control (Redd)")) +
  geom_line(aes(levels, RedTreat, group = 1,  colour = "Treatment 1 (Redd)")) +
  labs(list(title = PlotTitle, x = "Levels Pre in SD", y="Levels Post in SD", colour = "Lines" ))
Plot1
}

fitname<-sem(modelYNewPurpose_interaction, CranReddam, missing='fiml', meanstructure=TRUE,fixed.x=T) 
## Found more than one class "Model" in cache; using the first, from namespace 'lavaan'
summary(fitname)
## lavaan (0.5-20) converged normally after  26 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                         Estimate  Std.Err  Z-value  P(>|z|)
##   SCALED_2_NewPurpose ~                                    
##     GROUP1                 0.354    0.255    1.388    0.165
##     GROUP2                 0.138    0.190    0.729    0.466
##     SCALED_1_NwPrp         0.572    0.071    8.022    0.000
##     NwPrp_1.GROUP1        -0.086    0.341   -0.252    0.801
##     NwPrp_1.GROUP2        -0.453    0.211   -2.149    0.032
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)
##     SCALED_2_NwPrp   -0.132    0.170   -0.776    0.438
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)
##     SCALED_2_NwPrp    0.637    0.077    8.298    0.000
#SimpleSlopes Function

SimpleSlopesYouth<-function(fitname){
fit<-(parameterEstimates(fitname)) 
Treat=1
Control=0
Group0 <-fit[22,4]
Group1<- fit[1,4]
Group2<- fit[2,4]
T1 = fit[3,4]
interaction1 = fit[4,4]
interaction2 = fit[5,4]
TreatHighT2 =  Group0 + T1*1 + Group2*Treat + interaction2*1*Treat
TreatMediumT2 =  Group0 + T1*0 + Group2*Treat + interaction2*0*Treat
TreatLowT2 =  Group0 + T1*-1 + Group2*Treat + interaction2*-1*Treat
ControlHighT2 =  Group0 + T1*1 
ControlMediumT2 =  Group0 + T1*0 
ControlLowT2 =  Group0 + T1*-1 
#Group 1
RedTreatHighT2 =  Group0 + T1*1 + Group1 + interaction1*1
RedTreatMediumT2 =  Group0 + T1*0 + Group1 + interaction1*0
RedTreatT2 =  Group0 + T1*-1 + Group1 + interaction1*-1
Treat_T2 = c(TreatLowT2, TreatMediumT2, TreatHighT2)
Control_T2 = c(ControlLowT2, ControlMediumT2, ControlHighT2)
RedTreat  = c(RedTreatT2, RedTreatMediumT2, RedTreatHighT2)
levels = c("-1","0","1")
fdsd<-data.frame(levels, Treat_T2,Control_T2, RedTreat)
round_df<-function(df, num){nums<-map_lgl(df, is.numeric);df[,nums]<-round(df[,nums],num);(df)}
round_df(fdsd,2)}

#Results Function - Contains Fits, Coefficiants Table and SimpleSlopes Table

resultsYouth<-function(modelname, fitname, data, interactionterm1, interactionterm2, current_scale_name, new_scale_name){
fitname<-sem(modelname, data, missing='fiml', meanstructure=TRUE,fixed.x=T) 
fits<- summary(fitname,fit.measures=TRUE,rsquare=TRUE,standardize=T)  
table<-FitTableYouth(fitname, interactionterm1, interactionterm2, current_scale_name, new_scale_name)
slopes<-SimpleSlopesYouth(fitname)
all<-list((table), (slopes))
all
}

#Plots Function

plotsYouth<-function(modelname, fitname, data,  new_scale_name){
fitname<-sem(modelname, data, missing='fiml', meanstructure=TRUE,fixed.x=T)  
PlotInterYouth(fitname, new_scale_name)
}

Fits

#########################################
#################  New Purpose  ###########
#########################################
 
resultsYouth(modelname = modelYNewPurpose_interaction, fitname = NewPurposeFit, data = CranReddam, interactionterm1 = "NewPurpose_1.GROUP1", interactionterm2 = "NewPurpose_1.GROUP2", current_scale_name = "NewPurpose", new_scale_name = "New Purpose Scale")
## lavaan (0.5-20) converged normally after  26 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               60.967
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -733.444
##   Loglikelihood unrestricted model (H1)       -733.444
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1480.888
##   Bayesian (BIC)                              1504.676
##   Sample-size adjusted Bayesian (BIC)         1482.492
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                         Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_NewPurpose ~                                             
##     GROUP1                 0.354    0.255    1.388    0.165    0.354
##     GROUP2                 0.138    0.190    0.729    0.466    0.138
##     SCALED_1_NwPrp         0.572    0.071    8.022    0.000    0.572
##     NwPrp_1.GROUP1        -0.086    0.341   -0.252    0.801   -0.086
##     NwPrp_1.GROUP2        -0.453    0.211   -2.149    0.032   -0.453
##   Std.all
##          
##     0.132
##     0.065
##     0.570
##    -0.024
##    -0.173
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_NwPrp   -0.132    0.170   -0.776    0.438   -0.132   -0.132
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_NwPrp    0.637    0.077    8.298    0.000    0.637    0.638
## 
## R-Square:
##                    Estimate
##     SCALED_2_NwPrp    0.362
## [[1]]
##                     Item     β   SE     z    p       90% CI
## 1              Intercept -0.13 0.17 -0.78 0.44   -0.47, 0.2
## 2                 GROUP1  0.35 0.26  1.39 0.17  -0.15, 0.85
## 3                 GROUP2  0.14 0.19  0.73 0.47  -0.23, 0.51
## 4      New Purpose Scale  0.57 0.07  8.02 0.00   0.43, 0.71
## 5 Interaction w/ Group 1 -0.09 0.34 -0.25 0.80  -0.75, 0.58
## 6 Interaction w/ Group 2 -0.45 0.21 -2.15 0.03 -0.87, -0.04
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.11      -0.70    -0.26
## 2      0     0.01      -0.13     0.22
## 3      1     0.12       0.44     0.71
plotsYouth(modelname = modelYNewPurpose_interaction, fitname = NewPurposeFit, data = CranReddam,  new_scale_name = "New Purpose")

#########################################
#################  MLQP  #################
#########################################

resultsYouth(modelname = modelYMLQP_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "MLQ_1.GROUP1", interactionterm2 = "MLQ_1.GROUP2", current_scale_name = "MLQP", new_scale_name = "MLQ-P T1")
## lavaan (0.5-20) converged normally after  25 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               68.986
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -922.511
##   Loglikelihood unrestricted model (H1)       -922.511
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1859.023
##   Bayesian (BIC)                              1882.810
##   Sample-size adjusted Bayesian (BIC)         1860.626
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_MLQP ~                                                       
##     GROUP1            0.419    0.256    1.634    0.102    0.419    0.155
##     GROUP2            0.221    0.199    1.112    0.266    0.221    0.104
##     SCALED_1_MLQP     0.619    0.069    8.967    0.000    0.619    0.612
##     MLQ_1.GROUP1     -0.096    0.204   -0.469    0.639   -0.096   -0.044
##     MLQ_1.GROUP2     -0.327    0.152   -2.145    0.032   -0.327   -0.192
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MLQP    -0.209    0.181   -1.155    0.248   -0.209   -0.207
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MLQP     0.601    0.072    8.294    0.000    0.601    0.592
## 
## R-Square:
##                    Estimate
##     SCALED_2_MLQP     0.408
## [[1]]
##                     Item     β   SE     z    p       90% CI
## 1              Intercept -0.21 0.18 -1.16 0.25  -0.56, 0.15
## 2                 GROUP1  0.42 0.26  1.63 0.10  -0.08, 0.92
## 3                 GROUP2  0.22 0.20  1.11 0.27  -0.17, 0.61
## 4               MLQ-P T1  0.62 0.07  8.97 0.00   0.48, 0.75
## 5 Interaction w/ Group 1 -0.10 0.20 -0.47 0.64    -0.5, 0.3
## 6 Interaction w/ Group 2 -0.33 0.15 -2.15 0.03 -0.63, -0.03
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.28      -0.83    -0.31
## 2      0     0.01      -0.21     0.21
## 3      1     0.30       0.41     0.73
plotsYouth(modelname = modelYMLQP_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "MLQ - P (Steger)")

#########################################
#################  MLQS #################
#########################################

resultsYouth(modelname = modelYMLQS_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "MLQS_1.GROUP1", interactionterm2 = "MLQS_1.GROUP2", current_scale_name = "MLQS", new_scale_name = "MLQ-S T1")
## lavaan (0.5-20) converged normally after  23 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               21.829
##   Degrees of freedom                                 5
##   P-value                                        0.001
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1010.935
##   Loglikelihood unrestricted model (H1)      -1010.935
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                2035.870
##   Bayesian (BIC)                              2059.657
##   Sample-size adjusted Bayesian (BIC)         2037.474
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_MLQS ~                                                       
##     GROUP1           -0.016    0.294   -0.056    0.956   -0.016   -0.006
##     GROUP2           -0.294    0.221   -1.332    0.183   -0.294   -0.139
##     SCALED_1_MLQS     0.324    0.082    3.956    0.000    0.324    0.322
##     MLQS_1.GROUP1     0.398    0.194    2.056    0.040    0.398    0.217
##     MLQS_1.GROUP2     0.189    0.163    1.158    0.247    0.189    0.123
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MLQS     0.225    0.200    1.125    0.261    0.225    0.224
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MLQS     0.846    0.102    8.293    0.000    0.846    0.842
## 
## R-Square:
##                    Estimate
##     SCALED_2_MLQS     0.158
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.22 0.20  1.12 0.26 -0.17, 0.62
## 2                 GROUP1 -0.02 0.29 -0.06 0.96 -0.59, 0.56
## 3                 GROUP2 -0.29 0.22 -1.33 0.18 -0.73, 0.14
## 4               MLQ-S T1  0.32 0.08  3.96 0.00  0.16, 0.48
## 5 Interaction w/ Group 1  0.40 0.19  2.06 0.04  0.02, 0.78
## 6 Interaction w/ Group 2  0.19 0.16  1.16 0.25 -0.13, 0.51
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.58      -0.10    -0.51
## 2      0    -0.07       0.22     0.21
## 3      1     0.44       0.55     0.93
plotsYouth(modelname = modelYMLQS_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "MLQ - S (Steger)")

#########################################
##############  Happiness ###############
#########################################

   
resultsYouth(modelname = modelYHappiness_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "Happiness_1.GROUP1", interactionterm2 = "Happiness_1.GROUP2", current_scale_name = "Happy", new_scale_name = "Subjective Happiness T1")
## lavaan (0.5-20) converged normally after  27 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               38.764
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -713.819
##   Loglikelihood unrestricted model (H1)       -713.819
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1441.639
##   Bayesian (BIC)                              1465.426
##   Sample-size adjusted Bayesian (BIC)         1443.243
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_Happy ~                                                      
##     GROUP1            0.015    0.279    0.053    0.958    0.015    0.006
##     GROUP2           -0.083    0.215   -0.385    0.700   -0.083   -0.040
##     SCALED_1_Happy    0.477    0.074    6.488    0.000    0.477    0.484
##     Hppns_1.GROUP1    0.286    0.361    0.793    0.428    0.286    0.086
##     Hppns_1.GROUP2    0.265    0.285    0.931    0.352    0.265    0.098
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Happy    0.059    0.196    0.299    0.765    0.059    0.059
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Happy    0.730    0.090    8.130    0.000    0.730    0.751
## 
## R-Square:
##                    Estimate
##     SCALED_2_Happy    0.249
## [[1]]
##                      Item     β   SE     z    p      90% CI
## 1               Intercept  0.06 0.20  0.30 0.77 -0.33, 0.44
## 2                  GROUP1  0.01 0.28  0.05 0.96 -0.53, 0.56
## 3                  GROUP2 -0.08 0.21 -0.38 0.70  -0.5, 0.34
## 4 Subjective Happiness T1  0.48 0.07  6.49 0.00  0.33, 0.62
## 5  Interaction w/ Group 1  0.29 0.36  0.79 0.43 -0.42, 0.99
## 6  Interaction w/ Group 2  0.27 0.28  0.93 0.35 -0.29, 0.82
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.77      -0.42    -0.69
## 2      0    -0.02       0.06     0.07
## 3      1     0.72       0.54     0.84
plotsYouth(modelname = modelYHappiness_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Subjective Happiness")

#########################################
############## Science SC ###############
#########################################
   
resultsYouth(modelname = modelYScienceSC_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "SciencSC_1.GROUP1", interactionterm2 = "SciencSC_1.GROUP2", current_scale_name = "SciencSC", new_scale_name = "Science Self Concept T1")
## lavaan (0.5-20) converged normally after  21 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         2
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic              110.548
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -934.264
##   Loglikelihood unrestricted model (H1)       -934.264
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1882.529
##   Bayesian (BIC)                              1906.316
##   Sample-size adjusted Bayesian (BIC)         1884.133
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                       Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_SciencSC ~                                             
##     GROUP1               0.054    0.211    0.254    0.800    0.054
##     GROUP2              -0.103    0.160   -0.645    0.519   -0.103
##     SCALED_1_ScnSC       0.825    0.065   12.632    0.000    0.825
##     ScnSC_1.GROUP1      -0.187    0.183   -1.023    0.306   -0.187
##     ScnSC_1.GROUP2      -0.086    0.134   -0.644    0.519   -0.086
##   Std.all
##          
##     0.019
##    -0.046
##     0.782
##    -0.090
##    -0.049
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_ScnSC    0.011    0.144    0.073    0.942    0.011    0.010
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_ScnSC    0.446    0.054    8.307    0.000    0.446    0.402
## 
## R-Square:
##                    Estimate
##     SCALED_2_ScnSC    0.598
## [[1]]
##                      Item     β   SE     z    p      90% CI
## 1               Intercept  0.01 0.14  0.07 0.94 -0.27, 0.29
## 2                  GROUP1  0.05 0.21  0.25 0.80 -0.36, 0.47
## 3                  GROUP2 -0.10 0.16 -0.64 0.52 -0.42, 0.21
## 4 Science Self Concept T1  0.82 0.07 12.63 0.00   0.7, 0.95
## 5  Interaction w/ Group 1 -0.19 0.18 -1.02 0.31 -0.55, 0.17
## 6  Interaction w/ Group 2 -0.09 0.13 -0.64 0.52 -0.35, 0.18
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.83      -0.81    -0.57
## 2      0    -0.09       0.01     0.06
## 3      1     0.65       0.84     0.70
plotsYouth(modelname = modelYScienceSC_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Science Self Concept (Marsh)")                                                                         

#########################################
############## EnglishSC_1 ##############
#########################################

resultsYouth(modelname = modelYEnglishSC_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "EnglishSC_1.GROUP1", interactionterm2 = "EnglishSC_1.GROUP2", current_scale_name = "EnglishSC", new_scale_name = "English Self Concept T1")
## lavaan (0.5-20) converged normally after  22 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         2
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic              108.914
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -814.083
##   Loglikelihood unrestricted model (H1)       -814.083
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1642.166
##   Bayesian (BIC)                              1665.953
##   Sample-size adjusted Bayesian (BIC)         1643.770
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                        Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_EnglishSC ~                                             
##     GROUP1                0.143    0.226    0.633    0.527    0.143
##     GROUP2                0.082    0.178    0.461    0.645    0.082
##     SCALED_1_EngSC        0.715    0.059   12.171    0.000    0.715
##     EngSC_1.GROUP1       -0.083    0.213   -0.390    0.696   -0.083
##     EngSC_1.GROUP2       -0.079    0.162   -0.486    0.627   -0.079
##   Std.all
##          
##     0.055
##     0.040
##     0.731
##    -0.034
##    -0.039
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_EngSC   -0.027    0.163   -0.164    0.870   -0.027   -0.027
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_EngSC    0.451    0.054    8.307    0.000    0.451    0.474
## 
## R-Square:
##                    Estimate
##     SCALED_2_EngSC    0.526
## [[1]]
##                      Item     β   SE     z    p      90% CI
## 1               Intercept -0.03 0.16 -0.16 0.87 -0.35, 0.29
## 2                  GROUP1  0.14 0.23  0.63 0.53  -0.3, 0.59
## 3                  GROUP2  0.08 0.18  0.46 0.65 -0.27, 0.43
## 4 English Self Concept T1  0.72 0.06 12.17 0.00   0.6, 0.83
## 5  Interaction w/ Group 1 -0.08 0.21 -0.39 0.70  -0.5, 0.33
## 6  Interaction w/ Group 2 -0.08 0.16 -0.49 0.63  -0.4, 0.24
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.58      -0.74    -0.52
## 2      0     0.06      -0.03     0.12
## 3      1     0.69       0.69     0.75
plotsYouth(modelname = modelYEnglishSC_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "English Self Concept (Marsh)")

#########################################
################ Math SC ################
#########################################
resultsYouth(modelname = modelYMathSC_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "MathSC_1.GROUP1", interactionterm2 = "MathSC_1.GROUP2", current_scale_name = "MathSC", new_scale_name = "Math Self Concept T1")
## lavaan (0.5-20) converged normally after  22 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         2
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic              129.253
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -900.720
##   Loglikelihood unrestricted model (H1)       -900.720
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1815.441
##   Bayesian (BIC)                              1839.228
##   Sample-size adjusted Bayesian (BIC)         1817.045
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                     Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_MathSC ~                                                      
##     GROUP1             0.032    0.231    0.139    0.890    0.032    0.012
##     GROUP2            -0.120    0.146   -0.823    0.411   -0.120   -0.056
##     SCALED_1_MthSC     0.800    0.067   12.007    0.000    0.800    0.787
##     MthSC_1.GROUP1    -0.151    0.253   -0.598    0.550   -0.151   -0.069
##     MthSC_1.GROUP2    -0.069    0.142   -0.487    0.626   -0.069   -0.039
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MthSC    0.040    0.131    0.307    0.759    0.040    0.040
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_MthSC    0.389    0.047    8.307    0.000    0.389    0.378
## 
## R-Square:
##                    Estimate
##     SCALED_2_MthSC    0.622
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.04 0.13  0.31 0.76  -0.22, 0.3
## 2                 GROUP1  0.03 0.23  0.14 0.89 -0.42, 0.48
## 3                 GROUP2 -0.12 0.15 -0.82 0.41 -0.41, 0.17
## 4   Math Self Concept T1  0.80 0.07 12.01 0.00  0.67, 0.93
## 5 Interaction w/ Group 1 -0.15 0.25 -0.60 0.55 -0.65, 0.34
## 6 Interaction w/ Group 2 -0.07 0.14 -0.49 0.63 -0.35, 0.21
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.81      -0.76    -0.58
## 2      0    -0.08       0.04     0.07
## 3      1     0.65       0.84     0.72
plotsYouth(modelname = modelYEnglishSC_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Math Self Concept (Marsh)")

#########################################
########## General Academic SC ##########
#########################################
 
resultsYouth(modelname = modelYGASC_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "GeneralAcademic_1.GROUP1", interactionterm2 = "GeneralAcademic_1.GROUP2", current_scale_name = "GeneralAcademicSC", new_scale_name = "General Academic Self Concept T1")
## lavaan (0.5-20) converged normally after  22 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         2
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               96.733
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -768.443
##   Loglikelihood unrestricted model (H1)       -768.443
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1550.887
##   Bayesian (BIC)                              1574.674
##   Sample-size adjusted Bayesian (BIC)         1552.491
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                              Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_GeneralAcademic ~                                             
##     GROUP1                     -0.055    0.218   -0.252    0.801   -0.055
##     GROUP2                     -0.101    0.163   -0.618    0.536   -0.101
##     SCALED_1_GnrlA              0.776    0.066   11.742    0.000    0.776
##     GnrlA_1.GROUP1              0.437    0.283    1.547    0.122    0.437
##     GnrlA_1.GROUP2              0.009    0.207    0.043    0.965    0.009
##   Std.all
##          
##    -0.019
##    -0.045
##     0.727
##     0.136
##     0.003
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_GnrlA    0.051    0.147    0.350    0.726    0.051    0.048
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_GnrlA    0.493    0.059    8.307    0.000    0.493    0.434
## 
## R-Square:
##                    Estimate
##     SCALED_2_GnrlA    0.566
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.05 0.15  0.35 0.73 -0.24, 0.34
## 2                 GROUP1 -0.06 0.22 -0.25 0.80 -0.48, 0.37
## 3                 GROUP2 -0.10 0.16 -0.62 0.54 -0.42, 0.22
## 4        GeneralAcademic  0.78 0.07 11.74 0.00  0.65, 0.91
## 5 Interaction w/ Group 1  0.44 0.28  1.55 0.12 -0.12, 0.99
## 6 Interaction w/ Group 2  0.01 0.21  0.04 0.97  -0.4, 0.41
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.84      -0.73    -1.22
## 2      0    -0.05       0.05     0.00
## 3      1     0.74       0.83     1.21
plotsYouth(modelname = modelYGASC_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "General Academic Self Concept")

#########################################
#################  LET  #################
#########################################
   
resultsYouth(modelname = modelYLET_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "LET_1.GROUP1", interactionterm2 = "LET_1.GROUP2", current_scale_name = "LET", new_scale_name = "Life Engagement T1")
## lavaan (0.5-20) converged normally after  27 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               61.733
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -648.250
##   Loglikelihood unrestricted model (H1)       -648.250
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1310.500
##   Bayesian (BIC)                              1334.287
##   Sample-size adjusted Bayesian (BIC)         1312.104
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_LET ~                                                        
##     GROUP1           -0.573    0.253   -2.267    0.023   -0.573   -0.214
##     GROUP2           -0.168    0.187   -0.897    0.370   -0.168   -0.079
##     SCALED_1_LET      0.601    0.069    8.691    0.000    0.601    0.599
##     LfEng_1.GROUP1   -0.104    0.396   -0.263    0.793   -0.104   -0.025
##     LfEng_1.GROUP2   -0.420    0.297   -1.411    0.158   -0.420   -0.130
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_LET      0.257    0.167    1.539    0.124    0.257    0.257
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_LET      0.631    0.076    8.274    0.000    0.631    0.630
## 
## R-Square:
##                    Estimate
##     SCALED_2_LET      0.370
## [[1]]
##                      Item     β   SE     z    p       90% CI
## 1               Intercept  0.26 0.17  1.54 0.12  -0.07, 0.59
## 2                  GROUP1 -0.57 0.25 -2.27 0.02 -1.07, -0.08
## 3                  GROUP2 -0.17 0.19 -0.90 0.37   -0.53, 0.2
## 4      Life Engagement T1  0.60 0.07  8.69 0.00   0.47, 0.74
## 5 LifeEngagement_1.GROUP1 -0.10 0.40 -0.26 0.79  -0.88, 0.67
## 6 LifeEngagement_1.GROUP2 -0.42 0.30 -1.41 0.16     -1, 0.16
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.09      -0.34    -0.81
## 2      0     0.09       0.26    -0.32
## 3      1     0.27       0.86     0.18
plotsYouth(modelname = modelYLET_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Life Engagement Test")                                                           

#########################################
################### LS  ###################
#########################################
                                                                    
resultsYouth(modelname = modelYLS_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "LS_1.GROUP1", interactionterm2 = "LS_1.GROUP2", current_scale_name = "LifeSatisfaction", new_scale_name = "Life Satisfaction T1")
## lavaan (0.5-20) converged normally after  25 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               41.780
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -797.445
##   Loglikelihood unrestricted model (H1)       -797.445
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1608.890
##   Bayesian (BIC)                              1632.677
##   Sample-size adjusted Bayesian (BIC)         1610.493
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_LS ~                                                         
##     GROUP1            0.675    0.267    2.532    0.011    0.675    0.250
##     GROUP2            0.108    0.198    0.544    0.587    0.108    0.051
##     SCALED_1_LS       0.503    0.078    6.480    0.000    0.503    0.498
##     LfSts_1.GROUP1   -0.047    0.284   -0.165    0.869   -0.047   -0.016
##     LfSts_1.GROUP2   -0.220    0.184   -1.192    0.233   -0.220   -0.110
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_LS      -0.116    0.178   -0.652    0.515   -0.116   -0.115
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_LS       0.712    0.088    8.111    0.000    0.712    0.702
## 
## R-Square:
##                    Estimate
##     SCALED_2_LS       0.298
## [[1]]
##                            Item     β   SE     z    p      90% CI
## 1                     Intercept -0.12 0.18 -0.65 0.51 -0.46, 0.23
## 2                        GROUP1  0.68 0.27  2.53 0.01   0.15, 1.2
## 3                        GROUP2  0.11 0.20  0.54 0.59  -0.28, 0.5
## 4                            LS  0.50 0.08  6.48 0.00  0.35, 0.66
## 5 Life Satisfaction T1_1.GROUP1 -0.05 0.28 -0.17 0.87  -0.6, 0.51
## 6 Life Satisfaction T1_1.GROUP2 -0.22 0.18 -1.19 0.23 -0.58, 0.14
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.29      -0.62     0.10
## 2      0    -0.01      -0.12     0.56
## 3      1     0.28       0.39     1.02
plotsYouth(modelname = modelYLS_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Life Satisfaction Test")         

#########################################
############### Optimism #################
#########################################
                                                                                                        
resultsYouth(modelname = modelYOptimism_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "Optimism_1.GROUP1", interactionterm2 = "Optimism_1.GROUP2", current_scale_name = "Optimism", new_scale_name = "Optimism T1")
## lavaan (0.5-20) converged normally after  27 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               33.192
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -636.404
##   Loglikelihood unrestricted model (H1)       -636.404
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1286.807
##   Bayesian (BIC)                              1310.594
##   Sample-size adjusted Bayesian (BIC)         1288.411
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                       Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_Optimism ~                                             
##     GROUP1              -0.077    0.275   -0.279    0.780   -0.077
##     GROUP2              -0.061    0.206   -0.294    0.769   -0.061
##     SCALED_1_Optms       0.434    0.079    5.511    0.000    0.434
##     Optms_1.GROUP1      -1.007    0.413   -2.439    0.015   -1.007
##     Optms_1.GROUP2      -0.359    0.325   -1.106    0.269   -0.359
##   Std.all
##          
##    -0.029
##    -0.029
##     0.432
##    -0.246
##    -0.109
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Optms   -0.014    0.184   -0.078    0.938   -0.014   -0.014
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Optms    0.770    0.094    8.216    0.000    0.770    0.774
## 
## R-Square:
##                    Estimate
##     SCALED_2_Optms    0.226
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept -0.01 0.18 -0.08 0.94 -0.37, 0.35
## 2                 GROUP1 -0.08 0.28 -0.28 0.78 -0.62, 0.46
## 3                 GROUP2 -0.06 0.21 -0.29 0.77 -0.47, 0.34
## 4            Optimism T1  0.43 0.08  5.51 0.00  0.28, 0.59
## 5 Interaction w/ Group 1 -1.01 0.41 -2.44 0.01 -1.82, -0.2
## 6 Interaction w/ Group 2 -0.36 0.32 -1.11 0.27    -1, 0.28
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.15      -0.45     0.48
## 2      0    -0.08      -0.01    -0.09
## 3      1     0.00       0.42    -0.66
plotsYouth(modelname = modelYOptimism_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Optimism - LOT-R")                                                                                            

#########################################
#################  PWB ###################
#########################################

resultsYouth(modelname = modelYPWB_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "PurposePWB_1.GROUP1", interactionterm2 = "PurposePWB_1.GROUP2", current_scale_name = "PWB", new_scale_name = "Ryff Purpose")
## lavaan (0.5-20) converged normally after  27 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               32.483
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -669.547
##   Loglikelihood unrestricted model (H1)       -669.547
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1353.093
##   Bayesian (BIC)                              1376.881
##   Sample-size adjusted Bayesian (BIC)         1354.697
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_PWB ~                                                        
##     GROUP1           -0.353    0.300   -1.180    0.238   -0.353   -0.133
##     GROUP2           -0.084    0.207   -0.406    0.685   -0.084   -0.040
##     SCALED_1_PWB      0.456    0.087    5.262    0.000    0.456    0.458
##     PrPWB_1.GROUP1   -0.017    0.466   -0.036    0.972   -0.017   -0.004
##     PrPWB_1.GROUP2   -0.315    0.238   -1.322    0.186   -0.315   -0.109
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_PWB      0.133    0.185    0.719    0.472    0.133    0.134
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_PWB      0.777    0.094    8.237    0.000    0.777    0.788
## 
## R-Square:
##                    Estimate
##     SCALED_2_PWB      0.212
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.13 0.18  0.72 0.47 -0.23, 0.49
## 2                 GROUP1 -0.35 0.30 -1.18 0.24 -0.94, 0.23
## 3                 GROUP2 -0.08 0.21 -0.41 0.68 -0.49, 0.32
## 4           Ryff Purpose  0.46 0.09  5.26 0.00  0.29, 0.63
## 5 Interaction w/ Group 1 -0.02 0.47 -0.04 0.97  -0.93, 0.9
## 6 Interaction w/ Group 2 -0.31 0.24 -1.32 0.19 -0.78, 0.15
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.09      -0.32    -0.66
## 2      0     0.05       0.13    -0.22
## 3      1     0.19       0.59     0.22
plotsYouth(modelname = modelYPWB_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Ryff Purpose Subscale")

#########################################
#################  APSI  ###################
#########################################

resultsYouth(modelname = modelYAPSI_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "PurposeAPSI_No36_1.GROUP1", interactionterm2 = "PurposeAPSI_No36_1.GROUP2", current_scale_name = "APSI", new_scale_name = "Sense of Idenitity")
## lavaan (0.5-20) converged normally after  26 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               63.436
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -678.504
##   Loglikelihood unrestricted model (H1)       -678.504
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1371.008
##   Bayesian (BIC)                              1394.795
##   Sample-size adjusted Bayesian (BIC)         1372.612
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_APSI ~                                                       
##     GROUP1            0.132    0.253    0.520    0.603    0.132    0.050
##     GROUP2            0.120    0.190    0.629    0.529    0.120    0.057
##     SCALED_1_APSI     0.570    0.069    8.244    0.000    0.570    0.570
##     PAPSI_N36_1.GR    0.106    0.333    0.318    0.751    0.106    0.028
##     PAPSI_N36_1.GR   -0.505    0.229   -2.209    0.027   -0.505   -0.176
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI    -0.082    0.170   -0.481    0.630   -0.082   -0.082
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI     0.619    0.075    8.234    0.000    0.619    0.629
## 
## R-Square:
##                    Estimate
##     SCALED_2_APSI     0.371
## [[1]]
##                     Item     β   SE     z    p       90% CI
## 1              Intercept -0.08 0.17 -0.48 0.63  -0.41, 0.25
## 2                 GROUP1  0.13 0.25  0.52 0.60  -0.36, 0.63
## 3                 GROUP2  0.12 0.19  0.63 0.53  -0.25, 0.49
## 4     Sense of Idenitity  0.57 0.07  8.24 0.00   0.43, 0.71
## 5 Interaction w/ Group 1  0.11 0.33  0.32 0.75  -0.55, 0.76
## 6 Interaction w/ Group 2 -0.51 0.23 -2.21 0.03 -0.95, -0.06
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.03      -0.65    -0.63
## 2      0     0.04      -0.08     0.05
## 3      1     0.10       0.49     0.73
plotsYouth(modelname = modelYAPSI_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "APSI - Sense of Identity Subscale")

#########################################
############### Resiliance ##############
#########################################

resultsYouth(modelname = modelYGRIT_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "Grit_1.GROUP1", interactionterm2 = "Grit_1.GROUP2", current_scale_name = "Res", new_scale_name = "Resiliance")
## lavaan (0.5-20) converged normally after  21 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               51.254
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1064.549
##   Loglikelihood unrestricted model (H1)      -1064.549
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                2143.099
##   Bayesian (BIC)                              2166.886
##   Sample-size adjusted Bayesian (BIC)         2144.702
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_Res ~                                                        
##     GROUP1           -0.332    0.264   -1.257    0.209   -0.332   -0.126
##     GROUP2           -0.234    0.195   -1.202    0.229   -0.234   -0.112
##     SCALED_1_Res      0.495    0.071    6.962    0.000    0.495    0.498
##     Grit_1.GROUP1     0.167    0.131    1.280    0.201    0.167    0.111
##     Grit_1.GROUP2    -0.161    0.091   -1.761    0.078   -0.161   -0.146
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Res      0.168    0.175    0.962    0.336    0.168    0.171
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_Res      0.674    0.082    8.209    0.000    0.674    0.691
## 
## R-Square:
##                    Estimate
##     SCALED_2_Res      0.309
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.17 0.18  0.96 0.34 -0.17, 0.51
## 2                 GROUP1 -0.33 0.26 -1.26 0.21 -0.85, 0.19
## 3                 GROUP2 -0.23 0.19 -1.20 0.23 -0.62, 0.15
## 4             Resiliance  0.49 0.07  6.96 0.00  0.36, 0.63
## 5 Interaction w/ Group 1  0.17 0.13  1.28 0.20 -0.09, 0.42
## 6 Interaction w/ Group 2 -0.16 0.09 -1.76 0.08 -0.34, 0.02
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.40      -0.33    -0.83
## 2      0    -0.07       0.17    -0.16
## 3      1     0.27       0.66     0.50
plotsYouth(modelname = modelYGRIT_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Resiliance")

#########################################
############# Self Esteem ###############
#########################################

resultsYouth(modelname = modelYSeleEsteem_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "SelfEsteem_1.GROUP1", interactionterm2 = "SelfEsteem_1.GROUP2", current_scale_name = "Self Esteem", new_scale_name = "Resiliance")
## lavaan (0.5-20) converged normally after  26 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               46.416
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -654.169
##   Loglikelihood unrestricted model (H1)       -654.169
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1322.338
##   Bayesian (BIC)                              1346.125
##   Sample-size adjusted Bayesian (BIC)         1323.942
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                         Estimate  Std.Err  Z-value  P(>|z|)   Std.lv
##   SCALED_2_SelfEsteem ~                                             
##     GROUP1                 0.218    0.264    0.827    0.408    0.218
##     GROUP2                 0.083    0.197    0.423    0.672    0.083
##     SCALED_1_SlfEs         0.519    0.072    7.178    0.000    0.519
##     SlfEs_1.GROUP1         0.394    0.386    1.021    0.307    0.394
##     SlfEs_1.GROUP2        -0.059    0.267   -0.220    0.825   -0.059
##   Std.all
##          
##     0.081
##     0.039
##     0.516
##     0.100
##    -0.019
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_SlfEs   -0.068    0.177   -0.386    0.699   -0.068   -0.068
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_SlfEs    0.697    0.085    8.199    0.000    0.697    0.696
## 
## R-Square:
##                    Estimate
##     SCALED_2_SlfEs    0.304
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept -0.07 0.18 -0.39 0.70 -0.41, 0.28
## 2                 GROUP1  0.22 0.26  0.83 0.41  -0.3, 0.74
## 3                 GROUP2  0.08 0.20  0.42 0.67  -0.3, 0.47
## 4             SelfEsteem  0.52 0.07  7.18 0.00  0.38, 0.66
## 5 Interaction w/ Group 1  0.39 0.39  1.02 0.31 -0.36, 1.15
## 6 Interaction w/ Group 2 -0.06 0.27 -0.22 0.83 -0.58, 0.46
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.45      -0.59    -0.76
## 2      0     0.02      -0.07     0.15
## 3      1     0.48       0.45     1.06
plotsYouth(modelname = modelYSeleEsteem_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "Global Self Esteem (SDQI)")

#########################################
############### APSI FG #################
#########################################
 
resultsYouth(modelname = modelYAPSIFG_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "APSI_FG_1.GROUP1", interactionterm2 = "APSI_FG_1.GROUP2", current_scale_name = "APSI_FG", new_scale_name = "APSI Future Goals")
## lavaan (0.5-20) converged normally after  27 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               42.102
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -685.571
##   Loglikelihood unrestricted model (H1)       -685.571
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1385.141
##   Bayesian (BIC)                              1408.928
##   Sample-size adjusted Bayesian (BIC)         1386.745
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                      Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_APSI_FG ~                                                      
##     GROUP1              0.034    0.270    0.125    0.900    0.034    0.013
##     GROUP2             -0.060    0.204   -0.295    0.768   -0.060   -0.029
##     SCALED_1_APSI_      0.488    0.073    6.655    0.000    0.488    0.490
##     APSI_FG_1.GROU      0.204    0.359    0.568    0.570    0.204    0.054
##     APSI_FG_1.GROU     -0.452    0.260   -1.741    0.082   -0.452   -0.163
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI_    0.051    0.183    0.281    0.779    0.051    0.052
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI_    0.727    0.088    8.266    0.000    0.727    0.742
## 
## R-Square:
##                    Estimate
##     SCALED_2_APSI_    0.258
## [[1]]
##                     Item     β   SE     z    p      90% CI
## 1              Intercept  0.05 0.18  0.28 0.78 -0.31, 0.41
## 2                 GROUP1  0.03 0.27  0.13 0.90  -0.5, 0.56
## 3                 GROUP2 -0.06 0.20 -0.29 0.77 -0.46, 0.34
## 4      APSI Future Goals  0.49 0.07  6.66 0.00  0.34, 0.63
## 5 Interaction w/ Group 1  0.20 0.36  0.57 0.57  -0.5, 0.91
## 6 Interaction w/ Group 2 -0.45 0.26 -1.74 0.08 -0.96, 0.06
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.04      -0.44    -0.61
## 2      0    -0.01       0.05     0.09
## 3      1     0.03       0.54     0.78
plotsYouth(modelname = modelYAPSIFG_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "APSI Future Goals")                                                                                                    

#########################################
########### APSI Feeling Now ############
#########################################                                                               

 
resultsYouth(modelname = modelYAPSIFN_interaction,  fitname = Fit, data = CranReddam, interactionterm1 = "APSI_FN_1.GROUP1", interactionterm2 = "APSI_FN_1.GROUP2", current_scale_name = "APSI_FN", new_scale_name = "APSI Feeling Now")
## lavaan (0.5-20) converged normally after  25 iterations
## 
##   Number of observations                           221
## 
##   Number of missing patterns                         4
## 
##   Estimator                                         ML
##   Minimum Function Test Statistic                0.000
##   Degrees of freedom                                 0
## 
## Model test baseline model:
## 
##   Minimum Function Test Statistic               46.266
##   Degrees of freedom                                 5
##   P-value                                        0.000
## 
## User model versus baseline model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -782.895
##   Loglikelihood unrestricted model (H1)       -782.895
## 
##   Number of free parameters                          7
##   Akaike (AIC)                                1579.790
##   Bayesian (BIC)                              1603.577
##   Sample-size adjusted Bayesian (BIC)         1581.394
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent Confidence Interval          0.000  0.000
##   P-value RMSEA <= 0.05                          1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Information                                 Observed
##   Standard Errors                             Standard
## 
## Regressions:
##                      Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##   SCALED_2_APSI_FN ~                                                      
##     GROUP1              0.203    0.271    0.749    0.454    0.203    0.076
##     GROUP2              0.178    0.200    0.890    0.374    0.178    0.085
##     SCALED_1_APSI_      0.481    0.074    6.518    0.000    0.481    0.482
##     APSI_FN_1.GROU     -0.215    0.279   -0.769    0.442   -0.215   -0.073
##     APSI_FN_1.GROU     -0.445    0.198   -2.244    0.025   -0.445   -0.193
## 
## Intercepts:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI_   -0.151    0.179   -0.841    0.400   -0.151   -0.152
## 
## Variances:
##                    Estimate  Std.Err  Z-value  P(>|z|)   Std.lv  Std.all
##     SCALED_2_APSI_    0.703    0.085    8.240    0.000    0.703    0.712
## 
## R-Square:
##                    Estimate
##     SCALED_2_APSI_    0.288
## [[1]]
##                     Item     β   SE     z    p       90% CI
## 1              Intercept -0.15 0.18 -0.84 0.40    -0.5, 0.2
## 2                 GROUP1  0.20 0.27  0.75 0.45  -0.33, 0.73
## 3                 GROUP2  0.18 0.20  0.89 0.37  -0.21, 0.57
## 4       APSI Feeling Now  0.48 0.07  6.52 0.00   0.34, 0.63
## 5 Interaction w/ Group 1 -0.21 0.28 -0.77 0.44  -0.76, 0.33
## 6 Interaction w/ Group 2 -0.44 0.20 -2.24 0.02 -0.83, -0.06
## 
## [[2]]
##   levels Treat_T2 Control_T2 RedTreat
## 1     -1    -0.01      -0.63    -0.21
## 2      0     0.03      -0.15     0.05
## 3      1     0.06       0.33     0.32
plotsYouth(modelname = modelYAPSIFN_interaction, fitname = Fit, data = CranReddam,  new_scale_name = "APSI Feeling Now")