2
$\begingroup$

In order to analyse which factors have greater weight in the proportion of incidence (number of infected inidivuals against total individuals), the interaction of all factors (habitat, site and seasons) must be tested by a linear mixed model (LMM).

The predictor variables are habitat, considering at the same time the random factors season and sampling site and the response factor was the incidence value.

The dataset that I am using is this: https://drive.google.com/file/d/1fVuJNdZ593L6LoIKNhUynRGGIsN-IdxV/view?usp=sharing

I performed the LMM. Habitat as fixed factor and Season and site as random

             LMM_habitats <- lme(Incidence ~ Habitat, 
                         random = ~1|Season/Site,data = Incidence)

And I get the next error:

             summary(LMM_habitats )
             Linear mixed-effects model fit by REML
              Data: Incidence 
                     AIC       BIC   logLik
               -59.68649 -50.61563 36.84324

             Random effects:
              Formula: ~1 | Season
                      (Intercept)
             StdDev: 1.757018e-06

              Formula: ~1 | Site %in% Season
                     (Intercept)     Residual
             StdDev:  0.05336431 0.0003025349

                              Fixed effects: Incidence ~ Habitat 
                                   Value  Std.Error DF   t-value p-value
             (Intercept)       0.3787000 0.02668258 25  14.19278       0
             HabitatEdge      -0.3526818 0.03115855 25 -11.31894       0
             HabitatOakwood   -0.3524625 0.03267936 25 -10.78548       0
             HabitatWasteland -0.3760250 0.03267936 25 -11.50650       0
              Correlation: 
                              (Intr) HbttEd HbttOk
             HabitatEdge      -0.856              
             HabitatOakwood   -0.816  0.699       
             HabitatWasteland -0.816  0.699  0.667

             Standardized Within-Group Residuals:
                       Min            Q1           Med            Q3           Max 
             -0.0118981048 -0.0027639916 -0.0002841735  0.0004382114  0.0139696498 

             Number of Observations: 31
             Number of Groups: 
                       Season Site %in% Season 
                            3               31 

              get_variance_residual(LMM_habitats )
             var.residual 
             9.152738e-08 
             Warning message:
             Can't compute random effect variances. Some variance components equal zero.
             Solution: Respecify random structure!

Why is it happening? Thank you in advance.

$\endgroup$

1 Answer 1

2
$\begingroup$

There are two problems here.

Note that Season/Site is the same as Season + Season:Site.

You are specifying Season as a grouping factor for random intercepts, but you have only 3 seasons, so you are asking the software to estimate the variance for a random variable with only 3 observations.Season should be a fixed effect.

Then since you have 16 sites, Season:Site has 48 levels, however your total dataset contains only 31 observations. Of course, when you remove Season from the random structure, this problem will also go away.

So this model would make more sense:

lme(Incidence ~ Habitat + Season, random = ~1|Site 
$\endgroup$
5
  • $\begingroup$ However, I am trying to obtain the percentage of the variance explained by the fixed effects. I am using LMM_habitats <- lme(Incidence ~ Habitat + Season, random=~1|Site,data = Incidence) vc_fixed <- as.matrix(vcov(LMM_habitats )) var_fixed <- diag(vc_fixed); var_fixed and I get this output: (Intercept) HabitatEdge HabitatOakwood HabitatWasteland SeasonSpring SeasonSummer 0.0014200762 0.0020746951 0.0022753646 0.0022753646 0.0001337797 0.0004310081 I would like to know how to obtain the variance of Crop and Autumn predictable variables. Thank you in advance $\endgroup$ Commented Oct 4, 2020 at 13:17
  • 1
    $\begingroup$ I don't see any variable called Crop or Autumn, but anyway it sounds like you want some kind of $R^2$. In your situation I would just fit a linear model, using lm with fixed effects for season, site and habitat (and any other variables of interest), and compare the $R^2$ for that model with another model with season (or whatever other variable(s) you are interested in) omitted. Note that $R^2$ is not well defined for mixed models. I would also advise some caution with intepreting your model(s), as I expect that Habitat may be a mediator of the Season-->Incidence causal path. $\endgroup$ Commented Oct 4, 2020 at 13:53
  • $\begingroup$ I think that in this post explain better my trouble, stats.stackexchange.com/questions/490362/… please, could you help me? thank you in advance $\endgroup$ Commented Oct 4, 2020 at 14:04
  • 1
    $\begingroup$ Similar to @AdriánP.L., I tried GLMM using a radnom effect of only two levels. So now I know that random effects need a certain minimum amount of levels. I also thought that each level in a random effect needs a minimum amount of observations. I wonder whether there is a guideline concerning these issues - how many levels and how many oberservations per level are needed? And should this be a question on its own right? $\endgroup$
    – yenats
    Commented Mar 15, 2021 at 16:11
  • $\begingroup$ @yenats Please ask a new question regardng all of that, $\endgroup$ Commented Mar 15, 2021 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.