Learn R Programming

NlsyLinks (version 1.003)

AceLavaanGroup: A simple multiple-group ACE model with the lavaan package.

Description

This function uses the lavaan package to estimate a univariate ACE model, using multiple groups. Each group has a unique value of R (i.e., the Relatedness coefficient).

Usage

AceLavaanGroup(dsClean, estimateA=TRUE, estimateC=TRUE, printOutput=FALSE)

Arguments

dsClean
The data.frame containing complete cases for the R groups to be included in the estimation.
estimateA
Should the A variance component be estimated? A^2 represents the proportion of variability due to a shared genetic influence.
estimateC
Should the C variance component be estimated? C^2 represents the proportion of variability due to a shared environmental influence.
printOutput
Indicates if the estimated parameters and fit statistics are printed to the console.

Value

  • An AceEstimate object.

Details

The variance component for E is always estimated.

References

The lavaan package is developed by Yves Rosseel at Ghent University. Two good starting points are the documentation (http://cran.r-project.org/web/packages/lavaan/) and his upcoming JSS paper (http://users.ugent.be/~yrosseel/lavaan/lavaanJSSpreview.pdf).

See Also

Further ACE model details are discussed in our package's vignette (in the console, type vignette("NlsyAce")).

Examples

Run this code
dsFull <- Links79PairExpanded #Start with the built-in data.frame in NlsyLinks
oName_1 <- "MathStandardized_1" #Stands for Manifest1
oName_2 <- "MathStandardized_2" #Stands for Manifest2

dsGroupSummary <- RGroupSummary(dsFull, oName_1, oName_2)
dsClean <- CleanSemAceDataset(dsDirty=dsFull, dsGroupSummary, oName_1, oName_2)

ace <- AceLavaanGroup(dsClean)
ace

#Should produce:
# [1] "Results of ACE estimation: [show]"
#     ASquared     CSquared     ESquared    CaseCount 
#    0.6701032    0.1167060    0.2131907 8292.0000000 

library(lavaan) #Load the package to access methods of the lavaan class.
GetDetails(ace)

#Exmaine fit stats like Chi-Squared, RMSEA, CFI, etc.
fitMeasures(GetDetails(ace)) #The function 'fitMeasures' is defined in the lavaan package.

#Examine low-level details like each group's individual parameter estimates and standard errors.
summary(GetDetails(ace))

#Extract low-level details. This may be useful when programming simulations.
inspect(GetDetails(ace), what="converged") #The lavaan package defines 'inspect'.
inspect(GetDetails(ace), what="coef")

Run the code above in your browser using DataLab