Displaying 1 result from an estimated 1 matches for "spline_df".
Did you mean:
spline_dev
2008 Feb 25
0
logLik calculation in gls (nlme)
...(.)),
data=dat)
expdev = -2*logLik(g1)
## Fitting the true model recovers
## the true parameters nicely:
coef(g1)
## Fit a series of splines:
sfit <- function(d) {
form <- bquote(y~ns(x,df=.(d)))
gls(eval(form),
weights=varPower(form=~fitted(.)),
data=dat)
}
spline_df = c(3:15,20,25,40)
spline_list = lapply(as.list(spline_df),sfit)
## calculate deviances:
spline_dev = -2*sapply(spline_list,logLik)
plot(spline_df,spline_dev,type="b",
ylim=range(c(expdev,spline_dev)))
abline(h=expdev,col=2)