Learn R Programming

api2lm (version 0.2)

coef_compare: Compare coefficients of 2 models

Description

Compare the coefficients to two fitted models. The models must have the same coefficients.

Usage

coef_compare(model1, model2, digits = 3, verbose = TRUE)

Value

A matrix.

Arguments

model1

A fitted model object from the lm function.

model2

A fitted model object from the lm function.

digits

A positive integer indicating how many significant digits are to be used for numeric and complex numbers. This argument is passed to format.

verbose

A logical value indicating whether the matrix should be printed. The default is TRUE.

Examples

Run this code
# fit model
lmod1 <- lm(murder ~ hs_grad + urban + poverty + single,
           data = crime2009)
#fit without DC
lmod2 <- lm(murder ~ hs_grad + urban + poverty + single,
            data = crime2009[-9, ])
#compare coefficients of models
coef_compare(lmod1, lmod2)

Run the code above in your browser using DataLab