Learn R Programming

fda.usc (version 2.1.0)

predict.fregre.gls: Predictions from a functional gls object

Description

The predictions for the functional generalized least squares fitted linear model represented by object are obtained at the covariate values defined in newx.

Usage

# S3 method for fregre.gls
predict(
  object,
  newx = NULL,
  type = "response",
  se.fit = FALSE,
  scale = NULL,
  df,
  interval = "none",
  ...
)

# S3 method for fregre.igls predict( object, newx = NULL, data, df = df, weights = 1, pred.var, n.ahead = 1L, ... )

Value

a vector with the predicted values.

Arguments

object

fregre.gls object.

newx

An optional data list in which to look for variables with which to predict. If omitted, the fitted values are used. List of new explanatory data.

type

Type of prediction (response or model term).

se.fit

=TRUE (not default) standard error estimates are returned for each prediction.

scale

Scale parameter for std.err. calculation.

df

Degrees of freedom for scale.

interval

Type of interval calculation.

...

Further arguments passed to or from other methods.

data

Data frame with the time or spatinal index

weights

variance weights for prediction. This can be a numeric vector or a one-sided model formula. In the latter case, it is interpreted as an expression evaluated in newdata

pred.var

the variance(s) for future observations to be assumed for prediction intervals. See link{predict.lm} for more details.

n.ahead

number of steps ahead at which to predict.

Author

Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@udc.es

References

Oviedo de la Fuente, M., Febrero-Bande, M., Pilar Munoz, and Dominguez, A. Predicting seasonal influenza transmission using Functional Regression Models with Temporal Dependence. arXiv:1610.08718. https://arxiv.org/abs/1610.08718

See Also

fregre.gls

Examples

Run this code
if (FALSE) {
data(tecator)
ind<-1:190
x <-fdata.deriv(tecator$absorp.fdata,nderiv=1)
dataf=as.data.frame(tecator$y)
dataf$itime <- 1:nrow(x)
ldat=list("df"=dataf[ind,],"x"=x[ind])
newldat=list("df"=dataf[-ind,],"x"=x[-ind])
newy <- tecator$y$Fat[-ind]
ff <- Fat ~ x
res.lm <- fregre.lm(ff,data=ldat)
summary(res.lm)
res.gls <- fregre.gls(ff,data=ldat, correlation=corAR1())
summary(res.gls)
par.cor <- list("cor.ARMA"=list("p"=1))
par.cor <- list("cor.ARMA"=list("index"=c("itime"),"p"=1))
res.igls <- fregre.igls(ff,data=ldat,correlation=par.cor) 
pred.lm <- predict(res.lm,newldat)
pred.gls <- predict(res.gls,newldat)
pred.igls <- predict(res.igls,newldat)
mean((pred.lm-newldat$df$Fat)^2)
mean((pred.gls-newldat$df$Fat)^2)
mean((pred.igls-newldat$df$Fat)^2)
}

Run the code above in your browser using DataLab