[R-sig-ME] R-sig-mixed-models Digest, Vol 65, Issue 68

Nicholas Lewin-Koh nikko at hailmail.net
Wed May 30 18:08:47 CEST 2012


Hi Karel
If you are using mgcv look at the help page for predict.gam. Simon has
examples
of several complex contrasts using the predict function. So to get
a confidence interval on the difference between two predictions you can
use the
predict function with type='lp'
from the predict.gam help page:
#########################################################
## now get variance of sum of predictions using lpmatrix
#########################################################
Xp <- predict(b,newd,type="lpmatrix") 

## Xp %*% coef(b) yields vector of predictions

a <- rep(1,31)
Xs <- t(a) %*% Xp ## Xs %*% coef(b) gives sum of predictions
var.sum <- Xs %*% b$Vp %*% t(Xs)
 
This is not the exact formula but it is close to what you want.

Nicholas
> Date: Tue, 29 May 2012 16:05:14 +0200
> From: Karel Viaene <karel.viaene at Ugent.be>
> To: r-sig-mixed-models at r-project.org
> Subject: [R-sig-ME] How to test if two gamm-predictions are
> 	significantly	different?
> Message-ID: <4FC4D79A.1000106 at Ugent.be>
> Content-Type: text/plain
> 
> Dear R community,
> 
> A quick sketch of my situation:
> 
> I have two continuous explanatory variables ("concentration" and "time") 
> and a continuous response variable, "biomass".
> 
> I've fitted a gamm model to these data using the package mgcv and want 
> to predict at what concentration the biomass is significantly different 
> from the control treatment (i.e. a concentration of 0) for a given point 
> in time.
> 
> I've done this by predicting the biomass for a series of 1000 
> concentrations at a given point in time (using "predict"), constructing 
> 95% confidence intervals for these predictions by adding and subtracting 
> 1.96*SE and then selecting the lowest concentration where the two CI 
> show no overlap.
> 
> However I've realized that this technique is not adequate because two 
> points can also be significantly different at the 5% significance level 
> when the 95% CI do overlap and I want to calculate the lowest possible 
> concentration. I've read some literature about this and am considering 
> the following method:
> 
> * Calculate the difference between the control (C0) and a predicted 
> point (e.g. C1), thus C0-C1.
> * Construct a 95% CI for this difference by adding and subtracting 
> 1.96*sqrt(SE0^2 + SE1^2).
> * Do this for all predictions.
> * Select the lowest concentration where the 95% CI does not include 0.
> 
> Could you give me some feedback about this as I'm unsure if this method 
> can be used for gamms. Any comments or suggestions are much appreciated.
> 
> Many thanks in advance & kind regards
> 
> Karel
> 
> -- 
> Karel Viaene
> Ghent University
> Laboratory of Environmental Toxicology and Aquatic Ecology
> Plateaustraat 22
> 9000 Ghent, Belgium
> tel: +32 (0) 9 264 3779
>



More information about the R-sig-mixed-models mailing list