Projpred varsel specifying search_terms

Could somebody show me how to specify the search_terms list in the varsel() function?

Here is a minimal example, model first …

library(rstanarm)

n ← 30
d ← 5
x ← matrix(rnorm(nd), nrow=n)
y ← x[,1] + 0.5
rnorm(n)
data ← data.frame(x,y)
fit ← stan_glm(y ~ X1 + X2 + X3 + X4 + X5,
gaussian(),
data=data)

Then varsel on all terms in the model works OK.

library(projpred)
vs1 ← varsel(fit)
vs1

But how to select a subset of terms?


vs2 ← varsel(fit, search_terms=c(“X1”,“X2”,“X3”), method=“forward”)

vs3 ← varsel(fit, search_terms=list(“X1”,“X2”,“X3”), method=“forward”)

tt ← terms(fit)
term_list ← as.list(attr(tt, “variables”))
vs4 ← varsel(fit, search_terms=tt, method=“forward”)


All of these show the same error message
Error in sub[“kl”, i] : incorrect number of dimensions

What am I doing wrong?

Sorry for the delay. We’re lacking a proper documentation and vignette for search_terms. There’s some discussion at Advice on using search_terms in projpred - #4 by AlejandroCatalina

I have collected this and similar questions here. Perhaps the connection to related threads helps until this is resolved in the projpred package (e.g., by an explanation in the documentation).

Also sorry for delay for reply from me!

I could not find much in the forum searching for “varsel”. Searching on projpred shows a lot more about using varsel.

I have been looking at this in more detail– I will post something on the forum in the next day or so.

image002.jpg