context("test r(t) calculation")
fp <- list(proj.steps = seq(1970.5, 2017.5, 0.1),
ss = list(hiv_steps_per_year = 10L))
theta <- c(-0.472059, -2.48137, -1.526043, 1991.537677, -0.002029, -0.009331,
-0.019139, -0.028173, -0.025564, -0.005239, 0.016973, 0.027784,
0.026376, 0.033292, 0.03951, 0.032905, 0.018688, 0.003738, -0.000138,
2.214167, 0.158778, -4.796518, -0.10654, -9.750137, -0.132826)
rvec_out <- c(0.611043, 0.610771, 0.610492, 0.610208, 0.609917, 0.609621,
0.609318, 0.609009, 0.608694, 0.608372, 0.608043, 0.607708, 0.607365,
0.607015, 0.606658, 0.606294, 0.605922, 0.605542, 0.605155, 0.604759,
0.604356, 0.603944, 0.603523, 0.603094, 0.602656, 0.602209, 0.601753,
0.601288, 0.600813, 0.600329, 0.599835, 0.599331, 0.598816, 0.598291,
0.597756, 0.59721, 0.596652, 0.596084, 0.595504, 0.594913, 0.59431,
0.593695, 0.593068, 0.592428, 0.591776, 0.591111, 0.590433, 0.589742,
0.589037, 0.588318, 0.587586, 0.586839, 0.586078, 0.585302, 0.584511,
0.583705, 0.582884, 0.582047, 0.581194, 0.580325, 0.57944, 0.578538,
0.577619, 0.576683, 0.57573, 0.574759, 0.57377, 0.572763, 0.571738,
0.570694, 0.569631, 0.568549, 0.567447, 0.566326, 0.565184, 0.564023,
0.562841, 0.561638, 0.560414, 0.559169, 0.557902, 0.556614, 0.555304,
0.553971, 0.552616, 0.551238, 0.549837, 0.548413, 0.546966, 0.545494,
0.543999, 0.54248, 0.540936, 0.539368, 0.537775, 0.536158, 0.534515,
0.532846, 0.531152, 0.529433, 0.527687, 0.525916, 0.524118, 0.522295,
0.520444, 0.518567, 0.516664, 0.514734, 0.512777, 0.510793, 0.508782,
0.506744, 0.504679, 0.502587, 0.500468, 0.498321, 0.496148, 0.493947,
0.49172, 0.489465, 0.487184, 0.484875, 0.48254, 0.480179, 0.477791,
0.475377, 0.472936, 0.47047, 0.467978, 0.465461, 0.462918, 0.46035,
0.457758, 0.455141, 0.452501, 0.449836, 0.447148, 0.444438, 0.441704,
0.438949, 0.436172, 0.433374, 0.430555, 0.427716, 0.424857, 0.421979,
0.419082, 0.416168, 0.413235, 0.410287, 0.407322, 0.404341, 0.401346,
0.398336, 0.395313, 0.392277, 0.389229, 0.38617, 0.383101, 0.380021,
0.376933, 0.373837, 0.370733, 0.367622, 0.364506, 0.361386, 0.358261,
0.355133, 0.352002, 0.34887, 0.345738, 0.342606, 0.339475, 0.336346,
0.33322, 0.330097, 0.326979, 0.323867, 0.320761, 0.317663, 0.314572,
0.31149, 0.308418, 0.305357, 0.302307, 0.299269, 0.296244, 0.293233,
0.290236, 0.287255, 0.284289, 0.281341, 0.27841, 0.275497, 0.272603,
0.269728, 0.266873, 0.264039, 0.261227, 0.258436, 0.255668, 0.252923,
0.250201, 0.247504, 0.24483, 0.242182, 0.239559, 0.236962, 0.234391,
0.231846, 0.229328, 0.226838, 0.224374, 0.221939, 0.219531, 0.217152,
0.214801, 0.212478, 0.210184, 0.207919, 0.205682, 0.203475, 0.201297,
0.199148, 0.197029, 0.194938, 0.192877, 0.190845, 0.188842, 0.186868,
0.184923, 0.183007, 0.181121, 0.179262, 0.177433, 0.175632, 0.173859,
0.172114, 0.170398, 0.168709, 0.167048, 0.165414, 0.163808, 0.162228,
0.160675, 0.159149, 0.157648, 0.156174, 0.154725, 0.153302, 0.151904,
0.150531, 0.149183, 0.147858, 0.146558, 0.145281, 0.144028, 0.142798,
0.141591, 0.140406, 0.139243, 0.138102, 0.136983, 0.135885, 0.134808,
0.133751, 0.132715, 0.131699, 0.130702, 0.129725, 0.128767, 0.127828,
0.126907, 0.126004, 0.125119, 0.124252, 0.123401, 0.122568, 0.121752,
0.120952, 0.120167, 0.119399, 0.118646, 0.117909, 0.117186, 0.116478,
0.115785, 0.115106, 0.11444, 0.113788, 0.11315, 0.112525, 0.111912,
0.111313, 0.110725, 0.11015, 0.109587, 0.109035, 0.108495, 0.107966,
0.107449, 0.106941, 0.106445, 0.105959, 0.105483, 0.105017, 0.104561,
0.104114, 0.103677, 0.103249, 0.10283, 0.10242, 0.102019, 0.101626,
0.101241, 0.100864, 0.100496, 0.100135, 0.099782, 0.099436, 0.099098,
0.098766, 0.098442, 0.098125, 0.097815, 0.097511, 0.097511, 0.097219,
0.096938, 0.096669, 0.096411, 0.096163, 0.095926, 0.095698, 0.095479,
0.09527, 0.095056, 0.094849, 0.094649, 0.094455, 0.094268, 0.094087,
0.093912, 0.093742, 0.093578, 0.093419, 0.093229, 0.093041, 0.092856,
0.092674, 0.092494, 0.092316, 0.092141, 0.091967, 0.091795, 0.091625,
0.091406, 0.091187, 0.090968, 0.090748, 0.090528, 0.090306, 0.090084,
0.089861, 0.089637, 0.089412, 0.089203, 0.088994, 0.088784, 0.088572,
0.088359, 0.088145, 0.087929, 0.087711, 0.087492, 0.087271, 0.087225,
0.08718, 0.087134, 0.087088, 0.087043, 0.086997, 0.086952, 0.086906,
0.086861, 0.086815, 0.086962, 0.08711, 0.087258, 0.087406, 0.087555,
0.087704, 0.087853, 0.088002, 0.088151, 0.088301, 0.088547, 0.088793,
0.08904, 0.089288, 0.089536, 0.089785, 0.090035, 0.090286, 0.090537,
0.090789, 0.091029, 0.091269, 0.09151, 0.091752, 0.091994, 0.092237,
0.092481, 0.092725, 0.09297, 0.093215, 0.093526, 0.093838, 0.094151,
0.094465, 0.09478, 0.095096, 0.095413, 0.095731, 0.096051, 0.096371,
0.096752, 0.097135, 0.09752, 0.097906, 0.098294, 0.098683, 0.099073,
0.099466, 0.099859, 0.100255, 0.100585, 0.100917, 0.101249, 0.101583,
0.101918, 0.102254, 0.102591, 0.102929, 0.103268, 0.103609, 0.103802,
0.103996, 0.104191, 0.104386, 0.104581, 0.104777, 0.104973, 0.105169,
0.105366, 0.105563, 0.105602, 0.105642, 0.105681, 0.105721, 0.10576,
0.1058, 0.10584, 0.105879, 0.105919, 0.105958, 0.105957, 0.105955,
0.105954, 0.105952, 0.105951, 0.10595)
## Prepare r-hybrid model
fp <- prepare_rhybrid(fp, tsEpidemicStart = 1975.5, rw_start = 2003, rw_trans = 5, rw_dk = 1.0)
## Create r(t) vector for theta inputs
rvec <- create_rvec(theta, fp$rt)
test_that("r-hybrid r(t) returns expected value", {
expect_equal(round(create_rvec(theta, fp$rt), 6), rvec_out)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.