#################################################################################### # L1 - INTRODUCTION # # NMST570 # # Last update: 30/09/2019 # #################################################################################### # Slides available at http://www.cs.cas.cz/martinkova/NMST570 # HW assignment available at http://www.cs.cas.cz/hladka/documents/NMST570_HW1.pdf # Data available at http://www.cs.cas.cz/hladka/documents/LSAT7.csv # Data from Bock & Lieberman (1970); contains 5 dichotomously scored items obtained # from the Law School Admissions Test, section 7. # Dataset can be also found in mirt package, LSAT7 # Bock, R. D., & Lieberman, M. (1970). # Fitting a response model for n dichotomously scored items. # Psychometrika, 35(2), 179-197. # Loading packages # install.packages("ggplot") library(ggplot2) # install.packages("moments") library(moments) # install.packages("ShinyItemAnalysis") library(ShinyItemAnalysis) #################################################################################### # Upload data ###################################################################### #################################################################################### data <- read.csv("LSAT7.csv") # alternatively # data <- mirt::expand.table(LSAT7) #################################################################################### # Total scores calculation and their basic summary ################################# #################################################################################### # total score calculation score <- rowSums(data) # summary of total score c(min = min(score), max = max(score), mean = mean(score), median = median(score), SD = sd(score), kurtosis = kurtosis(score), skewness = skewness(score)) #################################################################################### # Histogram ######################################################################## #################################################################################### # colors by cut-score cut <- median(score) # cut-score color <- c(rep("red", cut - min(score)), "gray", rep("blue", max(score) - cut)) df <- data.frame(score) # histogram ggplot(df, aes(score)) + geom_histogram(binwidth = 1, fill = color, col = "black") + xlab("Total score") + ylab("Number of respondents") + theme_app() #################################################################################### # Z-score calculation ############################################################## #################################################################################### (z_score <- scale(score)) # alternatively # z_score <- (score - mean(score))/sd(score) #################################################################################### # T-score calculation ############################################################## #################################################################################### (t_score <- 50 + 10*z_score)