Using the R Squared statistic

Bayesian Regression Modeling with rstanarm

Jake Thompson

Psychometrician, ATLAS, University of Kansas

What is R squared?

  • Coefficient of determination

Bayesian Regression Modeling with rstanarm

What is R squared?

  • Coefficient of determination

Bayesian Regression Modeling with rstanarm

What is R squared?

  • Coefficient of determination

Bayesian Regression Modeling with rstanarm

Calculating R squared statistic

lm_model <- lm(kid_score ~ mom_iq, data = kidiq)
lm_summary <- summary(lm_model)
lm_summary$r.squared
0.2009512
ss_res <- var(residuals(lm_model))
ss_total <- var(residuals(lm_model)) + var(fitted(lm_model))
1 - (ss_res / ss_total)
0.2009512
Bayesian Regression Modeling with rstanarm

The R squared statistic of a Bayesian Model

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq)

ss_res <- var(residuals(stan_model))
ss_total <- var(fitted(stan_model)) + var(residuals(stan_model))
1 - (ss_res / ss_total)
0.2004996
lm_summary$r.squared
0.2009512
Bayesian Regression Modeling with rstanarm

Let's practice!

Bayesian Regression Modeling with rstanarm

Preparing Video For Download...