Learn R Programming

⚠️There's a newer version (3.2.0) of this package.Take me there.

Ternary Plots for Trinomial Regression Models

Presentation

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 handled in a user-friendly way. Theoretical and methodological details are illustrated and discussed in Santi, Dickson, and Espa (2019).

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 (Hamilton and Ferry 2018) which, in turn, is based on the package ggplot2 (Wickham 2017).

Graphical representation based on standard graphics is made available through the package Ternary (Smith 2017) by functions plot3logit and TernaryField, and by the plot method of field3logit objects.

See the help of field3logit for representing composite effects and multifield3logit for drawing multiple fields and the presentation vignette plot3logit-overview by typing:

vignette('plot3logit-overview', package = 'plot3logit')

Compatibility

Function field3logit of package plot3logit 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 the help of the package (type ? 'plot3logit-package') for furhter details.

An example

Fit a trilogit model by means of package nnet where the student’s employment situation is analysed with respect to all variables in the dataset cross_1year:

data(cross_1year)
library(nnet)
mod0 <- multinom(employment_sit ~ ., data = cross_1year)

The gender effect is analysed by means of a ternary plot which is generated in two steps, however, package plot3logit should be loaded:

library(plot3logit)

Firstly, the vector field is computed:

field0 <- field3logit(mod0, 'genderFemale')

Secondly, the field is represented on a ternary plot, using either gg-graphics:

gg3logit(field0) + stat_field3logit()

or standard graphics:

plot(field0)

References

Hamilton, N. E., and M. Ferry. 2018. “ggtern: Ternary Diagrams Using ggplot2.” Journal of Statistical Software, Code Snippets 87 (3): 1–17. doi:10.18637/jss.v087.c03.

Santi, F., M. M. Dickson, and G. Espa. 2019. “A Graphical Tool for Interpreting Regression Coefficients of Trinomial Logit Models.” The American Statistician 73 (2): 200–207. doi:10.1080/00031305.2018.1442368.

Smith, M. R. 2017. “Ternary: An R Package for Creating Ternary Plots.” Zenodo.

Wickham, H. 2017. ggplot2: Elegant Graphics for Data Analysis. New York: Springer-Verlag.

Copy Link

Version

Install

install.packages('plot3logit')

Monthly Downloads

173

Version

2.2.0

License

GPL (>= 2)

Maintainer

Flavio Santi

Last Published

July 19th, 2020

Functions in plot3logit (2.2.0)

deprecated-functions

List of deprecated and defunct functions
gg3logit

Create a new gg3logit
get_vdelta

It computes the vector of covariate change
field3logit

Computation of the vector field
gen_path

Generates a curve of the field
labels

Set the labels of a field3logit or a multifield3logit object
pc2p0

Computation of starting points of curves of the field
multifield3logit

Multiple trilogit fields
plot3logit-deprecated

Computation and representation of the vector field
plot3logit-package

Ternary Plots for Trinomial Regression Models
stat_conf3logit

Add the confidence regions of a field to a gg3logit plot
stat_3logit

Add a field and confidence regions to a gg3logit plot
XB2P

Computes trinomial probability distributions implied by linear predictors
stat_field3logit

Add a field to a gg3logit plot
effect

Draw a change in the probability distribution on an existing plot
simplify_field3logit

field3logit simplification function and test
reexports

Objects exported from other packages
versor

Computes the versor
tbl2matrix

Convert a tibble to a matrix
convex_comb

Computes convex combinations of two vectors
cross_1year

Master's students' employment condition
v2vedge

Computes the coordinates of a vertex on the edge
read_model

Builds up matrix of coefficients from fitted models
vcovB2vcovDeltaB

Covariance matrix of covariate change
confregion

It computes the confidence region in the ternary space
autoplot.field3logit

Create a gg3logit plot with field and confidence regions
DeltaB2vroles

Identification of roles of vertices in non-degenerate cases
DeltaB2pc

Identification of equispaced central points
add_confregions

Computes the confidence regions of covariate effects
P2XB

Compute the linear predictors implied by trinomial probability distributions
TernaryField

Draw a field on an existing ternary plot
add_confregions_field3logit

It adds the confidence regions to a "field3logit" object
USvote2016

Self-reported votes from VOTER Survey in 2016