diff --git a/R/check_args.R b/R/check_args.R index 2ac171b..93bc07e 100644 --- a/R/check_args.R +++ b/R/check_args.R @@ -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") diff --git a/tests/testthat/test_SRE.R b/tests/testthat/test_SRE.R index dcce4d0..28595b7 100644 --- a/tests/testthat/test_SRE.R +++ b/tests/testthat/test_SRE.R @@ -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}) })