[R] pglm package: fitted values and residuals

Achim Zeileis Achim.Zeileis at uibk.ac.at
Thu Apr 25 22:45:36 CEST 2013


On Thu, 25 Apr 2013, Ista Zahn wrote:

> On Thu, Apr 25, 2013 at 3:14 PM, Paul Johnson <pauljohn32 at gmail.com> wrote:
>> On Wed, Apr 24, 2013 at 4:37 PM, Achim Zeileis <Achim.Zeileis at uibk.ac.at> wrote:
>>> On Wed, 24 Apr 2013, Paul Johnson wrote:
>>>
>>>> On Wed, Apr 24, 2013 at 3:11 AM,  <alfonso.carfora at uniparthenope.it>
>>>> wrote:
>>>>
>>>>> I'm using the package pglm and I'have estimated a "random probit model".
>>>>> I need to save in a vector the fitted values and the residuals of the model
>>>>> but I can not do it.
>>>>>
>>>>> I tried with the command fitted.values using the following procedure
>>>>> without results:
>>>>>
>>>> This is one of those "ask the pglm authors" questions. You should take it
>>>> up with the authors of the package.  There is a specialized email list
>>>> R-sig-mixed where you will find more people working on this exact same
>>>> thing.
>>>>
>>>> pglm looks like fun to me, but it is not quite done, so far as I can tell.
>>>
>>> I'm sure that there are many. One of my attempts to write up a list is in
>>> Table 1 of vignette("betareg", package = "betareg").
>>
>> Yes! That's exactly the list I was thinking of.  It was driving me
>> crazy I could not find it.
>>
>> Thanks for the explanation.  I don't think I should have implied that
>> the pglm author must actually implement all the methods, it is
>> certainly acceptable to leverage the methods that exist.  It just
>> happened that the ones I tested were not implemented by any of the
>> affiliated packages.
>>
>> But this thread leads me to one question I've wondered about recently.
>>
>> Suppose I run somebody's regression function and out comes an object.
>>
>> Do we have a way to ask that object "what are all of the methods that
>> might apply to you?"
>
> Yes, minus the "might":
>
> library(pglm)
> example(pglm) # produces an object named "la"
> sapply(class(la), function(x) methods(class=x)) # lists functions with
> methods for objects of this class

Well, this shows you the methods that are available for the class but not 
necessarily what arguments are supported. And even if the arguments are 
available they do not necessarily mean the same thing. And some things may 
or may not work via inheritance...

So coming back to Paul's question: Yes, I think it would be nice to have 
support for this and in fact I have thought about similar infrastructure. 
But so far I didn't have a good idea for a sufficiently robust/reliable 
implementation. There are just so many details in the different model 
objects that can be handled differently.

Best,
Z

> Best,
> Ista
>
> Here's why I wondered. You've noticed that
>> predict.lm has the interval="confidence" argument, but predict.glm
>> does not. So if I receive a regression model, I'd like to say to it
>> "do you have a predict method" and if I could get that predict method,
>> I could check to see if there is a formal argument interval. If it
>> does not, maybe I'd craft one for them.
>>
>> pj
>>
>>
>>
>>> Personally, I don't write anova() methods for my model objects because I can
>>> leverage lrtest() and waldtest() from "lmtest" and linearHypothesis() and
>>> deltaMethod() from "car" as long as certain standard methods are available,
>>> including coef(), vcov(), logLik(), etc.
>>>
>>> Similarly, an AIC() method is typically not needed as long as logLik() is
>>> available. And BIC() works if nobs() is available in addition.
>>>
>>> Best,
>>> Z
>>>
>>>>
>>>> pj
>>>>
>>>>> library(pglm)
>>>>>
>>>>> m1_S<-pglm(Feed ~ Cons_PC_1 + imp_gen_1 + LGDP_PC_1 + lnEI_1 +
>>>>>
>>>>> SH_Ren_1,data,family=binomial(probit),model="random",method="bfgs",index=c("Year","IDCountry"))
>>>>>
>>>>> m1_S$fitted.values
>>>>> residuals(m1)
>>>>>
>>>>>
>>>>> Can someone help me about it?
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>> ______________________________________________
>>>> 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.
>>>>
>>>
>>
>>
>>
>> --
>> Paul E. Johnson
>> Professor, Political Science      Assoc. Director
>> 1541 Lilac Lane, Room 504      Center for Research Methods
>> University of Kansas                 University of Kansas
>> http://pj.freefaculty.org               http://quant.ku.edu
>>
>> ______________________________________________
>> 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.
>
> ______________________________________________
> 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