Rob Knell
2011-Mar-15 08:22 UTC
[R] binary exogenous variable in path analysis in sem or lavaan
Hello all I'm trying to run some path analysis in either sem or lavaan (preferably lavaan because I find its interface easier to use). Most of my variables are continuously distributed and fairly well-behaved but I have a single exogenous variable (sex) which is not continuously distributed. Preliminary model fitting suggests that there aren't any sex by (anything else) interactions. The two approaches to dealing with this that I've come up with are to code it as a numerical variable (1 & 2 for female and male) and run the analysis as normal, or to run two separate models, one for males and one for females. I'd prefer to do the former because it will make interpretation easier and also give a larger sample size for the model fit but I'm not sure how acceptable that is. I know that some SEM packages are able to cope with categorical variables - is there any way to do this in R? Thanks for any help Regards Rob
yrosseel
2011-Mar-24 08:04 UTC
[R] binary exogenous variable in path analysis in sem or lavaan
Rob, If 'sex' is indeed an exogenous variable (ie. predictor only), you can simply code it as (1=male, 2=female) and use it as a covariate in any sem model. In lavaan, you can explicitly use the argument 'fixed.x=TRUE', which will regard all exogenous covariates as fixed variables. Their means/variances/covariances are not included in the model estimation (so they do not have to be normally distributed), but they are simply set at their sample values. In essence, this is exactly what happens in ordinary regression, when a categorical predictor is recoded as a dummy variable. Yves. -- View this message in context: http://r.789695.n4.nabble.com/binary-exogenous-variable-in-path-analysis-in-sem-or-lavaan-tp3355987p3401870.html Sent from the R help mailing list archive at Nabble.com.
Apparently Analagous Threads
- Incorrect degrees of freedom in SEM model using lavaan
- Structural equation modeling in R(lavaan,sem)
- appropriate covariance matrix for multiple nominal exogenous and multiple continuous endogenous variables in SEM
- FIML using lavaan returns zeroes for coefficients
- CFA with lavaan or with SEM