tests/testthat/test-lm-model-explore.R

testthat::test_that('lm_model_explore',{
  test = data.frame(y1 = rnorm(1000,2,3),
                    y2 = rnorm(1000,10,2),
                    y3 = rnorm(1000,1,4),
                    x1 = rnorm(1000,100,10),
                    x2 = rnorm(1000,10,1),
                    x3 = rnorm(1000,6,2),
                    m1 = rnorm(1000,3,1),
                    m2 = rnorm(1000,2,0.5),
                    m3 = rnorm(1000,9,0.1),
                    c1 = rnorm(1000,5,0.4),
                    c2 = rnorm(1000,2,0.2),
                    c3 = rnorm(1000,7,0.9)
  )
  
  mod_result = lm_model_explore(data = test, 
                                response_variable = c(y1,y2,y3),
                                predictor_variable = c(x1,x2,x3),
                                two_way_interaction_variable = c(m1,m2,m3),
                                control_variable = c(c1,c2,c3),
                                return_result = T,
                                verbose = F,
                                show_p = T)
  
  testthat::expect_equal(nrow(mod_result),expected = 27)
  
})

testthat::test_that('lm_model_explore',{
  test = data.frame(y1 = rnorm(1000,2,3),
                    y2 = rnorm(1000,10,2),
                    y3 = rnorm(1000,1,4),
                    x1 = rnorm(1000,100,10),
                    x2 = rnorm(1000,10,1),
                    x3 = rnorm(1000,6,2),
                    m1 = rnorm(1000,3,1),
                    m2 = rnorm(1000,2,0.5),
                    m3 = rnorm(1000,9,0.1),
                    c1 = rnorm(1000,5,0.4),
                    c2 = rnorm(1000,2,0.2),
                    c3 = rnorm(1000,7,0.9)
  )
  
  mod_result = lm_model_explore(data = test, 
                                response_variable = c(y1,y2,y3),
                                predictor_variable = c(x1,x2,x3),
                                two_way_interaction_variable = c(m1,m2),
                                three_way_interaction_variable = c(m3),
                                control_variable = c(c1,c2,c3),
                                return_result = T,
                                verbose = F,
                                show_p = T)
  
  testthat::expect_equal(nrow(mod_result),expected = 18)
  
})
jasonmoy28/psycModel documentation built on Sept. 6, 2024, 11:45 a.m.