No articles match
Using the loo package (version >= 2.0.0)14 days ago
Introduction | Setup | Example: Poisson vs negative binomial for the roaches dataset | Background and model fitting | Roaches data | Fit Poisson model | Using the loo package for model checking and comparison | Computing PSIS-LOO and checking diagnostics | Plotting Pareto $k$ diagnostics | Marginal posterior predictive checks | Try alternative model with more flexibility | Comparing the models on expected log predictive density | References
Visual MCMC diagnostics using the bayesplot package3 months ago
Introduction | Setup | Example model | Diagnostics for the No-U-Turn Sampler | Divergent transitions | mcmc_parcoord | mcmc_pairs | mcmc_scatter | mcmc_trace | mcmc_nuts_divergence | Energy and Bayesian fraction of missing information | mcmc_nuts_energy | General MCMC diagnostics | Rhat: potential scale reduction statistic | mcmc_rhat, mcmc_rhat_hist | Effective sample size | mcmc_neff, mcmc_neff_hist | Autocorrelation | mcmc_acf, mcmc_acf_bar | References
Graphical posterior predictive checks using the bayesplot package3 months ago
Introduction | Graphical posterior predictive checks (PPCs) | Setup | Example models | Defining y and yrep | Histograms and density estimates | ppc_dens_overlay | ppc_hist | Distributions of test statistics | ppc_stat | Other PPCs and PPCs by group | ppc_stat_grouped | Using *_data() functions for custom plots | Providing an interface to bayesplot PPCs from another package | Defining a pp_check method | Examples of pp_check methods in other packages | References
Plotting MCMC draws using the bayesplot package3 months ago
Introduction | Setup | Example model | Posterior uncertainty intervals | mcmc_intervals, mcmc_areas | Univariate marginal posterior distributions | mcmc_hist | mcmc_hist_by_chain | mcmc_dens | mcmc_dens_overlay | mcmc_violin | Bivariate plots | mcmc_scatter | mcmc_hex | mcmc_pairs | Trace plots | mcmc_trace | mcmc_trace_highlight | Using *_data() functions for custom plots | References
Holdout validation and K-fold cross-validation of Stan programs with the loo package6 months ago
Introduction | Example: Eradication of Roaches using holdout validation approach | Coding the Stan model | Setup | Holdout validation | Splitting the data between train and test | Fitting the model with RStan | Computing holdout elpd: | K-fold cross validation | Splitting the data in folds | Fitting and extracting the log pointwise predictive densities for each fold | Computing K-fold elpd: | References
Avoiding model refits in leave-one-out cross-validation with moment matching6 months ago
Introduction | Example: Eradication of Roaches | Coding the Stan model | Setup | Fitting the model with RStan | Moment matching correction for importance sampling | Using loo_moment_match() directly | References
Step by step guide for creating a package that depends on RStan7 months ago
Introduction | Creating the package skeleton | Read-and-delete-me file | Stan files | R files | Documentation | Install and use | Advanced options | Adding additional Stan models to an existing R package with Stan models | Links
projpred: Projection predictive feature selection7 months ago
Introduction | Data | Reference model | Variable selection | Preliminary cv_varsel() run | Final cv_varsel() run | Predictive performance plot from final cv_varsel() run | Decision for final submodel size | Predictive performance table from final cv_varsel() run | Predictor ranking(s) from final cv_varsel() run and identification of the selected submodel | Post-selection inference | Marginals of the projected posterior | Predictions | Supported types of models | Troubleshooting | Non-convergence of predictive performance | Overfitting | Issues with the traditional projection | Issues with the augmented-data projection | Speed | References
RStan: the R interface to Stan7 months ago
Introduction | Prerequisites | Typical Workflow | Example | Write a Stan Program | Preparing the Data | Sample from the Posterior Distribution | Arguments to the stan Function | Data Preprocessing and Passing | Methods for the "stanfit" Class | Sampling Difficulties | Additional Topics | User-defined Stan Functions | The Log-Posterior (function and gradient) | Optimization in Stan | Model Compilation | Running Multiple Chains in Parallel | See Also
Latent projection predictive feature selection7 months ago
Introduction | General idea | Implementation | Example: Poisson distribution | Data | Reference model | Variable selection using the latent projection | Variable selection using the traditional projection | Conclusion | Example: Negative binomial distribution | Censored observations (survival analysis) | Example: Weibull distribution with right-censored observations | Example: Log-normal distribution with right-censored observations | References
Add Content to the Posterior Database using R1 years ago
Adding the Data | Adding the Model | Adding the Posterior | Checking the final posterior, data and model | Add Posterior Reference Draws
Estimating Survival (Time-to-Event) Models with rstanarm1 years ago
Preamble | Introduction | Modelling framework | Data and notation | Hazard, cumulative hazard, and survival | Delayed entry | Model formulations | Hazard scale models | M-splines model (the default): | Exponential model: | Weibull model: | Gompertz model: | B-splines model (for the log baseline hazard): | Accelerated failure time (AFT) models | Linear predictor | Hazard ratios | Acceleration factors and survival time ratios | Time-fixed vs time-varying effects | Relationship between proportional hazards and AFT models | Multilevel survival models | Estimation framework | Log posterior | Log likelihood | Evaluating integrals in the log likelihood | Prior distributions | Intercept | Estimation | Prediction framework | Survival predictions without clustering | Survival predictions with clustering | Conditional survival probabilities | Standardised survival probabilities | Implementation | Overview | Main modelling function | Default knot locations | Post-estimation functions | Usage examples | Example: A flexible parametric proportional hazards model | Example: Non-proportional hazards modelled using B-splines | Example: Non-proportional hazards modelled using a piecewise constant function | Example: Hierarchical survival models | References | Appendix A: Parameterisations on the hazard scale | Exponential model | Weibull model | Gompertz model | M-spline model | B-spline model | Extension to time-varying coefficients (i.e. non-proportional hazards) | Appendix B: Parameterisations under accelerated failure times | Extension to time-varying coefficients (i.e. time-varying acceleration factors)
Getting started with CmdStanR2 years ago
Introduction | Installing CmdStan | Compiling a model | Running MCMC | Posterior summary statistics | Summaries from the posterior package | CmdStan's stansummary utility | Posterior draws | Extracting draws | Plotting draws | Sampler diagnostics | Extracting diagnostic values for each iteration and chain | Sampler diagnostic warnings and summaries | CmdStan's diagnose utility | Running optimization and variational inference | Optimization | Laplace Approximation | Variational (ADVI) | Variational (Pathfinder) | Saving fitted model objects | Comparison with RStan | Additional resources
Pareto-khat diagnostics2 years ago
Introduction | Example | Simulated data | MCMC convergence diagnostics | Pareto-$\hat{k}$ | Pareto smoothing | Minimum sample size required | Convergence rate | Pareto-$\hat{k}$-threshold | Pareto diagnostics | Discussion | Reference
The posterior R package2 years ago
Introduction | Installation | Example | Draws formats | Available formats | Converting between formats | Converting regular R objects to draws formats | Example: create draws_matrix from a matrix | Example: create draws_matrix from multiple vectors | Manipulating draws objects | Subsetting | Mutating (transformations of variables) | Renaming | Binding | Summaries and diagnostics | summarise_draws() basic usage | Changing column names | Using custom functions | Specifying functions using lambda-like syntax | Other diagnostics | Other methods for working with draws objects | References
Estimating Generalized Linear Models for Continuous Data with rstanarm2 years ago
Introduction | Likelihood | Priors | Posterior | Linear Regression Example | Model comparison | The posterior predictive distribution | Graphical posterior predictive checks | Generating predictions | Gamma Regression Example | References
Estimating Generalized Linear Models for Count Data with rstanarm2 years ago
Introduction | Likelihood | Priors | Posterior | Poisson and Negative Binomial Regression Example | References
Working with Posteriors2 years ago
Summary statistics | Extracting posterior draws/samples | Structured draws similar to rstan::extract()
Approximate leave-future-out cross-validation for Bayesian time series models2 years ago
Introduction | $M$-step-ahead predictions | Approximate $M$-SAP using importance-sampling | Autoregressive models | Case Study: Annual measurements of the level of Lake Huron | 1-step-ahead predictions leaving out all future values | Exact 1-step-ahead predictions | Approximate 1-step-ahead predictions | $M$-step-ahead predictions leaving out all future values | Exact $M$-step-ahead predictions | Approximate $M$-step-ahead predictions | Conclusion | References | Appendix | Appendix: Session information | Appendix: Licenses
Bayesian Stacking and Pseudo-BMA weights using the loo package2 years ago
Introduction | Setup | Example: Primate milk | Example: Oceanic tool complexity | Simpler coding using loo_model_weights function | References
Leave-one-out cross-validation for non-factorized models2 years ago
Introduction | LOO-CV for multivariate normal models | Approximate LOO-CV using integrated importance-sampling | Exact LOO-CV with re-fitting | Lagged SAR models | Case Study: Neighborhood Crime in Columbus, Ohio | Fit lagged SAR model | Approximate LOO-CV | Exact LOO-CV | Working with Stan directly | Conclusion | References
Mixture IS leave-one-out cross-validation for high-dimensional Bayesian models2 years ago
Introduction | Setup: load packages and set seed | Model | Dataset | PSIS estimators and Pareto-$k$ diagnostics | Mixture estimators | Comparison with benchmark values obtained with long simulations | References
Using Leave-one-out cross-validation for large data2 years ago
Introduction | Setup | Example: Well water in Bangladesh | Coding the Stan model | Fitting the model with RStan | Approximate LOO-CV using PSIS-LOO and subsampling | Adding additional subsamples | Specifying estimator and sampling method | Approximate LOO-CV using PSIS-LOO with posterior approximations | Combining the posterior approximation method with subsampling | Comparing models | References
Writing Stan programs for use with the loo package2 years ago
Introduction | Example: Well water in Bangladesh | Coding the Stan model | Fitting the model with RStan | Computing approximate leave-one-out cross-validation using PSIS-LOO | Comparing models | References
How to Use the rstanarm Package2 years ago
Introduction | Step 1: Specify a posterior distribution | Note on "prior beliefs" and default priors | Step 2: Draw from the posterior distribution | Step 3: Criticize the model | Step 4: Analyze manipulations of predictors | Troubleshooting | Markov chains did not converge | Divergent transitions | Maximum treedepth exceeded | Conclusion | References
How does CmdStanR work?3 years ago
Introduction | Compilation | Immediate compilation | Delayed compilation | Pedantic check | Stan model variables | Executable location | Processing data | Named list of R objects | JSON file | R dump file | Writing CmdStan output to CSV | Default temporary files | Non-temporary files | Reading CmdStan output into R | Lazy CSV reading | read_cmdstan_csv() | as_cmdstan_fit() | Saving and accessing advanced algorithm info (latent dynamics) | Developing using CmdStanR | Pre-compiled Stan models in R packages | Troubleshooting and debugging
rvar: The Random Variable Datatype3 years ago
Introduction | The rvars datatype | rvar_factor and rvar_ordered subtypes | The draws_rvars datatype | Math with rvars | Expectations and summary functions | Constants | Using existing R functions and expressions with rvars | Converting functions with rfun() | Evaluating expressions with rdo() | Evaluating random number generators with rvar_rng() | Broadcasting | Slicing and conditionals | Subsetting rvars by draw: x[] | Conditionals using rvar_ifelse() | Selecting different elements in each draw: x[[]] | Applying functions over rvars | Looping over draws and rvars | Using rvars in data frames and in ggplot2
R Markdown CmdStan Engine3 years ago
Option 1: Using RStan for all chunks | Option 2: Using CmdStanR for all chunks | Example | Option 3: Using both RStan and CmdStanR in the same R Markdown document | Caching chunks | Running interactively
Hierarchical Partial Pooling for Repeated Binary Trials3 years ago
Introduction | Repeated Binary Trials | Baseball Hits (Efron and Morris 1975) | Pooling | Fitting the Models | Complete Pooling | No Pooling | Partial Pooling | Observed vs. Estimated Chance of Success | Posterior Predictive Distribution | Evaluating Held-Out Data Predictions | Simulating Replicated Data | Prediction for New Trials | Calibration | Sharpness | Why Evaluate with the Predictive Posterior? | $\log E[p(\tilde{y} , | , \theta)]$ vs $E[\log p(\tilde{y} , | , \theta)]$ | Posterior expectation of the log predictive density | Approximating the expected log predictive density | Predicting New Observations | Estimating Event Probabilities | Multiple Comparisons | Ranking | Who has the Highest Chance of Success? | Graphical Posterior Predictive Checks | Test Statistics and Bayesian $p$-Values | Comparing Observed and Replicated Data | Discussion | Exercises | References | Additional Data Sets | Rat tumors (N = 71) | Surgical mortality (N = 12) | Baseball hits 1996 AL (N = 308)
Interfacing with External C++ Code3 years ago
Profiling Stan programs with CmdStanR3 years ago
Introduction | Adding profiling statements to a Stan program | Accessing the profiling information from R | Comparing to a faster version of the model | Per-gradient timings, and memory usage | Accessing and saving the profile files | References
Guidelines for Developers of R Packages Interfacing with Stan4 years ago
Note to developers | Guidelines for R packages providing interfaces to Stan | General package structure and development | Stan code | R code and documentation | Recommended resources
Prior Distributions for rstanarm Models4 years ago
July 2020 Update | Introduction | Default (Weakly Informative) Prior Distributions | Default priors and scale adjustments | Regression coefficients | Intercept | Auxiliary parameters | Note on data-based priors | Disabling prior scale adjustments | How to Specify Flat Priors (and why you typically shouldn't) | Uninformative is usually unwarranted and unrealistic (flat is frequently frivolous and fictional) | Specifying flat priors | Informative Prior Distributions
Probabilistic A/B Testing with rstanarm4 years ago
Abstract | Introduction | Continuous Data | Count Data | Benefits of Bayesian Methods | Conclusion | Acknowlegements | References | Appendix A: Refresher on p-values | Appendix B: Hierarchical Example
Estimating Joint Models for Longitudinal and Time-to-Event Data with rstanarm4 years ago
Preamble | Introduction | Technical details | Model formulation | Longitudinal submodel(s) | Event submodel | Association structures | Assumptions | Log posterior distribution | Model predictions | Individual-specific predictions for in-sample individuals (for $0 \leq t \leq T_i$) | Individual-specific predictions for in-sample individuals (for $t > C_i$) | Individual-specific predictions for out-of-sample individuals (i.e. dynamic predictions) | Population-level (i.e. marginal) predictions | Standardised survival probabilities | Model extensions | Delayed entry (left-truncation) | Multilevel clustering | Model comparison | LOO/WAIC in the context of joint models | Usage examples | Dataset used in the examples | Fitting the models | Univariate joint model (current value association structure) | Univariate joint model (current value and current slope association structure) | Multivariate joint model (current value association structures) | Posterior predictions | Predicted individual-specific longitudinal trajectory for in-sample individuals | Predicted individual-specific survival curves for in-sample individuals | Combined plot of longitudinal trajectories and survival curves | Predicted individual-specific longitudinal trajectory and survival curve for out-of-sample individuals (i.e. dynamic predictions) | Predicted population-level longitudinal trajectory | Standardised survival curves | References
Deploying to shinyapps.io4 years ago
Step 1: ShinyApps account | Step 2: Use deploy_shinystan to deploy your app to shinyapps.io
Estimating Generalized (Non-)Linear Models with Group-Specific Terms with rstanarm5 years ago
Introduction | GLMs with group-specific terms | Priors on covariance matrices | Overview | Details | Comparison with lme4 | Advantage: better uncertainty estimates | Advantage: incorporate prior information | Disadvantage: speed | Relationship to glmer | Relationship to gamm4 | Relationship to nlmer | Conclusion
Getting Started5 years ago
Using the ShinyStan app with different types of objects | stanfit objects | stanreg and brmsfit objects | mcmc.list objects | Other types of objects | 3-D array | List of matrices | Other functions in the shinystan package | Generating new quantities | Storing your model code in a shinystan object | Renaming a model
Estimating Generalized Linear Models for Binary and Binomial Data with rstanarm6 years ago
Introduction | Likelihood | Priors | Posterior | Logistic Regression Example | Conditional Logit Models | Binomial Models | Going Further | References
Simulation Based Calibration6 years ago
References
Accessing the contents of a stanfit object6 years ago
Posterior draws | extract() | as.matrix(), as.data.frame(), as.array() | Posterior summary statistics and convergence diagnostics | Sampler diagnostics | Model code | Initial values | (P)RNG seed | Warmup and sampling times
MRP with rstanarm6 years ago
The Data | Exploring Graphically | Comparing sample to population | Effect of the post-stratification variable on preference for cats | Interaction effect | Design effect | Population Estimate | Estimates for states | Other formats | Alternate methods of modelling | Appendix | Examples of other formulas | Code to simulate the data | References
Estimating ANOVA Models with rstanarm6 years ago
Introduction | Likelihood | Priors | Example | Conclusion
Modeling Rates/Proportions using Beta Regression with rstanarm6 years ago
Introduction | Likelihood | Priors | Posterior | An Example Using Simulated Data | An Example Using Gasoline Data | References
Estimating Regularized Linear Models with rstanarm6 years ago
Introduction | Likelihood | QR Decomposition | Priors | Posterior | Example | Alternative Approach | Conclusion | References
Estimating Ordinal Regression Models with rstanarm6 years ago
Introduction | Likelihood | Priors | Example | Conclusion