[R] Plotting GEE confidence bands using "predict"
Shige Song
shigesong at gmail.com
Mon Oct 17 17:36:08 CEST 2011
Hi Jason,
I would go for Zelig package to get simulated values and confidence
intervals. It can handle gee model.
Shige
On Mon, Oct 17, 2011 at 9:38 AM, JASON M. HILL <jmh656 at psu.edu> wrote:
> Hello Fellow R
> Users,I have
> spent the last week trying to find a work around to this problem and I can't
> seem to solve it. I simply want to plot my GEE model result with 95% confidence
> bands.
>
>
> I am using the geepack package to run a basic GEE model involving
> nestling weights, to a Gaussian distribution, with "exchangeable" error
> structure. I am examining how nestling weight varies as a function of distance
> from a plot boundary.
>
>
>
> The response variable (WEIGHT) and the explanatory
> variable (DISTANCE) are both continuous. The clustering factor (MOTHER) is
> entered into my model to account for similarity of nestlings from the same nest
> produced by a given mother.
>
>
> My simplified code is
> as follows:
>
>
> summary(model1<-geeglm(WEIGHT~DISTANCE,
> id=MOTHER,data=df,corstr="exchangeable")))
> #I've included part of the
> model output
> here
>
>
>
> <Coefficients:
> <
> Estimate Std.err
> Wald Pr(>|W|)
>
> <(Intercept) 15.8702 0.4416
> 1291.8 < 2e-16 ***
> <Initiationdate -0.0664
> 0.0157 17.9 2.4e-05
> ***
> <
> <Estimated Scale
> Parameters:
> <
> < Estimate
> Std.err
> <(Intercept) 5.78
> 2.46
>
>
>
>
>
>
> plot(df$DISTANCE,df$WEIGHT)
>
>
> abline(model1)
>
>
> x<-seq(min(df$DISTANCE),max(df$DISTANCE),l=1000)
>
>
> y<-predict(model1,data.frame(DISTANCE=x))
>
>
> Everything is fine up until this last line of code, when I get the following
> error message:
>
>
>
> "Warning message:
> In predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == :
> calling predict.lm(<fake-lm-object>) ..."
>
>
>
> This isn't a geepack problem because I get the same error message using the gee
> package as well. The above simplified code is how I usually create and plot 95%
> CI bands for a linear model, followed by:
>
>
> matlines(x,y)
>
>
> I have read through the package PDFs and searched the web and archives of
> various listservs without success. Any help would be most appreciative. Seems
> like there should be a simple work-around. Thank you,
> Jason
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list