Hi everybody, I would like to compare using the Akaike Information Criteria (AIC) a quadratic model and a piecewise fitted model. Is it correct to use AIC to compare this models with such a different structure? Thanks in advance Angel # A simple example a<-1 b<-2 xx<-seq(-15,15,length=50) # Generate sequence of xs yy<- 2 + 1.2*xx -0.2*xx^2 + runif(50, 0,8) #add some noise ## FIT models lmXX<-lm(yy~xx) # Fit linear model cuad<-lm(yy~xx+I(xx^2)) # Fit quadratic model require(quantreg) segXX<-segmented(lmXX,seg.Z=~xx,psi=list(xx=5)) # Fit piecewise model ## Visualize results plot(xx,yy) plot.segmented(segXX,add=T) lines(xx,coef(cuad)[1]+coef(cuad)[2]*xx + coef(cuad)[3]*xx^2,col="blue") c(AIC_cuadratic=AIC(cuad),AIC_segmented=AIC(segXX)) # Obviously AIC for the cuadratic model is lower than piecewise, so I would chose this model over a piecewise fit in this case. But is the use of AIC correct? [[alternative HTML version deleted]]