March 2019
Beginner to intermediate
448 pages
13h 14m
English
We will use the same house prices example that we used in the previous recipes for linear regression. We have a price variable, and several regressors, such as the number of bedrooms, bathrooms, and so on:
library(rstan)library(coda)library(DrBats)data = read.csv("/Users/admin/Documents/R_book/chapter3/house_prices.csv")model ="data {real y[125];real x[125,6];}parameters {real <lower=0> beta[6];real sigma;real alpha;}model {beta ~ normal(5,20);for (n in 1:125)y[n] ~ normal(alpha + beta[1]*x[n,1] + beta[2]*x[n,2] + beta[3]*x[n,3] + beta[4]*x[n,4] + beta[5]*x[n,5] ...Read now
Unlock full access