0

According to me, the wiggle code is correct, but I am unable to see why it is not working. Any suggestions? I use merTools version 0.5.0, and Rstudio Version 1.2.5001

# These are sample data
CatAnx <- read.fwf(file=("http://www.stat.ufl.edu/~winner/data/cats_anxiety1.dat"), 
            widths=c(-6,2,-5,3,-5,3,-7,1,-7,1,-7,1,-7,1,-7,1,-6,2,-6,2,-6,2,-6,2,-6,2))
colnames(CatAnx) <- c('ID', 'Weight', 'Age_Months', 'Gender', 'Environment', 'Origin', 
  'Treatment', 'Result', 'EmoTime1', 'EmoTime2', 'EmoTime3', 'EmoTime4', 'EmoTime5')

library("reshape2")
CatAnxRM <- melt(CatAnx, id.vars=c("ID", "Gender", "Treatment"), 
  measure.vars=c("EmoTime1",  "EmoTime2", "EmoTime3","EmoTime4", "EmoTime5"))
CatAnxRM$Sex <- with(CatAnxRM, ifelse(Gender==1, "Neut Female",
        ifelse(Gender==2, "Neut Male", "Whole Female")))
        CatAnxRM$Time <- with(CatAnxRM, ifelse(variable=="EmoTime1", 1, 
        ifelse(variable=="EmoTime2", 2, ifelse(variable=="EmoTime3", 3,
                              ifelse(variable=="EmoTime4", 4,5)))))
        CatAnxRM.Male <- subset(CatAnxRM, Gender=="2")

# Run the model
library("lme4")
Male.lmer <- lmer(value ~ Treatment * Time + (Time + 1|ID), data=CatAnxRM.Male)

# Wiggle the data
library("merTools")
wiggle(Male.lmer, varlist = "Time", valueslist = CatAnxRM.Male$Time)

Error in wiggle(Male.lmer, varlist = "Time", valueslist = CatAnxRM.Male$Time) : varlist and valueslist must be equi-length.`

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • The data are included: http://www.stat.ufl.edu/~winner/data/cats_anxiety1.dat – Frans van der Slik Oct 11 '19 at 15:08
  • 1
    Well, valueslist needs to be a list, not a vector. So `valueslist = list(AnxScores$Time)` would get rid of that message. But then the next problem is that `wiggle` takes a data.frame according to the documentation but you seem to be passing in a "lme4" model. That doesn't make sense. – MrFlick Oct 11 '19 at 15:17
  • Hi Herr Flick, thanks for the response. So, you can't wiggle with lemr4. It could with glemr: https://stackoverflow.com/questions/26514095/having-issues-using-the-lme4-predict-function-on-my-mixed-models/32594019#32594019 – Frans van der Slik Oct 11 '19 at 17:43
  • I am new to this list, so posting doesn't always behave the way I expect, Sorry for the inconvenience. Has using wiggle never been possible by means of lemr4? Interesting...Unfortunately, glemr is not available anymore. Is there a possiblity to run a glemr anyhow? – Frans van der Slik Oct 11 '19 at 18:04
  • In the example you linked to they are passing `newData` to wiggle. They are not passing the `glemr` model. – MrFlick Oct 11 '19 at 18:18
  • I can't follow you anymore, I believe. In your first post you state that I was passing a "lme4" model, which didn't make sense. Well, try to pass a model by means of newData, and you will run in exactly the same problem. – Frans van der Slik Oct 12 '19 at 07:45
  • Moreover, a colleague of mine ran a "lme4" model by means of newData about a year ago with no apparent problems. I simply can't repeat his analyses. So it is less obvious that "it doesn't make sense". My hunch is that "R" has changed the rules of the game without notice. – Frans van der Slik Oct 12 '19 at 08:01
  • I ran the following model: – Frans van der Slik Oct 14 '19 at 08:37
  • # Run the model Male.lmer <- lmer(value ~ Treatment * Time + (Time + 1|ID), data=CatAnxRM.Male) newData <- draw(Male.lmer, type = "average") Number of observations < 20, random effect quantiles may not be well-defined. a<-sort(unique(CatAnxRM.Male$Time)) b <- a[seq(1, length(a), 1)] newData <- wiggle(Male.lmer, varlist = "Time", valueslist = CatAnxRM.Male$Time) Error in wiggle(Male.lmer, varlist = "Time", valueslist = CatAnxRM.Male$Time) : varlist and valueslist must be equi-length. length(a) [1] 5 length(b) [1] 5 What goes wrong? I have no clue. – Frans van der Slik Oct 14 '19 at 08:38
  • wiggle has been updated. The following code doesn't work anymore: – Frans van der Slik Oct 15 '19 at 09:42
  • wiggle(Male.lmer, varlist = "Time", valueslist = CatAnxRM.Male$Time). It has to be altered in wiggle(Male.lmer, varlist = "Time", valueslist = list(CatAnxRM.Male$Time)) – Frans van der Slik Oct 15 '19 at 09:44

0 Answers0