Constant fitted.value
jclchan opened this issue · 9 comments
After fixing interruptions by browser(), polyfit() always generate constant fitted.values for all observations. Furthermore, the degree in getPoly() was always 1, even I set the deg to be non-1 value. Can you take a look? Thanks!
========================
library("polyreg")
model <- polyFit(cbind(train$x, train$y), deg=4)
for getting the adjusted r-square
library("rsq")
rsq(model$fit)
Output:
getPoly time: 0.023 0.001 0.024 0 0
lm() time: 0.002 0 0.002 0 0
Length Class Mode
xy 11358 -none- numeric
degree 1 -none- numeric
maxInteractDeg 1 -none- numeric
use 1 -none- character
poly.xy 1 data.frame list
fit 11 lm list
PCA 0 -none- NULL
pca.portion 1 -none- numeric
pca.xy 0 -none- NULL
pcaCol 1 -none- numeric
pcaLocation 1 -none- character
glmMethod 0 -none- NULL
classProblem 1 -none- logical
classes 1 -none- logical
[1] 0
Fixed just now, within the last minute. Sorry for the error.
I am watching this repo for a while now and I think it's an interesting project. What do you think about adding unit tests? I might be able to help you to add a few, high-level tests, e.g. using testthat
and travis
for continuous integration.
Actually, I am not a fan of Travis. We have it on our partools package, currently disabled. There are two many things that are long-running, require graphics and so on for this to be practical.
But yes, creating a tests/ directory is on my TODO list. The package has grown in size and complexity to the point that something like this is needed. Maybe it is Travis; we'll have to see.
For now, though, we are busy getting the package ready for CRAN. The documentation, for instance, is woefully incomplete right now, and this must be remedied.
Announcement coming soon!
Well up to you whether you want to add tests before or after the release.
incomplete but have started posting some tests here: https://github.com/matloff/polyreg/blob/master/unit_tests/polyreg_tests.md
just added those, loosely organized by the comments in the code
For example
usethis::use_testthat()
to initiate testthat tesing.usethis::use_test("general")
to create a test file calledgeneral.R
.- Modify the file, eg like this:
testthat::expect_equal_to_reference(some_fun(), "test-object")
The first time you call testthat::expect_equal_to_reference()
, the reference value is created. The file needs to be added to version control because it will be overwritten by default (you will get a warning) if you execute the test again and the result changes. If you don't want this, you can set update = FALSE
and the test will fail every time.
Then, you can just use devtools::test()
with Cmd + Shift + T in RStudio and you get a nice output in the console and see which tests fail, warn and pass. Here's an example from the styler package.
Fixed just now, within the last minute. Sorry for the error.
Thanks a lot!