3

I am doing a functional regression in R (package fda)and am supposed to eliminate the intercept term. But the fda package in R seems have no such formula.

Here is what I wish to do:

fit.fd <- fRegress(Acc.fd~Velo.fd - 1)

where Acc.fd and Velo.fd are two functional objects in the package fda. But it is no different from:

fit.fd <- fRegress(Acc.fd~Velo.fd)

Since the result is deeply nested, I am adding an example so the codes could be run on a small scale and detail of result could be generated.

list3d <- rep(0, 10*5*2)
list3d <- array(list3d, c(10,5, 2))
# The data is 5 functions each evaluated at 10 points
# Indep variable
list3d[, , 2] <- matrix(rnorm(50, 0, 1), 10, 5)
# Response variable
list3d[, , 1] <- matrix(rnorm(50, 0, 0.1) , 10, 5)+list3d[, , 2] ^ 2 
dimnames(list3d)[[1]] <- seq(0,9)
time.range <- c(0, 9)
time.basis <- create.fourier.basis(time.range, nbasis = 3)
lfd <- vec2Lfd(c(0, (2*pi/20)^2, 0), rangeval = time.range)
time.lfd<- smooth.basisPar(seq(0,9),  list3d , time.basis, Lfdobj = lfd, lambda = 0.01)$fd
Acc.fd <- time.lfd[, 1]
Velo.fd <- time.lfd[, 2]
# Expecting to see without intercept here
fit.fd <- fRegress(Acc.fd ~ Velo.fd - 1)
# plot of coef func
plot(plotpoints, eval.fd(plotpoints, fit.fd$betaestlis$Velo.fd$fd))
# Plot of intercept func, I wish to limit it to zero
plot(plotpoints, eval.fd(plotpoints, fit.fd$betaestlis$const$fd))

# Compare with regular functional regression with no restriction
fit.fd <- fRegress(Acc.fd ~ Velo.fd)
plot(plotpoints, eval.fd(plotpoints, fit.fd$betaestlis$Velo.fd$fd))

So the no intercept option does not work the same way as in lm? Could anyone helps me out here? Many thanks!

Richard Li
  • 101
  • 3
  • If possible, provide us with reproducible data. At least **show** us by using `summary` function what the outputs of both these regressions are. And are you sure your regression line (of best fit) will/should definitely pass thro' origin (removing intercept)? – Arun Mar 02 '13 at 10:55
  • I have added some test data to the example and thank you for helping! – Richard Li Mar 02 '13 at 11:34

0 Answers0