I wonder if there is any tool to compare 2 regression models on the same sample pool. In general more terms you put into the model the closer the fit, but you risk over fitting. For example:
>> mdl=fitglm(FitZV,FitDataV,'linear')mdl = Generalized linear regression model: y ~ 1 + x1 Distribution = NormalEstimated Coefficients: Estimate SE tStat pValue ________ __________ _______ ______ (Intercept) 81.101 0.0085111 9528.9 0 x1 -0.22506 0.00058189 -386.77 0 9638 observations, 9636 error degrees of freedomEstimated Dispersion: 0.698F-statistic vs. constant model: 1.5e+05, p-value = 0>> mdl2=fitglm(FitZV,FitDataV,'purequadratic')mdl2 = Generalized linear regression model: y ~ 1 + x1 + x1^2 Distribution = NormalEstimated Coefficients: Estimate SE tStat pValue ___________ __________ _______ __________ (Intercept) 81.286 0.012269 6625.6 0 x1 -0.22447 0.00057029 -393.6 0 x1^2 -0.00086632 4.2147e-05 -20.555 6.3993e-929638 observations, 9635 error degrees of freedomEstimated Dispersion: 0.668F-statistic vs. constant model: 7.83e+04, p-value = 0
Both mdl and mdl2 are statically better than a constant model, but does mdl2 explain the dataset significantly better than mdl (or the oppsite)? From what I have found devianceTest only test the model to constant, but couldn't find a function to compare 2 models? If anyone can point me to the right direction that would be appreciated.
Best Answer