I am trying to run a Oaxaca decomposition using the oaxaca package, but the inclusion of certain variables seems to trigger the error "non-conformable arguments." As far as I can tell, the error seems to only arise with the inclusion of certain factor/categorical variables, but not all factor/categorical variables.
Here is a minimal reproducible example of my dataset, wvs_reduc:
structure(list(emp = c(1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0,
1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0), education = structure(c(4L, 3L, 2L, 2L, 3L,
3L, 2L, 6L, 4L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 4L, 4L, 1L, 2L, 4L,
4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 3L, 2L, 4L, 4L, 4L, 3L,
2L, 4L, 3L), .Label = c("No Formal Education", "Primary or Less",
"Incomplete Secondary", "Secondary", "Incomplete University",
"University or More"), class = "factor"), marital = structure(c(1L,
1L, 3L, 3L, 1L, 3L, 3L, 1L, 1L, 3L, 3L, 1L, 3L, 4L, 3L, 1L, 1L,
4L, 3L, 1L, 3L, 4L, 1L, 3L, 3L, 3L, 3L, 1L, 3L, 4L, 4L, 4L, 4L,
3L, 3L, 4L, 3L, 3L, 4L, 3L), .Label = c("single", "cohabiting",
"married", "previously married"), class = "factor"), Arab = c(1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA,
-40L), class = c("tbl_df", "tbl", "data.frame"))
When I run the command:
library(oaxaca)
oaxaca(emp ~ education + marital | Arab,
data = wvs_reduc, group.weights = 0, R = 10)
I get the error message: Error in t(x.mean.A) %*% delta.A : non-conformable arguments.
In case it is relevant, when I run the command on my larger dataset, I instead get a similar but not-identical error with the inclusion of the variable "marital" but not "education" or other factor variables:
Error in t(x.mean.A - x.mean.B) %*% beta.B : non-conformable arguments