newdata_to_X: Convert data frame of covariate values to a design matrix

Description Usage Arguments Details Value Examples

Description

Convert data frame of covariate values to a design matrix

Usage

1
newdata_to_X(newdata, wide, intercept = TRUE)

Arguments

newdata

Data frame where each row is a vector of covariate values defining an alternative focus quantity.

wide

Wide model which includes these covariates.

intercept

Include an intercept as the first column.

Details

Numeric values can be supplied for factor levels that are character strings denoting numbers (like "1" or "2").

Value

"Design" matrix of covariate values defining alternative focuses, with factors expanded to their contrasts. This is in the form required by the X argument of fic, with one row per alternative focus. The columns correspond to coefficients in a linear-type model. For the built-in focus functions such as mean_normal and prob_logistic, these coefficients include an intercept, but user-written focuses may be written in such a way as not to require an intercept (as in the example in the "skew normal" vignette).

Examples

1
2
3
4
5
bwt.glm <- glm(low ~ lwtkg + age + smoke + ftv, data=birthwt, family="binomial")
newdata <- data.frame(lwtkg=1, age=60, smoke=0, ftv="2+")
newdata_to_X(newdata, bwt.glm)

## See the Cox regression section of the main package vignette for another example.

fic documentation built on May 1, 2019, 7:55 p.m.