> Duncan Murdoch
> on Fri, 27 Apr 2018 10:28:16 -0400 writes:
> On 27/04/2018 9:25 AM, Hadley Wickham wrote:
>> Hi all,
>>
>> Very surprising (to me!) and mystifying result from predict.glm(): the
>> predictions vary depending on whether or not I use ns() or
>
On Fri, Apr 27, 2018 at 7:28 AM, Duncan Murdoch
wrote:
> On 27/04/2018 9:25 AM, Hadley Wickham wrote:
>>
>> Hi all,
>>
>> Very surprising (to me!) and mystifying result from predict.glm(): the
>> predictions vary depending on whether or not I use ns() or
>> splines::ns(). Reprex follows: >
>> libr
On 27/04/2018 9:25 AM, Hadley Wickham wrote:
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows: >
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5)
Hi Hadley,
This is related to how the terms are constructed. If you look at terms(m1)
versus terms(m2), you see that in the case of m1 the knots are added to the
attribute predvars. Contrary, when using splines::ns() this doesn't happen.
Compare:
mf <- model.frame(claim ~ ns(wind, df = 5), data =
Can’t copy from my computer as gmail is blocked at work but if it helps,
the “predvars” attribute if the terms object is not the same.
Avi
On Fri, Apr 27, 2018 at 9:25 AM Hadley Wickham wrote:
> Hi all,
>
> Very surprising (to me!) and mystifying result from predict.glm(): the
> predictions var
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows:
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5))
mns <- c(3.4, 3.6)
sds <- c(0.24, 0.35)
dat$wi