# fregre.glm

##### Fitting Functional Generalized Linear Models

Computes functional generalized linear model between functional covariate \(X^j(t)\) (and non functional covariate \(Z^j\)) and scalar response \(Y\) using basis representation.

- Keywords
- regression

##### Usage

```
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 \(\beta(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 \(\eta\) via a link function \(g(.)\).

$$E[Y|X,Z]=\eta=g^{-1}(\alpha+\sum_{j=1}^{p}\beta_{j}Z^{j}+\sum_{k=1}^{q}\frac{1}{\sqrt{T_k}}\int_{T_k}{X^{k}(t)\beta_{k}(t)dt})$$

where \(Z=\left[ Z^1,\cdots,Z^p \right]\) are the non functional covariates and \(X(t)=\left[ X^{1}(t_1),\cdots,X^{q}(t_q) \right]\) 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 \(\beta(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:

`basis.x`

Basis used for`fdata`

or`fd`

covariates.`basis.b`

Basis used for beta parameter estimation.`beta.l`

List of estimated beta parameter of functional covariates.`data`

List that containing the variables in the model.`formula`

formula.`CV`

predicted response by cross-validation.

##### Note

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

procedure.

##### 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

```
# 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)
# }
```

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