Learn R Programming

plot3logit (version 2.2.0)

plot3logit-package: Ternary Plots for Trinomial Regression Models

Description

An implementation of the ternary plot for interpreting regression coefficients of trinomial regression models, as proposed in santi2019;textualplot3logit.

Arguments

Compatibility

Function field3logit() can read trinomial regression estimates from the output of the following functions:

  • multinom of package nnet (logit regression);

  • polr of package MASS (ordinal logit regression);

  • mlogit of package mlogit (logit regression);

  • vgam of package VGAM (logit regression).

Moreover, explicit matrix of regression coefficients can be passed to field3logit(). See examples and function field3logit() for further details.

Details

The package permits the covariate effects of trinomial regression models to be represented graphically by means of a ternary plot. The aim of the plots is helping the interpretation of regression coefficients in terms of the effects that a change in regressors' values has on the probability distribution of the dependent variable. Such changes may involve either a single regressor, or a group of them (composite changes), and the package permits both cases to be represented in a user-friendly way. Methodological details are illustrated and discussed in santi2019;textualplot3logit.

The package can read the results of both categorical and ordinal trinomial logit regression fitted by various functions (see the next section) and creates a field3logit object which may be represented by means of functions gg3logit() and stat_field3logit().

The plot3logit package inherits graphical classes and methods from the package ggtern hamilton2018plot3logit which, in turn, is based on the ggplot2 package wickham2016plot3logit.

Graphical representation based on standard graphics is made available through the package Ternary smith2017plot3logit by function TernaryField() and in particular by the method plot of field3logit class.

Since version 2.0.0, plot3logit permits one to draw also the confidence regions associated to the covariates effects. See the vignette of the package (type vignette('plot3logit-overview')) and the help of function stat_conf3logit() for some examples.

References

See Also

field3logit(), gg3logit(), TernaryField().

Examples

Run this code
# NOT RUN {
data(cross_1year)

# Read from "nnet::multinom"
library(nnet)
mod0 <- multinom(employment_sit ~ gender + finalgrade, data = cross_1year)
field0 <- field3logit(mod0, 'genderFemale')
gg3logit(field0) + stat_field3logit()

# Read from "MASS::polr"
library(MASS)
mydata <- cross_1year
mydata$finalgrade <- factor(mydata$finalgrade,
  c('Low', 'Average', 'High'), ordered = TRUE)
mod1 <- polr(finalgrade ~ gender + irregularity, data = mydata)
field1 <- field3logit(mod1, 'genderFemale')
gg3logit(field1) + stat_field3logit()

# Read from "mlogit::mlogit"
library(mlogit)
mydata <- mlogit.data(cross_1year, choice = 'employment_sit', shape = 'wide')
mod2 <- mlogit(employment_sit ~ 0 | gender + finalgrade, data = mydata)
field2 <- field3logit(mod2, 'genderFemale')
gg3logit(field2) + stat_field3logit()

# Read from matrix
M <- matrix(c(-2.05, 0.46, -2.46, 0.37), nrow = 2)
rownames(M) <- c('(Intercept)', 'genderFemale')
attr(M, 'labs') <- c('Employed', 'Unemployed', 'Trainee')
field3 <- field3logit(M, c(0, 1))
gg3logit(field3) + stat_field3logit()
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab