简体   繁体   中英

Creating a GLMM with binomial response and a mix of categorical/continuous variables

I am analysing several amphibian sightings (6000+ records) to understand what environmental variables influence the presence and absence of amphibians. The response variable for each amphibian species is a logical vector (true,false), and the environmental factors comprise continuous numerical (road distance, pond distance) and categorical variables (months, years, areas). I created a Generalised Linear Mixed Model, (GLMM, package lme4) scaling down the numerical variables and I chose Area (where the sightings occured) as a random effect.

-Is the scaling /100 acceptable? Road distance and pond distance are in m. and often include big numbers (3000m, etc). Scaling also removed the rescaling error message that this model was initially giving me .

-Will the random effect work as intended (1|Area)? I am not sure about the synthax of this feature.

Thank you in advance.

Here is one of the amphibian models I created:

C.TOAD.BI<-glmer(C.TOAD~+Habitat.type+I(pond.dist/100)+I(road.dist/100)+I(urban.dist/100)+Year+Month+(1|Area), family = binomial(link="logit"),data = Amphibians)

The syntax you have used to specify your random effect structure will work. The model you have provided is known as a random-intercept model, which in your case will estimate a random intercept for each of the areas in your data.

For the scaling issue, I would recommend centering your pond.dist and road.dist first before re-scaling. It's difficult without a sample of your data, but I believe the following code will work (which uses tidyverse functions) to center your variables. If you re-run the model with centered pond distance and road distance and still receive scaling issues, in my experience it is ok to simply divide your variable values by a constant to remove the scaling issue. If you do so, just be cognizant of the change in interpretation.

Amphibians %>% group_by(Area) %>% mutate(pond.dist_c = pond.dist - mean(pond.dist), road.dist_c = road.dist - mean(road.dist))

When centering by Area, the interpretation of these effects will change a bit. In the case of pond distance, you would interpret the effect as the estimated increase in log odds of an amphibian sighting associated with an increase in pond distance relative to an area's mean pond distance .

If you'd like, you can also specify random effects in your model. These can be done by adding any variable that varies by Area into your random effect syntax. For instance, (1 + pond.dist | Area) . This would allow the model estimate a unique effect of pond distance for each area.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM