test_that("rout_fitter", { x = c(0, 2^(-4:4)) theta = c(0, 100, log(.5), 2) y = c(99.91, 96.892, 90.782, 79.24, 51.838, 18.849, 7.098, -1.697, 0.278, 1.136) fit1 = rout_fitter(NULL, hill_model, x=x, y=y) fit2 = rout_fitter(c( theta, log(2) ), hill_model, x=x, y=y) expect_true(sum(fit1$outlier.adj)==0) expect_true(sum(fit2$outlier.adj)==0) ii = c(6, 9) y[ii] = hill_model(theta, x[ii]) + 15 fit3 = rout_fitter(c( theta, log(2) ), hill_model, x=x, y=y, Q=0.05) expect_true(sum(fit3$outlier)==2) expect_true(sum(fit3$outlier.adj)==0) fit3 = rout_fitter(c( theta, log(2) ), hill_model, x=x, y=y, Q=0.1) expect_true(sum(fit3$outlier)==2) expect_true(sum(fit3$outlier.adj)==2) ## hill_quad_model theta = c(0, 100, 2, 1, -0.5) ## Model parameters y = c(-3.204, -3.269, 4.488, 41.994, 69.658, 85.627, 90.797, 101.094, 83.925, 72.863) fit1 = rout_fitter(NULL, hill_quad_model, x=x, y=y, Q=0.01 ) expect_true(sum(fit1$outlier.adj)==0) ii = c(3, 7) y[ii] = hill_quad_model(theta, x[ii]) - 30 fit2 = rout_fitter(NULL, hill_quad_model, x=x, y=y, Q=0.1 ) expect_true(sum(fit2$outlier)==2) expect_true(sum(fit2$outlier.adj)==2) })