|
| 1 | +test_that("fit_power_law() works", { |
| 2 | + # g <- sample_pa(100) # increase this number to have a better estimate |
| 3 | + # d <- degree(g, mode = "in") |
| 4 | + d <- c( |
| 5 | + 9, 3, 8, 1, 10, 4, 8, 0, 4, 4, 5, 2, 2, 7, 2, 0, 0, 0, 1, 0, 5, 0, 1, 2, 0, 0, |
| 6 | + 1, 3, 0, 1, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, |
| 7 | + 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, |
| 8 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 |
| 9 | + ) |
| 10 | + |
| 11 | + expected <- list( |
| 12 | + continuous = FALSE, |
| 13 | + alpha = 1.9113310272735056, |
| 14 | + xmin = 1, |
| 15 | + logLik = -65.06453615610745, |
| 16 | + KS.stat = 0.07720553650317852 |
| 17 | + ) |
| 18 | + fit <- fit_power_law(d) |
| 19 | + |
| 20 | + expect_equal(fit, expected) |
| 21 | + |
| 22 | + set.seed(20241017) |
| 23 | + expected_p <- 0.2308 |
| 24 | + fit <- fit_power_law(d, p.value = TRUE) |
| 25 | + |
| 26 | + expect_equal(fit[names(fit) != "KS.p"], expected) |
| 27 | + expect_equal(fit$KS.p, expected_p) |
| 28 | +}) |
0 commit comments