Description Usage Arguments Details Examples
not used by user, typically
1 2 3 4 |
x |
intervenable exposures (character vector) |
z |
covariates (character vector) |
y |
outcome |
binvars |
= non-outcome variables that are binary (character vector) |
matx |
optional, name of matrix with intervenable exposures |
standardizex |
logical, should x be standardized? |
binary |
logical, is outcome binary? |
vectorized |
logical, should model be expressed in vector notation when possible? |
xintv |
matrix with ncol = number of intervenable exposures, nrow = number of interventions. Each value is on [0,1] and represents the proportional decrease in the value of x upon hypothetical intervention |
lorem ipsum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # library(rstan)
dgm <- function(N=100, trueRD=0.2){
x1 = rbinom(N, 1, 0.5)
py00 = runif(N)*0.1 + 0.4
l2 = rbinom(N, 1, 1/(1+exp(-1 + x1 + py00)))
x2 = rbinom(N, 1, 1/(1+exp(-1 + x1 + l2)))
py = py00 + trueRD*((x1 + x2)/2) #true risk difference per unit exposure;
y = rbinom(N, 1, py)
data.frame(x1, l2, x2, y)
}
dat = as.list(dgm(100))
dat$N = 100
dat$p = 5
source("~/Epiprojects/wellwater/sims/code/make_stan_terms.R")
mod = stan_basic(x=c('x1', 'x2'), z = 'l2', y='y',
binvars=c('x1', 'x2', 'l2'), xintv = rbind(c(1,0), c(0,1),c(1,1)),
vectorized = TRUE, binary=TRUE, matx = NULL)
cat(mod)
# usage in stan (or edit by hand)
# not run
# stan(model_code = mod, data = dat, chains=1, iter=100)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.