Skip to main content
edited tags
Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
Source Link

Comparing two models through ANOVA with different types of functions

See this file here: Decay.TXT.

I first tried to fit the logarithmic model first

dec = read.table('decay.txt', header=T)
attach(dec)
logy <- log(y)
model1 <- lm(logy ~ x)

And now I try to fit a quadratic model into the data:

model2 <- lm(y ~ x + I(x^2))

I now attempt to get the r^2 (r-squared values) of the models.

(rsq1 <- summary(model1)$r.squared)
[1] 0.8307964

(rsq2 <- summary(model2)$r.squared)
[1] 0.9079788

Obviously as seen, here the coefficient of determination of the quadratic regression model is better than the exponential regression model (for this dataset).

However, the critical appraisal of these models says otherwise. For the exponential model, we see that: Exponential regression

And for the quadratic polynomial model, we see that: Quadratic regression

The QQ Plot reveals something strange with the residuals for the Quadratic regression i.e "Not Normally Distributed".

Now I am trying to use ANOVA, to compare the two models. And I type:

anova(model1, model2)  

and there is an error regarding the missing variable y. What is the right way to conduct the anova ?