Lab exercise 2

Please upload your completed .pdf file on Moodle by 23:59pm.

  1. Suppose you want to create a function named item_analysis that takes a response data.frame as its input and returns a list object containing total score, item difficulty, and item discrimination. Complete the following lines of code.
item_analysis <- function(response) {
  # total score
  total_score <- 
  # item difficulty
  item_diff <- 
  # item discrimination
  n_items <- ncol(response)
  item_disc <- numeric(  )
  for(j in 1:n_items){
  # create a list object named result
  result <- list(

  1. From resp, find out who has the lowest total score (case number) and find the corresponding total score.

hint: which.max() function returns the location where the maximum value lies inside a vector.

  1. From resp, find out which item is most difficult (item number), and its corresponding difficulty.