tests/testthat/test-5-piaac.R

skip_on_cran()
require(testthat)
require(EdSurvey)
options(width = 500)
options(useFancyQuotes=FALSE)
source("REF-5-piaac.R") # has REF output in it

context("PIAAC data reads in correctly")
if(!exists("edsurveyHome")) {
  if (Sys.info()[['sysname']] == "Windows") {
    edsurveyHome <- "C:/EdSurveyData/"
  } else {
    edsurveyHome <- "~/EdSurveyData/"
  }
}

if (!dir.exists(edsurveyHome)) {
  dir.create(edsurveyHome)
}

test_that("PIAAC data reads in correctly", {
  expect_silent(downloadPIAAC(root=edsurveyHome, round = 1, verbose = FALSE))
  usa <<- readPIAAC(file.path(edsurveyHome, "PIAAC", "Round 1"), countries = c("usa"), verbose=FALSE)
  nor <<- readPIAAC(file.path(edsurveyHome, "PIAAC", "Round 1"), countries = c("nor"), verbose=FALSE)
  deu <<- readPIAAC(file.path(edsurveyHome, "PIAAC", "Round 1"), countries = c("deu"), verbose=FALSE)
})

context("PIAAC data Wald test examples")
test_that("Wald test works correctly for PIAAC data", {
  
  myLogit <- logit.sdf(lit ~ i_q04j + j_q02a, data = usa)
  wt <- waldTest(model = myLogit, coefficients = "i_q04j", H0 = 1)
  wt5 <- capture.output(wt)
  expect_equal(wt5, wt5REF)
  
  myLogit <- logit.sdf(lit ~ i_q04j + j_q02a, data = nor)
  wt <- waldTest(model = myLogit, coefficients = "i_q04j", H0 = 1)
  wt6 <- capture.output(wt)
  expect_equal(wt6, wt6REF)
  
  myLogit <- logit.sdf(lit ~ i_q04j + j_q02a, data = deu)
  wt <- waldTest(model = myLogit, coefficients = "i_q04j", H0 = 1)
  wt7 <- capture.output(wt)
  expect_equal(wt7, wt7REF)
})

Try the EdSurvey package in your browser

Any scripts or data that you put into this service are public.

EdSurvey documentation built on May 2, 2019, 7:30 a.m.