\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Niki (worlddoit)} \pdfinfo{ /Title (r-psy1.pdf) /Creator (Cheatography) /Author (Niki (worlddoit)) /Subject (r psy1 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{000A8F} \definecolor{LightBackground}{HTML}{F7F7FB} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{r psy1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Niki (worlddoit)} via \textcolor{DarkBackground}{\uline{cheatography.com/170195/cs/36141/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Niki (worlddoit) \\ \uline{cheatography.com/worlddoit} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 16th December, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Intro}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{This is material to prepare for application in R in Psychometrics. \newline % Row Count 2 (+ 2) Resources: \{\{popup="https://bookdown.org/sz\_psyc490/r4psychometics/"\}\}website\{\{/popup\}\} \newline % Row Count 4 (+ 2) Material made by: {\emph{Susu Zhang}}% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CTT Item Analysis}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{1.1) Response data}} \newline % Row Count 1 (+ 1) `resp \textless{}- read.table('resp.txt', header = F, sep = '\textbackslash{}t')`\{\{noshy\}\} \newline % Row Count 3 (+ 2) The imported data set resp contains 100 subjects' dichotomous responses to 40 GRE questions. \newline % Row Count 5 (+ 2) {\bf{Output 1.1}} \newline % Row Count 6 (+ 1) {\bf{1.2) CTT Item Analysis}} \newline % Row Count 7 (+ 1) The total score of each subject can be obtained by the row sums. \newline % Row Count 9 (+ 2) `total.score \textless{}- rowSums(resp)`\{\{noshy\}\} \newline % Row Count 10 (+ 1) {\bf{Output 1.2}} \newline % Row Count 11 (+ 1) The item difficulty in CTT can be obtained by calculating the proportion of correct answers of each item. \newline % Row Count 14 (+ 3) `item.diff \textless{}- colMeans(resp)`\{\{noshy\}\} \newline % Row Count 15 (+ 1) {\bf{Output 1.3}} \newline % Row Count 16 (+ 1) {\bf{1.3) Item discrimination}} \newline % Row Count 17 (+ 1) The item discrimination in CTT can be obtained by the point biserial correlation between the item response and the total score. \newline % Row Count 20 (+ 3) `n.items \textless{}- ncol(resp) \# number of items`\{\{noshy\}\} \newline % Row Count 22 (+ 2) `total.score \textless{}- rowSums(resp) \# total score`\{\{noshy\}\} \newline % Row Count 24 (+ 2) `item.disc \textless{}- numeric(n.items) \# output vector`\{\{noshy\}\} \newline % Row Count 26 (+ 2) `for(i in 1:n.items)\{ \# sequence`\{\{noshy\}\} \newline % Row Count 28 (+ 2) ` item.disc{[}i{]} \textless{}- cor(total.score, resp{[},i{]})\} \# body `\{\{noshy\}\} \newline % Row Count 30 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CTT Item Analysis (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Output 1.4}}% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 1.1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671168051_1.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 1.2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671168085_2.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 1.3}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671168108_3.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 1.4}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671168128_ экрана 2022-12-16 в 6.21.03.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Validity}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{A test has validity if it measures what it purports to measure. There are three types of validities; content validity, criterion-related validity, and construct validity. \newline % Row Count 4 (+ 4) `test1 \textless{}- read.table("test1.txt")`\{\{noshy\}\} \newline % Row Count 5 (+ 1) `test2 \textless{}- read.table("test2.txt")`\{\{noshy\}\} \newline % Row Count 6 (+ 1) {\bf{2.1) Criterion Related Validity}} \newline % Row Count 7 (+ 1) `total\_X \textless{}- rowSums(test1)`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `total\_Y \textless{}- rowSums(test2)`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `rho\_xy \textless{}- cor(total\_X, total\_Y)`\{\{noshy\}\} \newline % Row Count 10 (+ 1) The validity coefficient is 0.6024. \newline % Row Count 11 (+ 1) {\bf{2.2) Correction for attenuation}} \newline % Row Count 12 (+ 1) `coeff.alpha \textless{}- function(responses)\{`\{\{noshy\}\} \newline % Row Count 13 (+ 1) ` \# Get number of items (N) and individuals`\{\{noshy\}\} \newline % Row Count 15 (+ 2) ` n.items \textless{}- ncol(responses)`\{\{noshy\}\} \newline % Row Count 16 (+ 1) ` n.persons \textless{}- nrow(responses)`\{\{noshy\}\} \newline % Row Count 17 (+ 1) ` \# Get individual total scores`\{\{noshy\}\} \newline % Row Count 18 (+ 1) ` x \textless{}- rowSums(responses)`\{\{noshy\}\} \newline % Row Count 19 (+ 1) ` \# Get observed-score variance of whole test (X)`\{\{noshy\}\} \newline % Row Count 21 (+ 2) ` var.x \textless{}- var(x)*(n.persons-1)/n.persons`\{\{noshy\}\} \newline % Row Count 23 (+ 2) ` \# Get observed-score variance of each item (Y\_j)`\{\{noshy\}\} \newline % Row Count 25 (+ 2) ` var.y \textless{}- numeric(n.items)`\{\{noshy\}\} \newline % Row Count 26 (+ 1) ` for(i in 1:n.items)\{`\{\{noshy\}\} \newline % Row Count 27 (+ 1) ` var.y{[}i{]} \textless{}- var(responses{[},i{]})*(n.persons-1)/n.persons`\{\{noshy\}\} \newline % Row Count 29 (+ 2) ` \}`\{\{noshy\}\} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Validity (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{` \# Apply the alpha formula`\{\{noshy\}\} \newline % Row Count 1 (+ 1) ` alpha \textless{}- (n.items/(n.items-1))*(1 - sum(var.y)/var.x)`\{\{noshy\}\} \newline % Row Count 3 (+ 2) ` return(alpha)`\{\{noshy\}\} \newline % Row Count 4 (+ 1) `\}`\{\{noshy\}\} \newline % Row Count 5 (+ 1) `rho\_xx \textless{}- coeff.alpha(test1)`\{\{noshy\}\} \newline % Row Count 6 (+ 1) `rho\_xx`\{\{noshy\}\} \newline % Row Count 7 (+ 1) `\#\# {[}1{]} 0.6061799`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `rho\_yy \textless{}- coeff.alpha(test2)`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `rho\_yy`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `\#\# {[}1{]} 0.6439105`\{\{noshy\}\} \newline % Row Count 11 (+ 1) `rho\_txty \textless{}- rho\_xy / (sqrt(rho\_xx) * sqrt(rho\_yy))`\{\{noshy\}\} \newline % Row Count 13 (+ 2) `rho\_txty`\{\{noshy\}\} \newline % Row Count 14 (+ 1) `\#\# {[}1{]} 0.9641909`\{\{noshy\}\} \newline % Row Count 15 (+ 1) Obtain the true score correlation.% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Decision Table}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Decision table or a contingency table based on a test score and a criterion score. From the contingency table, students will be able to understand and obtain the hit rate, sensitivity, specificity, and base rate in R. Test scores are often used for making screening decisions. \newline % Row Count 6 (+ 6) {\bf{3.1) Decision Table}} \newline % Row Count 7 (+ 1) `test1 \textless{}- read.table("test1.txt")`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `test2 \textless{}- read.table("test2.txt")`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `\# total scores`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `X \textless{}- rowSums(test1)`\{\{noshy\}\} \newline % Row Count 11 (+ 1) `Y \textless{}- rowSums(test2)`\{\{noshy\}\} \newline % Row Count 12 (+ 1) `predicted \textless{}- (X \textgreater{}= 13)`\{\{noshy\}\} \newline % Row Count 13 (+ 1) `actual \textless{}- (Y \textgreater{}= 13)`\{\{noshy\}\} \newline % Row Count 14 (+ 1) `head(predicted)`\{\{noshy\}\} \newline % Row Count 15 (+ 1) `\#\# {[}1{]} FALSE TRUE FALSE FALSE FALSE FALSE`\{\{noshy\}\} \newline % Row Count 17 (+ 2) `head(actual)`\{\{noshy\}\} \newline % Row Count 18 (+ 1) `\#\# {[}1{]} FALSE FALSE TRUE FALSE FALSE FALSE`\{\{noshy\}\} \newline % Row Count 20 (+ 2) `sum(predicted)`\{\{noshy\}\} \newline % Row Count 21 (+ 1) `\#\# {[}1{]} 44`\{\{noshy\}\} \newline % Row Count 22 (+ 1) `sum(actual)`\{\{noshy\}\} \newline % Row Count 23 (+ 1) `\#\# {[}1{]} 33`\{\{noshy\}\} \newline % Row Count 24 (+ 1) `mean(predicted)`\{\{noshy\}\} \newline % Row Count 25 (+ 1) `\#\# {[}1{]} 0.44`\{\{noshy\}\} \newline % Row Count 26 (+ 1) `mean(actual)`\{\{noshy\}\} \newline % Row Count 27 (+ 1) `\#\# {[}1{]} 0.33`\{\{noshy\}\} \newline % Row Count 28 (+ 1) `match \textless{}- cbind(predicted, actual)`\{\{noshy\}\} \newline % Row Count 29 (+ 1) `decision \textless{}- table(actual, predicted)`\{\{noshy\}\} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Decision Table (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`decision`\{\{noshy\}\} \newline % Row Count 1 (+ 1) {\bf{Output 3.1}} \newline % Row Count 2 (+ 1) {\bf{3.2) Hit Rate }} \newline % Row Count 3 (+ 1) `mean(predicted == actual)`\{\{noshy\}\} \newline % Row Count 4 (+ 1) `\#\# {[}1{]} 0.71`\{\{noshy\}\} \newline % Row Count 5 (+ 1) `decision{[}1,1{]} \# Correct rejection`\{\{noshy\}\} \newline % Row Count 6 (+ 1) `\#\# {[}1{]} 47`\{\{noshy\}\} \newline % Row Count 7 (+ 1) `decision{[}2,2{]} \# Hit`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `\#\# {[}1{]} 24`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `sum(decision) \# Number of examinees`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `\#\# {[}1{]} 100`\{\{noshy\}\} \newline % Row Count 11 (+ 1) `(decision{[}1,1{]} + decision{[}2,2{]}) / sum(decision) \# hit rate`\{\{noshy\}\} \newline % Row Count 13 (+ 2) `\#\# {[}1{]} 0.71`\{\{noshy\}\} \newline % Row Count 14 (+ 1) {\bf{3.3) Sensitivity and Specificity}} \newline % Row Count 15 (+ 1) `decision{[}2,2{]} \# hit`\{\{noshy\}\} \newline % Row Count 16 (+ 1) `\#\# {[}1{]} 24`\{\{noshy\}\} \newline % Row Count 17 (+ 1) `decision{[}2,1{]} \# miss`\{\{noshy\}\} \newline % Row Count 18 (+ 1) `\#\# {[}1{]} 9`\{\{noshy\}\} \newline % Row Count 19 (+ 1) `decision{[}2,2{]} / (decision{[}2,2{]} + decision{[}2,1{]}) \# sensitivity`\{\{noshy\}\} \newline % Row Count 21 (+ 2) `\#\# {[}1{]} 0.7272727`\{\{noshy\}\} \newline % Row Count 22 (+ 1) `decision{[}1,1{]} \# correct rejection`\{\{noshy\}\} \newline % Row Count 23 (+ 1) `\#\# {[}1{]} 47`\{\{noshy\}\} \newline % Row Count 24 (+ 1) `decision{[}1,2{]} \# false alarm`\{\{noshy\}\} \newline % Row Count 25 (+ 1) `\#\# {[}1{]} 20`\{\{noshy\}\} \newline % Row Count 26 (+ 1) `decision{[}1,1{]} / (decision{[}1,1{]} + decision{[}1,2{]}) \# specificity`\{\{noshy\}\} \newline % Row Count 28 (+ 2) `\#\# {[}1{]} 0.7014925`\{\{noshy\}\} \newline % Row Count 29 (+ 1) `mean(predicted{[}actual == TRUE{]} == TRUE) \# sensitivity`\{\{noshy\}\} \newline % Row Count 31 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Decision Table (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`\#\# {[}1{]} 0.7272727`\{\{noshy\}\} \newline % Row Count 1 (+ 1) `mean(predicted{[}actual == FALSE{]} == FALSE) \# specificity`\{\{noshy\}\} \newline % Row Count 3 (+ 2) `\#\# {[}1{]} 0.7014925`\{\{noshy\}\} \newline % Row Count 4 (+ 1) {\bf{3.4) Base Rate}} \newline % Row Count 5 (+ 1) `mean(actual)`\{\{noshy\}\} \newline % Row Count 6 (+ 1) `\#\# {[}1{]} 0.33`\{\{noshy\}\} \newline % Row Count 7 (+ 1) `(decision{[}2,1{]} + decision{[}2,2{]}) / sum(decision)`\{\{noshy\}\} \newline % Row Count 9 (+ 2) `\#\# {[}1{]} 0.33`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `sum(decision{[}2,{]}) / sum(decision)`\{\{noshy\}\} \newline % Row Count 11 (+ 1) `\#\# {[}1{]} 0.33`\{\{noshy\}\} \newline % Row Count 12 (+ 1) `rowSums(decision){[}2{]} / sum(decision)`\{\{noshy\}\} \newline % Row Count 13 (+ 1) `\#\# TRUE `\{\{noshy\}\} \newline % Row Count 14 (+ 1) `\#\# 0.33`\{\{noshy\}\}% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 3.1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671172186_ экрана 2022-12-16 в 7.17.19.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{h}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Test Construction}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Suppose that we developed a new test containing N newly written items. The test is designed to measure a unidimensional latent construct. Also, the test items are assumed to be essentially tau− equivalent. This N-item test is administered to a pretest sample. \newline % Row Count 6 (+ 6) {\bf{ 4.1) Item Difficulty }} \newline % Row Count 7 (+ 1) `responses \textless{}- read.table(".")`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `Y \textless{}- read.table(".")`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `difficulty \textless{}- colMeans(responses)`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `difficulty`\{\{noshy\}\} \newline % Row Count 11 (+ 1) {\bf{Output 4.1}} \newline % Row Count 12 (+ 1) {\bf{ 4.2) Item Discrimination }} \newline % Row Count 13 (+ 1) `X \textless{}- rowSums(responses) \# total score`\{\{noshy\}\} \newline % Row Count 14 (+ 1) `discrimination \textless{}- numeric(ncol(responses)) \# outcome vector`\{\{noshy\}\} \newline % Row Count 16 (+ 2) `for(i in 1:ncol(responses))\{`\{\{noshy\}\} \newline % Row Count 17 (+ 1) ` discrimination{[}i{]} \textless{}- cor(responses{[},i{]}, X) \# Pearson correlation between the i-th item score and the total score`\{\{noshy\}\} \newline % Row Count 20 (+ 3) `\}` \newline % Row Count 21 (+ 1) `discrimination`\{\{noshy\}\} \newline % Row Count 22 (+ 1) {\bf{Output 4.2}} \newline % Row Count 23 (+ 1) {\bf{ 4.3) Item-score SD }} \newline % Row Count 24 (+ 1) `item\_sd \textless{}- sqrt(difficulty * (1-difficulty))`\{\{noshy\}\} \newline % Row Count 26 (+ 2) `item\_sd`\{\{noshy\}\} \newline % Row Count 27 (+ 1) {\bf{Output 4.3}} \newline % Row Count 28 (+ 1) {\bf{ 4.4) Item Reliability }} \newline % Row Count 29 (+ 1) `item\_rel \textless{}- item\_sd * discrimination`\{\{noshy\}\} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Test Construction (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`round(item\_rel, 2) \# round to 2 digits`\{\{noshy\}\} \newline % Row Count 2 (+ 2) {\bf{Output 4.4}} \newline % Row Count 3 (+ 1) {\bf{ 4.5) Item Validity }} \newline % Row Count 4 (+ 1) `r\_iy \textless{}- numeric(ncol(responses))`\{\{noshy\}\} \newline % Row Count 5 (+ 1) `for(i in 1:ncol(responses))\{`\{\{noshy\}\} \newline % Row Count 6 (+ 1) ` r\_iy{[}i{]} \textless{}- cor(responses{[},i{]}, Y) \# replace each value by r\_iy`\{\{noshy\}\} \newline % Row Count 8 (+ 2) `\}`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `item\_val \textless{}- item\_sd * r\_iy`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `round(item\_val, 2)`\{\{noshy\}\} \newline % Row Count 11 (+ 1) {\bf{Output 4.5}}% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 4.1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671199723_1.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 4.2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671199743_2.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 4.3}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671199769_3.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 4.4}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671199790_4.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 4.5}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671199817_5.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Exploratory Factor Analysis}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Factor analysis (FA) assumes that there are a number of underlying (latent) factors affecting the observed scores on items/tests. In other words, the traits underlying a test might be multidimensional. \newline % Row Count 5 (+ 5) `scores \textless{}- read.table(".")`\{\{noshy\}\} \newline % Row Count 6 (+ 1) `cor.subtests \textless{}- cor(scores)`\{\{noshy\}\} \newline % Row Count 7 (+ 1) `factanal(x = scores, factors = 1)`\{\{noshy\}\} \newline % Row Count 8 (+ 1) `factanal(x = scores, factors = 2)`\{\{noshy\}\} \newline % Row Count 9 (+ 1) `cov.mat \textless{}- cov(scores)`\{\{noshy\}\} \newline % Row Count 10 (+ 1) `factanal(covmat=cov.mat, factors = 2, n.obs = nrow(scores))`\{\{noshy\}\} \newline % Row Count 12 (+ 2) `output \textless{}- factanal(x = scores, factors = 2, scores = 'regression')`\{\{noshy\}\} \newline % Row Count 14 (+ 2) `varimax \textless{}- factanal(scores, factors = 2, rotation="varimax", scores="regression")`\{\{noshy\}\} \newline % Row Count 16 (+ 2) `promax \textless{}- factanal(scores, factors = 2, rotation="promax", scores="regression")`\{\{noshy\}\} \newline % Row Count 18 (+ 2) `library(psych)`\{\{noshy\}\} \newline % Row Count 19 (+ 1) `output2 \textless{}- fa(scores, \# input data`\{\{noshy\}\} \newline % Row Count 20 (+ 1) ` nfactors = 2, \# number of factors`\{\{noshy\}\} \newline % Row Count 22 (+ 2) ` rotate = "varimax", \# rotation`\{\{noshy\}\} \newline % Row Count 24 (+ 2) ` scores = "regression") \# factor score estimation`\{\{noshy\}\} \newline % Row Count 26 (+ 2) `output2\$loadings \# factor loadings`\{\{noshy\}\} \newline % Row Count 27 (+ 1) {\bf{Output 5}}% Row Count 28 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 5}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671201493_ экрана 2022-12-16 в 15.34.59.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Item Response Theory}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Item response theory models the nonlinear relationship between the examinee's trait and the probability of response. \newline % Row Count 3 (+ 3) `GRE40 \textless{}- read.table(".")`\{\{noshy\}\} \newline % Row Count 4 (+ 1) `par(mfrow=c(1,3))`\{\{noshy\}\} \newline % Row Count 5 (+ 1) `hist(GRE40\$a)`\{\{noshy\}\} \newline % Row Count 6 (+ 1) `hist(GRE40\$b)`\{\{noshy\}\} \newline % Row Count 7 (+ 1) `hist(GRE40\$c)`\{\{noshy\}\} \newline % Row Count 8 (+ 1) {\bf{Output 6.1}} \newline % Row Count 9 (+ 1) {\bf{Output 6.2}} \newline % Row Count 10 (+ 1) `irt.p \textless{}- function(theta,a,b,c)\{ \#ability and item parameters as scalars`\{\{noshy\}\} \newline % Row Count 12 (+ 2) ` p \textless{}- c + (1-c)/(1 + exp(-1.7{\emph{a}}(theta-b)))`\{\{noshy\}\} \newline % Row Count 14 (+ 2) ` return(p)`\{\{noshy\}\} \newline % Row Count 15 (+ 1) `\}`\{\{noshy\}\} \newline % Row Count 16 (+ 1) `irt.p(theta = 0, a = 1, b = -.2, c = .25)`\{\{noshy\}\} \newline % Row Count 18 (+ 2) `\#\# {[}1{]} 0.6881429`\{\{noshy\}\} \newline % Row Count 19 (+ 1) `irt.p(theta = -1, a = 1, b = -.2, c = .25)`\{\{noshy\}\} \newline % Row Count 21 (+ 2) `\#\# {[}1{]} 0.4031802`\{\{noshy\}\} \newline % Row Count 22 (+ 1) `theta\_seq \textless{}- seq(from = -4, to = 4, by = .1)`\{\{noshy\}\} \newline % Row Count 24 (+ 2) `p\_item1 \textless{}- numeric(length(theta\_seq))`\{\{noshy\}\} \newline % Row Count 25 (+ 1) `for(t in 1:length(theta\_seq))\{`\{\{noshy\}\} \newline % Row Count 26 (+ 1) ` p\_item1{[}t{]} \textless{}- irt.p(theta = theta\_seq{[}t{]},`\{\{noshy\}\} \newline % Row Count 28 (+ 2) ` a = GRE40\$a{[}1{]},`\{\{noshy\}\} \newline % Row Count 29 (+ 1) ` b = GRE40\$b{[}1{]},`\{\{noshy\}\} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Item Response Theory (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{` c = GRE40\$c{[}1{]})`\{\{noshy\}\} \newline % Row Count 1 (+ 1) `\}`\{\{noshy\}\} \newline % Row Count 2 (+ 1) `plot(theta\_seq, p\_item1, type = 'l', ylim=c(0,1))`\{\{noshy\}\} \newline % Row Count 4 (+ 2) {\bf{Output 6.3}}% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(*Additional)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 6.1}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671202175_1.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 6.2}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671202194_2.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Output 6.3}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671202213_3.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Item Response Theory}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/worlddoit_1671202932_ экрана 2022-12-16 в 16.01.27.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}