Skip to content

These methods tidy the coefficients of mnl and nl models generated by the functions of the mlogit package.

Usage

# S3 method for class 'mlogit'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

Arguments

x

an object returned from mlogit::mlogit().

conf.int

Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to FALSE.

conf.level

The confidence level to use for the confidence interval if conf.int = TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.

...

Additional arguments. Not used. Needed to match generic signature only. Cautionary note: Misspelled arguments will be absorbed in ..., where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you pass conf.lvel = 0.9, all computation will proceed using conf.level = 0.95. Two exceptions here are:

  • tidy() methods will warn when supplied an exponentiate argument if it will be ignored.

  • augment() methods will warn when supplied a newdata argument if it will be ignored.

See also

Value

A tibble::tibble() with columns:

conf.high

Upper bound on the confidence interval for the estimate.

conf.low

Lower bound on the confidence interval for the estimate.

estimate

The estimated value of the regression term.

p.value

The two-sided p-value associated with the observed statistic.

statistic

The value of a T-statistic to use in a hypothesis that the regression term is non-zero.

std.error

The standard error of the regression term.

term

The name of the regression term.

Examples


# load libraries for models and data
library(mlogit)

data("Fishing", package = "mlogit")
Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode")

# fit model
m <- mlogit(mode ~ price + catch | income, data = Fish)

# summarize model fit with tidiers
tidy(m)
#> # A tibble: 8 × 5
#>   term                  estimate std.error statistic  p.value
#>   <chr>                    <dbl>     <dbl>     <dbl>    <dbl>
#> 1 (Intercept):boat     0.527     0.223         2.37  1.79e- 2
#> 2 (Intercept):charter  1.69      0.224         7.56  3.95e-14
#> 3 (Intercept):pier     0.778     0.220         3.53  4.18e- 4
#> 4 price               -0.0251    0.00173     -14.5   0       
#> 5 catch                0.358     0.110         3.26  1.12e- 3
#> 6 income:boat          0.0000894 0.0000501     1.79  7.40e- 2
#> 7 income:charter      -0.0000333 0.0000503    -0.661 5.08e- 1
#> 8 income:pier         -0.000128  0.0000506    -2.52  1.18e- 2
augment(m)
#> # A tibble: 4,728 × 9
#>       id alternative chosen price  catch income .probability .fitted
#>    <int> <fct>       <lgl>  <dbl>  <dbl>  <dbl>        <dbl>   <dbl>
#>  1     1 beach       FALSE  158.  0.0678  7083.      0.125    -3.94 
#>  2     1 boat        FALSE  158.  0.260   7083.      0.427    -2.71 
#>  3     1 charter     TRUE   183.  0.539   7083.      0.339    -2.94 
#>  4     1 pier        FALSE  158.  0.0503  7083.      0.109    -4.07 
#>  5     2 beach       FALSE   15.1 0.105   1250.      0.116    -0.342
#>  6     2 boat        FALSE   10.5 0.157   1250.      0.251     0.431
#>  7     2 charter     TRUE    34.5 0.467   1250.      0.423     0.952
#>  8     2 pier        FALSE   15.1 0.0451  1250.      0.210     0.255
#>  9     3 beach       FALSE  162.  0.533   3750.      0.00689  -3.87 
#> 10     3 boat        TRUE    24.3 0.241   3750.      0.465     0.338
#> # ℹ 4,718 more rows
#> # ℹ 1 more variable: .resid <dbl>
glance(m)
#> # A tibble: 1 × 6
#>   logLik  rho2 rho20   AIC   BIC  nobs
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 -1215. 0.189 0.258 2446.    NA  1182