Ternary Plots for Trinomial Regression Models

An implementation of the ternary plot for interpreting regression coefficients of trinomial regression models, as proposed in Santi, Dickson and Espa (2019) . Ternary plots can be drawn using either 'ggtern' package (based on 'ggplot2') or 'Ternary' package (based on standard graphics).


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 (2018).

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_3logit.

The plot3logit package inherits graphical classes and methods from the package ggtern (Hamilton 2018) which, in turn, is based on the package ggplot2 (Wickham 2016).

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.

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).

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_3logit()

or standard graphics:

plot(field0)

References

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

Santi F., M. M. Dickson, G. Espa (2018) “A graphical tool for interpreting regression coefficients of trinomial logit models”, The American Statistician. https://doi.org/10.1080/00031305.2018.1442368

Smith M. R. (2017). “Ternary: An R Package for Creating Ternary Plots”, Zenodo. https://doi.org/10.5281/zenodo.1068996

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

News

plot3logit 1.0.1

Major changes

  • Bug solved for as.data.frame.field3logit when a zero-coefficient model is passed to field3logit. The previous version was not able to return a data.frame correctly built. Functions stat_3logit, and TernaryField have been adapted so as to draw points instead of arrows.

Minor changes

  • Interface of fortify methods has been redefined by including argument data, so that now all fortify methods of the package are compliant with the interface of the generic.

  • field3logit now can read categories labels of the dependent variable from attribute labs when argument model is a matrix. Example in the help of package presentation has been updated.

Typos and other marginal changes

  • CITATION file has been amended: the title of the package and other typos have been corrected.

  • Revision of the file README.md.

plot3logit 1.0.0

First release of the package plot3logit on CRAN!

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("plot3logit")

1.0.2 by Flavio Santi, 11 days ago


https://www.flaviosanti.it/software/plot3logit


Report a bug at https://github.com/f-santi/plot3logit


Browse source code at https://github.com/cran/plot3logit


Authors: Flavio Santi [cre, aut] , Maria Michela Dickson [aut] , Giuseppe Espa [aut]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports ellipse, ggplot2, graphics, magrittr, reshape2, stats, utils

Depends on ggtern, Ternary

Suggests MASS, mlogit, nnet, knitr, rmarkdown


See at CRAN