get.dgp: get.dgp

Description Usage Arguments Value Examples

View source: R/chooseGen.R

Description

randomly creates a dgp and attempts to satisfy user specs. Number of covariates is not limited but may take a while beyond d = 20 with too many terms. Limit time with depth and maxterms parameters.

Usage

1
2
3
get.dgp(n, d, pos = 0.01, minATE = -2, minBV = 0, depth, maxterms,
  minterms, mininters, num.binaries = floor(d/4), force.confounding = TRUE,
  skewing = c(-1, 1))

Arguments

n,

sample size

d,

dimension of potential confounders

pos,

a small value to make sure prop scores are in (pos, 1 - pos)

minATE,

minimum causal risk difference for the population.

minBV,

minimum blip variance for population

depth,

specify depth of interaction–must be less than or equal d.

maxterms,

maximum terms per interaction. For example, this would limit two way interactions to maximally 10 terms as well as three way or main terms. With high dimension it is wise to set this low because it might take a while otherwise. Still in development–perhaps future will set this for each depth

minterms

sets a minimum number of total covariate terms, including interactions with eachother–do not set lower than 1.

mininters

sets the minimum number of interactions with treatment to include This must be bigger or equal to minterms

num.binaries

specifies number of main terms you want as binaries, must be less than d.

force.confounding

forces variables used for p-score to overlap with those used for outcome regression.

skewing

randomly skews an otherwise centered dgp for generating binary treatment default is c(-1, 1). Set to c(-5,-1) to deliberately skew more regularly or widen to c(-3, 3) to skew more randomly.

Value

a sample DF, the true average treatment effect, ATE0 and blip variance BV0, the sample pscores, PGn, the sample true blips, blip_n, the sample true prob of death under treatment, PQ1n, and prob of death under control PQ0n

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# getting a random sample from a randomly drawn dgp.  We specify 3 covariates, a minimum population ATE of .1
# a minimum variance of blip of .03, up to 2 way interactions, limit positivity violations to less than 1% of the
# population having propensity scores below .05 or above .95, 1 binary, up to 1 interaction terms and at least 1
# term included as a covariate in outcome regression and in treatment mechanism
dgp = get.dgp(n = 1000, d = 3, pos = 0.05, minATE = .1, minBV = .03, depth = 2, maxterms = 3, minterms = 1, 
              mininters = 1, num.binaries = 1) 

# population blip variance
dgp$BV0
# population average treatment effect
dgp$ATE0
# sample proportion with treatment
mean(dgp$DF$A)
# sample proportion who died
mean(dgp$DF$Y)
# min sample pscore
min(dgp$PGn)
# max sample pscore
max(dgp$PGn)
# sample dataframe
head(dgp$DF)
# histogram of blips
hist(dgp$blip_n)
# histogram of propensity scores
hist(dgp$PGn)

jlstiles/sim.papers documentation built on May 23, 2019, 5:03 a.m.