Skip to content
Snippets Groups Projects
Commit 623f4984 authored by Walmes Marques Zeviani's avatar Walmes Marques Zeviani
Browse files

Adicona o dir tests/ e arquivos com testes nas funções de ll.

parent 678b7309
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -46,6 +46,7 @@ Suggests: ...@@ -46,6 +46,7 @@ Suggests:
knitr, knitr,
rmarkdown, rmarkdown,
shiny, shiny,
rpanel rpanel,
testthat
VignetteBuilder: knitr VignetteBuilder: knitr
RoxygenNote: 5.0.1 RoxygenNote: 5.0.1
library(testthat)
library(MRDCr)
test_check("MRDCr")
context("Testa as Funções de Probabilidade")
test_that("Iguais a Poisson", {
y <- 0:30
lambda <- 30 * runif(1)
py_pois <- dpois(x = y, lambda = lambda)
py_pgnz <- dpgnz(y = y, lambda = lambda, alpha = 0)
py_gcnt <- dgcnt(y = y, lambda = lambda, alpha = 1)
expect_equal(py_pgnz, py_pois)
expect_equal(py_gcnt, py_pois)
})
context("Testa as Funções de Log-Verossimilhança")
test_that("Tem os mesmo argumentos", {
apropos("formals")
a_gcnt <- as.list(formals(llgcnt))
a_pgnz <- as.list(formals(llpgnz))
expect_equal(a_gcnt, a_pgnz)
})
test_that("São iguais a Poisson", {
y <- 0:10
X <- cbind(y * 0 + 1)
lamb <- 10 * runif(1)
ll_pois <- -sum(dpois(x = y, lambda = lamb, log = TRUE))
ll_pgnz <- llpgnz(params = c(0, log(lamb)), y = y, X = X)
ll_gcnt <- llgcnt(params = c(log(1), log(lamb)), y = y, X = X)
expect_equal(ll_pgnz, expected = ll_pois)
expect_equal(ll_gcnt, expected = ll_pois)
})
test_that("Inteiros negativos resultam em Warning", {
y <- -4:-1
X <- cbind(y * 0 + 1)
lamb <- 10 * runif(1)
expect_warning(llpgnz(params = c(0, log(lamb)), y = y, X = X))
expect_warning(llgcnt(params = c(log(1), log(lamb)), y = y, X = X))
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment