Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Martin Maechler
> 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 >

Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Hadley Wickham
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

Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Duncan Murdoch
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)

Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Joris Meys
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 =

Re: [Rd] predict.glm returns different results for the same model

2018-04-27 Thread Avraham Adler
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

[Rd] predict.glm returns different results for the same model

2018-04-27 Thread Hadley Wickham
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