| DPI | R Documentation |
The Directed Prediction Index (DPI) is a quasi-causal inference method for cross-sectional data designed to quantify the relative endogeneity (relative dependence) of outcome (Y) vs. predictor (X) variables in regression models. By comparing the proportion of variance explained (R-squared) between the Y-as-outcome model and the X-as-outcome model while controlling for a sufficient number of possible confounders, it can suggest a plausible (admissible) direction of influence from a more exogenous variable (X) to a more endogenous variable (Y). Methodological details are provided at https://psychbruce.github.io/DPI/.
DPI(
model,
x,
y,
data = NULL,
k.cov = 1,
n.sim = 1000,
alpha = 0.05,
bonf = FALSE,
pseudoBF = FALSE,
seed = NULL,
progress,
file = NULL,
width = 6,
height = 4,
dpi = 500
)
model |
Model object ( |
x |
Independent (predictor) variable. |
y |
Dependent (outcome) variable. |
data |
[Optional] Defaults to |
k.cov |
Number of random covariates (simulating potential omitted variables) added to each simulation sample.
|
n.sim |
Number of simulation samples. Defaults to |
alpha |
Significance level for computing the
|
bonf |
Bonferroni correction to control for false positive rates:
|
pseudoBF |
Use normalized pseudo Bayes Factors Defaults to |
seed |
Random seed for replicable results. Defaults to |
progress |
Show progress bar. Defaults to |
file |
File name of saved plot ( |
width, height |
Width and height (in inches) of saved plot. Defaults to |
dpi |
Dots per inch (figure resolution). Defaults to |
Return a data.frame of simulation results:
DPI = Direction * Significance
= (R2.Y - R2.X) * (1 - tanh(p.beta.xy/alpha/2))
if pseudoBF=FALSE (default, suggested)
more conservative estimates
= (R2.Y - R2.X) * plogis(log(pseudo.BF.xy))
if pseudoBF=TRUE
less conservative for insignificant X-Y relationship
delta.R2
R2.Y - R2.X
R2.Y
R^2 of regression model predicting Y using X and all other covariates
R2.X
R^2 of regression model predicting X using Y and all other covariates
t.beta.xy
t value for coefficient of X predicting Y (always equal to t value for coefficient of Y predicting X) when controlling for all other covariates
p.beta.xy
p value for coefficient of X predicting Y (always equal to p value for coefficient of Y predicting X) when controlling for all other covariates
df.beta.xy
residual degree of freedom (df) of t.beta.xy
r.partial.xy
partial correlation (always with the same t value as t.beta.xy) between X and Y when controlling for all other covariates
sigmoid.p.xy
sigmoid p value as 1 - tanh(p.beta.xy/alpha/2)
pseudo.BF.xy
pseudo Bayes Factors (BF_{10}) computed from p value p.beta.xy and sample size nobs(model), see p_to_bf()
S3method.dpi
DPI_curve()
DPI_dag()
BNs_dag()
cor_net()
p_to_bf()
# input a fitted model
model = lm(Ozone ~ ., data=airquality)
DPI(model, x="Solar.R", y="Ozone", seed=1) # DPI > 0
DPI(model, x="Wind", y="Ozone", seed=1) # DPI > 0
DPI(model, x="Solar.R", y="Wind", seed=1) # unrelated
# or input raw data, test with more random covs
DPI(data=airquality, x="Solar.R", y="Ozone",
k.cov=10, seed=1)
DPI(data=airquality, x="Wind", y="Ozone",
k.cov=10, seed=1)
DPI(data=airquality, x="Solar.R", y="Wind",
k.cov=10, seed=1)
# or use pseudo Bayes Factors for the significance score
# (less conservative for insignificant X-Y relationship)
DPI(data=airquality, x="Solar.R", y="Ozone", k.cov=10,
pseudoBF=TRUE, seed=1) # DPI > 0 (true positive)
DPI(data=airquality, x="Wind", y="Ozone", k.cov=10,
pseudoBF=TRUE, seed=1) # DPI > 0 (true positive)
DPI(data=airquality, x="Solar.R", y="Wind", k.cov=10,
pseudoBF=TRUE, seed=1) # DPI > 0 (false positive!)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.