Aan de slagGa gratis aan de slag

Posterior inference for multivariate regression

The 10,000 iteration RJAGS simulation output, rail_sim_2, is in your workspace along with a data frame of the Markov chain output:

> head(rail_chains_2, 2)
         a b.1.      b.2.        c         s
1 49.76954    0 -12.62112 4.999202 111.02247
2 30.22211    0  -3.16221 4.853491  98.11892 

You will use these 10,000 unique sets of parameter values to summarize the posterior mean trend in the relationships between trail volume, weekday status, and hightemp.

Deze oefening maakt deel uit van de cursus

Bayesian Modeling with RJAGS

Cursus bekijken

Oefeninstructies

Construct a scatterplot of volume by hightemp.

  • Use color to distinguish between weekdays & weekends.
  • Superimpose a red line that represents the posterior mean trend of the linear relationship between volume and hightemp for weekends: m = a + c Z
  • Superimpose a turquoise3 line that represents the posterior mean trend of the linear relationship between volume and hightemp for weekdays: m = (a + b.2.) + c Z

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Plot the posterior mean regression models
ggplot(___, aes(x = ___, y = ___, color = ___)) + 
    geom_point() + 
    geom_abline(intercept = mean(___), slope = mean(___), color = "red") + 
    geom_abline(intercept = mean(___) + mean(___), slope = mean(___), color = "turquoise3")
Code bewerken en uitvoeren