Closed seananderson closed 7 years ago
predict.rrfield
worked with newdata = model_fit$data
and the only difference between the data coming out of the model fit and the simulated data was that the model fit data was also of class tbl
.
When I wrap newdata
in as.tbl
everything miraculously works. I have no idea why. https://github.com/seananderson/rrfields/commit/110f9c1053c52c455e91c4bf775bcd5776e963a0
I'll test this with subsets of the data as well.
I thought I was going crazy. Model fit comparisons between correctly and incorrectly specified just weren't making sense (the incorrect model was often better). Then occasionally in some scripts they would make sense. Then they would stop working again.
I finally discovered the reason. I think the
predict.rrfield
function is somehow resorting the data ifnewdata
is specified. It works correctly otherwise.There's a simple unit test here that is broken: https://github.com/seananderson/rrfields/blob/bea28dda856bf64afe0d1c187139ac81c412e530/tests/testthat/test-predict.R
The solution isn't obvious to me yet, but I'm still digging into it.