R: Comparison Table For Linear Models

TMod {DescTools} | R Documentation

## Comparison Table For Linear Models

### Description

Collect the coefficients and some qualifying statistics of given linear models and organize it in a table for comparison and reporting.

### Usage

    TMod(..., FUN = NULL)

    ModSummary(x, ...)

    ## S3 method for class 'lm'
    ModSummary(x, conf.level=0.95, ...)
    ## S3 method for class 'glm'
    ModSummary(x, conf.level=0.95, ...)

### Arguments

`x` | a (general) linear model object.
`...` | a list of (general) linear models.
`conf.level` | the level for the confidence intervals.
`FUN` | function with arguments `est`, `se`, `tval`, `pval`, `lci`, `uci` to display the coefficients.

### Details

TMod constructs a comparing table of estimates for regression models.

### Value

character table

### Author(s)

Andri Signorell <andri@signorell.net>

### See Also

`help`

### Examples

    r.full <- lm(Fertility ~ . , swiss)
    r.nox <- lm(Fertility ~ . -Examination - Catholic, swiss)
    r.grp <- lm(Fertility ~ . -Education - Catholic + CutQ(Catholic), swiss)
    r.gam <- glm(Fertility ~ . , swiss, family=Gamma(link="identity"))
    r.gama <- glm(Fertility ~ .- Agriculture , swiss, family=Gamma(link="identity"))

    TMod(r.full, r.nox, r.grp, r.gam, r.gama)

    # display confidence intervals
    TMod(r.full, r.nox, r.gam, FUN = function(est, se, tval, pval, lci, uci){
      gettextf("%s [%s, %s]",
               Format(est, fmt=Fmt("num")),
               Format(lci, digits=3),
               Format(uci, digits=2)
               )
    })

    # cbind interface is not supported!!
    # d.titanic <- reshape(as.data.frame(Titanic),
    #                       idvar = c("Class","Sex","Age"),
    #                       timevar="Survived",
    #                       direction = "wide")
    #
    # r.glm0 <- glm(cbind(Freq.Yes, Freq.No) ~ 1, data=d.titanic, family="binomial")
    # r.glm1 <- glm(cbind(Freq.Yes, Freq.No) ~ Class, data=d.titanic, family="binomial")
    # r.glm2 <- glm(cbind(Freq.Yes, Freq.No) ~ ., data=d.titanic, family="binomial")

    d.titanic <- Untable(Titanic)

    r.glm0 <- glm(Survived ~ 1, data=d.titanic, family="binomial")
    r.glm1 <- glm(Survived ~ Class, data=d.titanic, family="binomial")
    r.glm2 <- glm(Survived ~ ., data=d.titanic, family="binomial")

    TMod(r.glm0, r.glm1, r.glm2)

[Package DescTools version 0.99.25 Index]