0
$\begingroup$

Say I have data of 500+ species at different locations .

I have my response Y and I want to find out how my continuous predictor humidity effects my Y. I ideally would control for the impact of species by using a linear mixed model LMM and using species as random effect. However 80% of my species have just 1 individual and a very few have 1000 or more, making this quite unbalanced. So using a LMM may not be a good idea?

I thought about weighting the species instead.

If I give a species with one individual the weight 1 , a species with two individuals the weight 1/2 and so on , so defining my weight as 1/n, I would like to make sure that my model can incorporate the species information, so that my predictions are not influenced more by e.g., the top 10 species with individuals 100+ .Their Y values should not be equal to 100 other species with 1 individual in the regression.

how can I do this in R? there is a weights argument in lm() so I could do:

lm(Y ~ X, weights=1/n) 

however the weight in lm() is the weight of the uncertainty I have in my point or the variance, so I think I cannot use it this way.

What would be an appropriate method with robust estimates of standard errors for my coefficients. I saw that there is the package library(survey) with the function svyglm(). Would specifying weights there as below be correct?

des <- svydesign(id=~1, weights= ~n, data=data)
svyglm(Y ~ X, des)

Or are there better options to achieve equal weighting of species .

(Note I think I cannot simply average over species because those are at different locations, so I would also need to average my predictor X then for those species)

$\endgroup$
3
  • $\begingroup$ "making this quite unbalanced" Does the model not converge? I'm not sure it is a good idea to put extremely high relative weight on observations from species with low number of observations. Do you not also have a random effect for location? $\endgroup$
    – Roland
    Commented Nov 4, 2022 at 7:04
  • $\begingroup$ It get a singular fit with lme4. Yes, I think a random effect for location is likely, but location correlates with X and a location random effect would (I expect) be different for each species and I would need to nest random effects somehow,but most species only occur at one location. So I am not sure if it is a good idea to add this level of complexity, making it even more unbalanced? Would another option be to use simply the lm_robust package that calculates robust SE and allows clusters like: lm_robust(Y~X,clusters=species, weights=?) but here again weights seem to be uncertainty based $\endgroup$
    – Jmmer
    Commented Nov 4, 2022 at 16:47
  • $\begingroup$ Thanks for your help, my last comments was too long. This is the link to the lm_robust approach: declaredesign.org/r/estimatr/articles/mathematical-notes.html $\endgroup$
    – Jmmer
    Commented Nov 4, 2022 at 16:57

0

Your Answer

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