Learn R Programming

FREG (version 1.1)

freg: Functional linear regression model

Description

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

Usage

freg(formula, betalist = NULL)

Arguments

formula

a formula expression of the form response ~ predictors. On the left side of the formula, y is a numeric 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

Examples

Run this code
# NOT RUN {
library(fda)
y = log10(apply(daily$precav,2,sum))
x = daily$tempav
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
formula = y ~ xfd
# betalist is an optional argument
bbasis = create.fourier.basis(c(1,365),5) # 5 basis functions
betalist = list(bbasis)
freg.model = freg(formula = formula, betalist = betalist)

# Functional variable and two scalar variables
latitude = CanadianWeather$coordinates[,1]
longitude = CanadianWeather$coordinates[,2]
xfdlist = list(xfd, latitude, longitude)
cbasis = create.constant.basis(c(1,365))
betalist = list(bbasis, cbasis, cbasis)
formula = y ~ xfd + latitude + longitude
freg.model = freg(formula = formula, betalist = betalist)
print(freg.model$coefficients)

# }

Run the code above in your browser using DataLab