[R] Correction in error

Gyanendra Pokharel
Mon, 07 Nov 2011 20:10:15 -0000

Hello R community, following is my code and it shows error, can some one
fix this error and explain why this occurs?

gibbs <-function(m,n, theta = 0, lambda = 1){
    alpha <- 1.5
    beta <- 1.5
    gamma <- 1.5
    x<- array(0,c(m+1, 3))
    x[1,1] <- theta
    x[1,2] <- lambda
    x[1,3]<- n
    for(t in 2:m+1){
        x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1])
        x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta)
        x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma)
    }
    x
}
gibbs(100, 10)

Gyn

	[[alternative HTML version deleted]]