Skip to content

Commit e8eb4bd

Browse files
authored
Merge pull request #14 from kellychang4/edit-formula
Loosen testthat Criterion
2 parents 23583d0 + 7d83472 commit e8eb4bd

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

tests/testthat/test-fit-models.R

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
test_that("build_formula runs as expected", {
2-
32
expect_identical(
43
build_formula(target = "fa"),
54
as.formula("fa ~ s(nodeID) + s(subjectID, bs = 're')", env = .GlobalEnv)
@@ -76,14 +75,14 @@ test_that("estimate_smooth_basis.default runs as expected", {
7675

7776
estimated_information <- estimate_smooth_basis(
7877
target = "md",
79-
smooth_terms = "s(nodeID, bs = 'ts', k = seq(2, 20, 8))",
78+
smooth_terms = "s(nodeID, bs = 'ts', k = seq(12, 24, 4))",
8079
df = df_sarica,
8180
)
82-
expected_term <- "s(nodeID, bs = 'ts', k = 18)"
81+
expected_term <- "s(nodeID, bs = 'ts', k = 20)"
8382
expect_identical(estimated_information$est_terms, expected_term)
8483
expected_values <- estimated_information$k_estimates %>%
8584
dplyr::filter(term == expected_term)
86-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
85+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
8786

8887
estimated_information <- estimate_smooth_basis(
8988
target = "fa",
@@ -95,7 +94,7 @@ test_that("estimate_smooth_basis.default runs as expected", {
9594
expect_identical(estimated_information$est_terms, expected_term)
9695
expected_values <- estimated_information$k_estimates %>%
9796
dplyr::filter(term == expected_term)
98-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
97+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
9998

10099
estimated_information <- estimate_smooth_basis(
101100
target = "fa",
@@ -109,22 +108,22 @@ test_that("estimate_smooth_basis.default runs as expected", {
109108
expect_identical(estimated_information$est_terms, expected_term)
110109
expected_values <- estimated_information$k_estimates %>%
111110
dplyr::filter(term == expected_term)
112-
expect_identical(expected_values$k_index > 0.98 && expected_values$p_value > 0.1, TRUE)
111+
expect_true(expected_values$k_index > 0.98 && expected_values$p_value > 0.1)
113112

114113
estimated_information <- estimate_smooth_basis(
115114
target = "fa",
116-
smooth_terms = c("s(age, k = 1:10)", "s(nodeID, by = group, bs = 'fs', k = c(7,9), m = 3)"),
115+
smooth_terms = c("s(age, k = 1:10)", "s(nodeID, by = group, bs = 'fs', k = c(4,9), m = 3)"),
117116
df = df_sarica,
118117
regressors = "group"
119118
)
120119
expected_term <- c("s(age, bs = 'tp', k = 10)", "s(nodeID, by = group, bs = 'fs', m = 3, k = 9)")
121120
expect_identical(estimated_information$est_terms, expected_term)
122121
expected_values <- estimated_information$k_estimates %>%
123122
dplyr::filter(term == expected_term[1]) # age term
124-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, FALSE)
123+
expect_false(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
125124
expected_values <- estimated_information$k_estimates %>%
126125
dplyr::filter(term == expected_term[2]) # node term
127-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
126+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
128127
})
129128

130129

@@ -133,14 +132,14 @@ test_that("estimate_smooth_basis.formula runs as expected", {
133132
dplyr::filter(tractID == "Right Corticospinal")
134133

135134
estimated_information <- estimate_smooth_basis(
136-
formula = md ~ s(nodeID, bs = "ts", k = seq(2, 20, 8)),
135+
formula = md ~ s(nodeID, bs = "ts", k = seq(12, 24, 4)),
137136
df = df_sarica
138137
)
139-
expected_term <- "s(nodeID, bs = 'ts', k = 18)"
138+
expected_term <- "s(nodeID, bs = 'ts', k = 20)"
140139
expect_identical(estimated_information$est_terms, expected_term)
141140
expected_values <- estimated_information$k_estimates %>%
142141
dplyr::filter(term == expected_term)
143-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
142+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
144143

145144
estimated_information <- estimate_smooth_basis(
146145
formula = fa ~ age + group + s(nodeID, by = group, bs = "fs"),
@@ -150,7 +149,7 @@ test_that("estimate_smooth_basis.formula runs as expected", {
150149
expect_identical(estimated_information$est_terms, expected_term)
151150
expected_values <- estimated_information$k_estimates %>%
152151
dplyr::filter(term == expected_term)
153-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
152+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
154153

155154
estimated_information <- estimate_smooth_basis(
156155
formula = fa ~ age + group + s(nodeID, by = group, bs = "fs", k = c(4, 11)),
@@ -162,21 +161,21 @@ test_that("estimate_smooth_basis.formula runs as expected", {
162161
expect_identical(estimated_information$est_terms, expected_term)
163162
expected_values <- estimated_information$k_estimates %>%
164163
dplyr::filter(term == expected_term)
165-
expect_identical(expected_values$k_index > 0.98 && expected_values$p_value > 0.1, TRUE)
164+
expect_true(expected_values$k_index > 0.98 && expected_values$p_value > 0.1)
166165

167166
estimated_information <- estimate_smooth_basis(
168167
formula = fa ~ group + s(age, k = 1:10)
169-
+ s(nodeID, by = group, bs = "fs", k = c(7,9), m = 3),
168+
+ s(nodeID, by = group, bs = "fs", k = c(4,9), m = 3),
170169
df = df_sarica,
171170
)
172171
expected_term <- c("s(age, bs = 'tp', k = 10)", "s(nodeID, by = group, bs = 'fs', m = 3, k = 9)")
173172
expect_identical(estimated_information$est_terms, expected_term)
174173
expected_values <- estimated_information$k_estimates %>%
175174
dplyr::filter(term == expected_term[1]) # age term
176-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, FALSE)
175+
expect_false(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
177176
expected_values <- estimated_information$k_estimates %>%
178177
dplyr::filter(term == expected_term[2]) # node term
179-
expect_identical(expected_values$k_index > 0.95 && expected_values$p_value > 0.05, TRUE)
178+
expect_true(expected_values$k_index > 0.95 && expected_values$p_value > 0.05)
180179
})
181180

182181

0 commit comments

Comments
 (0)