[R] Correction in error

2011-11-07 Thread Gyanendra Pokharel
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

Re: [R] Correction in error

2011-11-07 Thread Sarah Goslee
Hi, I see two problems right off: On Mon, Nov 7, 2011 at 3:10 PM, Gyanendra Pokharel gyanendra.pokha...@gmail.com wrote: 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

Re: [R] Correction in error

2011-11-07 Thread R. Michael Weylandt
The first argument to rbinom() is how many random samples you want to draw, not whatever you seem to think it is. It's not matching the size of what you mean to assign it to: in particular note that x[t-1, 3] is zero for t=3 which is where you initialize it. (I.e., you are also probably getting

Re: [R] Correction in error

2011-11-07 Thread William Dunlap
: Monday, November 07, 2011 12:26 PM To: Gyanendra Pokharel Cc: R-help@r-project.org Subject: Re: [R] Correction in error Hi, I see two problems right off: On Mon, Nov 7, 2011 at 3:10 PM, Gyanendra Pokharel gyanendra.pokha...@gmail.com wrote: Hello R community, following is my code

Re: [R] Correction in error

2011-11-07 Thread Dennis Murphy
Hi: In your function call, x[1, 1] = theta = 0. In the first line of the loop, your rbinom() call works out to be x[2, 1] - rbinom(x[1, 3], 1, x[1, 1]) = rbinom(10, 1, 0) That likely accounts for the error message: Error in x[t, 1] - rbinom(x[t - 1, 3], 1, x[t - 1, 1]) : replacement