# Stan the Gathering, April 29th ## rvars in E posterior package Matthew Kay's rvars new datatype in posterior ([pull request](https://github.com/stan-dev/posterior/pull/123)) makes it easy to do, e.g., ``` > rv = as_draws_rvars(fit_lin$draws()) > mu = rv$alpha + rv$beta*data_lin$year > bayesR2 = rvar_var(mu) / (rvar_var(mu) + rv$sigma^2) > bayesR2 rvar<1000,4>[1] mean ± sd: [1] 0.097 ± 0.062 ``` Note that data_lin is regular dataframe, and mu is a vector of mean predictions in rvars format, and rvars handles vectors and matrices from Stan, too. As rvars stores the chain information it's easy to get convergence diagnostics and MCSE's for the derived quantities, too. ``` > summary(bayesR2, quantile2, default_convergence_measures()) # A tibble: 1 x 6 variable q5 q95 rhat ess_bulk ess_tail <chr> <dbl> <dbl> <dbl> <dbl> <dbl> 1 bayesR2 0.0111 0.214 1.00 1223. 1258. ```