Skip to content

Commit

Permalink
skip tests with INLA compatibility issues on multiple platforms on CI…
Browse files Browse the repository at this point in the history
…, still testing them locally
  • Loading branch information
richardli committed Jan 4, 2025
1 parent 5611c59 commit 849ec29
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/testthat/test-smoothDirect.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test_that("smoothDirect works for national model", {
test_that("smoothDirect works for subnational model", {

skip_on_cran()
skip_on_ci()
library(INLA)
# make devtools::check() happy with single process
inla.setOption( num.threads = 1 )
Expand Down
36 changes: 35 additions & 1 deletion tests/testthat/test-smoothSurvey.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,52 @@ test_that("smoothSurvey: Cluster-level model works", {
expect_equal(fit6$smooth, fit7$smooth, tolerance = 0.01)


})


})


test_that("smoothSurvey: Cluster-level model works with Gaussian likelihood", {

skip_on_cran()
skip_on_ci()
library(INLA)
# make devtools::check() happy with single process
inla.setOption( num.threads = 1 )


##
## 4. Unit-level model with continuous response
## (or nested error models)

# The unit-level model assumes for each of the i-th unit,
# Y_{i} ~ intercept + region_effect + IID_i
# where IID_i is the error term specific to i-th unit

# When more than one level of cluster sampling is carried out,
# they are ignored here. Only the input unit is considered.
# So here we do not need to specify clusterVar any more.
fit9 <- smoothSurvey(data= data,
Amat=DemoMap2$Amat, response.type="gaussian",
is.unit.level = TRUE, responseVar="age", strataVar.within = NULL,
regionVar="region", clusterVar = NULL, CI = 0.95)
expect_equal(class(fit9), "SUMMERmodel.svy")
expect_equal(dim(fit9$smooth), c(8, 13))

# To compare, we may also model PSU-level responses. As an illustration,
data.median <- aggregate(age~region + urbanicity + clustid,
data = data, FUN = median)

fit10 <- smoothSurvey(data= data.median,
Amat=DemoMap2$Amat, response.type="gaussian",
is.unit.level = TRUE, responseVar="age", strataVar.within = NULL,
regionVar="region", clusterVar = "clustid", CI = 0.95)
# Notice these two should not be the same, but should not be very far either
expect_equal(fit9$smooth, fit10$smooth, tolerance = 1)




# For unit-level models, we need to create stratification variable within regions
data <- DemoData2
data$urbanicity <- "rural"
Expand Down

0 comments on commit 849ec29

Please sign in to comment.