sim.chngpt: Simulation Function

Description Usage Arguments Details Value Examples

View source: R/sim.chngpt.R

Description

Generate simulation datasets for change point Monte Carlo studies.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
sim.chngpt (
    mean.model=c("thresholded","thresholdedItxn","quadratic","quadratic2b","cubic2b",
        "exp","flatHyperbolic","z2","z2hinge","z2segmented","z2linear"), 
    threshold.type=c("NA","step","hinge","segmented","segmented2","stegmented"),
#segmented2 differs from segmented in parameterization, it is studied in Cheng 2008
    b.transition=Inf,
    family=c("binomial","gaussian"), 
    x.distr=c("norm","norm3","norm6","imb","lin","mix","gam","zbinary","gam1","gam2",
        "fixnorm", "fixnorm3", "fixnorm6"), # gam1 is a hack to allow e. be different
    e.=NULL, mu.x=4.7, sd.x=NULL, sd=0.3, 
    alpha=NULL, alpha.candidate=NULL, coef.z=log(1.4), beta=NULL, beta.itxn=NULL, 
    n, seed, 
    weighted=FALSE, # sampling weights
    heteroscedastic=FALSE,
    verbose=FALSE) 

Arguments

threshold.type

string. Types of threshold effect to simulate, only applicable when label does not start with sigmoid.

family

string. Glm family.

n
seed
weighted
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.
verbose

Boolean

b.transition
sd
alpha.candidate

Candidate values of alpha, used in code to determine alpha values

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)

chngpt documentation built on June 2, 2018, 1:04 a.m.

Related to sim.chngpt in chngpt...