lspline: Linear Spline

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/shapes.r

Description

Generate a basis for a linear spline for piecewise regression

Usage

1
2
lspline(var, knots = NULL, nknots = NULL, percentiles = NULL, 
	marginal = FALSE, names = NULL)

Arguments

var

the covariate to generate the basis

knots

a vector indicating the positions of the knots. See Details

nknots

an integer indicating the number of knots. See Details

percentiles

a vector of percentiles indicating the positions of the knots. See Details

marginal

logical indicating whether the effect for each interval of the spline represents the change in slope from the preceding one. Default is FALSE, so the coefficients represent the slope of the interval

names

a vector of quoted strings with alternate names for the columns of the resulting matrix. The length must be the number of knots plus 1

Details

This functions implements in R the Stata mkspline command. For further references see the article Gould (1993).

It is necessary to set either of knots, nknots, or percentiles. If more than one is specified, it will throw an error. If nknots is specified the intervals created will be equally spaced.

The function is designed to be called directly from within a formula. Therefore, there is no need to create the basis prior to fitting the model.

This function is very useful for exploring the exposure-response curve of the pollutants.

Value

This function returns a matrix with the basis for a linear spline. The number of columns in the matrix is the number of knots plus 1. The columns are named accordingly or after names

Author(s)

Washington Junger wjunger@ims.uerj.br and Antonio Ponce de Leon ponce@ims.uerj.br

References

Gould, W. W. (1993) Linear splines and piecewise linear functions. Stata Technical Bulletin 15, 13–17.

Schwartz, J., Spix, C., Touloumi, G. et al. (1996) Methodological issues in studies of air pollution and daily counts of deaths or hospital admissions. J Epidemiol. Community Health 50 (suppl 1), S12–S18.

See Also

smooth.spline,setup

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(admrio)
setup(admrio,"date")





f <- resp5~s(time)+weekdays+s(tmpmax)+s(humid)+lspline(pm10,knots=c(52.50,61.02,74.75))
m <- fit_core(f)
print_summary(m)

wjunger/ares documentation built on Dec. 23, 2021, 5:17 p.m.