[R] Problem in R2WinBUGS
Berend Hasselman
bhh at xs4all.nl
Wed Dec 31 08:54:10 CET 2014
> On 31-12-2014, at 08:27, thanoon younis <thanoon.younis80 at gmail.com> wrote:
>
> Dear all members
> I have a problem with the code below when i wanted to change the continuous
> random variables to mixed ordered categorical and dichotomous as follow
>
> #transform theta to ordinal variables
> yo <- array(0, dim=c(i,5,100))
> for(j in 1:5){
> if(v[j] < 0.25){
> yo[i,j,t] = 1
> }else if(v[j] >=0.25 & v[j] < 0.5){
> yo[i,j,t] = 2
> }else if(v[j] >=0.5 & v[j] < 0.75){
> yo[i,j,t] = 3
> }else{
> yo[i,j,t] = 4
> }
> }}
>
> #transform theta1 to dichotomousvariables
> for (j in 6:9) { if (v[j]>0) yo[i,j,t]<-1 else yo[i,j,t]<-0 }
>
> i found this error
>
>
> *Error in yo[i, j, t] <- 1 : subscript out of bounds*
>
>
>
> any Guidance would highly appreciated.
>
How can we? You have not provided sufficient information.
Where are i and t given values? What are the values?
Why don’t you just try print(i) and print(t) before the for (j in 6:9) ?
Also have a look at the expression creating y0.
You specify 5 columns.
In the final loop you assign to column j with values starting at 6 and ending at 9; larger than 5.
Berend
> Regards
> --
> Thanoon Y. Thanoon
> PhD Candidate
> Department of Mathematical Sciences
> Faculty of Science
> University Technology Malaysia, UTM
> E.Mail: Thanoon.younis80 at gmail.com
> E.Mail: dawn_prayer80 at yahoo.com
> Facebook:Thanoon Younis AL-Shakerchy
> Twitter: Thanoon Alshakerchy
> H.P:00601127550205
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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