Skip to contents

The DPI curve analysis.

Usage

DPI_curve(
  model,
  y,
  x,
  data = NULL,
  k.covs = 1:10,
  n.sim = 1000,
  seed = NULL,
  file = NULL,
  width = 6,
  height = 4,
  dpi = 500
)

Arguments

model

Model object (lm).

y

Dependent (outcome) variable.

x

Independent (predictor) variable.

data

[Optional] Defaults to NULL. If data is specified, then model will be ignored and a linear model lm({y} ~ {x} + .) will be fitted inside. This is helpful for exploring all variables in a dataset.

k.covs

An integer vector of number of random covariates (simulating potential omitted variables) added to each simulation sample. Defaults to 1:10 (producing DPI results for k.cov=1~10). For details, see DPI.

n.sim

Number of simulation samples. Defaults to 1000.

seed

Random seed for replicable results. Defaults to NULL.

file

File name of saved plot (".png" or ".pdf").

width, height

Width and height (in inches) of saved plot. Defaults to 6 and 4.

dpi

Dots per inch (figure resolution). Defaults to 500.

Value

Return a data.frame of DPI curve results.

Examples

model = lm(Ozone ~ ., data=airquality)
DPIs = DPI_curve(model, y="Ozone", x="Solar.R", seed=1)
#> ⠙ Simulation k.covs: 1/10 ███████████████████████████████   10% [00:00:3.4]
#> ⠹ Simulation k.covs: 2/10 ███████████████████████████████   20% [00:00:07]
#> ⠸ Simulation k.covs: 3/10 ███████████████████████████████   30% [00:00:10.6]
#> ⠼ Simulation k.covs: 4/10 ███████████████████████████████   40% [00:00:14.4]
#> ⠴ Simulation k.covs: 5/10 ███████████████████████████████   50% [00:00:18.4]
#> ⠦ Simulation k.covs: 6/10 ███████████████████████████████   60% [00:00:22.5]
#> ⠧ Simulation k.covs: 7/10 ███████████████████████████████   70% [00:00:26.7]
#> ⠇ Simulation k.covs: 8/10 ███████████████████████████████   80% [00:00:31.2]
#> ⠏ Simulation k.covs: 9/10 ███████████████████████████████   90% [00:00:35.6]
#>  10 * 1000 simulation samples estimated in 40.3s
#> 
plot(DPIs)  # ggplot object