392  mtcars-simple1

regression
en
bayes
frequentist
qm1
stats-nutshell
mtcars
Veröffentlichungsdatum

4. September 2022

Schlüsselwörter

Aufgaben, Statistik, Prognose, Modellierung, R, Datenanalyse, Regression

392.1 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 causal effect of horse power given the above model! Report the point estimate.

Notes:

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

392.2 Solution

Compute Model:

lm1_freq <- lm(mpg ~ hp + cyl + disp, data = mtcars)

library(rstanarm)
lm1_bayes <- stan_glm(mpg ~ hp + cyl + disp, data = mtcars, refresh = 0)

Get parameters:

parameters(lm1_freq)
parameters(lm1_bayes)

The coefficient is estimated as about -0.01


Categories:

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