Search code examples
rpredictionmontecarlouncertainty

Predictive distribution with Monte Carlo


I want to obtain a distribution over each prediction point i.e. for each value of dependent variable y. In the dependent variable y, I have 199 observations and for each observation, I want a distribution.So my output should be a matrix of 199*100. How can I obtain that? I tried the Monte Carlo simulation for T=100.But every time, its a vector of 199 instead of matrix 199*100.R-Code is here


Solution

  • You could do something like

    mc_pred <- matrix(nrow = 199, ncol = 100)
    
    for (i in 1:100) {
        mc_pred[, i] <- predict(model, x_test)
    }