Skip to content

Commit

Permalink
Fix minor bug in check_args when multiple ST objects are given
Browse files Browse the repository at this point in the history
  • Loading branch information
msainsburydale committed Jul 16, 2024
1 parent 306d26e commit 7fd9615
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/check_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
stop("If the response is Gaussian and observational error is not going to be estimated,
please supply a field 'std' in the data objects")

if(response == "gaussian" && !est_error && !all(sapply(data, function(x) x$std >= 0)))
if(response == "gaussian" && !est_error && !all(unlist(sapply(data, function(x) x$std >= 0))))
stop("If the response is Gaussian and observational error is not going to be estimated,
the std field must contain only positive numbers")

Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test_SRE.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ test_that("SRE space-time sphere works",{

### summary works?
expect_true({summary(S);TRUE})

## Test with multiple ST objects with differing amounts of data
point_to_remove <- 2
updated_data <- STobj@data[-point_to_remove, ]
updated_coords <- STobj@sp[-point_to_remove, ]
updated_time <- STobj@time[-point_to_remove]
STobj2 <- STIDF(updated_coords, updated_time, data = updated_data)
S <- SRE(f,list(STobj, STobj2),G,
grid_BAUs,
est_error = FALSE)
expect_is(S,"SRE")
S <- SRE.fit(S,n_EM = 3,tol = 1e-5,print_lik=FALSE)
expect_is(S,"SRE")
grid_BAUs <- predict(S)
expect_is(grid_BAUs,"STFDF")
grid_BAUs <- predict(S,obs_fs = FALSE)
expect_is(grid_BAUs,"STFDF")
expect_true({summary(S);TRUE})
})


0 comments on commit 7fd9615

Please sign in to comment.