[R] Censoring in R2OpenBUGS
Uwe Ligges
ligges at statistik.tu-dortmund.de
Thu Feb 12 23:07:04 CET 2015
On 12.02.2015 16:05, arnabkm2007 wrote:
> Hi,
>
> I am trying to run the following model for OpenBUGS and want to use
> R2OpenBUGS package. The model specifies weibull distribution for censored
> data.
>
>
> weibull.model <- function()
> {
>
> for(i in 1:n)
> {
>
> exp.alpha[i] ~ dgamma(a.alpha, b.alpha)
> alpha[i] <- log(exp.alpha[i])
>
> linear.part[i] <- alpha[i] + inprod(nu[ ], x[i, ])
> lambda[i] <- exp(linear.part[i])
>
> time[i] ~ (dweib(shape, lambda[i]) C(censored.time[i], ))
>
> }
>
> shape ~ dgamma(a.shape, b.shape)
>
> for(j in 1:p)
> {
>
> beta[j] ~ dnorm(prior.mean, prior.tau)
> gamma[j] ~ dbern(pi[j])
> pi[j] ~ dbeta(1, 1)
> nu[j] <- beta[j] * gamma[j]
>
> }
>
> }
>
>
>
> But R is throwing the following error.
>
> Error: unexpected symbol in:
> "
> time[i] ~ (dweib(shape, lambda[i]) C"
>
> Any help regarding this will be appreciated.
See ?write.model:
"As a difference, BUGS syntax allows truncation specification like this:
dnorm(...) I(...) but this is illegal in R. To overcome this
incompatibility, use dummy operator %_% before I(...): dnorm(...) %_%
I(...). The dummy operator %_% will be removed before the BUGS code is
saved."
Best,
Uwe Ligges
> Thanks & Regards,
> Arnab
>
>
> Arnab Kumar Maity
> Graduate Teaching Assistant
> Division of Statistics
> Northern Illinois University
> DeKalb, IL 60115
> Email: maity at math.niu.edu
> Ph: 779-777-3428
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Censoring-in-R2OpenBUGS-tp4703160.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list