refunders / refund

Regression with functional data
40 stars 23 forks source link

Piping data into pfr() breaks, but only sometimes #103

Open jeff-goldsmith opened 1 year ago

jeff-goldsmith commented 1 year ago

In the example below, providing the data argument in the function call works with and without a scalar predictor (with a functional predictor in both cases). But piping a dataset in and using the . placeholder only works when there is no scalar predictor.

Any thoughts on why this might be the case?

Probably not critical at this juncture, since you can fit the model easily -- but might be nice to address.

library(refund)
library(tidyverse)

data(DTI)
DTI1 <- DTI[DTI$visit==1 & complete.cases(DTI),]

## WORKS: 

# functional predictor only
fit.lf <- 
  pfr(pasat ~ lf(cca, k=30, bs="ps"), data = DTI1)

# functional predictor only using pipes
fit.lf <- 
  DTI1 %>% 
  pfr(pasat ~ lf(cca, k=30, bs="ps"), data = .)

# functional and scalar predictor
fit.lf <- 
  pfr(pasat ~ case + lf(cca, k=30, bs="ps"), data = DTI1)

## BREAKS:

# functional and scalar predictor
fit.lf <- 
  DTI1 %>% 
  pfr(pasat ~ case + lf(cca, k=30, bs="ps"), data = .)
#> Error in eval(call$data): object '.' not found

Created on 2023-03-15 with reprex v2.0.2