IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Bayesian Modeling with RJAGS

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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")
Modifica ed esegui il codice