I got an error
quitting from lines 696-706 (pool-no-pool.Rmd)
Error in eval(expr, envir, enclos) : object 'ss_hier_logit' not found
I'm new to R (started learning a week ago), so maybe it's my fault.
You can also send me the HTML file.
Aki
I'll fix the issue, and I'll send you the HTML. The PDF's
just too huge because it uses PDF figures (probably configurable
if I could somehow penetrate the knitr doc).
I'm not sure what I'm looking at. Which piece of it
reduces size relative to the defaults?
Before releasing to our users, I'd like to get some feedback
on a knitr doc I wrote as an intro to hierarchical modeling
for repeated binary trials. It lives here:
stan-dev/example-models/knitr/efron-morris/pool-no-pool.Rmd
Avi
I'm also plotting replications for the kind of chi-by-eye
thing Andrew likes.
I'm only vaguely familiar with power calculations from Gelman and
Hill, so I tried reading this:
https://en.wikipedia.org/wiki/Statistical_power
which says it's:
the probability that the test correctly rejects the null hypothesis (H0)
when the alternative hypothesis (H1) is true.
All the negation is like a logic puzzle.
1) You have:
df <- data.frame(FirstName = df$FirstName,
LastName = df$LastName,
Hits = df$Hits,
At.Bats = df$At.Bats,
RemainingAt.Bats = df$RemainingAt.Bats,
RemainingHits = df$SeasonHits - df$Hits)
but you can do the same thing like this:
df <- with(df, data.frame(FirstName, LastName,
Hits, At.Bats,
RemainingAt.Bats,
RemainingHits = SeasonHits - Hits))
which avoids the df$ on every line and the repetition of variable names (which are both pet peeves of mine, but maybe that's just me).
2) The same thing goes for working with the lists that rstan::extract returns. For
example, this
phi_sim <- ss_hier$phi;
kappa_sim <- ss_hier$kappa;
df_bda3_fig_5_3 <- data.frame(x = log(phi_sim / (1 - phi_sim)),
y = log(kappa_sim));
can be done in one line without the intermediate steps of creating phi_sim and
kappa_sim:
df_bda3_fig_5_3 <- with(ss_hier, data.frame(x = log(phi / (1 - phi)),
y = log(kappa)))
3) You can do the same thing later in the file when working with the next model:
mu_sim <- ss_hier_logit$mu;
sigma_sim <- ss_hier_logit$sigma;
df_bda3_fig_5_3_logit <- data.frame(x = mu_sim,
y = log(sigma_sim));
can all be replaced with the one line
df_bda3_fig_5_3_logit <- with(ss_hier_logit, data.frame(x = mu_sim,
y = log(sigma_sim)))
Again, this really is a fantastic tutorial. And of course feel free to ignore my R code preferences. The way you have it now definitely works just fine.
Jonah
You received this message because you are subscribed to a topic in the Google Groups "stan development mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-dev/Cea1RdQZMSA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.
I got as far as this step (just did it yesterday) and go this:
label: unnamed-chunk-14 (with options)
List of 1
$ comment: logi NA
|........................ | 37%
ordinary text without R code
|......................... | 38%
label: unnamed-chunk-15
Quitting from lines 801-813 (pool-no-pool.Rmd)
Error in with(ss_hier_logit, data.frame(x = alpha_1_centered, y = log(sigma))) :
object 'ss_hier_logit' not found
>
> to get the basic HTML. I couldn't get it to keep the figures
> separate, even trying what Ben suggested (I'm probably doing it
> wrong).
>
> Here's the abstract:
>
> This note illustrates the effects on posterior inference of pooling
> data (aka sharing strength) across items for repeated binary trial
> data. It provides Stan models and R code to fit and check predictive
> models for three situations: (a) complete pooling, which assumes each
> item is the same, (b) no pooling, which assumes the items are
> unrelated, and (c) partial pooling, where the similarity among the
> items is estimated. We consider two hierarchical models to estimate
> the partial pooling, one with a beta prior on chance of success and
> another with a normal prior on the log odds of success. The note
> explains with working examples how to (i) fit models in RStan and plot
> the results in R ussing ggplot2, (ii) estimate event probabilities,
> (iii) evaluate posterior predictive densities to compare model
> predictions, (iv) rank items by chance of success, (v) perform
> multiple comparisons in several settings, (vi) replicate new data for
> posterior p-values, and (vii) perform graphical posterior predictive
> checks.
>
> - Bob