Interactively building test forms from an IRT perspective An application of R and Shiny
[This article was first published on Educate-R - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
- Pros:
Reproducible Research
- Reproducible research has become popular.
- Commonly a document that contains both analysis and text.
- This can be done with
Rmarkdown
andknitr.
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
- Data analysts may use
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
- Using JavaScript - D3 graphics (
- Interactive Tables
- Using DT R package
Reporting from Shiny
- Using
Rmarkdown
andknitr
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.
- Define output.
- Clean up UI last.
Summary
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://educate-r.org
- Slides: http://educate-r.org/2016/02/18/cspshiny/
To leave a comment for the author, please follow the link and comment on their blog: Educate-R - R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.