sim.chngpt {chngpt} | R Documentation |
Simulation Function
Description
Generate simulation datasets for change point Monte Carlo studies.
Usage
sim.chngpt (mean.model = c("thresholded", "thresholdedItxn",
"quadratic", "quadratic2b", "cubic2b", "exp",
"flatHyperbolic", "z2", "z2hinge", "z2segmented",
"z2linear", "logistic"), threshold.type = c("NA",
"M01", "M02", "M03", "M10", "M20", "M30", "M11",
"M21", "M12", "M22", "M22c", "M31", "M13", "M33c",
"hinge", "segmented", "upperhinge", "segmented2",
"step", "stegmented"), b.transition = Inf, family =
c("binomial", "gaussian"), x.distr = c("norm",
"norm3", "norm6", "imb", "lin", "mix", "gam",
"zbinary", "gam1", "gam2", "fixnorm", "unif"), e. =
NULL, mu.x = 4.7, sd.x = NULL, sd = 0.3, mu.z = 0,
alpha = NULL, alpha.candidate = NULL, coef.z =
log(1.4), beta = NULL, beta.itxn = NULL,
logistic.slope = 15, n, seed, weighted = FALSE,
heteroscedastic = FALSE, ar = FALSE, verbose = FALSE)
sim.twophase.ran.inte(threshold.type, n, seed)
sim.threephase(n, seed, gamma = 1, e = 3, beta_e = 5, f = 7, beta_f = 2, coef.z = 1)
Arguments
threshold.type |
string. Types of threshold effect to simulate, only applicable when label does not start with sigmoid. |
family |
string. Glm family. |
n |
n |
mu.z |
n |
seed |
seed |
weighted |
beta |
beta |
beta |
coef.z |
numeric. Coefficient for z. |
beta.itxn |
numeric. Coefficient for z. |
alpha |
numeric, intercept. |
mu.x |
numeric |
sd.x |
numeric |
mean.model |
numeric |
x.distr |
string. Possible values: norm (normal distribution), gam (gamma distribution). gam1 is a hack to allow e. be different |
e. |
e. |
verbose |
Boolean |
b.transition |
b. |
sd |
b. |
ar |
autocorrelation |
alpha.candidate |
Candidate values of alpha, used in code to determine alpha values |
e |
e |
beta_e |
beta_e |
f |
f |
beta_f |
beta_f |
logistic.slope |
beta_f |
gamma |
beta_f |
heteroscedastic |
Boolean. |
Details
mean.model, threshold.type and b.transition all affect mean models.
Value
A data frame with following columns:
y |
0/1 outcome |
x |
observed covariate that we are interested in |
x.star |
unobserved covariate that underlies x |
z |
additional covariate |
In addition, columns starting with 'w' are covariates that we also adjust in the model; columns starting with 'x' are covariates derived from x.
Examples
seed=2
par(mfrow=c(2,2))
dat=sim.chngpt(mean.model="thresholded", threshold.type="hinge", family="gaussian", beta=0, n=200,
seed=seed, alpha=-1, x.distr="norm", e.=4, heteroscedastic=FALSE)
plot(y~z, dat)
dat=sim.chngpt(mean.model="thresholded", threshold.type="hinge", family="gaussian", beta=0, n=200,
seed=seed, alpha=-1, x.distr="norm", e.=4, heteroscedastic=TRUE)
plot(y~z, dat)
dat=sim.chngpt(mean.model="z2", threshold.type="hinge", family="gaussian", beta=1, n=200,
seed=seed, alpha=1, x.distr="norm", e.=4, heteroscedastic=FALSE)
plot(y~z, dat)
dat=sim.chngpt(mean.model="z2", threshold.type="hinge", family="gaussian", beta=1, n=200,
seed=seed, alpha=1, x.distr="norm", e.=4, heteroscedastic=TRUE)
plot(y~z, dat)