# NOT RUN {
## load the registration data
data(reg)
## NOTE: We set the number of MCMC draws to be a very small number in
## the following examples; i.e., convergence has not been properly
## assessed. See Imai, Lu and Strauss (2006) for more complete examples.
## fit the nonparametric model to give in-sample predictions
## store the parameters to make population inference later
# }
# NOT RUN {
res <- ecoNP(Y ~ X, data = reg, n.draws = 50, param = TRUE, verbose = TRUE)
##summarize the results
summary(res)
## obtain out-of-sample prediction
out <- predict(res, verbose = TRUE)
## summarize the results
summary(out)
## density plots of the out-of-sample predictions
par(mfrow=c(2,1))
plot(density(out[,1]), main = "W1")
plot(density(out[,2]), main = "W2")
## load the Robinson's census data
data(census)
## fit the parametric model with contextual effects and N
## using the default prior specification
res1 <- ecoNP(Y ~ X, N = N, context = TRUE, param = TRUE, data = census,
n.draws = 25, verbose = TRUE)
## summarize the results
summary(res1)
## out-of sample prediction
pres1 <- predict(res1)
summary(pres1)
# }
Run the code above in your browser using DataLab