Learn R Programming

FREG (version 1.1)

lfreg: Functional logistic regression model

Description

Functional logistic regression model in which the response variable is a factor variable whereas the independent variables are functional variables. Independent variables could also be scalar variables.

Usage

lfreg(formula, betalist = NULL)

Arguments

formula

a formula expression of the form response ~ predictors. On the left side of the formula, y is a factor variable whereas on the right side, X can be either functional data object of class fd or a scalar variable of class numeric. The length of a scalar variable must equal the length of a response variable. Similarly, the number of observations of a functional covariate must equal the length of a response variable.

betalist

an optional argument. A list which contains beta regression coefficient functions for independent variables. If betalist is not provided, the number of estimated beta regression coefficient functions for one functional covariate would equal the number of basis functions used to represent that functional covariate. For a scalar variable, beta regression coefficient function is also a functional object whose basis is constant. Needless to say, for a scalar variable, there will be one beta regression coefficient.

Value

call

call of the lfreg function

x.count

number of predictors

xfdlist

a list of functional data objects. The length of the list is equal to the number of predictors

betalist

a list of beta regression coefficient functions

coefficients

estimated beta regression coefficient functions

fitted.values

predicted values of a response variable y

loglik

a value of log-likelihood function at optimum

df

degrees of freedom

AIC

Akaike information criterion

iteration

number of iterations needed for convergence criterion to be met

Examples

Run this code
# NOT RUN {
library(fda)
precipitation_data = CanadianWeather$daily[,,"Precipitation.mm"]
annualprec = apply(precipitation_data,2,sum)
y = ifelse(annualprec<mean(annualprec), 0, 1)
y = as.factor(y)
x = CanadianWeather$daily[,,"Temperature.C"]
xbasis = create.fourier.basis(c(1,365),5) # 5 basis functions
# smoothing of the data and extraction of functional data object
xfd = smooth.basis(c(1:365),x,xbasis)$fd
# bbasis and betalist are optional arguments
bbasis = create.fourier.basis(c(0,365),3) # 3 bf
betalist = list(bbasis)
formula = y ~ xfd
lfreg.model = lfreg(formula, betalist = betalist)
# add scalar variables
latitude = CanadianWeather$coordinates[,1]
longitude = CanadianWeather$coordinates[,2]
# cbasis and betalist are optional arguments
cbasis = create.constant.basis(c(1,365))
betalist = list(bbasis, cbasis, cbasis)
formula = y ~ xfd + latitude + longitude
lfreg.model = lfreg(formula, betalist = betalist)
# }

Run the code above in your browser using DataLab