hohenTp<- read.table("C:/CLIM/HohenT.txt",header=T) ### attach(hohenTp) #--------------------------------------------------------------- polypre<- function(Y,n,x1,x2,x3,x4,tst){ polpr<- 1:(n+1) #vector of dim n+1 polpr[1:tst]<- mean(Y[1:tst]) for (t in tst:n) {poly<-lm(Y[1:t]~x1[1:t]+x2[1:t]+x3[1:t]+x4[1:t]) b<- poly$coefficients #$b vector of dim 5 t1<- t+1 polpr[t1]<-b[1]+b[2]*x1[t1]+b[3]*x2[t1]+b[4]*x3[t1]+b[5]*x4[t1] } return(polpr) } #----Preparing the input of function polypre-------------------- n<- length(Year); tst<- trunc(n/5); ts1<- tst+1 Y<-Tyear/100 x1<- 1:(n+1)-n/2; x2<-x1*x1; x3<-x2*x1; x4<-x2*x2 Ypred<- polypre(Y,n,x1,x2,x3,x4,tst) "Poly_t-prediction last decade"; Ypred[(n-9):n] Ypre<- Ypred[ts1:n]; Yres<- Y[ts1:n]-Ypre; MSQ<- mean(Yres*Yres) c("stdRes"=sqrt(var(Yres)), "MSQ"=MSQ,"rootMSQ"=sqrt(MSQ)) rm(list=objects()) ###