r - Interaction term failing lmerTest with In pf(F.stat, qr(Lc)$rank, nu.F) : NaNs produced -


i trying carry out lmertest on 2 separate datasets, , reason getting following error 1 of datasets.

in pf(f.stat, qr(lc)$rank, nu.f) : nans produced

this dataset gives me p-value of interaction term between habitat , soil without issue.

anova(lmer(sqrt(abs) ~ habitat*soil + (1|species), data=frl_light, reml=t))

analysis of variance table of type iii   satterthwaite  approximation degrees of freedom                sum sq  mean sq numdf  dendf f.value  pr(>f)   habitat      0.057617 0.028809     2 8.8434  1.0880 0.37805   soil         0.232708 0.232708     1 2.6732  8.7888 0.06848 . habitat:soil 0.308003 0.154001     2 2.7134  5.8163 0.10443   --- signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

this dataset has similar structure throws error, , fails give p-value interaction between habitat , light. density degree of freedom measurement 0, problem.

anova(lmer(sqrt(abs) ~ habitat*light + (1|species), data=frl_soil, reml=t))

analysis of variance table of type iii   satterthwaite  approximation degrees of freedom                sum sq  mean sq numdf  dendf f.value pr(>f) habitat       0.00845 0.004223     2 7.9751  0.3494 0.7154 light         0.01634 0.016336     1 1.9241  1.3517 0.3689 habitat:light 0.42813 0.214067     2 0.0000 17.7124        warning message: in pf(f.stat, qr(lc)$rank, nu.f) : nans produced 

i have no idea why lmertest works 1 dataset not other both datasets appear me @ least, virtually indistinguishable 1 another. if there can shed light on matter, please help.

update 1: have tried ben bolker's suggestion use kenward-roger estimation instead. however, our answers seem differing. running r 3.3.1, lme4 1.1-12 , lmertest 2.0-32. output

anova(lmer(sqrt(abs) ~ habitat*light + (1|species), + data = frl_soil, reml = t), + ddf="kenward-roger")

anova lme4 returned computational error has occurred in lmertest analysis of variance table               df  sum sq  mean sq f value habitat        2 0.00244 0.001219  0.1009 light          1 0.00476 0.004763  0.3941 habitat:light  2 0.42813 0.214067 17.7124 

update 1.1: here's output of mixed-model analysis sas, added additional column square-root of abs, sqrtabs.

filename reffile '/folders/myfolders/frl_soil.csv';

proc import datafile=reffile dbms=csv out=work.frlsoil; getnames=yes; run;

proc contents data=work.frlsoil; run;

%web_open_table(work.frlsoil);

proc mixed data = work.frlsoil; class species habitat light sqrtabs; model sqrtabs = habitat light habitat*light / ddfm=kenwardroger; random intercept species; run;

type 3 tests of fixed effects effect         num df   den df  f value     pr > f habitat             2       10     1.11     0.3681 light               1       10     0.45     0.5159 habitat*light       2       10     0.27     0.7716 

i can't tell why satterthwaite approximation gives zero-df estimate here (which indeed why error , no $p$-value interaction); you'd have work through code in detail see (type lmertest:::calcsatterthmultdf , start digging ...) did little bit of digging; key lines therein are

e <- sum((nu.m/(nu.m - 2)) * as.numeric(nu.m > 2)) nu.f <- 2 * e * as.numeric(e > q)/(e - q) 

where (i think) nu.m ($\nu_m$) number of degrees of freedom estimated welch-satterthwaite approximation. don't know why (1) lmertest sets e , hence nu.f 0 when nu.m <= 2; (2) particular combination of within-group variances in 1 data set gives nu.m < 2 , in other data set doesn't ...

in meantime, though, can use kenward-roger approximation if (it's computationally more expensive, in general more accurate ...) using data set second link:

frl_soil <- read.csv("frl_soil.csv") library(lmertest) head(frl_soil,2) ##   x species habitat light        abs ## 1 1  ani2gr     gen  g.cs 2.67477395 ## 2 2  diptac     gen  g.cs 0.09549154 anova(lmer(sqrt(abs) ~ habitat*light + (1|species),              data=frl_soil, reml=true),       ddf="kenward-roger") ## analysis of variance table of type iii   kenward-roger  ## approximation degrees of freedom ##                sum sq  mean sq numdf  dendf f.value  pr(>f)   ## habitat       0.00842 0.004208     2 8.1220  0.3482 0.71602   ## light         0.01568 0.015679     1 2.0712  1.2973 0.36928   ## habitat:light 0.40886 0.204432     2 2.0713 16.9152 0.05212 . sessioninfo() ## other attached packages: ## [1] lmertest_2.0-32 lme4_1.1-13     matrix_1.2-6    

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -