umxTwoStage: Build a SEM implementing the instrumental variable design

View source: R/umx_build_high_level_models.R

umxTwoStageR Documentation

Build a SEM implementing the instrumental variable design

Description

umxMR (umxTwoStage) implements a Mendelian randomization or instrumental variable Structural Equation Model. For ease of learning, the parameters follow the tsls() function in the sem package.

Usage

umxTwoStage(
  formula = Y ~ X,
  instruments = ~qtl,
  data,
  std = FALSE,
  subset,
  contrasts = NULL,
  name = "IV_model",
  tryHard = c("no", "yes", "ordinal", "search"),
  ...
)

Arguments

formula

The structural equation to be estimated (default = Y ~ X). A constant is implied if not explicitly deleted.

instruments

A one-sided formula specifying instrumental variables (default = qtl).

data

Frame containing the variables in the model.

std

Standardize the manifests before running model (default is FALSE)

subset

(optional) vector specifying a subset of observations to be used in fitting the model.

contrasts

An optional list (not supported)

name

The model name (default is "IVmodel")

tryHard

Default ('no') uses normal mxRun. "yes" uses mxTryHard. Other options: "ordinal", "search"

...

arguments to be passed along. (not supported)

Details

The example is a Mendelian Randomization analysis showing the utility of SEM over two-stage regression.

The following figure shows how the MR model appears as a path diagram:

Figure: Mendelian Randomization analysis.png

Value

  • OpenMx::mxModel()

References

  • Fox, J. (1979) Simultaneous equation models and two-stage least-squares. In Schuessler, K. F. (ed.) Sociological Methodology, Jossey-Bass.

  • Greene, W. H. (1993) Econometric Analysis, Second Edition, Macmillan.

  • Sekula, P., Del Greco, M. F., Pattaro, C., & Kottgen, A. (2016). Mendelian Randomization as an Approach to Assess Causality Using Observational Data. Journal of the American Society of Nephrology, 27), 3253-3265. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1681/ASN.2016010098")}

See Also

  • umx_make_MR_data(), umxDiffMZ(), umxDoC(), umxDiscTwin()

Other Super-easy helpers: umx, umxEFA()

Examples

## Not run: 
# ====================================
# = Mendelian Randomization analysis =
# ====================================

library(umx)
df = umx_make_MR_data(10e4, Vqtl = 0.02, bXY = 0.1, bUX = 0.5, bUY = 0.5, pQTL = 0.5)
m1 = umxMR(Y ~ X, instruments = ~ qtl, data = df)
parameters(m1)
plot(m1, means = FALSE, min="") # help DiagrammR layout the plot.
m2 = umxModify(m1, "qtl_to_X", comparison=TRUE, tryHard="yes", name="QTL_affects_X") # yip
m3 = umxModify(m1, "X_to_Y"  , comparison=TRUE, tryHard="yes", name="X_affects_Y") # yip
plot(m3, means = FALSE)

# Errant analysis using ordinary least squares regression (WARNING this result is CONFOUNDED!!)
ols1 = lm(Y ~ X    , data = df); coef(ols1) # Inflated .35 effect of X on Y
ols2 = lm(Y ~ X + U, data = df); coef(ols2) # Controlling U reveals the true 0.1 beta weight

# Simulate date with no causal X -> Y effect.
df = umx_make_MR_data(10e4, Vqtl = 0.02, bXY = 0, bUX = 0.5, bUY = 0.5, pQTL = 0.5)
m1 = umxMR(Y ~ X, instruments = ~ qtl, data = df)
parameters(m1)

# ======================
# = Now with sem::tsls =
# ======================
# libs("sem")
m2 = sem::tsls(formula = Y ~ X, instruments = ~ qtl, data = df)
coef(m2)

# Try with missing value for one subject: A benefit of the FIML approach in OpenMx.
m3 = tsls(formula = Y ~ X, instruments = ~ qtl, data = (df[1, "qtl"] = NA))

## End(Not run)

tbates/umx documentation built on Dec. 14, 2024, 11:28 a.m.