Lab exercise 5

Please upload the knitted .pdf file on Moodle by 23:59.

Suppose we used the job screening test score \(x\) to make decisions about hiring and to predict the job performance score \(y\). The below code chunk produces the two scores from 500 examinees. Use the test score variables \(x\) and \(y\) to solve the problems.

set.seed(123)
x <- rbinom(500, 20, .45)
y <- rbinom(500, 20, .40)

  1. Suppose that the examinees with the test score \(x\) greater than or equal to 12 are hired. We can also categorize the examinees with the job performance score \(y\) greater than or equal to 12 as successful workers. Create a logical vector predicted indicating whether each examinee is hired or not. Also, create a logical vector actual indicating whether each examinee is successful or not.

  2. Create a \(2 \times 2\) decision table.

  3. Obtain the hit rate, the sensitivity, the specificity, and the base rate.

  4. Keep the cut score for outcome (job performance) fixed at 12. Calculate the proportion of hired individuals who will turn out successful when cut off score is 10.

hint:

The below code will return a logical vector indicating whether a hired individual is successful or not given a cut_score.

actual[x >= cut_score]
  1. Keep the cut score for outcome (job performance) fixed at 12. Change the cut score for the test score \(x\) from 1 to 20, and obtain the hit rate for each cut off score.

hint:

  • Complete the below code chunk
hit_rates <- numeric(20) # output object length of 20
for(i in 1:20){
  predicted_temp <- 
  hit_rates[i] <- 
}
hit_rates