Hello to everyboby Im Gianluca ....and i m a statistic student.
I have one problem that i think Dirk or some one "good like dirk" could help
to resolve :
iI would like to implement this following function in R code into inline code
with Rccp plugin :
MHWG<-function (logpost, start, n.iter, burn, thin, scale, ...)
{
pb <- txtProgressBar(min = 0, max = n.iter, style = 3)
p = length(start)
vth = array(0, dim = c(n.iter/thin, p))
f0 = logpost(start, ...)
arate = array(0, dim = c(1, p))
th0 = start
for (i in (-burn):n.iter) {
setTxtProgressBar(pb, i)
for (j in 1:p) {
th1 = th0
th1[j] = th0[j] + rnorm(1) * scale[j]
f1 = logpost(th1, ...)
u = runif(1) <= min(exp(f1 - f0),1)
th0[j] = th1[j] * (u == 1) + th0[j] * (u == 0)
f0 = f1 * (u == 1) + f0 * (u == 0)
vth[floor(i/thin), j] = th0[j]
arate[j] = arate[j] + u
}
}
arate = arate/n.iter
stuff = list(par = vth, accept = arate)
return(stuff)
}
So one argument of MHWG is logpost and is a R function with argument par
where par iso ne vector .... for example logpost(par)
Logpost<-function(par) { ...................} (in r code).
How can i call teh logpost function into the inline rccp code . In the MHWG
there is a difference f1-f0 where fi=logpost(par1) e f0=logpost(par 2)
for exemple.
help me please to implemet my problem ...and also i m "open" about
suggestion for implemeting the function
Sorry for all noise and thank also for the past mail that help me to learn
more about programming
Best regards... sorrry fo rmy bad English
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel