expand_inds: Form 'fic' model indicator argument in presence of factors

Description Usage Arguments Details Examples

Description

Given a model indicator inds identifying terms in a regression model, convert this to the format needed for fic by converting indicators for regression terms to indicators for inclusion of parameters. Only required if there are factors.

Usage

1
expand_inds(inds, wide)

Arguments

inds

Matrix or vector of indicators for which parameters are included in the submodel or submodels to be assessed.

A matrix should be supplied if there are multiple submodels. This should have number of rows equal to the number of submodels, and number of columns equal to the total number of parameters in the wide model. It contains 1s in the positions where the parameter is included in the submodel, and 0s in positions where the parameter is excluded. This should always be 1 in the positions defining the narrow model, as specified in inds0.

wide

Fitted model object containing the wide model.

Details

If a regression term is a factor, then the 0 or 1 indicating its inclusion/exclusion is replicated to a length given by the number of factor levels minus 1, that is, the number of parameters pertaining to that factor.

This function only works for classes of models for which the model.matrix function is understood and returns objects with an "assign" attribute. This includes all the commonly-used models in base R.

Examples

1
2
3
4
5
6
7
8
9
# Five terms in this model: intercept and four covariates,
# but the covariate "ftv" is a factor with 3 levels,
# so there are six parameters
bwt.glm <- glm(low ~ lwtkg + age + smoke + ftv, data=birthwt, family="binomial")

## Convert indicator for terms to indicator for parameters 
inds <- rbind(c(1,1,1,0,0),
              c(1,1,1,1,1))
expand_inds(inds, bwt.glm)

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