Closed josherrickson closed 7 months ago
Adam, this task is something we're looking to address between now and mid-May.
Josh, it strikes me that a reasonable starter regression test would be just to adapt robustbase's regression tests of their vcov calcs for poisson and/ro binomial
glms, L25, L77, L84 etc in their file tests/glmrob-1.R
. (They're using base R testing, so it's just checks to see that the result matches what's in the reference file.) Given that Adam has essentially just adapted their calculations to the sandwich
package framework. Would you agree?
Also, are there devtools
functions for assessing which lines are being hit in tests, or would you recommend something else? (If Adam already knows the answer to this, it'll still be news to me.
@xinhew0708, Josh's answers will be relevant to testing design branch functions as well.
Coverage is checked via the covr
package. If you run covr::report(file = 'coverage.html', browse = TRUE)
it will show you coverage; clicking on any file will show you line-by-line coverage.
(It generates a bunch of library stuff which is properly on .gitignore and I'd rather not pollute the repo, so I don't want to just upload my version of the results.)
I added some real basic tests (just making sure they returned matrices). @adamSales feel free to add more.
Here's an updated table.
File | Lines | Hits | Misses | Partials | Complexity | Coverage |
---|---|---|---|---|---|---|
R/propertee_package.R | 12 | 2 | 0 | 2 | 0 | 0.00% |
R/expand.model.frame.DA.R | 95 | 50 | 26 | 24 | 7 | 52.00% |
R/cov_adj.R | 114 | 50 | 44 | 6 | 207 | 88.00% |
R/lmrob_methods.R | 116 | 64 | 58 | 6 | 5 | 90.62% |
R/get_data_from_model.R | 210 | 89 | 81 | 8 | 3853 | 91.01% |
R/SandwichLayer.R | 309 | 121 | 112 | 9 | 203 | 92.56% |
R/glmrobMethods.R | 105 | 52 | 49 | 3 | 2 | 94.23% |
R/get_design.R | 147 | 67 | 65 | 2 | 572 | 97.01% |
R/as.lmitt.R | 195 | 80 | 78 | 2 | 203 | 97.50% |
R/dtable.R | 145 | 51 | 50 | 1 | 43 | 98.04% |
R/Design.R | 609 | 214 | 212 | 2 | 338 | 99.07% |
I'm confortable with this level of coverage from my end - the rest of the uncovered lines can't/don't need to be covered. (It's primarily trailing else
which can never be hit. The propertee_package.R file can't be tested (as far as I know) as it's just setting options. expand.model.frame.DA.R has a version check, so it's only ever gonna be half-covered depending on the R version.)
Leaving this open in case @adamSales wants to expand any testing, or @jwasserman2 wants to take a pass at SandwichLayer. Feel free to unassign yourselves once those are done.
Added tests to SandwichLayer and cov_adj in #166
Terrific. I'm gonna call this good enough!
I'll go through most of these. @adamSales Can you generate some basic tests for the glmrobMethods file? Mostly just try to hit each line of code once, as regression tests. I'm happy to place the tests into the appropriate context if you want to just write some testthat code in a temp file.