tests/testthat/test-prediction.R

test_that("prediction of abundances works", {
  
  
    model <- brve(y ~ x1 + x2, effort, data = frogs)
    
    frogs_new <- frogs
    frogs_new$x1 <- frogs_new$x1 / 10
    frogs_new$x2 <- frogs_new$x2 / 10
    
    
    # should error
    expect_error(
        predict(model, newdata = frogs_new, type = "abundance", se.fit = TRUE),
        "Cannot fit standard errors in abundance prediction in brve"
    )    
    
    # make predictions
    p <- predict(model, frogs_new, se.fit = FALSE)
    expect_true(all(p > 0 ))

  
})
eunices/brve documentation built on June 22, 2020, 12:07 a.m.