rstanarm+loo - add baseline elpd
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 401
- Forks
- 136
- PR merge metrics
- No merged PRs in 30d
Description
Summary:
To improve the interpretability of elpd, we can give a baseline elpd result without any covariates just by fitting the given distribution by family argument. We can do that without need to run Stan for the baseline model. We could print the baseline when printing the loo result for a single model.
Description:
Here is an example with Bernoulli. The example case is at https://cdn.rawgit.com/avehtari/BDA_R_demos/5964b1b7/demos_rstan/diabetes.html
compute baseline
m<-sum(2-as.numeric(diabetes$outcome)) # number of successes
ab=2 # beta prior weight for intercept, 2 is equal to uniform prior
elpd0<-log((m-1+ab/2)/(n-1+ab))m+log((n-m-1+ab/2)/(n-1+ab))(n-m) # -1 comes from leaving one out
elpd02<-log((m-1+ab/2)/(n-1+ab))^2m+log((n-m-1+ab/2)/(n-1+ab))^2(n-m)
sdelpd0=sqrt((c/(n-1)-(b/(n-1))^2)*n)
sprintf("The baseline by guessing the larger class elpd_loo %.1f sd %.1f",elpd0,sdelpd0)
alternatively if we want to use pointwise for making also the pairwise comparison
elpd0_pointwise=matrix(0,1,n)
mi=2-as.numeric(diabetes$outcome)
elpd0_pointwise[mi==1]=log((m-1+ab/2)/(n-1+ab))
elpd0_pointwise[mi==0]=log((n-m-1+ab/2)/(n-1+ab))
elpd0=sum(elpd0_pointwise)
sdelpd0=sd(elpd0_pointwise)*sqrt(n)
sprintf("The baseline by guessing the larger class elpd_loo %.1f sd %.1f",elpd0,sdelpd0)
Contributor guide
No contributing guide indexed for this repository
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 by reviewing how a single-model loo result is printed and how the supplied family argument is handled. Compare the Bernoulli baseline formulas and the pointwise alternative in the issue, then determine how baseline elpd should be calculated and displayed without running Stan. Done means the single-model loo output includes the baseline result with its uncertainty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- analytics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100