I've begun to think about the FPCR implementation for pfr(). Phil or Rayman, this is your stuff so you can of course overrule anything that I suggest.
I'm thinking of having FPC terms specified using a fpc() special term/function. e.g.,
fit <- pfr(Y ~ fpc(X) + other_covariates)
From what I understand of the FPCR algorithm, first, you fit a penalized B-spline basis to each function, then you calculate the principal components based on the smoothed functions. The loadings for each subject are used as (unpenalized) predictors in a linear model. Phil or Rayman, could you confirm?
These first two steps (b-spline smoothing followed by calculating the PC’s) are one way of doing FPCA. In refund we actually have a number of ways to do FPCA - e.g., in lf() and af() we allow for any of the following pre-smoothing “methods”: fpca.sc, fpca.face, fpca.ssvd, fpca.bspline, and fpca.interpolate. For the FPCR_R implementation, we could very easily allow for any of these methods - and to maintain consistency with the other functions, I think we should. Jeff has written a function to sort through and handle all these cases, which is held onto by the pfr object so the model knows how to use it to make predictions for a new dataset.
One issue is that I don’t think any of the existing fpca.XXX methods do the penalized B-spline basis that is in fpcr (fpca.bspline is unpenalized), though I think fpca.face is close to that, IIRC. We could add fpca.pspline to do penalized b-splines, or we could just use fpca.face if they are that similar. Either way, this would be the default presmooth method for fpc().
That's all I've really thought about so far. It seems like it would be pretty simple to implement a very basic version of the method fairly quickly. The things that would take more time to figure out are (1) the cross-validation stuff, and (2) allowing for 2-D functional predictors.
I've begun to think about the FPCR implementation for
pfr()
. Phil or Rayman, this is your stuff so you can of course overrule anything that I suggest.I'm thinking of having FPC terms specified using a
fpc()
special term/function. e.g.,From what I understand of the FPCR algorithm, first, you fit a penalized B-spline basis to each function, then you calculate the principal components based on the smoothed functions. The loadings for each subject are used as (unpenalized) predictors in a linear model. Phil or Rayman, could you confirm?
These first two steps (b-spline smoothing followed by calculating the PC’s) are one way of doing FPCA. In refund we actually have a number of ways to do FPCA - e.g., in
lf()
andaf()
we allow for any of the following pre-smoothing “methods”:fpca.sc
,fpca.face
,fpca.ssvd
,fpca.bspline
, andfpca.interpolate
. For the FPCR_R implementation, we could very easily allow for any of these methods - and to maintain consistency with the other functions, I think we should. Jeff has written a function to sort through and handle all these cases, which is held onto by thepfr
object so the model knows how to use it to make predictions for a new dataset.One issue is that I don’t think any of the existing
fpca.XXX
methods do the penalized B-spline basis that is infpcr
(fpca.bspline
is unpenalized), though I thinkfpca.face
is close to that, IIRC. We could addfpca.pspline
to do penalized b-splines, or we could just usefpca.face
if they are that similar. Either way, this would be the defaultpresmooth
method forfpc()
.That's all I've really thought about so far. It seems like it would be pretty simple to implement a very basic version of the method fairly quickly. The things that would take more time to figure out are (1) the cross-validation stuff, and (2) allowing for 2-D functional predictors.