/* Piecewise Linear & Polynomial OLS Overfit */ /* Data from Holton(2003)"Value-at-Risk" */ new; cls; let data[10,2]= 1.1 2.14 1.4 2.60 2.5 1.15 2.7 1.19 3.2 1.88 3.6 1.55 4.1 2.65 4.3 3.80 4.5 4.46 4.9 6.35 ; x=data[.,1]; y=data[.,2]; order={5,1,1}; /* You could try order=1 or order={1,1,1} instead. */ location={1 10, 1 5, 6 10}; call piecewise(y,x,order,location); proc piecewise(y,x,order,location); local n,z,x1,i,j,beta,xx,xs,points,npiece,xp,yp; n=rows(x); if maxc(maxc(location))>n or minc(minc(location))<1; errorlog "ERROR: Location index is out of range."; retp("."); endif; if not location[.,1]