Package 'logitFD'

Title: Functional Principal Components Logistic Regression
Description: Functions for fitting a functional principal components logit regression model in four different situations: ordinary and filtered functional principal components of functional predictors, included in the model according to their variability explanation power, and according to their prediction ability by stepwise methods. The proposed methods were developed in Escabias et al (2004) <doi:10.1080/10485250310001624738> and Escabias et al (2005) <doi:10.1016/j.csda.2005.03.011>.
Authors: Carmen Lucia Reina <[email protected]> Ana Maria Aguilera <[email protected]> and Manuel Escabias <[email protected]>
Maintainer: Manuel Escabias <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2024-12-17 06:53:43 UTC
Source: CRAN

Help Index


Filtered Functional Principal Component Logistic Regression by explained variability order

Description

Fit of the Filtered Functional Principal Component Logistic Regression model with selected Functional Principal Components included in the model according their explained variability.

Usage

logitFD.fpc(Response, FDobj = list(), ncomp = c(), nonFDvars = NULL)

Arguments

Response

Binary (numeric or character) vector of observations of the response variable.

FDobj

List of functional objects from fda package with the curves of the predictor functional variables.

ncomp

Numeric vector with the number of components to be considered for each functional predictor. The vector has equal lenght than FDobj.

nonFDvars

Matrix or data frame with the observations of non-functional variables.

Value

glm.fit

glm object of the fitted model. The object allows to use the summary() function for printing a summary of the fit, the anova() function to produce an analysis of variance table, and to extract useful features as coefficients, effects, fitted.values or residuals

Intercept

Intercept estimated parameter

betalist

List of functional objects (fdobj) of fda package with the estimated parameter functions. Each element of the list corresponds to the associated functional predictor located in the same position of FDobj. All methods of fd package can be used as the plot() function among others.

PC.variance

List of data frames with explained variability of functional principal components of functional predictors. Each element of the list contains the acumulation variance matrix corresponding to the associated functional variable in the same position.

ROC.curve

Object of the roc() function of the pROC package for prediction ability testing of the model. The object can be printed, plotted, or passed to many other functions

Author(s)

Carmen Lucia Reina <[email protected]> and Manuel Escabias <[email protected]>

Examples

library(fda.usc)
data(aemet)
Temp<-aemet$temp$data
Prec<-exp(aemet$logprec$data)
StationsVars<-aemet$df[,c("ind","altitude","longitude","latitude")]
StationsVars$North<-c(1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,1,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1)
TempMonth<-matrix(0,73,12)
PrecMonth<-matrix(0,73,12)
for (i in 1:nrow(TempMonth)){
  TempMonth[i,1]<-mean(Temp[i,1:31])
  PrecMonth[i,1]<-mean(Prec[i,1:31])
  TempMonth[i,2]<-mean(Temp[i,32:59])
  PrecMonth[i,2]<-mean(Prec[i,32:59])
  TempMonth[i,3]<-mean(Temp[i,60:90])
  PrecMonth[i,3]<-mean(Prec[i,60:90])
  TempMonth[i,4]<-mean(Temp[i,91:120])
  PrecMonth[i,4]<-mean(Prec[i,91:120])
  TempMonth[i,5]<-mean(Temp[i,121:151])
  PrecMonth[i,5]<-mean(Prec[i,121:151])
  TempMonth[i,6]<-mean(Temp[i,152:181])
  PrecMonth[i,6]<-mean(Prec[i,152:181])
  TempMonth[i,7]<-mean(Temp[i,182:212])
  PrecMonth[i,7]<-mean(Prec[i,182:212])
  TempMonth[i,8]<-mean(Temp[i,213:243])
  PrecMonth[i,8]<-mean(Prec[i,213:243])
  TempMonth[i,9]<-mean(Temp[i,244:273])
  PrecMonth[i,9]<-mean(Prec[i,244:273])
  TempMonth[i,10]<-mean(Temp[i,274:304])
  PrecMonth[i,10]<-mean(Prec[i,274:304])
  TempMonth[i,11]<-mean(Temp[i,305:334])
  PrecMonth[i,11]<-mean(Prec[i,305:334])
  TempMonth[i,12]<-mean(Temp[i,335:365])
  PrecMonth[i,12]<-mean(Prec[i,335:365])
  }
FourierBasis<-create.fourier.basis(rangeval = c(1,12),nbasis=7)
BsplineBasis<-create.bspline.basis(rangeval = c(1,12),nbasis=8)
TempMonth.fd<-Data2fd(argvals = c(1:12), y=t(TempMonth),basisobj = FourierBasis)
PrecMonth.fd<-Data2fd(argvals = c(1:12), y=t(PrecMonth),basisobj = BsplineBasis)
logitFD.fpc(Response=StationsVars$North,FDobj=list(TempMonth.fd,PrecMonth.fd),
 ncomp = c(3,4),nonFDvars = StationsVars[,c("altitude","longitude")])

Filtered Functional Principal Component Logistic Regression by stepwise order

Description

Fit of the Filtered Functional Principal Component Logistic Regression model with Functional Principal Components and nonfunctional variables included in the model according their prediction ability by an authomatic stepwise selection method.

Usage

logitFD.fpc.step(Response, FDobj = list(), nonFDvars = NULL)

Arguments

Response

Binary (numeric or character) vector of observations of the response variable.

FDobj

List of functional objects from fda package with the curves of the predictor functional variables.

nonFDvars

Matrix or data frame with the observations of non-functional variables.

Value

glm.fit

glm object of the fitted model. The object allows to use the summary() function for printing a summary of the fit, the anova() function to produce an analysis of variance table, and to extract useful features as coefficients, effects, fitted.values or residuals

Intercept

Intercept estimated parameter

betalist

List of functional objects (fdobj) of fda package with the estimated parameter functions. Each element of the list corresponds to the associated functional predictor located in the same position of FDobj. All methods of fd package can be used as the plot() function among others.

PC.variance

List of data frames with explained variability of functional principal components of functional predictors. Each element of the list contains the acumulation variance matrix corresponding to the associated functional variable in the same position.

ROC.curve

Object of the roc() function of the pROC package for prediction ability testing of the model. The object can be printed, plotted, or passed to many other functions

Author(s)

Carmen Lucia Reina <[email protected]> and Manuel Escabias <[email protected]>

Examples

library(fda.usc)
data(aemet)
Temp<-aemet$temp$data
Prec<-exp(aemet$logprec$data)
StationsVars<-aemet$df[,c("ind","altitude","longitude","latitude")]
StationsVars$North<-c(1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,1,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1)
TempMonth<-matrix(0,73,12)
PrecMonth<-matrix(0,73,12)
for (i in 1:nrow(TempMonth)){
  TempMonth[i,1]<-mean(Temp[i,1:31])
  PrecMonth[i,1]<-mean(Prec[i,1:31])
  TempMonth[i,2]<-mean(Temp[i,32:59])
  PrecMonth[i,2]<-mean(Prec[i,32:59])
  TempMonth[i,3]<-mean(Temp[i,60:90])
  PrecMonth[i,3]<-mean(Prec[i,60:90])
  TempMonth[i,4]<-mean(Temp[i,91:120])
  PrecMonth[i,4]<-mean(Prec[i,91:120])
  TempMonth[i,5]<-mean(Temp[i,121:151])
  PrecMonth[i,5]<-mean(Prec[i,121:151])
  TempMonth[i,6]<-mean(Temp[i,152:181])
  PrecMonth[i,6]<-mean(Prec[i,152:181])
  TempMonth[i,7]<-mean(Temp[i,182:212])
  PrecMonth[i,7]<-mean(Prec[i,182:212])
  TempMonth[i,8]<-mean(Temp[i,213:243])
  PrecMonth[i,8]<-mean(Prec[i,213:243])
  TempMonth[i,9]<-mean(Temp[i,244:273])
  PrecMonth[i,9]<-mean(Prec[i,244:273])
  TempMonth[i,10]<-mean(Temp[i,274:304])
  PrecMonth[i,10]<-mean(Prec[i,274:304])
  TempMonth[i,11]<-mean(Temp[i,305:334])
  PrecMonth[i,11]<-mean(Prec[i,305:334])
  TempMonth[i,12]<-mean(Temp[i,335:365])
  PrecMonth[i,12]<-mean(Prec[i,335:365])
  }
FourierBasis<-create.fourier.basis(rangeval = c(1,12),nbasis=7)
BsplineBasis<-create.bspline.basis(rangeval = c(1,12),nbasis=8)
TempMonth.fd<-Data2fd(argvals = c(1:12), y=t(TempMonth),basisobj = FourierBasis)
PrecMonth.fd<-Data2fd(argvals = c(1:12), y=t(PrecMonth),basisobj = BsplineBasis)
logitFD.fpc.step(Response=StationsVars$North,FDobj=list(TempMonth.fd,PrecMonth.fd),
 nonFDvars = StationsVars[,c("altitude","longitude")])

Functional Principal Component Logistic Regression by explained variability order

Description

Fit of the Functional Principal Component Logistic Regression model with selected Functional Principal Components included in the model according their explained variability.

Usage

logitFD.pc(Response, FDobj = list(), ncomp = c(), nonFDvars = NULL)

Arguments

Response

Binary (numeric or character) vector of observations of the response variable.

FDobj

List of functional objects from fda package with the curves of the predictor functional variables.

ncomp

Numeric vector with the number of components to be considered for each functional predictor. The vector has equal lenght than FDobj.

nonFDvars

Matrix or data frame with the observations of non-functional variables.

Value

glm.fit

glm object of the fitted model. The object allows to use the summary() function for printing a summary of the fit, the anova() function to produce an analysis of variance table, and to extract useful features as coefficients, effects, fitted.values or residuals

Intercept

Intercept estimated parameter

betalist

List of functional objects (fdobj) of fda package with the estimated parameter functions. Each element of the list corresponds to the associated functional predictor located in the same position of FDobj. All methods of fd package can be used as the plot() function among others.

PC.variance

List of data frames with explained variability of functional principal components of functional predictors. Each element of the list contains the acumulation variance matrix corresponding to the associated functional variable in the same position.

ROC.curve

Object of the roc() function of the pROC package for prediction ability testing of the model. The object can be printed, plotted, or passed to many other functions

Author(s)

Carmen Lucia Reina <[email protected]> and Manuel Escabias <[email protected]>

Examples

library(fda.usc)
data(aemet)
Temp<-aemet$temp$data
Prec<-exp(aemet$logprec$data)
StationsVars<-aemet$df[,c("ind","altitude","longitude","latitude")]
StationsVars$North<-c(1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,1,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1)
TempMonth<-matrix(0,73,12)
PrecMonth<-matrix(0,73,12)
for (i in 1:nrow(TempMonth)){
  TempMonth[i,1]<-mean(Temp[i,1:31])
  PrecMonth[i,1]<-mean(Prec[i,1:31])
  TempMonth[i,2]<-mean(Temp[i,32:59])
  PrecMonth[i,2]<-mean(Prec[i,32:59])
  TempMonth[i,3]<-mean(Temp[i,60:90])
  PrecMonth[i,3]<-mean(Prec[i,60:90])
  TempMonth[i,4]<-mean(Temp[i,91:120])
  PrecMonth[i,4]<-mean(Prec[i,91:120])
  TempMonth[i,5]<-mean(Temp[i,121:151])
  PrecMonth[i,5]<-mean(Prec[i,121:151])
  TempMonth[i,6]<-mean(Temp[i,152:181])
  PrecMonth[i,6]<-mean(Prec[i,152:181])
  TempMonth[i,7]<-mean(Temp[i,182:212])
  PrecMonth[i,7]<-mean(Prec[i,182:212])
  TempMonth[i,8]<-mean(Temp[i,213:243])
  PrecMonth[i,8]<-mean(Prec[i,213:243])
  TempMonth[i,9]<-mean(Temp[i,244:273])
  PrecMonth[i,9]<-mean(Prec[i,244:273])
  TempMonth[i,10]<-mean(Temp[i,274:304])
  PrecMonth[i,10]<-mean(Prec[i,274:304])
  TempMonth[i,11]<-mean(Temp[i,305:334])
  PrecMonth[i,11]<-mean(Prec[i,305:334])
  TempMonth[i,12]<-mean(Temp[i,335:365])
  PrecMonth[i,12]<-mean(Prec[i,335:365])
  }
FourierBasis<-create.fourier.basis(rangeval = c(1,12),nbasis=7)
BsplineBasis<-create.bspline.basis(rangeval = c(1,12),nbasis=8)
TempMonth.fd<-Data2fd(argvals = c(1:12), y=t(TempMonth),basisobj = FourierBasis)
PrecMonth.fd<-Data2fd(argvals = c(1:12), y=t(PrecMonth),basisobj = BsplineBasis)
logitFD.pc(Response=StationsVars$North,FDobj=list(TempMonth.fd,PrecMonth.fd),
 ncomp = c(3,4),nonFDvars = StationsVars[,c("altitude","longitude")])

Functional Principal Component Logistic Regression by stepwise order

Description

Fit of the Functional Principal Component Logistic Regression model with Functional Principal Components and nonfunctional variables included in the model according their prediction ability by an authomatic stepwise selection method.

Usage

logitFD.pc.step(Response, FDobj = list(), nonFDvars = NULL)

Arguments

Response

Binary (numeric or character) vector of observations of the response variable.

FDobj

List of functional objects from fda package with the curves of the predictor functional variables.

nonFDvars

Matrix or data frame with the observations of non-functional variables.

Value

glm.fit

glm object of the fitted model. The object allows to use the summary() function for printing a summary of the fit, the anova() function to produce an analysis of variance table, and to extract useful features as coefficients, effects, fitted.values or residuals

Intercept

Intercept estimated parameter

betalist

List of functional objects (fdobj) of fda package with the estimated parameter functions. Each element of the list corresponds to the associated functional predictor located in the same position of FDobj. All methods of fd package can be used as the plot() function among others.

PC.variance

List of data frames with explained variability of functional principal components of functional predictors. Each element of the list contains the acumulation variance matrix corresponding to the associated functional variable in the same position.

ROC.curve

Object of the roc() function of the pROC package for prediction ability testing of the model. The object can be printed, plotted, or passed to many other functions

Author(s)

Carmen Lucia Reina <[email protected]> and Manuel Escabias <[email protected]>

Examples

library(fda.usc)
data(aemet)
Temp<-aemet$temp$data
Prec<-exp(aemet$logprec$data)
StationsVars<-aemet$df[,c("ind","altitude","longitude","latitude")]
StationsVars$North<-c(1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,1,
0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1)
TempMonth<-matrix(0,73,12)
PrecMonth<-matrix(0,73,12)
for (i in 1:nrow(TempMonth)){
  TempMonth[i,1]<-mean(Temp[i,1:31])
  PrecMonth[i,1]<-mean(Prec[i,1:31])
  TempMonth[i,2]<-mean(Temp[i,32:59])
  PrecMonth[i,2]<-mean(Prec[i,32:59])
  TempMonth[i,3]<-mean(Temp[i,60:90])
  PrecMonth[i,3]<-mean(Prec[i,60:90])
  TempMonth[i,4]<-mean(Temp[i,91:120])
  PrecMonth[i,4]<-mean(Prec[i,91:120])
  TempMonth[i,5]<-mean(Temp[i,121:151])
  PrecMonth[i,5]<-mean(Prec[i,121:151])
  TempMonth[i,6]<-mean(Temp[i,152:181])
  PrecMonth[i,6]<-mean(Prec[i,152:181])
  TempMonth[i,7]<-mean(Temp[i,182:212])
  PrecMonth[i,7]<-mean(Prec[i,182:212])
  TempMonth[i,8]<-mean(Temp[i,213:243])
  PrecMonth[i,8]<-mean(Prec[i,213:243])
  TempMonth[i,9]<-mean(Temp[i,244:273])
  PrecMonth[i,9]<-mean(Prec[i,244:273])
  TempMonth[i,10]<-mean(Temp[i,274:304])
  PrecMonth[i,10]<-mean(Prec[i,274:304])
  TempMonth[i,11]<-mean(Temp[i,305:334])
  PrecMonth[i,11]<-mean(Prec[i,305:334])
  TempMonth[i,12]<-mean(Temp[i,335:365])
  PrecMonth[i,12]<-mean(Prec[i,335:365])
  }
FourierBasis<-create.fourier.basis(rangeval = c(1,12),nbasis=7)
BsplineBasis<-create.bspline.basis(rangeval = c(1,12),nbasis=8)
TempMonth.fd<-Data2fd(argvals = c(1:12), y=t(TempMonth),basisobj = FourierBasis)
PrecMonth.fd<-Data2fd(argvals = c(1:12), y=t(PrecMonth),basisobj = BsplineBasis)
logitFD.pc.step(Response=StationsVars$North,FDobj=list(TempMonth.fd,PrecMonth.fd),
 nonFDvars = StationsVars[,c("altitude","longitude")])