I examine temperature related mortality using dlnm package in R. I want to interpret lag effect at specific temperatures using this code:
#crossbasis matrix
cb<-crossbasis(data$Temperature,lag=21,argvar=list(fun="ns", knots=quantile(data$Temperature,c(10,75,90)/100,na.rm=T)), arglag=list(knots=logknots(21,3)))
#model model<-glm(mortality ~ cb + ns(Time,df=8*11) + (DayOfTheWeek), data, family=quasipoisson)
cen<-25.4 #centering value for predictions
#predictions pred<-crosspred(cb,model,by=0.1,cen=cen, cumul=TRUE)
If I run summary of pred I get this:
PREDICTIONS: values: 418 centered at: 25.4 range: -7.6 , 34.1 lag: 0 21 exponentiated: yes cumulative: yes
MODEL: parameters: 20 class: glm lm link: log
Then I try to plot:
plot(pred, "slices", var=1.8, col=2, pch=19, ylab="RR", xlab="Lag (days)")
But I get this error message:
Error in lines.crosspred(pred, "slices", var = 1.8: 'var' must match values used for prediction.
I can't figure out what I am doing wrong. I would really appreciate any help.