Can anyone explain to me why the following example produces two different smooths. (This is a simulation based on a rather larger real data set)
The only difference in the geom_smooth is the use of splines::ns versus ns
If using R 3.4.3 on windows and ggplot2 version 2.2.1
require(splines)
require(ggplot2)
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$wind = exp(rnorm(nrow(dat), mean=mns[dat$claim+1], sd=sds[dat$claim+1]))
dat = dat[order(dat$wind),]
ggplot(dat, aes(wind,claim))+geom_point()+
geom_smooth(method = "glm",
method.args = list(family = binomial),
formula = y ~ splines::ns(x, df=5))+
geom_smooth(method = "glm",
method.args = list(family = binomial),
formula = y ~ ns(x, df=5))