Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fregre.gsam.vs

Variable Selection using Functional Additive Models


Description

Computes functional GAM model between functional covariates (X(t_1),...,X(t_q)) and non functional covariates (Z1,...,Zp) with a scalar response Y.

Usage

fregre.gsam.vs(
  data = list(),
  y,
  include = "all",
  exclude = "none",
  family = gaussian(),
  weights = NULL,
  basis.x = NULL,
  kbs,
  dcor.min = 0.1,
  alpha = 0.05,
  par.model,
  xydist,
  trace = FALSE
)

Arguments

data

List that containing the variables in the model. "df" element is a data.frame containing the response and scalar covariates (numeric and factors variables are allowed). Functional covariates of class fdata or fd are included as named components in the data list.

y

Caracter string with the name of the scalar response variable.

include

vector with the name of variables to use. By default "all", all variables are used.

exclude

vector with the name of variables to not use. By default "none", no variable is deleted.

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.)

weights

weights

basis.x

List of basis for functional covariates, see same argument in fregre.gsam. By default, the function uses a basis of 4 PC to represent the functional covariate.

kbs

The dimension of the basis used to represent the smooth term. The default depends on the number of variables that the smooth is a function of.

dcor.min

Threshold for a variable to be entered into the model. X is discarded if the distance correlation R(X,e)< dcor.min (e is the residual of previous steps).

alpha

Alpha value for testing the independence among covariate X and residual e in previous steps. By default is 0.05.

par.model

Model parameters.

xydist

List with the inner distance matrices of each variable (all potential covariates and the response).

trace

Interactive Tracing and Debugging of Call.

Details

This function is an extension of the functional generalized spectral additive regression models: fregre.gsam where the E[Y|X,Z] is related to the linear prediction η via a link function g(.) with integrated smoothness estimation by the smooth functions f(.).

E[Y|X,Z]=η=g^{-1}(α+∑_i f_i(Z_{i})+∑_k^q∑_{j=1}^{k_q}{f_j^k(ξ_j^k)})

where ξ_j^k is the coefficient of the basis function expansion of X^k, (in PCA analysis ξ_j^k is the score of the j-functional PC of X^k.

The smooth functions f(.) can be added to the right hand side of the formula to specify that the linear predictor depends on smooth functions of predictors using smooth terms s and te as in gam (or linear functionals of these as and < X(t),β(t) > in fregre.glm).

Value

Return an object corresponding to the estimated additive mdoel using the selected variables (ame output as thefregre.gsam function) and the following elements:

  • gof, the goodness of fit for each step of VS algorithm.

  • i.predictor, vector with 1 if the variable is selected, 0 otherwise.

  • ipredictor, vector with the name of selected variables (in order of selection)

  • dcor, the value of distance correlation for each potential covariate and the residual of the model in each step.

Note

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

Author(s)

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

References

Febrero-Bande, M., Gonz\'alez-Manteiga, W. and Oviedo de la Fuente, M. Variable selection in functional additive regression models, (2018). Computational Statistics, 1-19. DOI: https://doi.org/10.1007/s00180-018-0844-5

See Also

See Also as: predict.fregre.gsam and summary.gam. Alternative methods: fregre.glm, fregre.gsam and fregre.gkam.

Examples

## Not run:  
data(tecator)
x=tecator$absorp.fdata
x1 <- fdata.deriv(x)
x2 <- fdata.deriv(x,nderiv=2)
y=tecator$y$Fat
xcat0 <- cut(rnorm(length(y)),4)
xcat1 <- cut(tecator$y$Protein,4)
xcat2 <- cut(tecator$y$Water,4)
ind <- 1:129
dat    <- data.frame("Fat"=y, x1$data, xcat1, xcat2)
ldat <- list("df"=dat[ind,],"x"=x[ind,],"x1"=x1[ind,],"x2"=x2[ind,])
# 3 functionals (x,x1,x2), 3 factors (xcat0, xcat1, xcat2)
# and 100 scalars (impact poitns of x1) 

# Time consuming
res.gam1 <- fregre.gsam.vs(data=ldat,y="Fat") # All the covariates
summary(res.gam1)
res.gam1$ipredictors

covar <- c("xcat0","xcat1","xcat2","x","x1","x2")
res.gam2 <- fregre.gsam.vs(data=ldat, y="Fat", include=covar)
summary(res.gam2)
res.gam2$ipredictors 

# Prediction like fregre.gsam() 
newldat <- list("df"=dat[-ind,],"x"=x[-ind,],"x1"=x1[-ind,],
                "x2"=x2[-ind,])
pred.gam1 <- predict(res.gam1,newldat)
pred.gam2 <- predict(res.gam2,newldat)
plot(dat[-ind,"Fat"],pred.gam1)
points(dat[-ind,"Fat"],pred.gam2,col=2)

## End(Not run)

fda.usc

Functional Data Analysis and Utilities for Statistical Computing

v2.0.2
GPL-2
Authors
Manuel Febrero Bande [aut], Manuel Oviedo de la Fuente [aut, cre], Pedro Galeano [ctb], Alicia Nieto [ctb], Eduardo Garcia-Portugues [ctb]
Initial release
2020-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.