Skip to content

Unclear use of FPCR for prediction #102

@Ddelval

Description

@Ddelval

Hi,

I have been trying to use the fpca regression provided in this packet. However, after browsing the documentation, I have not yet been able to find an example of how to do it.

I have tried the following:

  • Calling predict with the result of fpcr. For instance:
    library("refund")
    library("fda")
    fda_train = Data2fd(1:365, CanadianWeather$dailyAv[,1:25,1], create.fourier.basis(c(0,365),9))
    fda_test = Data2fd(1:365, CanadianWeather$dailyAv[,26,1], create.fourier.basis(c(0,365),9))
    y = CanadianWeather$coordinates[,1]
    
    predictor = fpcr(y[1:25], fdobj=fda_train, ncomp=5, store.gam = TRUE)
    predict(predictor, fdobj=fda_test)
    This does not work at all and throws the following error
    Error in UseMethod("predict"): no applicable method for 'predict' applied to an object of class "fpcr"
    
  • Looking to work around this error, I tried to manually set the class of the object returned by fpcr to "gam", which gets rid of the error but then predict returns the prediction for the training dataset instead of the one provided in the call to predict.

I suspect that maybe calling predict with different parameters might solve these issues. However, I have tried several combinations to no avail. Could you please provide an example of the sequence of functions that have to be called to use the linear model created in pfcr as a predictor?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions