setupExogenousCovariates: Set up exogenous model covariates

Description Usage Arguments Details Value Examples

View source: R/model.R

Description

\lifecycle

experimental In GWAS, including a number of the first principle components as covariates helps reduce false positives caused by population stratification. This function adds paths from covariates to manifest indicators (itemNames). Covariates are always treated as continuous variables (not ordinal).

Usage

1
setupExogenousCovariates(model, covariates, itemNames)

Arguments

model

an MxModel model, specified using RAM or LISREL notation. The model argument is designed to take the output from e.g. buildOneFac (or the other prebuilt GW-SEM functions), but advanced users can specify their own arbitrary OpenMx Model or use Onyx to draw their path diagrams.

covariates

a character vector naming covariates available in the model data

itemNames

a character vector of item names

Details

This is not the only way to adjust a model for covariates. For example, in a single factor model (e.g., buildOneFac), it would be more appropriate to adjust the latent factor instead of the manifest indicators. This is how endogenous covariates work. However, exogenous covariate adjustments to latent variables are only possible with a maximum likelihood fit function (mxFitFunctionML). For mxFitFunctionWLS, only manifest indicators can be adjusted for exogenous covariates. This function always adjusts manifest indicators regardless of the fit function.

You generally do not need to call this function directly because it is already called by buildOneFac and similar. This function is provided for advanced users who wish to write their own model building functions.

Value

The given MxModel with paths added from covariates to manifest indicators.

Examples

1
2
3
4
m1 <- mxModel("test", type="RAM",
              latentVars = "sex", manifestVars = "anxiety",
              mxData(data.frame(sex=rbinom(10,1,.5), anxiety=rnorm(10)), 'raw'))
m1 <- setupExogenousCovariates(m1, 'sex', 'anxiety')

gwsem documentation built on Jan. 18, 2022, 1:09 a.m.