Interactively building test forms from an IRT perspective: An application of R and Shiny
Brandon LeBeau
University of Iowa
Overview
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
Reproducible Research
- Reproducible research has become popular.
- Commonly a document that contains both analysis and text.
- This can be done with
Rmarkdown
and knitr.
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
Iterative Task Examples
- Building Assessments
- Exploratory Data Analysis
- Exploring Missing Data Patterns
- Model Selection/Building
Iterative Analysis Structure
What is Shiny?
Shiny
is an interactive web application framework for R.
Components of Shiny
- User Interface (ui.r)
- What the user sees and interacts with
- R Analysis (server.r)
- The R code running behind the scenes
User Interface
- Simple user interface example from RStudio
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
shinyServer(function(input, output) {
output$phonePlot <- renderPlot({
barplot(WorldPhones[ , input$region] * 1000,
main = input$region,
ylab = "Number of Telephones",
xlab = "Year")
})
})
Interactivity is Key
Tools for Interactivity
- Interactive Graphics
- Using JavaScript - D3 graphics (
rCharts
)
- Interactive static graphics - Garrett's presentation
- Interactive Tables
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
- The app can be written solely using R code
- Can use CSS, JavaScript, or HTML as needed
- User does not need to know any R
- Many hosting options
- Application can be as simple or complex as needed (both visually and functionally)
- Flexible output
Weaknesses of Using Shiny
- May take more time to develop initially
- 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
Demo
https://github.com/lebebr01/BuildForm
# 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
- Free valuable data analyst/scientist resources.
- Improve data literacy in the organization.
- Highly customizable
- Analysis (server.r)
- User interface (ui.r)
- Reporting
Weaknesses of Shiny for Iterative Data Analysis
- Need to train users
- Analysis
- Navigating web application
- Knowledge of JavaScript, CSS, or HTML useful.
Guidelines for Building Shiny Apps
- Understand reactive coding.
- Modularize your code - define functions for repetitive code chunks.
- Define scope early.
- Clean up UI last.
Summary
Shiny Resources
Questions?