stan-dev / stan-dev/projpred

`as.matrix.projection()` for GAMs: Naming scheme of parameters

Open
#152 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

additive enhancement
Dominant language
R
Stars
114
Forks
31
PR merge metrics
No merged PRs in 30d

Description

For GAMs, as.matrix.projection() does not follow brms's naming scheme (discussed in #75):

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

options(mc.cores = parallel::detectCores(logical = FALSE))
library(brms)
data(kidiq, package = "rstanarm")
fit_gauss <- brm(formula = kid_score ~ s(mom_iq),
                 data = kidiq,
                 seed = 469230)

library(projpred)
prj <- project(fit_gauss, solution_terms = c("s(mom_iq)"),
               ndraws = 25)
colnames(as.matrix(prj))

gives

 [1] "b_Intercept"   "b_s(mom_iq).1" "b_s(mom_iq).2" "b_s(mom_iq).3"
 [5] "b_s(mom_iq).4" "b_s(mom_iq).5" "b_s(mom_iq).6" "b_s(mom_iq).7"
 [9] "b_s(mom_iq).8" "b_s(mom_iq).9" "sigma"

whereas

colnames(as.matrix(fit_gauss))

gives

 [1] "b_Intercept"    "bs_smom_iq_1"   "sds_smom_iq_1"  "sigma"         
 [5] "s_smom_iq_1[1]" "s_smom_iq_1[2]" "s_smom_iq_1[3]" "s_smom_iq_1[4]"
 [9] "s_smom_iq_1[5]" "s_smom_iq_1[6]" "s_smom_iq_1[7]" "s_smom_iq_1[8]"
[13] "lp__"

Just a side note: As may be seen in issues #150 and #151, rstanarm uses a different naming scheme. It might make sense to have separate naming schemes depending on whether the reference model inherits from a "stanreg", a "brmsfit", or some different object. (In the latter case, one could use either rstanarm's or brms's naming scheme.) But that's probably a larger change and may be deferred to the future. I think for now, using brms naming scheme consistently should be enough.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with as.matrix.projection() and the project() path shown in the GAM reprex, then compare its column names with colnames(as.matrix(fit_gauss)). Review the naming discussion in #75 and the related rstanarm issues; done means the projected GAM matrix follows the brms naming scheme consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.