alfonso.carfora at uniparthenope.it

2013-Apr-24 08:11 UTC

### [R] pglm package: fitted values and residuals

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: 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 ****************************************************************************** IL MERITO DEGLI STUDENTI VIENE RICONOSCIUTO Il 5 per mille all'Universita' degli Studi di Napoli "Parthenope" incrementa le borse di studio agli studenti - codice fiscale 80018240632 http://www.uniparthenope.it/index.php/5xmille http://www.uniparthenope.it/index.php/it/avvisi-sito-di-ateneo/2943-la-parthenope-premia-il-tuo-voto-di-diploma-ed-il-tuo-imegno-con-i-proventi-del-5-per-mille Questa informativa e' inserita in automatico dal sistema al fine esclusivo della realizzazione dei fini istituzionali dell'ente.

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. Well, the authors have not gone the "extra step" to make their regression objects behave like other R regression objects. In case you need alternative software, ask in R-sig-mixed. You'll learn that most of these can be estimated with other packages. But I really like the homogeneous user interface that is spelled out in pglm, and I expect my students will run into the same questions that you have.. I just downloaded their source code, you probably ought to do that so you can understand what they are doing. They provide the fitting functions, but they do not do any of the other work necessary to make these functions fit together with the R class framework. There are no methods for "predict", anova, and so forth. I'm in their R folder looking for implementations: pauljohn at pols110:/tmp/pglm/R$ grep summary * pauljohn at pols110:/tmp/pglm/R$ grep predict * pauljohn at pols110:/tmp/pglm/R$ grep class * pauljohn at pols110:/tmp/pglm/R$ grep fitted * pglm.R: # glm models can be fitted Run> example(pglm)what can we do after that?> plot(anb)Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' ## Nothing. ## We do get a regression summary object, that's better than some packages provide:> anbsum <- summary(anb)## And a coefficient table> coef(anbsum)Estimate Std. error t value Pr(> t) (Intercept) -6.933764e-01 0.061391429 -11.294351205 1.399336e-29 wage 1.517009e-02 0.006375966 2.379261231 1.734738e-02 exper 1.314229e-03 0.007400129 0.177595444 8.590407e-01 ruralyes -8.594328e-05 0.051334716 -0.001674175 9.986642e-01> model.matrix(anb)Error in terms.default(object) : no terms component nor attribute> anova(anb)Error in UseMethod("anova") : no applicable method for 'anova' applied to an object of class "c('maxLik', 'maxim')"> predict(anb)Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('maxLik', 'maxim')" So, if you want those features with these models, you'll have to get busy and do a lot of coding! While working on regression support lately, I've reached the conclusion that if an R package that claims to "do regression" but does not provide methods for summary, predict, anova, nobs, fitted, logLik, AIC, and so forth, then it is not done yet. Otherwise, users like you who expect to be able to run methods like fitted or such have a bad experience, as you are having now. Maybe somebody reading this will remind us where the common list of R regression methods is listed. I know for sure I've seen a document about these things, but I'm baffled now trying to find it. But I'm sure there is one. 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 >