0
$\begingroup$

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 ?

$\endgroup$
2
$\begingroup$

The two models cannot be compared using anova() because the response variable is different (y vs. logy).

There are similar questions in the cloud: How to use anova for two models comparison?

You can compare:

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

anova(model1, model2) should tell if the model with the second order polynomial differ from the simple linear model.

$\endgroup$
2
  • $\begingroup$ this does not answer my question. The question did not refer to a computer science perspective, but a statistical perspective. In my humble opinion, your answer is a mechanical answer without the understanding of statistics. I know that the response variables are different ... but the root variable is still y and that should not stop me from comparing the two models. $\endgroup$
    – Indian
    Jul 7 '16 at 0:11
  • $\begingroup$ You are trying to use a statistical model to compare the two models using anova(). It just don't work if presumptions are not met. You have to find a way different than anova(). $\endgroup$
    – tmalves
    Jul 7 '16 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.