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

predict_sof_pc

Use a scalar-on-function linear regression model for prediction


Description

Predict new observations of the scalar response variable and calculate the corresponding prediction error, with prediction interval limits, given new observations of functional covariates and a fitted scalar-on-function linear regression model

Usage

predict_sof_pc(object, newdata = NULL, alpha = 0.05)

Arguments

object

A list obtained as output from sof_pc, i.e. a fitted scalar-on-function linear regression model.

newdata

An object of class mfd containing new observations of the functional covariates. If NULL, it is set as the functional covariates data used for model fitting.

alpha

A numeric value indicating the Type I error for the regression control chart and such that this function returns the 1-alpha prediction interval on the response. Default is 0.05.

Value

A data.frame with as many rows as the number of functional replications in newdata, with the following columns:

* fit: the predictions of the response variable corresponding to new_data,

* lwr: lower limit of the 1-alpha prediction interval on the response,

* upr: upper limit of the 1-alpha prediction interval on the response.

Examples

library(funcharts)
data("air")
air <- lapply(air, function(x) x[1:10, , drop = FALSE])
fun_covariates <- c("CO", "temperature")
mfdobj_x <- get_mfd_list(air[fun_covariates], lambda = 1e-2)
y <- rowMeans(air$NO2)
mod <- sof_pc(y, mfdobj_x)
predict_sof_pc(mod)

funcharts

Functional Control Charts

v1.0.0
GPL-3
Authors
Christian Capezza [cre, aut], Fabio Centofanti [aut], Antonio Lepore [aut], Alessandra Menafoglio [aut], Biagio Palumbo [aut], Simone Vantini [aut]
Initial release

We don't support your browser anymore

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