modelInfo {apsrtable} | R Documentation |
Model diagnostic / summary information to be included in apsrtable output.
modelInfo(x) ## S4 method for signature 'summary.lm': modelInfo(x) ## S4 method for signature 'summary.glm': modelInfo(x) ## S4 method for signature 'summary.tobit': modelInfo(x)
x |
A summary object. |
Returns a list containing model diagnostic information, with an interface described here to allow the user to change the information returned and thus presented. The method is called by apsrtable
within an lapply
on a list of model summaries. The modelInfo methods for a given model summary object simply return a list of arbitrary name-value pairs and give themselves the S3 class modelInfo
. The modelInfo method dispach uses formal S4 classes, however.
The example shows how one can change the summary for lm
objects to include only the N and residual σ.
It is highly likely you will have to call setOldClass
in order to register new modelInfo
methods for most types of model summary objects. S4 method dispach makes changing and overriding these functions much more straightforward than the alternative.
A list of named character objects representing the lines of model diagnostic information to be included for a given class of model. For example, the default for lm
reports the N, R^2, adjusted R^2, and residual σ. The default for glm
includes the N, AIC, BIC, and log-likelihood. Common names across model classes in the same table – e.g., the N – are matched by name, exactly like the model coefficients (indeed, the same functions aggregate terms and order across models.)
Michael Malecki <malecki at wustl.edu>
setMethod("modelInfo", "summary.lm", function(x) { env <- sys.parent() digits <- evalq(digits, env) model.info <- list( "$N$"=formatC(sum(x$df[1:2]),format="d"), "Resid. sd" = formatC(x$sigma,format="f",digits=digits)) class(model.info) <- "model.info" return(model.info) } ) example(apsrtable) ### Switch back to the default setMethod("modelInfo", "summary.lm", apsrtable:::modelInfo.summary.lm) ## Not run: example(apsrtable)