runehaubo / old-lmerTest

**OLD** lmerTest version - see runehaubo/lmerTestR for the new one
2 stars 0 forks source link

`step()` fails with simple models #6

Open nick-youngblut opened 6 years ago

nick-youngblut commented 6 years ago

With any relatively "simple" lmer models, I keep getting the following error when running lmerTest::step:

Error in `[<-.data.frame`(`*tmp*`, rownames(anm), c("Sum Sq", "Mean Sq", : replacement has 0 items, need 21
Traceback:

1. lmerTest::step(fm1)
2. stepFun(model = model, ddf = ddf, type = type, alpha.random = alpha.random, 
 .     alpha.fixed = alpha.fixed, reduce.fixed = reduce.fixed, reduce.random = reduce.random, 
 .     fixed.calc = fixed.calc, lsmeans.calc = lsmeans.calc, difflsmeans.calc = difflsmeans.calc, 
 .     test.effs = test.effs, keep.effs = keep.effs, change.contr = TRUE)
3. updateAnovaTable(resNSelim)
4. `[<-`(`*tmp*`, rownames(anm), c("Sum Sq", "Mean Sq", "NumDF"), 
 .     value = structure(logical(0), .Dim = c(0L, 3L), .Dimnames = list(
 .         NULL, c("Sum Sq", "Mean Sq", "Df"))))
5. `[<-.data.frame`(`*tmp*`, rownames(anm), c("Sum Sq", "Mean Sq", 
 .     "NumDF"), value = structure(logical(0), .Dim = c(0L, 3L), .Dimnames = list(
 .     NULL, c("Sum Sq", "Mean Sq", "Df"))))
6. stop(sprintf(ngettext(m, "replacement has %d item, need %d", 
 .     "replacement has %d items, need %d"), m, n * p), domain = NA)

For instance, if the model is something simple like:

fm1 = lmerTest::lmer(observation ~ height * age * BMI + (1|FamilyID), data=df)

No matter now I alter the formula, I keep getting the same error. Based on the error message, it's unclear what's going wrong. Does step() only work on more complicated models as shown in the example for the function?

runehaubo commented 6 years ago

Could you try the new lmerTest, i.e. devtools::install_github("runehaubo/lmerTestR") and post an issue there if the problem remains? In that case the it would be really good with a reproducible example as well.

Cheers Rune

nick-youngblut commented 6 years ago

It seems to be working. Thanks! When do you expect to have a new CRAN release? My department uses conda to manage all software, including R packages, and the lmerTest conda-forge feedstock must be updated with a new CRAN version (not a new GitHub release tag).

runehaubo commented 6 years ago

Unless you are using step on a model that you fitted with an old version of lmerTest (< 3.0.0) I don't think the behaviour of step should differ between CRAN and GitHub versions so I presume the current CRAN version is new enough for you.