lsmeans
has to reconstruct the dataset (including all predictor values) in order to determine the reference grid. The error message you report results from it’s being unable to do that. The only thing I can guess is that the data frame used to fit the model is no longer in the workspace or on the search path.
If you restore the dataset or make it visible, lsmeans
should work again. Alternatively, add , data = gra
to the lsmeans()
call.
Update 1
It turns out that the problem occurs in the code to handle the fact that this model is rank-deficient. Ironically, I think it relates to this entry in the NEWS
file for the ordinal package:
2014-11-12:
- Reimplementation of formula, model.frame and design matrix
processing motivated by a bug in model.matrix.clm and predict.clm
reported by Russell Lenth 2014-11-07 when implementing lsmeans support
for clm::ordinal.
I had put-in some code to work around that, and apparently,
- my workaround only worked until the aforementioned update
- not many users over the past 4 years are encountering rank-deficient
ordinal models; or at least I didn't hear from them if they did.
I am now trying to remember which lines of code are my workaround, and which are still needed... When I have this resolved, I'll push it to the github repository for emmeans, and in a month or so, emmeans will be updated on CRAN (it'll be a version greater than 1.3.1). Updating emmeans will make lsmeans work too, as now it is just a front-end for emmeans.
Update 2
It seems to be fixed now:
> lsmeans(gra.f,
+ pairwise ~ location + species,
+ adjust="tukey")
$`lsmeans`
location species lsmean SE df asymp.LCL asymp.UCL
B10 HD nonEst NA NA NA NA
B30 HD nonEst NA NA NA NA
B50 HD nonEst NA NA NA NA
B70 HD -0.2802 0.191 Inf -0.65519 0.0949
Black Pt HD -0.1298 0.325 Inf -0.76730 0.5077
Bolongo HD nonEst NA NA NA NA
... Several rows of output omitted ...
SMA TT nonEst NA NA NA NA
Confidence level used: 0.95
$contrasts
contrast estimate SE df z.ratio p.value
... MANY rows of output omitted ...
B70,HD - Magens,HD nonEst NA NA NA NA
B70,HD - SMA,HD nonEst NA NA NA NA
B70,HD - B10,HS -0.71283 0.225 Inf -3.162 0.4869
B70,HD - B30,HS 0.07174 0.227 Inf 0.316 1.0000
B70,HD - B50,HS -0.74197 0.228 Inf -3.253 0.4093
B70,HD - B70,HS -0.72863 0.226 Inf -3.229 0.4291
B70,HD - Black Pt,HS -0.10537 0.220 Inf -0.478 1.0000
B70,HD - Bolongo,HS nonEst NA NA NA NA
B70,HD - Fortuna,HS -0.64301 0.240 Inf -2.684 0.8656
B70,HD - Lindberg,HS -0.10132 0.220 Inf -0.460 1.0000
B70,HD - Magens,HS 0.02351 0.226 Inf 0.104 1.0000
B70,HD - SMA,HS -0.05100 0.219 Inf -0.232 1.0000
B70,HD - B10,HW nonEst NA NA NA NA
B70,HD - B30,HW nonEst NA NA NA NA
B70,HD - B50,HW nonEst NA NA NA NA
B70,HD - B70,HW nonEst NA NA NA NA
B70,HD - Black Pt,HW nonEst NA NA NA NA
B70,HD - Bolongo,HW nonEst NA NA NA NA
[ reached getOption("max.print") -- omitted 1059 rows ]
P value adjustment: tukey method for comparing a family of 50 estimates
However, your problems are just beginning. You have a large number of non-estimable combinations due to missing data. Good luck...
I will push the updated version to https://github.com/rvlenth/emmeans.