separationplot (version 1.3)

sp.categorical: Separation plots for variables with more than two outcome levels

Description

This function generates separation plots for polytomous dependent variables.

Usage

sp.categorical(pred, actual, file = NULL, cex = 1.5, ...)

Value

None. This function is used for its side effects only.

Arguments

pred

A matrix of fitted values. Each row represents one observation, and each column represents the probability of obtaining that outcome. The column names correspond to the outcome categories.

actual

A vector containing the actual outcomes corresponding to each observation.

file

The name and file path of where the pdf output should be written, if desired. If file=NULL the output will be written to the screen.

cex

Character expansion factor used for the outcome category labels.

...

Additional arguments passed to separationplot.

Author

Brian Greenhill <bgreenhill@albany.edu>

Details

This function is a wrapper for separationplot that generates a series of separation plots for each outcome category for a variable with more than two outcomes.

Please see the paper by Greenhill, Ward and Sacks for more information on the features of the separation plot.

References

Greenhill, Brian, Michael D. Ward, and Audrey Sacks. "The separation plot: A new visual method for evaluating the fit of binary models." American Journal of Political Science 55.4 (2011): 991-1002.

See Also

See separationplot for a description of the core function for generating separation plots.

Examples

Run this code
# \donttest{

# Example using an ordered probit model from Neumayer (2005) "Do international human rights
# treaties improve respect for human rights?"  Journal of Conflict Resolution, 49 (6), 2005,
# pp. 925-953 

library(foreign) 
library(MASS)

neumayer<-read.dta("http://www2.lse.ac.uk/dataFiles/
geographyAndEnvironment/Replication/Article%20for%20JCR%20(Human%20Rights).dta")

# create a new dataframe called "data4" that just contains the 
# variables we're interested in (and with simpler names).
data6<-na.omit(data.frame(DV=neumayer$aipts, laggedDV=neumayer$laipts, 
rat=neumayer$iccprmainrat, ingo.pc=neumayer$wiikngointerpc, 
dem=neumayer$politycorr020, extwar=neumayer$uppsalaexternalincountry, 
civwar=neumayer$uppsalainternal, gdp=neumayer$lngdp1995pc, 
pop=neumayer$lnpop, country=neumayer$country, year=neumayer$year))

# run the model (note that this is Model 6 of Table 2 of the published paper):
model6<-polr(as.ordered(DV)~laggedDV +rat + rat:ingo.pc + rat:dem 
+ingo.pc  +dem +extwar +civwar+gdp +pop, data=data6, Hess=T, method="probit")
summary(model6) 

sp.categorical(pred=model6$fitted.values, actual=as.character(model6$model[,1]), cex=2.5)

# }

Run the code above in your browser using DataLab