plot.oaxaca | R Documentation |
plot.oaxaca
is used to generate a set of coefficient bar plots that present the results of a Blinder-Oaxaca decomposition graphically.
## S3 method for class 'oaxaca' plot(x, decomposition = "threefold", type = "variables", group.weight = NULL, unexplained.split = FALSE, variables = NULL, components = NULL, component.left = FALSE, component.labels = NULL, variable.labels = NULL, ci = TRUE, ci.level = 0.95, title = "", xlab = "", ylab = "", bar.color = NULL, ...)
x |
an object of class |
decomposition |
specifies which type of decomposition will be presented. Can be either |
type |
specifies whether the results of an overall decomposition or a variable-by-variable decomposition will be presented. Can be either |
group.weight |
a numeric value that specifies the group weight for which the twofold decomposition results will be presented. Only relevant when argument |
unexplained.split |
a logical value that toggles whether, in the twofold decomposition, the presentation of the |
variables |
a character vector that specifies the variables for which coefficient bar plots are requested. If NULL, plots for all variables will be produced. Only relevant when argument |
components |
a character vector that specifies which decomposition components will be presented. For threefold decomposition, must be a subset of |
component.left |
a logical value that specifies whether the decomposition components will be presented along the left side of the coefficient bar plot. By default, the argument is set to |
component.labels |
a named character vector that specifies custom labels for individual decomposition components. The character vector elements contain the new labels, while the elements' names must correspond to the appropriate decomposition components: |
variable.labels |
a named character vector that specifies custom labels for the presented variables. The character vector elements contain the new labels, while the elements' names must contain the appropriate variable name. Only relevant when argument |
ci |
a logical value that toggles the presentation of confidence intervals (standard error bars) in the coefficient bar plots. |
ci.level |
a numeric value between 0 and 1 that specifies the confidence level for the presented confidence intervals. |
title |
a character string that contains the title of the coefficient bar plot. |
xlab |
a character string that specifies the horizontal axis label. |
ylab |
a character string that specifies the vertical axis label. |
bar.color |
a named vector that specifies the color of bars in the plot. The vector elements' names contain a string that identifies either the variable or the decomposition component that the color will be applied to. If no names are specifies, the bars will be colored from top to bottom. |
... |
additional arguments passed on to the aesthetic mapping ( |
Hlavac, Marek (2022). oaxaca: Blinder-Oaxaca Decomposition in R.
R package version 0.1.5. https://CRAN.R-project.org/package=oaxaca
Dr. Marek Hlavac < mhlavac at alumni.princeton.edu >
Social Policy Institute, Bratislava, Slovakia
Wickham, Hadley. (2009). ggplot2: Elegant Graphics for Data Analysis. Springer Science & Business Media.
oaxaca
# set random seed set.seed(08544) # load data set of Hispanic workers in Chicago data("chicago") # perform Blinder-Oaxaca Decomposition: # explain differences in log real wages across native and foreign-born groups oaxaca.results <- oaxaca(ln.real.wage ~ age + female + LTHS + some.college + college + advanced.degree | foreign.born, data = chicago, R = 50) # plot results of the threefold decomposition, variable-by-variable # only include educational variables # decomposition components along the left side of the plot plot(oaxaca.results, component.left = TRUE, variables = c("LTHS", "some.college", "college", "advanced.degree"), variable.labels = c("LTHS" = "less than high school", "some.college" = "some college", "advanced.degree" = "advanced degree")) # plot results of the twofold decomposition (overall results) # equal weight for Group A and B in reference coefficient determinantion (weight = 0.5) # unexplained portion split into A and B plot(oaxaca.results, decomposition = "twofold", type = "overall", group.weight = 0.5, unexplained.split = TRUE, bar.color = c("limegreen", "hotpink", "steelblue"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.