predict.freg: Predict FREG model

View source: R/predict_freg.R

predict.fregR Documentation

Predict FREG model

Description

Prediction of FREG model

Usage

## S3 method for class 'freg'
predict(object, ..., newdata = NULL)

Arguments

object

FREG model for which predictions are computed

...

additional arguments relevant for the generic method

newdata

an optional argument. Newdata should be organized as a list. The elements of the list are covariates from FREG model, respectively. No data transformation is needed. Thus, functional covariates are entered in the list newdata in their raw form. The predict.freg function will take care of the transformation of such covariates into the functional form of their equivalents from FREG model.

Value

predictions of dependent variable y

Examples


library(fda)
y = log10(apply(CanadianWeather$dailyAv[1:334,,2],2,sum))
x = CanadianWeather$dailyAv[1:334,,1] # temperature
xbasis = create.fourier.basis(c(1,334),5)
xfd = smooth.basis(c(1:335),x,xbasis)$fd
bbasis = create.fourier.basis(c(1,334),5)
latitude = CanadianWeather$coordinates[,1]
longitude = CanadianWeather$coordinates[,2]
xfdlist = list(xfd, latitude, longitude)
cbasis = create.constant.basis(c(1,334))
betalist = list(bbasis, cbasis, cbasis)
formula = y ~ xfd + latitude + longitude
freg.model = freg(formula = formula, betalist = betalist)
# Prediction with new data included
newdata = list(CanadianWeather$dailyAv[1:365,,1], latitude, longitude)
# newdata = list(xfd_1, latitude, longitude) #funct. and scalar variable(s)
yhat = predict(freg.model, newdata = newdata)


FREG documentation built on May 9, 2022, 5:07 p.m.

Related to predict.freg in FREG...