Displaying 1 result from an estimated 1 matches for "mu_t_cand".
2009 Oct 08
3
foreach loop - rejection method
...is is my first time using the foreach statement and I cant get it to work
properly so here is what i have
test<-function(){
repeat {
cand2[l-1]<-rinvgamma(1,phi,lambda[l-1])
q2<-dinvgamma(cand2[l-1],phi,lambda[l-1])
p2<-cand2[l-1]^-1.5*exp(-y[l]^2/(2*cand2[l-1]))*exp(-((log(cand2[l-1])-mu_t_cand[l-1])^2)/2*sigmasq)
ratio<-p2/(c[l-1]*q2)
if (runif(1)< ratio) {break}
}
f2[l-1]<-min(p2,c[l-1]*q2)
}}
foreach(l=2:(n-1),.combine=c,.packages='MCMCpack',.options.nws=li
st(chunkSize=250)) %dopar% test()
even though i've created the array earlier called cand2 when i run this co...