I am trying to recreate (in R) a frequentist hypothesis testing in Bayesian from, by calculating Bayes factors of the null (H0) and alternative (H1) models.
The model is simply a simple linear regression that tries to detect a trend in global temp. data from 1995 to 2009 (here). Therefore, H0 is no trend (i.e. slope = 0), or similary, the H0 model is a linear model with only the intercept.
So I calculated the lm()
of both models to arrive at negative log likelihood values that are significantly different. The p-value for the H1 lm() model is 0.0877.
I also calculated this in a Bayesian way by using MCMCpack, and I get negative log likelihood values that are super duper uber different. Log likelihood values of 13.7 and 4.3 are about a 10000 fold difference in their likelihood ratios (where >100 is considered to be "decisive").
The means and sds of the estimates are very similar, so why am I getting such different likelihood values? (particularly for the Bayesian H0 model) I feel like there is a gap in my understanding on marginal likelihoods, but I can't pinpoint the problem.
Thanks
library(MCMCpack)
## data: http://www.cru.uea.ac.uk/cru/data/temperature/hadcrut3gl.txt
head(hadcru, 2)
## Year 1 2 3 4 5 6 7 8 9 10
## 1 1850 -0.691 -0.357 -0.816 -0.586 -0.385 -0.311 -0.237 -0.340 -0.510 -0.504
## 2 1851 -0.345 -0.394 -0.503 -0.480 -0.391 -0.264 -0.279 -0.175 -0.211 -0.123
## 11 12 Avg
## 1 -0.259 -0.318 -0.443
## 2 -0.141 -0.151 -0.288
hadcru.lm <- lm(Avg ~ 1 + Year, data = subset(hadcru, (Year <= 2009 & Year >= 1995)))
hadcru.lm.zero <- lm(Avg ~ 1, data = subset(hadcru, (Year <= 2009 & Year >= 1995)))
hadcru.mcmc <- MCMCregress(Avg ~ 1 + Year, data = subset(hadcru, (Year <= 2009 & Year >= 1995)), thin = 100, mcmc = 100000, b0 = c(-20, 0), B0 = c(.00001, .00001), marginal = "Laplace")
hadcru.mcmc.zero <- MCMCregress(Avg ~ 1, data = subset(hadcru, (Year <= 2009 & Year >= 1995)), thin = 100, mcmc = 100000, b0 = c(0), B0 = c(.00001), marginal = "Laplace")
-logLik(hadcru.lm)
## 'log Lik.' -14.55338 (df=3)
-logLik(hadcru.lm.zero)
## 'log Lik.' -12.80723 (df=2)
attr(hadcru.mcmc, "logmarglike")
## [,1]
## [1,] -13.65188
attr(hadcru.mcmc.zero, "logmarglike")
## [,1]
## [1,] -4.310564