# predict.fregre.gkam

0th

Percentile

##### Predict method for functional regression model

Computes predictions for regression between functional (and non functional) explanatory variables and scalar response.

• predict.fregre.lm, Predict method for functional linear model of fregre.lm fits object using basis or principal component representation.

• predict.fregre.plm, Predict method for semi-functional linear regression model of fregre.plm fits object using using asymmetric kernel estimation.

• predict.fregre.glm, Predict method for functional generalized linear model of fregre.glm fits object using basis or principal component representation.

• predict.fregre.gsam, Predict method for functional generalized spectral additive model of fregre.gsam fits object using basis or principal component representation.

• predict.fregre.gkam, Predict method for functional generalized kernel additive model of fregre.gkam fits object using backfitting algorithm.

These functions use the model fitting function lm, glm or gam properties. If using functional data derived, is recommended to use a number of bases to represent beta lower than the number of bases used to represent the functional data. The first item in the data list of newx argument is called "df" and is a data frame with the response and non functional explanatory variables, as lm, glm or gam. Functional variables (fdata and fd class) are introduced in the following items in the data list of newx argument.

Keywords
regression
##### Usage
# S3 method for fregre.gkam
predict(object, newx = NULL, type = "response", ...)# S3 method for fregre.glm
predict(object, newx = NULL, type = "response", ...)# S3 method for fregre.gsam
predict(object, newx = NULL, type = "response", ...)# S3 method for fregre.lm
predict(
object,
newx = NULL,
type = "response",
se.fit = FALSE,
scale = NULL,
df = df,
interval = "none",
level = 0.95,
weights = 1,
pred.var = res.var/weights,
...
)# S3 method for fregre.plm
predict(object, newx = NULL, ...)
##### Arguments
object

fregre.lm, fregre.plm, fregre.glm, fregre.gsam or fregre.gkam 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).

Further arguments passed to or from other methods.

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.

level

Tolerance/confidence level.

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.

##### Value

Return the predicted values and optionally:

• predict.lm,predict.glm,predict.gam produces a vector of predictions or a matrix of predictions and bounds with column names fit, lwr, and upr if interval is set. If se.fit is TRUE, a list with the following components is returned: fit vector or matrix as above.

• se.fit standard error of predicted means.

• residual.scale residual standard deviations.

• df degrees of freedom for residual.

##### References

Febrero-Bande, M., Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. Journal of Statistical Software, 51(4), 1-28. http://www.jstatsoft.org/v51/i04/

##### See Also

See Also as: fregre.lm, fregre.plm, fregre.glm, fregre.gsam and fregre.gkam.

##### Aliases
• predict.fregre.gkam
• predict.fregre.glm
• predict.fregre.gsam
• predict.fregre.lm
• predict.fregre.plm
##### Examples
# NOT RUN {
data(tecator)
ind<-1:129
x=tecator$absorp.fdata x.d2<-fdata.deriv(x,nderiv=2) tt<-x[["argvals"]] dataf=as.data.frame(tecator$y)
nbasis.x=11;nbasis.b=7
basis1=create.bspline.basis(rangeval=range(tt),nbasis=nbasis.x)
basis2=create.bspline.basis(rangeval=range(tt),nbasis=nbasis.b)
basis.x=list("x.d2"=basis1)
basis.b=list("x.d2"=basis2)
ldata=list("df"=dataf[ind,],"x.d2"=x.d2[ind])

res=fregre.gsam(Fat~s(Water,k=3)+s(x.d2,k=3),data=ldata,
family=gaussian(),basis.x=basis.x,basis.b=basis.b)
newldata=list("df"=dataf[-ind,],"x.d2"=x.d2[-ind])
pred<-predict(res,newldata)
plot(pred,tecator$y$Fat[-ind])

res.glm=fregre.glm(Fat~Water+x.d2,data=ldata,family=gaussian(),
basis.x=basis.x,basis.b=basis.b)
pred.glm<-predict(res.glm,newldata)
newy<-tecator$y$Fat[-ind]
points(pred.glm,tecator$y$Fat[-ind],col=2)

# Time-consuming
res.gkam=fregre.gkam(Fat~x.d2,data=ldata)
pred.gkam=predict(res.gkam,newldata)
points(pred.gkam,tecator$y$Fat[-ind],col=4)

((1/length(newy))*sum((drop(newy)-pred)^2))/var(newy)
((1/length(newy))*sum((newy-pred.glm)^2))/var(newy)
((1/length(newy))*sum((newy-pred.gkam)^2))/var(newy)
# }

Documentation reproduced from package fda.usc, version 2.0.1, License: GPL-2

### Community examples

Looks like there are no examples yet.