5
$\begingroup$

I have a dataset where I have the Outcome of a case and the Country under review, as well as whether a judge (among a panel of judges) reviewing the case was also from the country under review, Country_Judge, categorised as TRUE or FALSE.

How can I measure the relationship between the Country_Judge and the Outcome of a case? I want to know whether a judge's nationality has an impact on the outcome of the cases.

$\endgroup$
  • $\begingroup$ This would traditionally be addressed using Logistic Regression. $\endgroup$ – R Hill Mar 19 '18 at 16:05
  • 1
    $\begingroup$ In general, a nice way of check relationship between categorical variables is via the co-occurrence matrices. Here an example about music genres: r-bloggers.com/clustering-music-genres-with-r But in your case, why not use something much simpler, like counting how many Guilty and Innocent sentenced per judges nationality? $\endgroup$ – Vincenzo Lavorini Mar 19 '18 at 16:23
2
$\begingroup$

Is Outcome also a boolean variable? If so, a simple prop.test will do.

Here's a toy dataset where a judge from the same country is less likely to give a guilty verdict.

library(tidyverse)
n<-1000
dataset<-tibble(country_judge = sample(c(TRUE,FALSE), n, 
                                           replace=T, prob=c(0.2,0.8))) %>%
  mutate(outcome = ifelse(country_judge,
                          sample(c("Guilty", "Innocent"), n, 
                                     replace=T, prob=c(0.4,0.6)),
                          sample(c("Guilty", "Innocent"), n, 
                                     replace=T, prob=c(0.5,0.5))))

dataset %>%
  group_by(country_judge) %>%
  summarise(p_guilty=mean(outcome=="Guilty"))

This will give something like:

# A tibble: 2 x 2
  country_judge  p_guilty
          <lgl>     <dbl>
1         FALSE 0.5108835
2          TRUE 0.3698630

Now, pull out vectors of trials, and "successes", and feed those into prop.test.

trials <- dataset %>%
  group_by(country_judge) %>%
  count() %>%
  pull(n)

successes <- dataset %>%
  filter(outcome=="Guilty") %>%
  group_by(country_judge) %>%
  count() %>%
  pull(n)

prop.test(successes, trials)

Which gives something like:

    2-sample test for equality of proportions with continuity correction

data:  successes out of trials
X-squared = 13.068, df = 1, p-value = 0.0003003
alternative hypothesis: two.sided
95 percent confidence interval:
 0.06517776 0.21686317
sample estimates:
   prop 1    prop 2 
0.5108835 0.3698630 
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.