On Mar 31, 2016, at 1:00 PM, Paul Johnson <pauljohn32 at gmail.com> wrote:
In the rockchalk package, I want to provide functions for regression
objects that are "well behaved." If an object responds to the methods
that lm or glm objects can handle, like coef(), nobs(), and summary(),
I want to be able to handle the same thing.
It is more difficult than expected to ask a given fitted model object
"do you respond to these functions: coef(), nobs(), summary()." How
would you do it?
I tried this with the methods() function but learned that all methods
that a class can perform are not listed. I'll demonstrate with a
regression "zz" that is created by the example in the plm package.
The coef() function succeeds on the zz object, but coef is not listed
in the list of methods that the function can carry out.
library(plm)
example(plm)
[1] ercomp fixef has.intercept model.matrix
[5] pFtest plmtest plot pmodel.response
[9] pooltest predict residuals summary
[13] vcovBK vcovDC vcovG vcovHC
[17] vcovNW vcovSCC
see '?methods' for accessing help and source code
methods(class = "panelmodel")
[1] deviance df.residual fitted has.intercept index
[6] nobs pbgtest pbsytest pcdtest pdim
[11] pdwtest phtest print pwartest pwfdtest
[16] pwtest residuals terms update vcov
see '?methods' for accessing help and source code
log(pcap) log(pc) log(emp) unemp
-0.026149654 0.292006925 0.768159473 -0.005297741
I don't understand why coef(zz) succeeds but coef is not listed as a method.