[R] prediction intervals (alpha and beta) for model average estimates from binomial glm and model.avg (library=dRedging)

Michelle Ensbey Michelle.Ensbey at nt.gov.au
Mon Apr 27 09:19:13 CEST 2009


Thanks for your swift reply

I'm sorry to say that I tried that, and it doesn't appear to work for predicting from the "model.avg" object (ouput). Model.avg is a model averaging function in dRedging. I am NOT trying to predict from the coefficients estimated directly from the glm.

For :
> fit1 <- glm(y~ dbh, family = binomial, data = data)

> fit2 <- glm(y~ dbh+vegperc, family = binomial, data = data)

> fit3 <- glm(y~ dbh, family = binomial, data = data)

##and the model averaging
> model.averaging <-model.avg(fit1,fit2,fit3, method="0")

##Then when trying to predict you get the error below I understand it is because it is not a glm (or other compatable object) but I thought maybe someone had come across and solved this problem already so I thought I'd check:

> predict(model.averaging)
OR
> predict(model.averaging,"Patch_Num")
Error in UseMethod("predict") : no applicable method for "predict"
##Comes up.
Does anyone have a function or code or has done this (for coefficients obtained from the model.avg function) in the past and can give advice.

Thanks again for your help, let me know if I've just missed something.
Cheers
M


-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Friday, 24 April 2009 10:24 PM
To: Michelle Ensbey
Cc: r-help at r-project.org
Subject: Re: [R] prediction intervals (alpha and beta) for model average estimates from binomial glm and model.avg (library=dRedging)

In R, the predict family of functions provides that facility. If you  
want the code it will be in the particular function associated with  
the model type.

?predict
?predict.glm
# the example illustrates creation of prediction curves on the  
response scale for  a specific range of data.
# create the desired CI's by appropriate use of the se.fit value  
returned from the predict call.
# This is the code inside predict.glm that does the work when se.fit  
is set as TRUE in the predict call:

se.fit <- pred$se.fit
switch(type, response = {
             se.fit <- se.fit * abs(family(object)$mu.eta(fit))
             fit <- family(object)$linkinv(fit)
         }, link = , terms = )

-- 
David Winsemius

On Apr 24, 2009, at 3:03 AM, Michelle Ensbey wrote:

> Hi all,
>
> I was wondering if there is a function out there, or someone has  
> written code for making confidence intervals around model averaged  
> predictions (y~á+âx). The model average estimates are from the  
> dRedging library?
>
> It seems a common thing but I can't seem to find one via the search  
> engines
>
> Examples of the models are:
>
> fit1 <- glm(y~ dbh, family = binomial, data = data)
>
> fit2 <- glm(y~ dbh+vegperc, family = binomial, data = data)
>
> fit3 <- glm(y~ dbh, family = binomial, data = data)
>
> and the model averaging
>
> model.averaging <-model.avg(fit1,fit2,fit3, method="0")
>
> and the output (from model.avg) has the following items:  
> Coefficient, Variance, Standard error, adjusted standard error and  
> lower and upper confidence interval for each parameter (and  
> intercept).
>
> What I would like to do is make "prediction intervals". I know I  
> need to include covariance and variance. Please let me know if  
> anyone has a function or code to get these prediction intervals out  
> of this output.
>
> Thanks in advance for your help, and please advise me if you need  
> more information
>
> M
> michelle.ensbey at nt.gov.au
>
> R version 2.8.1

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list