[R] Accessing elements of plm outputs

Achim Zeileis Achim.Zeileis at uibk.ac.at
Thu Apr 8 21:21:57 CEST 2010


On Thu, 8 Apr 2010, ECAMF wrote:

>
> Dear all,
>
> I've just migrated from STATA to R for runing panel regressions and I was
> very happy to discover the plm package. However, I have a problem when
> trying to access the "Total Sum of Squares" and "Residual Sum of Squares" on
> this output:
>
>> summary(output)
>
> Oneway (individual) effect Within Model
>
> Call:
> plm(formula = Y ~ X1 + X2, data = db, model = "within")
>
> Unbalanced Panel: n=10, T=9-11, N=108
>
> Residuals :
>   Min. 1st Qu.  Median 3rd Qu.    Max. 
> -6.500  -2.200  -0.374   1.550   8.730 
>
> Coefficients :
>         Estimate Std. Error t-value Pr(>|t|) 
> X1       113.302650   8.517736  13.302   <2e-16 ***
> X2       -0.084414   0.109625  -0.770   0.4432 
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 
>
> Total Sum of Squares:    3208.3
> Residual Sum of Squares: 1059.6
> F-statistic: 97.3365 on 2 and 96 DF, p-value: < 2.22e-16
>
>
> I would like to do so because I'm running some hundreds times a similar
> regression and I want to store those results in a vector and then plot them.
> I've tried to do so with 
>
>> summary(output)[] 
>
> but neither the "Total Sum of Squares" or the "Residual Sum of Squares" are
> on the list.

The residual sum of squares can be computed via
   sum(residuals(output)^2)

The total sum of squares is more difficult, I think. plm contains a tss() 
generic with suitable methods - but this is only used internally but not 
exported in the user interface. Thus, you currently have to do
   plm:::tss.plm(output)
This is really dirty as it accesses a specific method (rather than the 
generic) in the namespace (rather than the exported user interface). But I 
don't think there's currently a better way. The package authors (both 
Cc) might be able to give more guidance though.

hth,
Z

> I would be glad if somebody can help me.
>
> Thank you very much!
>
> Eduardo Marinho.
> -- 
> View this message in context: http://n4.nabble.com/Accessing-elements-of-plm-outputs-tp1774143p1774143.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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