<- lm(mpg ~ hp + cyl + disp, data = mtcars)
lm1_freq
library(rstanarm)
<- stan_glm(mpg ~ hp + cyl + disp, data = mtcars, refresh = 0) lm1_bayes
mtcars-simple2
regression
en
bayes
frequentist
qm1
stats-nutshell
mtcars
Exercise
We will use the dataset mtcars
in this exercise.
Assume your causal model of your research dictates that fuel economy is a linear function of horse power, cylinder count and displacement of the engine.
Compute the explained variance (point estimate) for the above model!
Notes:
- Use can either use frequentist or bayesian modeling.
- Use R for all computations.
- There are multiple ways to find a solution.
Solution
Compute Model:
Get R2:
library(easystats)
r2(lm1_freq)
# R2 for Linear Regression
R2: 0.768
adj. R2: 0.743
r2(lm1_bayes)
# Bayesian R2 with Compatibility Interval
Conditional R2: 0.748 (95% CI [0.605, 0.854])
The coefficient is estimated as about 0.77.
Categories:
- regression
- en
- bayes
- frequentist
- qm1
- stats-nutshell