<h1>Interactively building test forms from an IRT perspective: An application of R and Shiny</h1> <h2>Brandon LeBeau</h2> <h3>University of Iowa</h3> # Overview <img src=" /figs/flowchart.png" alt=""/> # R - R is an open source statistical programming language. - Pros: + Common statistical procedures are found in R + Can extend functionality with packages/functions - Cons: + Need to be comfortable with code <img src="/figs/Rlogo.png" alt=""/> # Reproducible Research - Reproducible research has become popular. - Commonly a document that contains both analysis and text. - This can be done with `Rmarkdown` and `knitr.` <img src="/figs/rmarkdown.PNG" alt=""/> <img src="/figs/knitr.PNG" alt=""/> # Iterative/Interactive Data Analysis - This type of analysis requires some input from the user. + Data analysts may use `R` + `Shiny` is a great option for code novices <img src="/figs/shiny.PNG" alt=""/> # Iterative Task Examples - Building Assessments - Exploratory Data Analysis - Exploring Missing Data Patterns - Model Selection/Building # Iterative Analysis Structure <img src="/figs/useless_meeting.PNG" alt=""/> # What is Shiny? - `Shiny` is an interactive web application framework for R. + Example: <http://shiny.rstudio.com/gallery/movie-explorer.html> <img src="/figs/shiny_example.PNG" alt=""/> # Components of Shiny 1. User Interface (ui.r) - What the user sees and interacts with 2. R Analysis (server.r) - The R code running behind the scenes # User Interface - Simple user interface example from RStudio - <http://shiny.rstudio.com/gallery/telephones-by-region.html> ```r shinyUI( fluidPage( titlePanel("Telephones by region"), sidebarLayout( sidebarPanel( selectInput("region", "Region:", choices = colnames(WorldPhones)), hr(), helpText("Data from AT&T (1961) The World's Telephones.") ), mainPanel( plotOutput("phonePlot") ) ) ) ) ``` # Server File - The server file for RStudio example - <http://shiny.rstudio.com/gallery/telephones-by-region.html> ```r shinyServer(function(input, output) { output$phonePlot <- renderPlot({ barplot(WorldPhones[ , input$region] * 1000, main = input$region, ylab = "Number of Telephones", xlab = "Year") }) }) ``` # Interactivity is Key <img src="/figs/interactivity.png" alt=""/> # Tools for Interactivity - Interactive Graphics + Using JavaScript - D3 graphics (`rCharts`) + Interactive static graphics - Garrett's presentation - Interactive Tables + Using DT R package # Reporting from Shiny - Using `Rmarkdown` and `knitr` to create customizable reproducible reports - Example: generate report button - Generate final data files - Example: download data button # Strengths of Using Shiny 1. The app can be written solely using R code - Can use CSS, JavaScript, or HTML as needed 2. User does not need to know any R 3. Many hosting options 4. Application can be as simple or complex as needed (both visually and functionally) 5. Flexible output # Weaknesses of Using Shiny 1. May take more time to develop initially 2. Need some R familiarity for development # Background for Demo - In educational assessment, we need to create new test forms - Exposure concerns - Add new content - Altering test landscape - Building test forms is an iterative process that involves gathering information from: - Item analyses - Test blueprints - Item response theory (IRT) # IRT Data ``` ## Item.1 Item.2 Item.3 Item.4 Item.5 Item.6 Item.7 Item.8 ## [1,] 1 1 1 1 1 1 1 1 ## [2,] 0 1 0 0 1 0 1 0 ## [3,] 1 1 1 0 1 0 1 0 ## [4,] 0 1 0 1 1 0 1 0 ## [5,] 0 1 1 1 1 0 1 1 ## [6,] 1 1 0 0 1 0 1 0 ``` # Logistic Curve <img src="/figs/logistic-1.png" alt=""/> # Demo <https://github.com/lebebr01/BuildForm> ```r # Basic Theme shiny::runGitHub('lebebr01/BuildForm', subdir = 'R', ref = 'basic') # shinydashboard shiny::runGitHub('lebebr01/BuildForm', subdir = 'R', ref = 'testmodule') ``` # Benefits of Shiny for Iterative Data Analysis 1. Free valuable data analyst/scientist resources. 2. Improve data literacy in the organization. 3. Highly customizable - Analysis (server.r) - User interface (ui.r) - Reporting # Weaknesses of Shiny for Iterative Data Analysis 1. Need to train users - Analysis - Navigating web application 2. Knowledge of JavaScript, CSS, or HTML useful. # Guidelines for Building Shiny Apps 1. Understand reactive coding. 2. Modularize your code - define functions for repetitive code chunks. 3. Define scope early. - Define output. 4. Clean up UI last. # Summary <img src="/figs/flowchart.png" alt=""/> # Shiny Resources - <http://shiny.rstudio.com/> - <http://shiny.rstudio.com/articles/> - <http://shiny.rstudio.com/gallery/> - <https://www.rstudio.com/products/shiny/shiny-user-showcase/> # Questions? - Twitter: @blebeau11 - Website: <http://brandonlebeau.org> - Slides: <http://brandonlebeau.org/2016/02/18/cspshiny/>