Create an object containing essential information to create the Stan file and data for Stan to draw posterior samples. Such information includes the specified model for principal stratum and outcome, the type of outcome, assumptions, and prior specification, etc.
PSObject(
S.formula,
Y.formula,
Y.family,
data = NULL,
strata = NULL,
ER = NULL,
prior_intercept = prior_flat(),
prior_coefficient = prior_normal(),
prior_sigma = prior_inv_gamma(),
prior_alpha = prior_inv_gamma(),
prior_lambda = prior_inv_gamma(),
prior_theta = prior_normal(),
survival.time.points = 50
)A list, containing important information describing the principal stratification model.
A PSFormula object converted from the input S.formula and Y.formula
Same as input.
A boolean value. TRUE if Y.family is survival_Cox or survival_AFT.
A PStrataInfo object converted from the input strata and ER.
Same as input.
A list of time points at which the estimated survival probability is evaluated.
A matrix. Each row corresponds to a valid (stratum, treatment, confounder, group) combination.
A character vector. The names of the levels of the treatment.
an object of class "PSFormula" (or an
object of class "formula" that can be coerced to
that class with data provided) specifying the model for principal
stratum and outcome respectively. See PSFormula for details.
an object of class "family": specifying the parametric
family of the model for the response and the link function. See the documentation
for glm for details on how such model fitting takes place.
Supported families and corresponding link functions are presented in 'Details' below.
(optional) a data frame object. This is required when either
S.formula or Y.formula is a formula object, to coerce
it into a PSFormula object. When this happens, the data frame should
contain all of the variables with names given in S.formula or Y.formula.
arguments to define the principal strata. See PStrataInfo for details.
Alternatively, one can pass an object of class PStrataInfo to strata,
and ER will be ignored.
prior distribution for corresponding parameters in the model.
a vector of time points at which the estimated survival probability is evaluated (only used when the type of outcome is survival), or an integer specifying the number of time points to be chosen. By default, the time points are chosen with equal distance from 0 to the 90% quantile of the observed outcome.
The supported family objects include two types: native families for ordinary outcome and
survival family for survival outcome.
For ordinary outcome, the below families and links are supported. See family for more details.
| family | link |
binomial | logit, probit, cauchit, log, cloglog |
gaussian | identity, log, inverse |
Gamma | inverse, identity, log |
poisson | log, identity, log |
inverse.gamma | 1/mu^2, inverse, identity, log |
The quasi family is not supported for the current version of the package.
For survival outcome, the family object is created by
survival(method = "Cox", link = "identity"), where method can be
either "Cox" for Weibull-Cox model or "AFT" for accelerated
failure time model. See survival for more details. For the current
version, only "identity" is used as the link function.
The gaussian family and the survival family with method = "AFT"
introduce an additional parameter sigma for the standard deviation, whose
prior distribution is specified by prior_sigma. Similarly, prior_alpha
specifies the prior distribution of alpha for Gamma family,
prior_lambda specifies the prior distribution of theta for inverse.gaussian family,
and prior_theta
specifies the prior distribution of theta for survival family with method = "Cox".
The models for principal stratum S.formula and response Y.formula
also involve a linear combination of terms, where the prior distribution of
the intercept and coefficients are specified by prior_intercept and
prior_coefficient respectively.
df <- data.frame(
Z = rbinom(10, 1, 0.5),
D = rbinom(10, 1, 0.5),
Y = rnorm(10),
X = 1:10
)
PSObject(
S.formula = Z + D ~ X,
Y.formula = Y ~ X,
Y.family = gaussian("identity"),
data = df,
strata = c(n = "00*", c = "01", a = "11*")
)
#------------------------------
PSObject(
S.formula = Z + D ~ 1,
Y.formula = Y ~ 1,
Y.family = gaussian("identity"),
data = sim_data_normal,
strata = c(n = "00*", c = "01", a = "11*")
)
Run the code above in your browser using DataLab