mtcars-simple3

regression
en
bayes
frequentist
qm1
stats-nutshell
qm2
mtcars
quiz
Published

September 4, 2022

Question

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.

Which of the predictors in the above model has the weakest causal impact on the output variable?

Notes:

  • Use can either use frequentist or bayesian modeling.
  • Use R for all computations.
  • There are multiple ways to find a solution.

Answerlist

  • cyl
  • hp
  • disp
  • All are equally strong
  • none of the above

Solution

library(rstanarm)
library(easystats)
library(tidyverse)

In order to gauge the relative importance of the predictors, we need to make sure they are on the same scale:

mtcars2 <-
  standardise(mtcars)

Compute Model:

lm1_freq <- lm(mpg ~ hp + cyl + disp, data = mtcars2)
lm1_bayes <- stan_glm(mpg ~ hp + cyl + disp, data = mtcars2, refresh = 0)

Get parameters:

parameters(lm1_bayes)
Parameter Median CI CI_low CI_high pd Rhat ESS_tail Prior_Distribution Prior_Location Prior_Scale
(Intercept) -0.0047208 0.95 -0.1855539 0.1874118 0.51900 1.0020558 2496 normal 0 2.5
hp -0.1708322 0.95 -0.5165460 0.1654627 0.84750 1.0004596 2329 normal 0 2.5
cyl -0.3543042 0.95 -0.8299114 0.1325995 0.93275 1.0001923 2206 normal 0 2.5
disp -0.3890579 0.95 -0.8364210 0.0532215 0.95475 0.9998886 2226 normal 0 2.5

Note that the absolute value of the coefficient’s estimate is what we are after.

The predictors with the strongest impact is disp, and cyl. The weakest influence has hp.

Aufgabenname: mtcars-simple3

Answerlist

  • wrong
  • correct
  • wrong
  • wrong
  • wrong

Meta-information

exname: mtcars-simple3 extype: schoice exsolution: 01000 exshuffle: TRUE expoints: 1


Categories:

  • regression
  • en
  • bayes
  • frequentist
  • qm1
  • stats-nutshell