Description Usage Arguments Details Value
Simulate a random data generating distribution. See Details to see how it's done.
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 26 27 28 29 | makeRandomDataT(n, maxD = 2, D = NULL, minObsA = 30,
func.distW = c("uniformW", "normalW", "bernoulliW", "binomialW", "gammaW",
"normalWCor", "bernoulliWCor", "uniformWCor", "gammaPointMassW",
"binomialFracW", "normalPointMassW"), funcG0.uni = c("linUni", "polyUni",
"sinUni", "jumpUni", "pLogisUni", "dNormUni", "qGammaUni", "dNormMixUni",
"cubicSplineUni", "linSplineUni"), funcG0.biv = c("linBiv", "polyBiv",
"sinBiv", "jumpBiv", "dNormAddBiv", "dNormMultBiv", "polyJumpBiv",
"sinJumpBiv", "dNormMultJumpBiv", "linSplineBiv"), funcG0.tri = c("linTri",
"polyTri", "sinTri", "jumpTri", "linJump2Tri", "linJump1Tri", "polyJump2Tri",
"polyJump1Tri", "sinJump2Tri", "sinJump1Tri", "dNormAddTri", "dNormMultTri",
"dNormMultJump2Tri", "dNormMultJump1Tri", "pLogisAddTri"),
funcG0.quad = c("linQuad", "polyQuad", "sinQuad", "jumpQuad",
"linJump2Quad", "linJump1Quad", "polyJump2Quad", "polyJump1Quad",
"sinJump2Quad", "sinJump1Quad", "dNormAddQuad", "dNormMultQuad",
"dNormMultJump2Quad", "dNormMultJump1Quad", "pLogisAddQuad"),
funcQ0.uni = c("linUni", "polyUni", "sinUni", "jumpUni", "pLogisUni",
"dNormUni", "qGammaUni", "dNormMixUni", "cubicSplineUni", "linSplineUni"),
funcQ0.biv = c("linBiv", "polyBiv", "sinBiv", "jumpBiv", "dNormAddBiv",
"dNormMultBiv", "polyJumpBiv", "sinJumpBiv", "dNormMultJumpBiv",
"linSplineBiv"), funcQ0.tri = c("linTri", "polyTri", "sinTri", "jumpTri",
"linJump2Tri", "linJump1Tri", "polyJump2Tri", "polyJump1Tri", "sinJump2Tri",
"sinJump1Tri", "dNormAddTri", "dNormMultTri", "dNormMultJump2Tri",
"dNormMultJump1Tri", "pLogisAddTri"), funcQ0.quad = c("linQuad", "polyQuad",
"sinQuad", "jumpQuad", "linJump2Quad", "linJump1Quad", "polyJump2Quad",
"polyJump1Quad", "sinJump2Quad", "sinJump1Quad", "dNormAddQuad",
"dNormMultQuad", "dNormMultJump2Quad", "dNormMultJump1Quad", "pLogisAddQuad"),
errY = c("normalErr", "uniformErr", "gammaErr", "normalErrAW",
"uniformErrAW"), minG0 = 0.001, minR2 = 0.01, maxR2 = 0.99,
pos = 0.005, skewing = c(-1, 1), ...)
|
n |
A |
maxD |
A |
funcG0.uni |
A |
funcG0.biv |
Ditto above, but for bivariate functions. |
funcG0.tri |
Ditto above, but for trivariate functions. |
funcQ0.uni |
Ditto |
funcQ0.biv |
Ditto |
funcQ0.tri |
Ditto |
errY |
A |
minG0 |
The minimum value for the propensity score (default 0.01). |
pos |
(1-2*pos)100% of pscores fall withing minG0 and 1- minG0, default is .005 |
distW.uncor |
A |
distW.cor |
Same as above, but generates a correlated covariate |
skewage |
default is c(-1,1). random add a skewing constant to the logit(pscores) |
Draw random data generating distribution. The code simulates as follows:
Simulate W
Choose D
, a random number of covariates from Uniform(1,maxD)
Randomly choose d1
, the distribution for first covariate, from distW.uncor
Call paste0(d1,".Parm")
(which is assumed to exist in the global environment) to get parameters for d1
Call d1
with parameters chosen in previous step to generate first covariate
Randomly choose d2
, the distribution for second covariate, from c(distW.uncor, distW.cor)
(now including correlated distributions).
Call paste0(d2,".Parm")
to get parameters for d2
Call d2
with parameters chosen in previous step and first covariate (to possibly induce correlation with previous covariate) to generate second covariate.
Continue until maxD
is reached.
Simulating A
Draw MG1
, a random number of main terms for propensity score, from Uniform(1,maxD)
For i
= 1,...,MG1
, draw f
a random function from funcG0.uni
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Call f
with x = W[,i]
to generate i
-th main term.
If D > 1
, draw MG2
, a random number of bivariate interactions for propensity, from Uniform(1,MG1-1
)
For i
= 1,...,MG2
, draw f
a random function from funcG0.biv
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Draw j
and k
, two random columns of W
Call f
with x1 = W[,j], x2 = W[,k]
to generate i
-th bivariate interaction term.
If D > 2
, draw MG3
, a random number of trivariate interactions for propensity, from Uniform(1,MG2-1
)
For i
= 1,...,MG3
, draw f
a random function from funcG0.tri
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Draw j
,k
,l
, three random columns of W
Call f
with x1 = W[,j], x2 = W[,k], x3 = W[,l]
to generate i
-th trivariate interaction term.
Sum together all main, bivariate, and trivariate terms to get the logit propensity score.
Divide the logit propensity score by 1.01 until the minimum propensity score is bigger than minG0
.
Draw A from Bernoulli distribution with conditional probability equal to the adjusted propensity score.
Simulating Y
Draw MQ1
, a random number of main terms for outcome regression score, from Uniform(2,maxD)
For i
= 1,...,MQ1
, draw f
a random function from funcQ0.uni
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Call f
with x = AW[,i]
to generate i
-th main term, where AW is matrix with first column A, other columns W.
If D > 1
, draw MQ2
, a random number of bivariate interactions for outcome regression, from Uniform(1,MQ1-1
)
For i
= 1,...,MQ2
, draw f
a random function from funcQ0.biv
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Draw j
and k
, two random columns of W
Call f
with x1 = W[,j], x2 = W[,k]
to generate i
-th bivariate interaction term.
If D > 2
, draw MQ3
, a random number of trivariate interactions for propensity, from Uniform(1,MQ2-1
)
For i
= 1,...,MQ3
, draw f
a random function from funcQ0.tri
Call paste0(f,"Parm")
(assumed to exist) to generate parameters for f
Draw j
,k
,l
, three random columns of W
Call f
with x1 = W[,j], x2 = W[,k], x3 = W[,l]
to generate i
-th trivariate interaction term.
Sum together all main, bivariate, and trivariate terms to get the conditional mean outcome, Q0
.
Draw errf
, arandom function from errY
from which to draw errors
Call paste0(errf,"Parm"
(assumed to exist) to generate random parameters for error distribution.
Call errf
with randomly chosen parameters to draw e
, an error for the outcome.
Let Y = Q0 + e
.
An object of class "makeRandomData"
with the following entries
W |
A matrix of covariates |
A |
A vector of binary treatments |
Y |
A vector of continuously valued outcome |
distW |
A list containing relevant information needed to reproduce data sets |
fnG0 |
A list of lists containing relevant information needed to reproduce data sets |
fnQ0 |
A list of lists containing relevant information needed to reproduce data sets |
distErrY |
A list containing relevant information needed to reproduce data sets |
divideLogitG0 |
A numeric of the scaling factor for the propensity |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.