Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lin

Generate a Basis Matrix with a Variable as Linear


Description

The function generates a basis matrix including a linear un-transformed variable. It is meant to be used internally by onebasis and crossbasis and not directly run by the users.

Usage

lin(x, intercept=FALSE)

Arguments

x

the predictor variable. Missing values are allowed.

intercept

logical. If TRUE, an intercept is included in the basis matrix, namely a vector of 1's.

Details

The function returns a basis matrix with the un-transformed variable, optionally with an intercept if intercept=TRUE.

Value

A matrix object of class "lin". It contains the attribute intercept.

Note

This function is mainly used internally thorugh onebasis to create basis matrices. It is not exported in the namespace, and can be accessed through the triple colon operator ':::' (see Examples below).

Author(s)

Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>

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

### simple use (accessing non-exported function through ':::')
dlnm:::lin(1:5)
dlnm:::lin(1:5, intercept=TRUE)

### use as an internal function in onebasis (note the centering)
b <- onebasis(chicagoNMMAPS$pm10, "lin")
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")

dlnm

Distributed Lag Non-Linear Models

v2.4.5
GPL (>= 2)
Authors
Antonio Gasparrini [aut, cre], Ben Armstrong [aut], Fabian Scheipl [ctb]
Initial release
2021-03-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.