projpred icon indicating copy to clipboard operation
projpred copied to clipboard

`split_formula()` for special terms

Open fweber144 opened this issue 3 years ago • 1 comments

It seems like split_formula() doesn't handle predictor terms with arithmetic expressions properly:

options(mc.cores = parallel::detectCores(logical = FALSE))
data("df_gaussian", package = "projpred")
mydat <- cbind("y" = df_gaussian$y, as.data.frame(df_gaussian$x))
library(rstanarm)
myfit <- stan_glm(y ~ V1 + abs(V2) + V3 + V4 + V5,
                  data = mydat,
                  seed = 1140350788)

library(projpred)
my_vs <- varsel(myfit, nclusters = 3, nclusters_pred = 5, seed = 34632)

throws the error

Error in out$smooth.spec[[1]] : subscript out of bounds

I guess the underlying issue is that within split_formula(), the term abs(V2) is recognized as an additive term (see object additive_terms there).

fweber144 avatar Jul 26 '21 12:07 fweber144

This is a known limitation of the current system and it’s on the todo list, thanks for reporting.

From: Frank Weber @.> Date: Monday, 26. July 2021 at 15.54 To: stan-dev/projpred @.> Cc: Subscribed @.***> Subject: [stan-dev/projpred] split_formula() for special terms (#182)

It seems like split_formula() doesn't handle predictor terms with arithmetic expressions properly:

options(mc.cores = parallel::detectCores(logical = FALSE))

data("df_gaussian", package = "projpred")

mydat <- cbind("y" = df_gaussian$y, as.data.frame(df_gaussian$x))

library(rstanarm)

myfit <- stan_glm(y ~ V1 + abs(V2) + V3 + V4 + V5,

              data = mydat,

              seed = 1140350788)

library(projpred)

my_vs <- varsel(myfit, nclusters = 3, nclusters_pred = 5, seed = 34632)

throws the error

Error in out$smooth.spec[[1]] : subscript out of bounds

I guess the underlying issue is that within split_formula(), the term abs(V2) is recognized as an additive term (see object additive_terms there).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/stan-dev/projpred/issues/182, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABZ5FH2NTN3T7OXHLQG3CJDTZVLJTANCNFSM5BABM52A.

AlejandroCatalina avatar Jul 31 '21 10:07 AlejandroCatalina