Roland
Roland

Reputation: 344

How I can simulate response variable from a model already fitted?

I already fitted a regression model with JAGS

model{
    for(i in 1:n) {
        y[i] ~ dbeta(alpha[i], beta[i])
        alpha[i] <- mu[i] * phi[i]
        beta[i]  <- (1 - mu[i]) * phi[i]
        log(phi[i]) <- -inprod(X2[i, ], delta[])
        cloglog(mu[i]) <- inprod(X1[i, ], B[])
    }

    for (j in 1:p){
        B[j] ~ dnorm(0, .001)
    }

    for(k in 1:s){
        delta[k] ~ dnorm(0, .001)
    }
}

But I need to simulate 50 samples of response variable where each one have size, to do some plots. How can I do it?

I found this thread a litle help Estimating unknown response variable in JAGS - unsupervised learning

Should I run the chain again given the values of posterior estimates that I already have as inits?

Upvotes: 1

Views: 243

Answers (2)

Marcelo Ventura
Marcelo Ventura

Reputation: 599

Yes, you can do exactly as you described, as long as you first create a new dataset with 50 observations and the variables Y, X1, and X2 as described by StatnMap (viz., 50 values for both X1 and X2 and 50 NAs for Y), but you will not need to rerun your model, as implied by StatnMap. Just to be clear: you can, but you do not need.

Upvotes: 0

S&#233;bastien Rochette
S&#233;bastien Rochette

Reputation: 6661

I assume that your data are y, X1 and X2.
You can add the 50 lines of data in your X1 and X2 covariates, and add 50 NA values in y. And modify n to include the 50 values.
Your model will then produce predictions for the 50 NA values for y added.

Upvotes: 1

Related Questions