Package separationplot

Similar documents
Package clustergeneration

Precept Five: Model Diagnostics for Binary Outcome Models and Ordered Probit

Package rnmf. February 20, 2015

Package gma. September 19, 2017

Package survidinri. February 20, 2015

Package EBMAforecast

Package gtheory. October 30, 2016

Package HIMA. November 8, 2017

Package reinforcedpred

Package darts. February 19, 2015

Package covtest. R topics documented:

Package cccrm. July 8, 2015

Package EnergyOnlineCPM

Package leiv. R topics documented: February 20, Version Type Package

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

Package idmtpreg. February 27, 2018

Package depth.plot. December 20, 2015

Package HarmonicRegression

Package CovSel. September 25, 2013

Package ChIPtest. July 20, 2016

Package CorrMixed. R topics documented: August 4, Type Package

Package RTransferEntropy

Package BayesNI. February 19, 2015

Package RI2by2. October 21, 2016

Package bayeslm. R topics documented: June 18, Type Package

Package Select. May 11, 2018

Package SK. May 16, 2018

Package SpatialNP. June 5, 2018

Package horseshoe. November 8, 2016

Package polypoly. R topics documented: May 27, 2017

Package BNN. February 2, 2018

Package sklarsomega. May 24, 2018

Package causalweight

Package sscor. January 28, 2016

Package OUwie. August 29, 2013

Package rcarto. March 20, 2013

Package lomb. February 20, 2015

Package severity. February 20, 2015

Package MultisiteMediation

Package Rarity. December 23, 2016

Package ForwardSearch

Package vhica. April 5, 2016

Package SimCorMultRes

Package Grace. R topics documented: April 9, Type Package

Package hierdiversity

Package monmlp. R topics documented: December 5, Type Package

The ICS Package. May 4, 2007

Package timelines. August 29, 2016

Package pearson7. June 22, 2016

Package MicroMacroMultilevel

Package epr. November 16, 2017

Package esaddle. R topics documented: January 9, 2017

Package platetools. R topics documented: June 25, Title Tools and Plots for Multi-Well Plates Version 0.1.1

Package MTA. R topics documented: May 14, Title Multiscalar Territorial Analysis Version 0.1.2

Package diffeq. February 19, 2015

Package denseflmm. R topics documented: March 17, 2017

Package ICBayes. September 24, 2017

Package RootsExtremaInflections

Package rarpack. August 29, 2016

Package metansue. July 11, 2018

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression

Package msbp. December 13, 2018

Package locfdr. July 15, Index 5

Package ForecastCombinations

Package gwqs. R topics documented: May 7, Type Package. Title Generalized Weighted Quantile Sum Regression. Version 1.1.0

Package aspi. R topics documented: September 20, 2016

Package fwsim. October 5, 2018

Package CPE. R topics documented: February 19, 2015

Package symmoments. R topics documented: February 20, Type Package

Package r2glmm. August 5, 2017

Package misctools. November 25, 2016

Package NonpModelCheck

Package ExtremeBounds

Package RSwissMaps. October 3, 2017

Package mpmcorrelogram

Package clogitboost. R topics documented: December 21, 2015

Package pssm. March 1, 2017

Package SpatPCA. R topics documented: February 20, Type Package

Package orclus. R topics documented: March 17, Version Date

Package weightquant. R topics documented: December 30, Type Package

Package univoutl. January 9, 2018

Package spcov. R topics documented: February 20, 2015

Package neuralnet. August 16, 2016

Package supernova. February 23, 2018

Package matrixnormal

Package noise. July 29, 2016

Package dhsic. R topics documented: July 27, 2017

Package ppcc. June 28, 2017

Package cellwise. June 26, 2018

Package funrar. March 5, 2018

Package MAVE. May 20, 2018

Package SEMModComp. R topics documented: February 19, Type Package Title Model Comparisons for SEM Version 1.0 Date Author Roy Levy

Package rarhsmm. March 20, 2018

Package plspolychaos

Package abundant. January 1, 2017

Package scpdsi. November 18, 2018

Package EMVS. April 24, 2018

Package MPkn. May 7, 2018

Package intrees. March 12, 2018

Package TwoStepCLogit

Transcription:

Package separationplot March 15, 2015 Type Package Title Separation Plots Version 1.1 Date 2015-03-15 Author Brian D. Greenhill, Michael D. Ward and Audrey Sacks Maintainer ORPHANED Suggests MASS, Hmisc, RColorBrewer, foreign Description Functions to generate separation plots for evaluation of model fit. License Artistic-2.0 Repository CRAN Date/Publication 2015-03-15 12:02:27 NeedsCompilation no X-CRAN-Original-Maintainer Brian Greenhill <brian.d.greenhill@dartmouth.edu> X-CRAN-Comment Orphaned on 2015-03-13 and corrected by the CRAN team as misuse of \{}donttest was not corrected. R topics documented: separationplot-package................................... 2 separationplot........................................ 3 sp.categorical........................................ 5 Index 8 1

2 separationplot-package separationplot-package Separation Plot Package Description Details Functions to generate separation plots Package: separationplot Type: Package Version: 1,0 Date: 2011-06-13 License: NA This package is still in development. Please contact Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> with any questions you may have. Author(s) Brian D. Greenhill, Michael D. Ward and Audrey Sacks Maintainer: Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> References Contact Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> for a copy of the paper that explains the concept of the separation plot. Examples # Very simple example from the introduction to the paper: # separationplot(pred=c(0.774, 0.364, 0.997, 0.728, 0.961, 0.422), actual=c(0,0,1,0,1,1), shuffle=false, line=false, type="rect", rectborder=1)

separationplot 3 separationplot Generate a Separation Plot Description Usage This is the core function for the generation of a separation plot. separationplot(pred, actual, type = "line", line = T, lwd1 = 0.5, lwd2 = 0.5, heading = "", xlab = "", shuffle = T, width = 9, height = 1.2, col0 = "#FEF0D9", col1 = "#E34A33", flag = NULL, flagcol = 1, file = NULL, newplot = T, locate = NULL, rectborder = NA, show.expected = F, zerosfirst = T, BW = F) Arguments pred Vector of predicted probabilities (on a continuous 0 to 1 scale). actual Vector of actual outcomes (each element must be either 0 or 1). type line lwd1 lwd2 heading xlab shuffle width height col0 col1 Should the individual lines on the separation plot be plotted as line segments (type="line") or rectangles (type="rect"), or should the probabilities in different regions of the plot be grouped into distinct bands (type="bands")? Should a trace line be added to the plot? The width of the individual line segments (only when type="line"). The width of the trace line (only when line=t). An optional title for the plot. An option x-axis label. If shuffle=t, the order of rows in the results data is randomized to break up any pre-existing patterns that may distort the appearance of the results in the special case where many of the observations share the same fitted values. This happens, for example, when the original dataframe is organized in such a way that all the cases with the event of interest come before the cases without the event. Note that when shuffle=t, the random number seed is reset to 1 each time this function is called. This ensures that replicable results can be obtained even when the order of observations is randomized. Width of the plot space (in inches). Height of the plot space (in inches). Color of the predicted probabilities corresponding to 0s in the actual vector. The default color has been chosen from one of the palettes on http: //colorbrewer2.org/. Color of the predicted probabilities corresponding to 1s in the actual vector. The default color has been chosen from one of the palettes on http: //colorbrewer2.org/.

4 separationplot flag flagcol file newplot locate rectborder show.expected zerosfirst BW A vector of row number(s) in the actual vector corresponding to the observations to flag. A vector of colors for the flags. 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. Should a new plotting space be opened up for the separation plot? Select newplot=f if you want the separation plot to be added to currently open output device. Number of lines (if any) on the separation plot that you want to identify with the mouse using the locator function. When type="rect", the value of this argument is passed to the border argument of the rect function used to draw the line segments. The default setting (rectborder=na) suppresses the drawing of borders around the individual segments of the plot. If show.expected=t, a marker is added to the plot showing the expected total number of events. The expected number of events is calculated by simply summing (and rounding) the predicted probabilities over all observations. When type="line", should the 0s be plotted in the background, and the 1s in the foreground, or vice-versa? This will affect the output when the number of observations is very large relative to the size of the plot. Should the Black and White color scheme be implemented? Details Please see the paper by Greenhill, Ward and Sacks for more information on the features of the separation plot. Value resultsmatrix The dataframe containing the data used to generate the separation plot. The first column is the vector of predicted probabilities, the second is the vector of actual outcomes, the third indicates which observations have been flagged using the flag argument above, the fourth gives the position of each observation on the horizontal axis of the separation plot, and the fifth gives the color used to plot each observation. Note This function is still being developed. Please contact Brian Greenhill with any questions or comments. Author(s) Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> References Contact Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> for a copy of the paper by Greenhill, Ward and Sacks that explains the concept of the separation plot.

sp.categorical 5 See Also See sp.categorical for plotting separation plots for models with polytomous dependent variables. Examples # Create a separation plot for a simple logit model: library(mass) set.seed(1) Sigma <- matrix(c(1,0.78,0.78,1),2,2) a<-(mvrnorm(n=500, rep(0, 2), Sigma)) a[,2][a[,2]>0.75]<-1 a[,2][a[,2]<=0.75]<-0 a[,1]<-a[,1]-min(a[,1]) a[,1]<-a[,1]/max(a[,1]) cor(a) # should be 0.55 model1<-glm(a[,2]~a[,1], family=binomial(link = "logit")) library(hmisc) somers2(model1$fitted.values, model1$y) separationplot(pred=model1$fitted.values, actual=model1$y, type="rect", line=true, show.expected=true, heading="example 1") 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,...) Arguments pred actual 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. A vector containing the actual outcomes corresponding to each observation.

6 sp.categorical file cex Details Value Note 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. Character expansion factor used for the outcome category labels.... Additional arguments passed to separationplot. 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. None. This function is used for its side effects only. This function is still being developed. Please contact Brian Greenhill with any questions or comments. Author(s) Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> References Contact Brian Greenhill <<brian.d.greenhill@dartmouth.edu>> for a copy of the paper by Greenhill, Ward and Sacks that explains the concept of the separation plot. See Also See separationplot for a description of the core function for generating separation plots. Examples ## no reason was given for \donttest here. # 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%20 # create a new dataframe called "data4" that just contains the variables

sp.categorical 7 # 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=TRUE, method="probit") summary(model6) sp.categorical(pred=model6$fitted.values, actual=as.character(model6$model[,1]), cex=2.5)

Index Topic \textasciitildekwd1 separationplot, 3 Topic \textasciitildekwd2 separationplot, 3 Topic separationplot separationplot-package, 2 Topic sp.categorical sp.categorical, 5 separationplot, 3, 6 separationplot-package, 2 sp.categorical, 5, 5 8