I am analyzing data on stream community before and after an invasive species removal event and have a dataset of dissimilarity values comparing the stream community at each time point in the dataset with the average community pre-removal. I have constructed a model for this dataset dissimilarity ~ cycle + discharge + biomass where cycle is the time of the measurement, discharge is mean stream discharge, and biomass is the biomass of invasive species removed from the stream as a measure of initial invasive community. Each variable is significant, as are the interactions cycle:discharge and cycle:biomass.
I am trying to assess the persistence of removal effects across discharge and biomass. I have the following code that will produce a graph very near what I want using the glht function in the multcomp library.
## create a graph of difference in predicted dissimilarity between cycle 8.2 ## (first post removal time point) with cycle 1 # create a sequence of discharge values Mean.Q.seq<-seq(0.05,0.7,0.05) # create a matrix for glht function providing coefficients for the model # components (i.e. 0s for unused components, 1*adjustment of the # intercept for cycle 8.2, Mean.Q.seq*adjustment of beta Mean.Q:Cycle8.2, # average biomass of 4750.5*adjustment of beta Inv.biomass:Cycle8.2) K.1<-cbind(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,Mean.Q.seq,0,0,0,0,0,0,0,0,0,0,0,0,4750.5,0,0,0,0,0,0,0,0,0,0,0,0) rownames(K.1)<-paste("Mean.Q",Mean.Q.seq) # use glht to calculate the differences bycycle.for.diffs<-glht(bycycle.model.0.b,linfct=K.1) # calculate the confidence intervals at each discharge value bycycle.ci<-confint(bycycle.for.diffs,level=0.95) # create graph par(mfrow=c(1,1)) plot(Mean.Q.seq,coef(bycycle.for.diffs),type="b", ylim=c(min(bycycle.ci$confint[,"lwr"]),max(bycycle.ci$confint[,"upr"])), xlab="Mean discharge",ylab="Predicted Dissimilarity, Cycle 8.1 - Pre-removal average") lines(Mean.Q.seq,bycycle.ci$confint[,"upr"]) lines(Mean.Q.seq,bycycle.ci$confint[,"lwr"]) abline(h=0,lty=3)
My question is whether there is any way to create this graph where the y values are the difference between predicted dissimilarity at cycle 8.2 and the average predicted dissimilarity for pre-removal time points (cycles 1-8.1) such that I can show with the CIs at what range of flow values the community is different from the pre-removal average at this time point? Comparing it to cycle 1 assumes that dissimilarity at cycle 1 is representative of general dissimilarity pre-removal, which is not given.