Closed rpruim closed 6 years ago
Looks like mod_eval()
is being used to get the results of the model. This returns a data frame. What is needed is a vector of just the results.
I'm writing a wrapper called mod_output()
to extract just this vector from the data frame.
This seems to have fixed the immediate error
library(mosaicModel)
#> Loading required package: mosaicCore
#> Loading required package: splines
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:mosaicCore':
#>
#> count, tally
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
mtcars <-
mtcars %>%
mutate(transmission = ifelse(am, "manual", "automatic"))
fuel_mod_2 <- lm(mpg ~ ns(hp, 2) * transmission, data = mtcars)
mod_error(fuel_mod_2)
#> Warning in mod_error(fuel_mod_2): Calculating error from training data.
#> mse
#> 5.915142
Created on 2018-06-18 by the reprex package (v0.2.0).
I've reverted a bit, renamed mod_eval_fun()
to mod_output()
as per #13. See #15 for a decision that still needs to be made. For now, a 1-column data frame is converted to a vector inside mod_error()
so that the error functions can be correctly evaluated.
Still need to investigate the cause.
Created on 2018-06-18 by the reprex package (v0.2.0).