Both sides previous revisionPrevious revisionNext revision | Previous revision |
r:path_analysis [2023/05/29 23:45] – hkimscil | r:path_analysis [2023/11/27 16:57] (current) – [Lavaan in R: explanation] hkimscil |
---|
* Step 2: Use 'lavaan' function to run analysis. Here, I will be saving the results in an R object called 'fit' (arbitrarily named). Inside the parenthesis are arguments separated by commas. The first argument contains the name of the object containing the model syntax (see above). The object is named 'model' (again, arbitrarily named above). Next, we have the 'data' argument. This identifies the object (i.e., data frame) containing the raw data. | * Step 2: Use 'lavaan' function to run analysis. Here, I will be saving the results in an R object called 'fit' (arbitrarily named). Inside the parenthesis are arguments separated by commas. The first argument contains the name of the object containing the model syntax (see above). The object is named 'model' (again, arbitrarily named above). Next, we have the 'data' argument. This identifies the object (i.e., data frame) containing the raw data. |
<code> | <code> |
fit<-lavaan(model,data=processdata) | fit<-lavaan(model, data=processdata) |
</code> | </code> |
* The 'summary' function can be used to obtain various fit measures and the parameter estimates for the model | * The 'summary' function can be used to obtain various fit measures and the parameter estimates for the model |
<code> | <code> |
summary(fit,fit.measures=TRUE) | summary(fit, fit.measures=TRUE) |
</code> | </code> |
* To obtain standardized estimates, use the 'standardized' argument (setting it to TRUE) when using the 'summary' function. You will need to interpret the Std.all column in the output, as it will provide standardized estimates for all measured variables in the model. | * To obtain standardized estimates, use the 'standardized' argument (setting it to TRUE) when using the 'summary' function. You will need to interpret the Std.all column in the output, as it will provide standardized estimates for all measured variables in the model. |
<code> | <code> |
summary(fit,fit.measures=TRUE,standardized=TRUE,rsquare=TRUE) | summary(fit, fit.measures=TRUE, standardized=TRUE, rsquare=TRUE) |
</code> | </code> |
| |
interest~~anxiety' | interest~~anxiety' |
| |
fit<-lavaan(model,data=processdata,auto.var=TRUE) | fit<-lavaan(model, data=processdata, auto.var=TRUE) |
summary(fit,fit.measures=TRUE,standardized=TRUE,rsquare=TRUE) | summary(fit, fit.measures=TRUE, standardized=TRUE, rsquare=TRUE) |
</code> | </code> |
| |
interest~~anxiety | interest~~anxiety |
' | ' |
fit <- lavaan(model. data=processdata) | fit <- lavaan(model, data=processdata) |
fit <- sem(model. data=processdata) | fit <- sem(model, data=processdata) |
| |
summary(fit, fit.measures=TRUE) | summary(fit, fit.measures=TRUE) |