fregre.glm: Fitting Functional Generalized Linear Models

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/fregre.glm.R

Description

Computes functional generalized linear model between functional covariate X_j(t) (and non functional covariate Z_j) and scalar response Y using basis representation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fregre.glm(
  formula,
  family = gaussian(),
  data,
  basis.x = NULL,
  basis.b = NULL,
  CV = FALSE,
  subset = NULL,
  ...
)

Arguments

formula

an object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under Details.

family

a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See family for details of family functions.)

data

List that containing the variables in the model.

basis.x

List of basis for functional explanatory data estimation.

basis.b

List of basis for β(t) parameter estimation.

CV

=TRUE, Cross-validation (CV) is done .

subset

an optional vector specifying a subset of observations to be used in the fitting process.

...

Further arguments passed to or from other methods.

Details

This function is an extension of the linear regression models: fregre.lm where the E[Y|X,Z] is related to the linear prediction η via a link function g(.).

E[Y|X,Z]= η = g^{-1}(α + ∑ β_j Z_j+∑ < X_k(t) , β_k(t) >)

where Z = [Z_1 ,..., Z_p] are the non functional covariates and X(t) = [ X_1(t_1) ,..., X_q(t_q)] are the functional ones.

The first item in the data list is called "df" and is a data frame with the response and non functional explanatory variables, as glm.

Functional covariates of class fdata or fd are introduced in the following items in the data list.
basis.x is a list of basis for represent each functional covariate. The basis object can be created by the function: create.pc.basis, pca.fd create.pc.basis, create.fdata.basis o create.basis.
basis.b is a list of basis for represent each β(t) parameter. If basis.x is a list of functional principal components basis (see create.pc.basis or pca.fd) the argument basis.b is ignored.

represent beta lower than the number of basis used to represent the functional data.

Value

Return glm object plus:

Note

If the formula only contains a non functional explanatory variables (multivariate covariates), the function compute a standard glm procedure.

Author(s)

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

References

Ramsay, James O., and Silverman, Bernard W. (2006), Functional Data Analysis, 2nd ed., Springer, New York.

McCullagh and Nelder (1989), Generalized Linear Models 2nd ed. Chapman and Hall.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S, New York: Springer.

See Also

See Also as: predict.fregre.glm and summary.glm.
Alternative method if family=gaussian: fregre.lm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run:  
data(tecator)
x=tecator$absorp.fdata
y=tecator$y$Fat
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)
f=Fat~Protein+x
basis.x=list("x"=basis1)
basis.b=list("x"=basis2)
ldata=list("df"=dataf,"x"=x)
res=fregre.glm(f,family=gaussian(),data=ldata,basis.x=basis.x,
basis.b=basis.b)
summary(res)

## End(Not run)

Example output

Loading required package: fda
Loading required package: splines
Loading required package: Matrix

Attaching package: 'fda'

The following object is masked from 'package:graphics':

    matplot

Loading required package: MASS
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-28. For overview type 'help("mgcv-package")'.
Loading required package: rpart

Call:
glm(formula = pf)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-9.6493  -1.8616   0.0345   2.1887   6.8098  

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  36.4452     3.1701  11.497  < 2e-16 ***
Protein      -1.0351     0.1789  -5.785 2.66e-08 ***
x.bspl4.1    29.7476     4.7372   6.280 1.98e-09 ***
x.bspl4.2   -37.5987     5.3338  -7.049 2.67e-11 ***
x.bspl4.3    25.0465     5.2888   4.736 4.06e-06 ***
x.bspl4.4   -12.6822     4.7391  -2.676  0.00805 ** 
x.bspl4.5    12.5458     6.3286   1.982  0.04877 *  
x.bspl4.6   -14.2270     7.7508  -1.836  0.06786 .  
x.bspl4.7    11.7799     6.2063   1.898  0.05909 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 8.569791)

    Null deviance: 34735.4  on 214  degrees of freedom
Residual deviance:  1765.4  on 206  degrees of freedom
AIC: 1082.8

Number of Fisher Scoring iterations: 2

fda.usc documentation built on Feb. 18, 2020, 1:07 a.m.