projpred icon indicating copy to clipboard operation
projpred copied to clipboard

`varsel()` for GAMMs: `object not found` error

Open fweber144 opened this issue 3 years ago • 1 comments

On branch develop (commit 96d8e11d6f0ad0a1f7836c51700cb676b364bee5), this reprex:

options(mc.cores = parallel::detectCores(logical = FALSE))
data("kidiq", package = "rstanarm")
kidiq_gr <- within(kidiq, {
  mom_age_gr <- cut(mom_age,
                    breaks = unique(quantile(mom_age, probs = seq(0, 1, 0.1))),
                    include.lowest = TRUE)
})
fit_gauss_gamm <- rstanarm::stan_gamm4(
  kid_score ~ s(mom_iq, by = mom_age_gr),
  random = ~ (mom_iq | mom_age_gr),
  data = kidiq_gr,
  iter = 500,
  seed = 734572
)

library(projpred)
### To avoid issue #144:
library(lme4)
###
vs_gauss_gamm <- varsel(fit_gauss_gamm, nclusters = 3, nclusters_pred = 5)

throws the following error:

Error in eval(formula[[2]], data, environment(formula)) : 
  object 'mom_age_gr' not found

fweber144 avatar Jun 10 '21 13:06 fweber144

This happens because we have not implemented parsing support for by syntax in smooth terms. It is desirable to have but we haven’t had the time yet.

Best, Alejandro On 10 Jun 2021, 4:09 PM +0300, Frank Weber @.***>, wrote:

On branch develop (commit 96d8e11), this reprex: options(mc.cores = parallel::detectCores(logical = FALSE)) data("kidiq", package = "rstanarm") kidiq_gr <- within(kidiq, { mom_age_gr <- cut(mom_age, breaks = unique(quantile(mom_age, probs = seq(0, 1, 0.1))), include.lowest = TRUE) }) fit_gauss_gamm <- rstanarm::stan_gamm4( kid_score ~ s(mom_iq, by = mom_age_gr), random = ~ (mom_iq | mom_age_gr), data = kidiq_gr, iter = 500, seed = 734572 )

library(projpred)

To avoid issue #144:

library(lme4)

vs_gauss_gamm <- varsel(fit_gauss_gamm, nclusters = 3, nclusters_pred = 5) throws the following error: Error in eval(formula[[2]], data, environment(formula)) : object 'mom_age_gr' not found — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

AlejandroCatalina avatar Jun 14 '21 17:06 AlejandroCatalina