Learn R Programming

dagitty (version 0.1-9)

localTests: Test Graph against Data

Description

Derives testable implications from the given graphical model and tests them against the given dataset.

Usage

localTests(x, data = NULL, type = c("cis", "tetrads", "tetrads.within",
  "tetrads.between", "tetrads.epistemic"), sample.cov = NULL,
  sample.nobs = NULL, conf.level = 0.95, R = NULL)

Arguments

x
the input graph, a DAG, MAG, or PDAG.
data
matrix or data frame containing the data.
type
character indicating which kind of local test to perform. Supported values are "cis" (conditional independencies), "tetrads" and "tetrads.type", where "type" is one of the items of the tetrad typology, e.g. "t
sample.cov
the sample covariance matrix; ignored if data is supplied. Either data or sample.cov and sample.nobs must be supplied.
sample.nobs
number of observations; ignored if data is supplied.
conf.level
determines the size of confidence intervals for test statistics.
R
how many bootstrap replicates for estimating confidence intervals. If NULL, then confidence intervals are based on normal approximation. For tetrads, the normal approximation is only valid in large samples even if the data are normally distr

Details

Tetrad implications can only be derived if a Gaussian model (i.e., a linear structural equation model) is postulated. Conditional independence implications (CI) do not require this assumption. However, both Tetrad and CI implications are tested parametrically: for Tetrads, Wishart's confidence interval formula is used, whereas for CIs, a Z test of zero conditional covariance (if the covariance matrix is given) or a test of regressional independence (it the raw data is given) is performed. Tetrad tests also support bootstrapping instead of estimating parametric confidence intervals.

Examples

Run this code
# Simulate full mediation model with measurement error of M1
d <- simulateSEM("dag{X->{U1 M2}->Y U1->M1}",.6,.6)

# Postulate and test full mediation model without measurement error
plotLocalTestResults(localTests( "dag{ X -> {M1 M2} -> Y }", d, "cis" ))

Run the code above in your browser using DataLab