`as.matrix.projection()` for GAMs: SDs for smoothing terms missing
Open
Nobody has claimed this yet.
additive
bug
- Dominant language
- R
- Stars
- 114
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
On branch develop (commit 96d8e11d6f0ad0a1f7836c51700cb676b364bee5), this reprex:
options(mc.cores = parallel::detectCores(logical = FALSE))
data("kidiq", package = "rstanarm")
kidiq <- head(kidiq, 45)
fit_gauss <- rstanarm::stan_gamm4(
kid_score ~ s(mom_iq),
data = kidiq,
iter = 500,
seed = 734572
)
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"
(so the output matrix does not include the SD(s) for the smoothing term) whereas
colnames(as.matrix(fit_gauss))
(correctly) gives
[1] "(Intercept)" "s(mom_iq).1"
[3] "s(mom_iq).2" "s(mom_iq).3"
[5] "s(mom_iq).4" "s(mom_iq).5"
[7] "s(mom_iq).6" "s(mom_iq).7"
[9] "s(mom_iq).8" "s(mom_iq).9"
[11] "sigma" "smooth_sd[s(mom_iq)1]"
[13] "smooth_sd[s(mom_iq)2]"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the as.matrix.projection() entry point and reproduce the supplied GAM example to compare its column names with as.matrix(fit_gauss). Trace how projection terms are converted into matrix columns, then ensure the smoothing-term SD columns are retained. Done means the projected matrix includes the expected smooth_sd columns for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100