modelInfo: Model fit and diagnostic functions for output

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 modelInfo(x) 
## S4 method for signature 'summary.lm'
modelInfo(x)
## S4 method for signature 'summary.glm'
modelInfo(x)
## S4 method for signature 'summary.svyglm'
modelInfo(x)
## S4 method for signature 'summary.tobit'
modelInfo(x)
## S4 method for signature 'summary.gee'
modelInfo(x)
## S4 method for signature 'summary.coxph'
modelInfo(x)
## S4 method for signature 'summary.clogit'
modelInfo(x)
## S4 method for signature 'summary.negbin'
modelInfo(x)
## S4 method for signature 'summary.lrm'
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 σ.

If you register a modelInfo method and it appears not to work, try calling setOldClass in order to register new modelInfo methods for your model summary object. Method dispatch in R has some subtleties.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
 

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)

## End(Not run)

apsrtable documentation built on May 2, 2019, 5:20 a.m.