tests/testthat/test_interaction.R

context('check interaction model')

library(dplyr)


test_that('interaction model parameters are stable over simulation',{
  
  set.seed(123)
  db = open_project('../verbAggression.db')
  f = fit_inter(db)
  ts = get_testscores(db)
  #close_project(db)
  
  simdat = r_score_IM(f, rep(ts$booklet_score,10))
  
  g = fit_inter(simdat)  
  
  f = coef(f)  
  g = coef(g)

  expect_gt(cor(f$beta_IM,g$beta_IM), 0.95, label='IM sim beta correlates >.95 true beta')
  
  i = seq(1,nrow(f),2)
  
  expect_gt(cor(f$sigma[i],g$sigma[i]), 0.9, label='IM sim sigma correlates >.9 true sigma')
    
})

Try the dexter package in your browser

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

dexter documentation built on Nov. 10, 2022, 5:15 p.m.