[R] MCMC regress, using runif()

Johannes Radinger JRadinger at gmx.at
Mon Aug 15 10:20:53 CEST 2011


Hello,

just to follow up a question from last week. Here what I've done so far (here an example):


library(MCMCpack)

Y=c(15,14,23,18,19,9,19,13)
X1=c(0.2,0.6,0.45,0.27,0.6,0.14,0.1,0.52)
X2a=c(17,22,21,18,19,25,8,19)
X2b=c(22,22,29,34,19,26,17,22)

X2 <- function()runif(length(X2a), X2a, X2b)

model1 <- MCMCregress(Y~X1+X2())
summary(model1)


but I am not sure if my X2-function is working in the MCMCpack?
Is a random number drawn each iteration step? I don't think so
as the results are varying greatly if I run the script several times.

Is there any other way to do several thousand runs of a linear regression,always drawing a random number for X2 and then compute average values for the regressions?

/Johannes


--



More information about the R-help mailing list