Skip to content

Instantly share code, notes, and snippets.

@markdly
markdly / html-multiple-choice.Rmd
Last active Jun 13, 2019
Multiple choice quiz question Rmarkdown
View html-multiple-choice.Rmd
---
output:
html_document:
theme: cerulean
---
### Example html multiple choice question using Rmarkdown
<!-- Render this Rmarkdown doc to html to make an interactive html / js multiple choice question -->
View haven-spss-value-labels.md
library(dplyr)
library(haven)
path <- system.file("examples", "iris.sav", package = "haven")
df <- read_sav(path)
head(df, 3)
#> # A tibble: 3 x 5
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species  
#>          <dbl>       <dbl>        <dbl>       <dbl> <dbl+lbl>
#> 1          5.1         3.5          1.4         0.2 1        
@markdly
markdly / 2pl_expected_score_plot_tam.md
Created Jun 12, 2018
Expected score plots using 2pl model: TAM vs homegrown
View 2pl_expected_score_plot_tam.md
library(tidyverse)
library(TAM)
#> Loading required package: CDM
#> Loading required package: mvtnorm
#> **********************************
#> ** CDM 6.2-91 (2018-05-02 17:29:27)      
#> ** Cognitive Diagnostic Models  **
#> **********************************
#> * TAM 2.12-18 (2018-05-25 11:14:38)
@markdly
markdly / anchor-trap-conquest.md
Last active Jun 21, 2018
anchor trap! comparison of free and anchored results when using set constraint = default or none in conquest
View anchor-trap-conquest.md

Free estimation (no anchors) using ConQuest gives the following item parameters for a 9 item test.

x <- c(0.39, -1.485, -1.138, -0.089, 0.901, 0.558, 0.225, -0.105, 0.743)

Next we add 3 logits to q1 through q5 and make q1 to q5 item anchors. q6 to q9 then still need to be calibrated. These are the results when:

anchored with set constraint = none;

View raw-text-of-answer.md

Does this do what you need?

#data for Paper
Paper <- c(1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9 )

#data for selectedES.prepost
selectedES.prepost <- c(0.0048, -0.1420, -0.3044, -1.3024, -0.4052, -0.6066, -0.1961, -1.1187, -0.4585, -0.8251, -0.5328, -1.3623, -0.5450, -0.4982, -0.5714, -0.8793, -0.3677, -0.3976, -0.6136, -0.7047, -0.8580, -0.5024, -0.8018, -0.8927, -0.3106, -0.5893, -0.6677, -1.6663, -1.1769, -0.8384, -0.5632, -0.5237, -0.3458, -0.9957, -0.5331, -0.7413, -0.0311, -0.4936, 0.5422, -0.0340)

#creating a test dataset
View itanal_export_example.md
library(tidyverse)
library(conquestr)
df <- cq_example(display = FALSE) %>% cq_itanal() %>%
  select(-data)

df1 <- df %>% select(item_index:delta)
df2 <- df %>% 
  mutate(resp_id = id) %>%
  select(item_index, resp_id, resp_stat) %>% 
View conquestr_example.md
library(conquestr)
library(tidyverse)
mydir <- "C:\\Users\\Mark\\Downloads"
myitanal <- cq_itanal(paste0(mydir, "\\Num_Y3.itn"))
myshow <- cq_show(paste0(mydir, "\\Num_Y3.shw"), fit = FALSE)

write_csv(myshow, paste0(mydir, "\\show.csv"))
myitanal %>%
  select(-c(data, resp_stat)) %>%
View tidyr-extract.md

From Ben Fitzpatrick. Gist adapted from Nicholas Tierney's

library(tidyverse)
ci <- c('11% - 20%', '21% - 30%', '0% - 9%')
ci %>% 
  as_tibble() %>% 
  extract(value, c("Lw", "Up"), "([0-9]+)% - ([0-9]+)%", convert = TRUE)
#> # A tibble: 3 x 2
#>      Lw    Up