
Last chance! 50% off unlimited learning
Sale ends in
modelInfo(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
"modelInfo"(x)
summary
object.lm
reports the $N, R^2$, adjusted $R^2$, and residual $\sigma$. 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.) 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 $\sigma$.
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.
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)
Run the code above in your browser using DataLab