The iNZight summary improves upon the base R summary output for fitted regression models. More information is provided and displayed in a more intuitive format. This function both creates and returns a summary object, as well as printing it.

iNZightSummary(
  x,
  method = "standard",
  reorder.factors = FALSE,
  digits = max(3, getOption("digits") - 3),
  symbolic.cor = x$symbolic.cor,
  signif.stars = getOption("show.signif.stars"),
  exclude = NULL,
  exponentiate.ci = FALSE,
  ...
)

Arguments

x

an object of class "lm", "glm" or "svyglm", usually the result of a call to the corresponding function.

method

one of either "standard" or "bootstrap". If "bootstrap", then bootstrapped estimates and standard errors are calculated; otherwise, uses the standard estimates.

reorder.factors

logical, if TRUE, and there are factors present in the model, then the most common level of the factor is set to be the baseline.

digits

the number of significant digits to use when printing.

symbolic.cor

logical, if TRUE, print the correlations in a symbolic form (see symnum), rather than as numbers.

signif.stars

logical, if TRUE, ‘significance stars’ are printed for each coefficient.

exclude

a character vector of names of variables to be excluded from the summary output (i.e., confounding variables).

exponentiate.ci

logical, if TRUE, the exponential of the confidence intervals will be printed if appropriate (log/logit link or log transformed response)

...

further arguments passed to and from other methods.

Value

An object of class summary.lm, summary.glm, or summary.svyglm.

Details

This summary function provides more information in the following ways:

Factor headers are now given. The base level for a factor is also listed with an estimate of 0. This is to make it clear what the base level of a factor is, rather than attempting to work out by deduction from what has already been printed.

The p-value of a factor is now given; this is the output from Anova, which calculates the p-value based off of Type III sums of squares, rather than sequentially as done by anova.

Each level of a factor is indented by 2 characters for its label and its p-value to distinguish between a factor, and levels of a factor.

The labels for each level of an interaction are now just the levels of the factor (separated by a .), rather than being prepended with the factor name also.

Note

If any level is not observed in a factor, no p-values will be printed on all factors. This is because we cannot calculate Type III sums of squares when this is the case.

The fitted model currently requires that the data are stored in a dataframe, which is pointed at by the data argument to lm (or equivalent).

See also

The model fitting functions lm, glm, and summary.

The survey package.

Function coef will extract the matrix of coefficients with standard errors, t-statistics and p-values.

To calculate p-values for factors, use Anova with type III sums of squares.

Author

Simon Potter, Tom Elliott.

Examples

m <- lm(Sepal.Length ~ ., data = iris)
iNZightSummary(m)
#> 
#> Model for: Sepal.Length
#> 
#> Coefficients:
#>                Estimate Std. Error    t value    p-value      2.5 %   97.5 %
#> (Intercept)   2.171e+00  2.798e-01  7.760e+00 1.43e-12   ***  1.618  2.72430
#> Sepal.Width   4.959e-01  8.607e-02  5.761e+00 4.87e-08   ***  0.326  0.66601
#> Petal.Length  8.292e-01  6.853e-02  1.210e+01  < 2e-16   ***  0.694  0.96469
#> Petal.Width  -3.152e-01  1.512e-01 -2.084e+00  0.03889   *   -0.614 -0.01631
#> Species                                        0.01033   *                  
#>   setosa              0          -          -          -          -        -
#>   versicolor -7.236e-01  2.402e-01 -3.013e+00    0.00306 **  -1.198 -0.24885
#>   virginica  -1.023e+00  3.337e-01 -3.067e+00    0.00258 **  -1.683 -0.36386
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
#> 
#> Residual standard error: 0.3068 on 144 degrees of freedom
#> Multiple R-squared: 0.8673,	Adjusted R-squared: 0.8627 
#> 

# exclude confounding variables for which you don't
# need to know about their coefficients:
iNZightSummary(m, exclude = "Sepal.Width")
#> 
#> Model for: Sepal.Length
#> 
#> The model has been adjusted for the following confounder(s):
#> 	Sepal.Width
#> 
#> Coefficients:
#>                Estimate Std. Error    t value    p-value      2.5 %   97.5 %
#> (Intercept)   2.171e+00  2.798e-01  7.760e+00 1.43e-12   ***  1.618  2.72430
#> Petal.Length  8.292e-01  6.853e-02  1.210e+01  < 2e-16   ***  0.694  0.96469
#> Petal.Width  -3.152e-01  1.512e-01 -2.084e+00  0.03889   *   -0.614 -0.01631
#> Species                                        0.01033   *                  
#>   setosa              0          -          -          -          -        -
#>   versicolor -7.236e-01  2.402e-01 -3.013e+00    0.00306 **  -1.198 -0.24885
#>   virginica  -1.023e+00  3.337e-01 -3.067e+00    0.00258 **  -1.683 -0.36386
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
#> 
#> Residual standard error: 0.3068 on 144 degrees of freedom
#> Multiple R-squared: 0.8673,	Adjusted R-squared: 0.8627 
#>