stan-dev / stan-dev/rstanarm

Question on "_NEW_"

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

Nobody has claimed this yet.

Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Summary:

The reason for having a new group level called "NEW" when performing stan_glmer

Description:

Why do we have a variable called b[(Intercept) Tree:_NEW_Tree]?

When I ran the R code below:

library(MASS) 
data()
nm1 <- stan_glmer(circumference ~ age + (1|Tree),data = Orange)
nm1_estimates <- rstan::extract(nm1$stanfit) 
head(nm1_estimates$b)

The matrix nm1_estimates$b has 6 columns. The col 1 to 5 corresponds to the five-level of "Tree", or b[(Intercept) Tree:3]:b[(Intercept) Tree:4]. The 6th column corresponds to b[(Intercept) Tree:_NEW_Tree]. b[(Intercept) Tree:3], b[(Intercept) Tree:4] and b[(Intercept) Tree:_NEW_Tree] are shown below:

nm1$stanfit

Why do we need a level b[(Intercept) Tree:_NEW_Tree]? How do we interpret it when we interpret the group effects?

According to the vignettes, "These random draws from the posterior distribution of the group-specific parameters are stored each time a joint model is estimated using stan_glmer, stan_mvmer, or stan_jm; they are saved under an ID value called "NEW".

Is the reason for having b[(Intercept) Tree:_NEW_Tree] because some levels might be missing when performing MCMC due to random simulation?

Reproducible Steps:

library(MASS)
data()
nm1 <- stan_glmer(circumference ~ age + (1|Tree),data = Orange)
nm1_estimates <- rstan::extract(nm1$stanfit)
head(nm1_estimates$b)

nm1$stanfit

RStanARM Version:

‘2.21.4’

R Version:

‘4.3.1’

Operating System:

macOS 11.7.7 (20G1345)

Contributor guide

No contributing guide indexed for this repository

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 the stan_glmer example and the vignette passage describing the "NEW" ID, then trace how nm1$stanfit exposes the b matrix. Document what the extra group level represents and how users should interpret it, including whether the reported MCMC explanation is correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.