After looking through several questions on stackexchange, and even applying many of the suggested methods I have come to a point where I would like to have an expert's advice if the methods applied on my dataset are correct. This is for my master-dissertation and up untill 1,5 months ago I never worked with R.
I studied the micro-habitat characteristics for the ovipostion of the Pyrgus Malvae butterfly. I measured several environmental variables as the percentage of the hostplant site area, more specifically with an example: the percentage of dwarf-shrub cover per host-plant site, or the percentage of wild-boar digging per hostplant site. Each site equals a circle with a radius of 25 cm with the hostplant in the center. For each occupied hostplant I selected a paired unoccupied hostplant.
The test I chose to use is a GLMM (glmer
from the package lme4
) since I want to account for several random effects such as the hostplant species (HP_spp
), the date on which I measured these variables (VS_Date
) and the pair number (Pair_nr
) of each occupied and unoccupied hostplant pair. In the GLMM I want to use my environmental variables as the response variable and use Occupancy (0 = unoccupied = no egg found; 1 = occupied) as the independent variable to check for differences within each environmental variable between the two levels of occupancy.
I have performed 3 different kind of glmer
:
I will use one of my variables as an example here: VS_G
= vegetation structure grass = the percentage of grass cover within a hostplant site.
1) standard glmer
with family = binomial
Note: VS_G is expressed as a decimal (i.e. 0.7 for 70% grass cover)
GLMMS106_VS_G_Occ <- glmer(VS_G~Occupancy +
(1|VS_Date) + (1|Pair_nr) + (1|HP_spp), family = binomial, data = PM_data106)
with this test I obviously get the error message:
Warning message: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
And a resulting p-value of:
#R Estimate Std. Error z value Pr(>|z|)
#R (Intercept) -0.665 0.290 -2.293 0.021869 *
#R Occupancy -2.574 0.777 -3.312 0.000925 ***
2) After looking up this error I found out I had to change my test since I am working with proportional data, so I applied 2 tests with the cbind command and the weights command:
2a) glmer
with cbind
Note: VS_G
is expressed as a integer (i.e. 70 for 70% grass cover), I created VS_G_inv = 100-VS_G
; so in case of VS_G == 70
, then VS_G_inv == 30
.
GLMMS106_VS_G_Occ <- glmer(cbind(VS_G, VS_G_inv)~Occupancy +
(1|VS_Date) + (1|Pair_nr) + (1|HP_spp), family = binomial, data = PM_data106)
Hooray! no error anymore however the p-value seems of:
#R Estimate Std. Error z value Pr(>|z|)
#R (Intercept) -0.58302 0.22478 -2.594 0.00949 **
#R Occupancy -0.96390 0.04594 -20.982 < 2e-16 ***
2b) glmer
with weights
Note: VS_G
is expressed as an integer (i.e. 70 for 70% grass cover) and VS_Weights
was created (= 100 for each site)
GLMMS106_VS_G_Occ <- glmer(VS_G/VS_Weights~Occupancy +
(1|VS_Date) + (1|Pair_nr) + (1|HP_spp), family = binomial, data = PM_data106, weights = VS_Weights)
Same result as the cbind
test:
#R Estimate Std. Error z value Pr(>|z|)
#R (Intercept) -0.58302 0.22478 -2.594 0.00949 **
#R Occupancy -0.96390 0.04594 -20.982 < 2e-16 ***
So after discussing this with my supervisors I found out that via using the cbind or weights command my sample size is increased by a factor 100 in this case. This in it's turn results in these very low p-values. So now I am wondering if the first test is ok to use after all?
glm
uses will be wrong. In 2a) and 2b) you estimate a model as if there where 100 coins flips 70 of which had a head. The latter "fake" 100 observation yields the much lower p-values. You only have on observations so this is clearly wrong. $\endgroup$