Hi, I'm trying to run an ordinal mixed effects model with Mixor command. I have 65 cases and repeated visits in 0, 6, 9, 12 and 18 months. My code is the following: cannabis<-c(datos$cannabis0, datos$cannabis6, datos$cannabis9, datos$cannabis12, datos$cannabis18) time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) id<-c(rep(datos$id, 5)) group<-c(rep(datos$group, 5)) res<-data.frame(cbind(id, group, time, cannabis)) names(res)<-c("id", "group", "time", "cannabis") res<-res[order(res$id),] cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id, na.exclude, which.random.slope=na, link="logit") summary(cannabismod) However, I have obtained this error: Error in xj[i] : invalid subscript type 'closure' Please, could anyone help me to solve it? Many thanks, Susana [https://edukiak.osakidetza.net/coronavirus/pie_email7.jpg] [[alternative HTML version deleted]]
Can't tell... example is not reproducible because it is missing "datos'. On June 9, 2020 4:33:24 AM PDT, SUSANA ALBERICH MESA <SUSANA.ALBERICHMESA at osakidetza.eus> wrote:>Hi, >I'm trying to run an ordinal mixed effects model with Mixor command. I >have 65 cases and repeated visits in 0, 6, 9, 12 and 18 months. My code >is the following: > >cannabis<-c(datos$cannabis0, datos$cannabis6, datos$cannabis9, >datos$cannabis12, datos$cannabis18) >time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) >id<-c(rep(datos$id, 5)) >group<-c(rep(datos$group, 5)) > >res<-data.frame(cbind(id, group, time, cannabis)) >names(res)<-c("id", "group", "time", "cannabis") >res<-res[order(res$id),] > >cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id, >na.exclude, which.random.slope=na, link="logit") >summary(cannabismod) > > >However, I have obtained this error: > >Error in xj[i] : invalid subscript type 'closure' > >Please, could anyone help me to solve it? > >Many thanks, >Susana > >[https://edukiak.osakidetza.net/coronavirus/pie_email7.jpg] > > > > [[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.-- Sent from my phone. Please excuse my brevity.
Not sure, and we don't have your data, datos, but this is almost always a bad thing to do: res<-data.frame(cbind(id, group, time, cannabis)) Change it to: res<-data.frame(id, group, time, cannabis) ## and you then won't need to name them either and see if that fixes things. Also, res$id is probably a factor: is order(res$id) really meaningful as a subscript? Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Jun 9, 2020 at 6:01 AM SUSANA ALBERICH MESA <SUSANA.ALBERICHMESA at osakidetza.eus> wrote:> Hi, > I'm trying to run an ordinal mixed effects model with Mixor command. I > have 65 cases and repeated visits in 0, 6, 9, 12 and 18 months. My code is > the following: > > cannabis<-c(datos$cannabis0, datos$cannabis6, datos$cannabis9, > datos$cannabis12, datos$cannabis18) > time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) > id<-c(rep(datos$id, 5)) > group<-c(rep(datos$group, 5)) > > res<-data.frame(cbind(id, group, time, cannabis)) > names(res)<-c("id", "group", "time", "cannabis") > res<-res[order(res$id),] > > cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id, > na.exclude, which.random.slope=na, link="logit") > summary(cannabismod) > > > However, I have obtained this error: > > Error in xj[i] : invalid subscript type 'closure' > > Please, could anyone help me to solve it? > > Many thanks, > Susana > > [https://edukiak.osakidetza.net/coronavirus/pie_email7.jpg] > > > > [[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. >[[alternative HTML version deleted]]
Dear Susana Without your dat it is hard to say (and it would have helped to know where mixor() comes from) but this almost always means that ne of your parameters to the call is not what you thought it was so trying str(res) might be enlightening. Also I do not see anywhere in your example where you define na unless it is really NA and you did not copy it correctly. Michael On 09/06/2020 12:33, SUSANA ALBERICH MESA wrote:> Hi, > I'm trying to run an ordinal mixed effects model with Mixor command. I have 65 cases and repeated visits in 0, 6, 9, 12 and 18 months. My code is the following: > > cannabis<-c(datos$cannabis0, datos$cannabis6, datos$cannabis9, datos$cannabis12, datos$cannabis18) > time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) > id<-c(rep(datos$id, 5)) > group<-c(rep(datos$group, 5)) > > res<-data.frame(cbind(id, group, time, cannabis)) > names(res)<-c("id", "group", "time", "cannabis") > res<-res[order(res$id),] > > cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id, na.exclude, which.random.slope=na, link="logit") > summary(cannabismod) > > > However, I have obtained this error: > > Error in xj[i] : invalid subscript type 'closure' > > Please, could anyone help me to solve it? > > Many thanks, > Susana > > [https://edukiak.osakidetza.net/coronavirus/pie_email7.jpg] > > > > [[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. >-- Michael http://www.dewey.myzen.co.uk/home.html
Hi Susana, I ran your code on a fake data frame: datos<-data.frame(id=paste0("s",1:65), group=c(rep("control",30),rep("treat",35)), cannabis0=sample(1:5,65,TRUE), cannabis6=sample(1:5,65,TRUE), cannabis9=sample(1:5,65,TRUE), cannabis12=sample(1:5,65,TRUE), cannabis18=sample(1:5,65,TRUE)) time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) id<-c(rep(datos$id, 5)) group<-c(rep(datos$group, 5)) res<-data.frame(cbind(id, group, time, cannabis)) names(res)<-c("id", "group", "time", "cannabis") res<-res[order(res$id),] library(mixor) cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id,which.random.slope=NA,link="logit") The error seems to be that you have inserted a function name "na.exclude" in the arguments. When I removed it as above, it ran okay with a warning. Jim On Tue, Jun 9, 2020 at 11:01 PM SUSANA ALBERICH MESA <SUSANA.ALBERICHMESA at osakidetza.eus> wrote:> > Hi, > I'm trying to run an ordinal mixed effects model with Mixor command. I have 65 cases and repeated visits in 0, 6, 9, 12 and 18 months. My code is the following: > > cannabis<-c(datos$cannabis0, datos$cannabis6, datos$cannabis9, datos$cannabis12, datos$cannabis18) > time<-c(rep(0, 65), rep(6, 65), rep(9, 65), rep(12, 65), rep(18, 65)) > id<-c(rep(datos$id, 5)) > group<-c(rep(datos$group, 5)) > > res<-data.frame(cbind(id, group, time, cannabis)) > names(res)<-c("id", "group", "time", "cannabis") > res<-res[order(res$id),] > > cannabismod<-mixor(cannabis~ time + as.factor(group), data=res, id=id, na.exclude, which.random.slope=na, link="logit") > summary(cannabismod) > > > However, I have obtained this error: > > Error in xj[i] : invalid subscript type 'closure' > > Please, could anyone help me to solve it? > > Many thanks, > Susana > > [https://edukiak.osakidetza.net/coronavirus/pie_email7.jpg] > > > > [[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.