modelInfo {apsrtable}R Documentation

Model fit and diagnostic functions for output

Description

Model diagnostic / summary information to be included in apsrtable output.

Usage

 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)

Arguments

x A summary object.

Details

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.

Value

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.)

Author(s)

Michael Malecki <malecki at wustl.edu>

See Also

sys.frame

Examples

 

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)

[Package apsrtable version 0.7-2 Index]