[R] Problem in R2WinBUGS
Berend Hasselman
bhh at xs4all.nl
Wed Dec 31 10:57:12 CET 2014
You should reply to the R-help list and not only to me .
yo in your answer to me does not correspond with the original mail.
It’s not possible to make sense of your code.
Berend
> On 31-12-2014, at 10:14, thanoon younis <thanoon.younis80 at gmail.com> wrote:
>
> thank you for your response
> N<-2000; P<-9
>
> yo<-matrix(data=NA,nrow=N,ncol=P); p<-numeric(P); v<-numeric(P)
>
> I want to change the continuous variables to mixed ordered categorical and dichotomous
>
> from 1:5 ordered categorical
> from 6:9 dichotomous
>
>
> Regards
>
> On 31 December 2014 at 10:54, Berend Hasselman <bhh at xs4all.nl> wrote:
>
> > 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.
>
>
>
>
> --
> 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
More information about the R-help
mailing list