prediction - How to compute log-predictive scores in R -


i using bayesian model averaging , bayesian lasso regression prediction , want evaluate accuracy of density forecasts using predictive log-scores.

i using bms package bayesian model averaging , monomvn package bayesian lasso. in bms package, function compute predictive log-scores implemented monomvn {bayesian lasso} not implemented.

i able compute predictive densities lasso object multiplying each posterior draw corresponding explanatory variable each single observation, have predictive densities each observation now.

how can estimate predictive log-score in r, given predictive densities , realized values?

best

update (solved)

after contacting 1 of authors of bms package, here implementation:

trainingidx <- 1:900 testidx <- 901:1000  # d = draws # n = length of test data # sigmasq = error variance draws # has dimension of (1 x d)  # predictivedensity = x.beta draws # has dimension of (n x d)   scores <- matrix(0, nrow = length(testidx), ncol = dim(predictivedensity)[2]) # create empty matrix log-predictive scores  for(obs in 1:length(testidx)){ # each observation   for(draw in 1:dim(predictivedensity)[2]){    # each draw     scores[obs,draw] <- dnorm(y[testidx,1][obs], mean = predictivedensity[obs,draw], sd = sqrt(sigmasq[draw]))   }   } lps <- -sum(log(rowmeans(scores)))/ length(testidx) 

one problem here that, implementation doesn't account parameter uncertainty, favor larger models, in-sample sigmasq tends smaller large models.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -