alexpghayes / modelling-in-r

an initial attempt to describe a grammar of modelling for r
https://alexpghayes.github.io/modelling-in-r/
3 stars 0 forks source link

Formulas don't necessarily define one-to-one maps #1

Open alexpghayes opened 6 years ago

alexpghayes commented 6 years ago
mod <- lm(mpg ~ splines::ns(hp, 2), mtcars)
head(predict(mod, mtcars))
#>         Mazda RX4     Mazda RX4 Wag        Datsun 710    Hornet 4 Drive 
#>          21.84731          21.84731          24.23134          21.84731 
#> Hornet Sportabout           Valiant 
#>          15.81473          22.52025
predict(mod, head(mtcars))
#>         Mazda RX4     Mazda RX4 Wag        Datsun 710    Hornet 4 Drive 
#>          21.47551          21.47551          30.71007          21.47551 
#> Hornet Sportabout           Valiant 
#>          15.50542          23.90986