tests/testthat/test_estimate_age_mixing.R

library(mixage)
context("main functions: estimate_age_mixing and likelihood")

source("common_test_defs.R")

test_that("MOME and FOME have rowsums equal to 1", {
    dv <- matrix(c("normal", rep("gamma", 2),
                   "identity", "log", "identity"), nrow = 3)
    for (i in 1:nrow(dv)) {
        mixing_mats <- estimate_age_mixing(choice_data = mixing_data,
                                           start_ages = start_ages,
                                           distribution = dv[i, 1],
                                           link = dv[i, 2],
                                           max_age = max_age,
                                           age_distribution = age_dist)
        expected <- rep(1, n_age)
        names(expected) <- start_ages
        expect_equal(rowSums(mixing_mats$MOME), expected)
        expect_equal(rowSums(mixing_mats$FOME), expected)
    }
})
caleb-easterly/mixage documentation built on May 12, 2019, 4:25 p.m.