I have an experiment with two treatments. It is a split plot experiment, with the structure Block/Treatment1/Treatment2. Each treatment has 2 levels. The dependent variable is presence/absence data for functional speceis groups. I am analysing the data using mixed models via lme4 and afex.
The model structure is as follows:
m <- lmer (DV ~ Treatment 1 * Treatment 2 + (1|Block/Treatment1), family = binomial)
For graphical purposes however, I want to plot the treatment means for each of the 4 treatment combinations (Treatment 1 level A and Treatment 2 level A; Treatment 1 level B Treatment 2 level A; Treatment 1 level B and Treatment 2 level A; Treatment 1 level B and Treatment 2 level B). I couldn't find an intuitive way to extract these mean and standard error values in R for data with a binomial error distribution, thus I am calculating these values by hand. I appreciate that the standard errors I calculate will not take into account the random effect structure in my dataset, but I cannot find a way to calculate them to include this random effect structure (using a mcmc simulation in language R to create HPD confidence intervals only works for Gaussian data).
As such, I want to calculate treatment means for the proportion of a particular functional group in a particular treatment combination, and then standard errors of these 4 treatment means.
Consider that the proportions I have for a particular treatment are:
Plot 1: 24/65 Plot 2 26/64 Plot 3: 25/65 Plot 4: 22/62 Plot 5: 30/66 Plot 6: 29/65
I understand that to calculate the average proportion I need to sum the total number of hits (sum of all the numerators above) and divide by the total sum of hits and misses (sum of all the denominators above). This gives me 0.40.
My question then is, how does one calculate the standard error of the resulting proportion?
Calling the proportion of hits p and misses q, I have the following formula for the standard error of a proportion:
Is this correct? In addition, what is n? Is n the number of proportions that make up the mean proportion (in this case 6) or the total number of hits and misses (i.e. sum of all the denominators above, which here is 387)?
I'm sorry that this is a simple question, I just cannot find an answer anywhere! Also i'm sorry if this is not the correct forum to post this in...