create_linear_constraints: Create a linear combination vector for a single-element-zero...

Description Usage Arguments Examples

View source: R/01-model-setup.R

Description

The most common and easiest to interpret constraint on a random walk model for a smooth term in a case-crossover model is simply to set a single element of the random effect to zero. This means that effects are interpreted as relative effects compared to this "reference" value. The reason this is the default constraint, as opposed to the usual "sum-to-zero" constraint used in random walk models, is because the main advantage of the "sum-to-zero" constraint is that it is orthogonal to the intercept in the model. In a case-crossover model, the intercept is not estimable, and while it's still totally possible to use a sum-to-zero constraint, it becomes less clear how to interpret it.

The function returns a named list of sparseVectors suitable for input into cc_control(). Specifically, the list items contain the sorted unique values of your covariate, the index of the zero value(s), the name of the variable, and a list of sparseVector(s) implementing the constraint(s).

Usage

1
create_linear_constraints(u, whichzero, nm = "")

Arguments

u

Covariate vector. You can pass it in raw (like data$u) or as a sorted vector of unique values.

whichzero

Actual values of u for which you want the random effect to be zero.

nm

The name of the covariate in your dataframe.

Examples

1
2
3
temperature <- c(10,15,20,25,30,35,40)
create_linear_constraints(temperature,30,"temperature")
create_linear_constraints(temperature,c(30,35),"temperature")

awstringer1/casecrossover documentation built on March 11, 2021, 4:41 a.m.