Produce fitted model for group (treatment or control)
Source:R/fulldata_model.R, R/within_group_model.R
fit_SensIAT_within_group_model.RdProduces a fitted model that may be used to produce estimates of mean and variance for the given group.
Usage
fit_SensIAT_fulldata_model(data, trt, ...)
fit_SensIAT_within_group_model(
group.data,
outcome_modeler,
id,
outcome,
time,
knots,
alpha = 0,
End = NULL,
intensity.args = list(),
outcome.args = list(),
influence.args = list(),
spline.degree = 3,
add.terminal.observations = TRUE,
loss = c("lp_mse", "quasi-likelihood"),
link = c("identity", "log", "logit"),
term2_method = c("fast", "original", "fixed_grid", "seeded_adaptive", "gauss_legendre"),
impute_data = NULL
)Arguments
- data
the full data set.
- trt
an expression that determine what is treated as the treatment. Everything not treatment is considered control.
- ...
common arguments passed to
fit_SensIAT_within_group_model.- group.data
The data for the group that is being analyzed. Preferably passed in as a single
tibblethat internally is subsetted/filtered as needed.- outcome_modeler
function for fitting the outcome model. Called with a formula, data argument and
outcome.argslist.- id
The variable that identifies the patient.
- outcome
The variable that contains the outcome.
- time
The variable that contains the time.
- knots
knot locations for defining the spline basis.
- alpha
The sensitivity parameter.
- End
The end time for this data analysis, we need to set the default value as the max value of the time.
- intensity.args
A list of optional arguments for intensity model. See the Intensity Arguments section.
- outcome.args
parameters as needed passed into the
outcome_modeler. One special element may be'model.modifications'which, if present, should be a formula that will be used to modify the outcome model per, update.formula.- influence.args
A list of optional arguments used when computing the influence. See the Influence Arguments section.
- spline.degree
The degree of the spline basis.
- add.terminal.observations
Logical indicating whether to add terminal observations to the data. If TRUE, data may not contain any
NAs. if FALSE, data will be assumed to already include the terminal observations- loss
The loss function to use. Options are
"lp_mse"(default) and"quasi-likelihood". Only used whenlinkis not"identity".- link
The link function to use. Options are
"identity"(default),"log", and"logit". When"identity", the original analytic formula is used; otherwise, the generalized iterative solver is used.- term2_method
Method for computing term2 influence components. Options are:
"fast"(default),"original","fixed_grid","seeded_adaptive","gauss_legendre". Only used whenlinkis not"identity".- impute_data
A function that takes
(t, df)and returns the imputed data at timet. IfNULL(default), a standard imputation function is generated automatically.
Value
a list with class SensIAT-fulldata-fitted-model with two components,
control and treatment, each of which is an independently fitted
SensIAT-within-group-fitted-model fit with the fit_within_group_model
function.
A SensIAT_within_group_model object containing:
models: List withintensityandoutcomesub-modelsdata: The transformed data used for fittingvariables: List of variable names (id, outcome, time)End: The end time for the analysisinfluence: Influence function values by patientalpha: Sensitivity parameter valuescoefficients: Estimated spline coefficients for each alphacoefficient.variance: Variance of coefficients for each alphabase: TheSplineBasisobjectV_inverse: Inverse of the Gram matrixlink: The link function usedloss: The loss function usedterm2_method: The term2 integration method used
Details
This function should be agnostic to whether it is being provided a treatment or control group.
Functions
fit_SensIAT_fulldata_model(): Fit the Marginal Mean Sensitivity Analysis with Tilting Assumption for Both Treatment and Control Groups.
Intensity Arguments
The intensity.args list may contain the following elements:
model.modificationsA formula that will be used to modify the intensity model from it's default, per update.formula.kernelThe kernel function for the intensity model. Default is the Epanechnikov kernel.bandwidthThe bandwidth for the intensity model kernel.
Influence Arguments
The influence.args list may contain the following elements:
methodThe method for integrating, adaptive or fixed quadrature. Default is'adaptive'.toleranceThe tolerance when using adaptive quadrature.deltaThe bin width for fixed quadrature.resolutionalternative todeltaby specifying the number of bins.fix_discontinuityWhether to account for the discontinuity in the influence at observation times.
Examples
# \donttest{
# Example 1: Default identity link (original analytic solution)
model <-
fit_SensIAT_within_group_model(
group.data = SensIAT_example_data,
outcome_modeler = fit_SensIAT_single_index_fixed_coef_model,
alpha = c(-0.6, -0.3, 0, 0.3, 0.6),
id = Subject_ID,
outcome = Outcome,
time = Time,
End = 830,
knots = c(60, 260, 460),
)
# Example 2: Log link with generalized iterative solver
model_log <-
fit_SensIAT_within_group_model(
group.data = SensIAT_example_data,
outcome_modeler = fit_SensIAT_single_index_fixed_coef_model,
alpha = 0,
id = Subject_ID,
outcome = Outcome,
time = Time,
End = 830,
knots = c(60, 260, 460),
link = "log",
loss = "lp_mse"
)
# }