Recommendations and Outlook
Models of Section 11.5
Sample size planning and a priori power analysis
#### Loading of data set
load("chapter_3.RData")
#### Activating of lavaan
library(lavaan)
library(simsem)
#### Fit correlated factor model to data from chapter 3
model.corr.fakt.mod<-
'
# Loneliness-self factor
L_self =~ Slon1+Slon2+Slon3
# Loneliness-parent factor
L_parent =~ Elon1+Elon2+Elon3
# Loneliness-peer factor
L_peer =~ Plon1+Plon2+Plon3
# Flourishing-self factor
F_self =~ Sflou1+Sflou2
# Flourishing-parent factor
F_parent =~ Eflou1+Eflou2
# Flourishing-peer factor
F_peer =~ Pflou1+Pflou2
'
model.corr.fakt.fit<-sem(model.corr.fakt.mod,data=chapter_3.dat,
meanstructure = TRUE,
estimator= "MLR",
missing= "fiml")
summary(model.corr.fakt.fit, standardized=TRUE, fit.measures = TRUE, rsquare=TRUE)
#### apriori power analysis via simulation study
simulate <- sim(nRep=NULL,
model=model.corr.fakt.fit,
n=seq(100, 375, 25),
generate=model.corr.fakt.fit)
#### plot power
plotPower(simulate,'L_parent~~L_peer')
plotPower(simulate,'F_parent~~F_peer')
#### find power
aprior.power <- getPower(simulate)
findPower(aprior.power,'N',.8)['L_parent~~L_peer']
findPower(aprior.power,'N',.8)['F_parent~~F_peer']
MPlus code and data