cplm: Fit a change point linear model

View source: R/models.R View source: R/cplm.R

cplmR Documentation

Fit a change point linear model

Description

Given a formula and data frame, this function will by default look for heating and cooling with an L1 penalized least-squares regression, then based on those results fit an ordinary least- squares regression of the selected model.

Usage

cplm(data, weather, controls)

Arguments

data

the dataset to perform the regression with

formula

a formula as would be used in a linear model

weights

an optional vector of observation weights, if non-NULL will use these for weighted least squares

heating

optional to force evaluation of a heating change point

cooling

optional to force evaluation of a cooling change point

se

estimate standard errors with a bootstrap re-sampling technique

nreps

number of bootstrap replicates, defaults to 200

parametric

specify TRUE for a parametric bootstrap, FALSE for a non-parametric bootstrap. Defaults to parametric for < 100 observations, non-parametric for >= 100 observations

lambda

optional override for L1 penalty. Modifies the mean-squared error from a full least-squares fit. Larger values correspond to larger penalties. A value of 0 corresponds to ordinary least-squares.

Value

An object of class 'cplm'. Contains the original data.frame as 'dataOrig', the model formula, the regression data.frame w/ truncated basis vars as 'data', Least-Squares coefficients as 'LS', L1 penalized coefficients as 'L1', and optionally a data.frame of 'bootstraps' if se = TRUE.

The following methods have been implemented for the 'cplm' class: print, coef, predict, plot, resids

See Also

plot.cplm to plot model output, residsPlot to plot residuals energy use (net of weather), summary.cplm to report coefficients + standard errors if calculated.

Examples

data(rfm)
mod <- cplm(eui ~ oat, data = rfm)
summary(mod)
coef(mod, "LS")
coef(mod, "L1")
plot(mod)

EcotopeResearch/rterm documentation built on Oct. 17, 2022, 4:02 p.m.