dlnm (version 2.3.9)

strata: Generate a Basis Matrix of Indicator Variables

Description

The function generates a basis matrix including indicator variables defining intervals (strata), through dummy parameterization. It is meant to be used internally by onebasis and crossbasis and not directly run by the users.

Usage

strata(x, df=1, breaks=NULL, ref=1, intercept=FALSE)

Arguments

x

the predictor variable. Missing values are allowed.

df

dimension of the basis, equal to the number of strata. They depend on breaks if provided.

breaks

internal cut-off points defining the strata as right-open intervals. If provided, they determine df.

ref

interval used as reference category. Default to the first stratum. See Details below.

intercept

logical. If TRUE, an intercept is included in the basis matrix. See Details below.

Value

A matrix object of class "strata". It contains the attributes df, breaks, ref and intercept, with values which can be different than the arguments provided due to internal reset.

Details

The strata are defined by right-open intervals specified through breaks. If these are not provided, a number of intervals defined by df is placed at equally-spaced quantiles. This step is performed through an internal call to cut.

The argument ref indentifies the reference category, specified by excluding the related stratum in the dummy parameterization of the basis. This defines control-treatment contrasts, where each interval is compared with the baseline (see contrast). If set to 0 (when intercept=TRUE), it provides a different parameterization, where each interval has its own baseline.

If intercept=TRUE, an intercept is included in the model. The default (when ref is different from 0) produces an additional variable with a constant value of 1, representing the baseline.

See Also

onebasis to generate basis matrices and crossbasis to generate cross-basis matrices.

See dlnm-package for an introduction to the package and for links to package vignettes providing more detailed information.

Examples

Run this code
# NOT RUN {
### simple use (accessing non-exported function through ':::')
dlnm:::strata(1:5, breaks=3)
dlnm:::strata(1:5, df=3)
dlnm:::strata(1:5, df=3, intercept=TRUE)
dlnm:::strata(1:5, df=3, ref=2, intercept=TRUE)

### use as an internal function in onebasis
b <- onebasis(chicagoNMMAPS$pm10, "strata", breaks=c(20,40))
summary(b)
model <- glm(death ~ b, family=quasipoisson(), chicagoNMMAPS)
pred <- crosspred(b, model, at=0:60)
plot(pred, xlab="PM10", ylab="RR", main="RR for PM10")
# }

Run the code above in your browser using DataLab