[R-sig-ME] Mixed cumulative link modelling - error message
Dan McCloy
drmccloy at uw.edu
Fri Aug 21 19:51:39 CEST 2015
If str() says that bob$rating is of type int, then it is of type int.
Observe:
foo <- data.frame(bar=seq(1,3,1), baz=factor(seq(4,6,1)),
qux=factor(seq(7,9,1), ordered=TRUE))
str(foo)
'data.frame': 3 obs. of 3 variables:
$ bar: num 1 2 3
$ baz: Factor w/ 3 levels "4","5","6": 1 2 3
$ qux: Ord.factor w/ 3 levels "7"<"8"<"9": 1 2 3
you need to do bob$rating <- factor(bob$rating, ordered=TRUE) before
running your model.
-- dan
Daniel McCloy
http://dan.mccloy.info/
Postdoctoral Research Fellow
Institute for Learning and Brain Sciences
University of Washington
On Fri, Aug 21, 2015 at 9:36 AM, Georgina Southon <g.southon at sheffield.ac.uk
> wrote:
> Hi,
>
> I hope someone can help. I have problems fitting a cumulative link mixed
> model to my data.
> Looking at the str output, rating shows as an integer, despite the fact
> that it shows as an ordered factor when asked is.factor. Is this the
> problem or is there something else I have overlooked?
>
> str(bob)
> 'data.frame': 283 obs. of 4 variables:
> $ site : Factor w/ 10 levels "ADD","BH","BR",..: 4 4 4 4 4 4 4 4 4 4
> ...
> $ person : Factor w/ 283 levels "ADD10","ADD11",..: 80 91 102 104 105
> 106 107 108 109 81 ...
> $ treatment: Factor w/ 2 levels "CONTROL","MEADOW": 2 2 2 2 2 2 2 2 2 2
> ...
> $ rating : int 4 3 4 2 3 4 5 5 5 3 ...
> >
> > m1<-clmm2(rating~treatment,random=person,data=bob)
>
> Error in clm2(location = rating ~ treatment, data = bob, subset = c("1", :
> response needs to be a factor
>
> Thanks for any feedback / advice!
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list