covnps: Extract covariance and p Values from Lavaan Output

View source: R/covnps.R

covnpsR Documentation

Extract covariance and p Values from Lavaan Output

Description

This function will extract covariance matrix information (if present) in the parameter estimate output of lavaan, as well as associated p-values.

This function can be useful to getting appropriate p-values when working with multilevel data, where ignoring the nested nature of the data can lead to artificially 'statistically-significant' associations.

Usage

covnps(fit, vnames)

Arguments

fit

can provide as summary(fit)$pe statement in lavaan

vnames

detail the variables you are associating

Details

There may be some fidgeting you will need to do to get the covariance matrix to be spit out when there are no predictors. If you are working with multilevel data, where you have mean-deviated all Level 1 variables (so mean = 0 for all in this set), you can predict those variables with a Level 2 variable, which should necessarily have r(L1,L2)=0, to force generation of covariances between everything.

It will frequently be useful to quickly convert the covariances to correlations, which can be done efficiently via cov2cor(out$cov)

Value

Will return covariances and associated pvalues in matrix form


Dustin-Wood/funfield documentation built on July 20, 2023, 7:10 a.m.