Description Usage Arguments Value Examples
View source: R/01-model-setup.R
Set up a casecrossover model for fitting: creates all internal objects and stores them in a list with class "cc_model_data". May contain standard linear terms "x" parsable by model.matrix() and smooth terms "s(x)" to which RW2 models are fit (see documentation for s()).
The data will be sorted using dplyr::arrange(id,case) where id and case are the names of the variables identifying the subject and the case day respectively.
The case column in your dataframe should contain a 0 for control days, and a positive integer for case days. If the case day is a 1, then the model is fit exactly as described in the paper; if it is a positive integer greater than 1, then this is equivalent to having a dataset where that subject is replicated that many times (i.e. the full log-likelihood for that subject is multiplied by case). This is a convenience to save dataset storage space/memory.
1 | model_setup(formula, data, control = cc_control(), verbose = FALSE)
|
formula |
A standard R formula; see description. Must contain a strata() term which defines the variable in "data" used to distringuish individual subjects. |
data |
A data.frame or tibble containing at minimum one column which groups subjects together, one column indicating the case day, and one or more columns containing covariates. |
control |
A list containing control parameters. See cc_control(). |
verbose |
Logical. Print progress and diagnostic information? Useful for debugging or keeping up with what the function is doing. |
An object of class cc_modeldata, for passing into future functions.
1 | model_setup(y~x + strata(id),data.frame(y = c(0,1),x = c(1,2),id = c(1,1)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.