11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

366 15. MISSING DATA AND OTHER OPPORTUNITIESEvery index i at which there is a missing value, there is also a parameter N i that will form anestimate for it.is is the model:k i ∼ Normal(µ i , σ) [likelihood for outcome k]µ i = α + β N N i + β M log M i [linear model]N i ∼ Normal(ν, σ N ) [likelihood/prior for obs/missing N]α ∼ Normal(0, 10)β N ∼ Normal(0, 1)β M ∼ Normal(0, 1)σ ∼ Cauchy(0, 1)ν ∼ Normal(0.5, 1)σ N ∼ Cauchy(0, 1)Note that when N i is observed, then the third line above is a likelihood, just like any old linearregression. But when N i is missing and therefore a parameter, that same line is interpretedas a prior. Since the parameters ν and σ N are also estimated, the prior is learned from thedata.Specifying this model in Stan can be done several different ways. All of the ways area little awkward, because the locations of missing values have to respected. e approachI’ll use here hews closely to the discussion just above: we’ll merge the observed values andparameters into a vector that we’ll use as “data” in the regression.First, get the data loaded and transform predictors:R code15.7library(rethinking)library(rstan)data(milk)d

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!