4
$\begingroup$

I would like to compare the goodness of fit for a regression model fitted to two separate groups (patients and controls).

I want to compare goodness of fit (as opposed to difference in slope). I thought one way of doing this would be comparing the R value of the model in patients vs the value in controls in a Fisher R-to-z comparison.

My question is whether it is more appropriate to use the 'Multiple R-squared' or the 'Adjusted R-squared'. Additionally if the Adjusted R squared is preferred then how would one deal with negative values?

Or please do let me know if the whole approach is wrong headed.

$\endgroup$
4
  • 1
    $\begingroup$ What is your broader goal? $\endgroup$
    – mkt
    Commented Feb 23, 2018 at 11:45
  • $\begingroup$ To determine whether a relationship appears to be present in one group, but not in the other, and ascribe a degree of statistical significance to this $\endgroup$
    – RobMcC
    Commented Feb 23, 2018 at 12:29
  • 2
    $\begingroup$ Note that showing that there is a relationship in one group and not in the other is not a basis for concluding that there is a difference between the two groups (doing so amounts to accepting the null for one of the groups). To answer your question, you need to directly test for an interaction. $\endgroup$
    – dbwilson
    Commented Mar 16, 2018 at 16:02
  • $\begingroup$ Many thanks - I suggested performing an R-to-z in order to address this? $\endgroup$
    – RobMcC
    Commented Mar 17, 2018 at 16:14

2 Answers 2

7
$\begingroup$

Looking at goodness of fit is not a, um, good fit for your actual goal, "to determine whether a relationship appears to be present in one group, but not in the other, and ascribe a degree of statistical significance to this". If there were a relationship in one group but not the other, then the relationship would differ by group. That is an interaction. To test this, fit a model with $X$ and $Y$, an indicator variable for group membership, and an interaction between $X$ and group. The test of that interaction is the first thing you need. In R, the model might look like this:

lm(y~x*group)

You may want to follow that up by testing if the relationship is significant in each of the groups. Since your group variable is a dummy code (0, 1), the 'main effect' of x is a test of the relationship between X and Y in the reference group. The simplest way to get the test of the relationship in the other group is to change the reference level of group, refit the model and then examine the main effect of X again. Here is a simple example, coded in R:

set.seed(1)                                                  # making this reproducible
x     = runif(n=20, min=0, max=10)                           # making x values
group = rep(c("A", "B"), each=10)                            # making the groups
group = factor(group)                                        #  & making it a factor
y     = 5 + 1*x[1:10] + rnorm(10, mean=0, sd=1)              # the y values for A
y     = c(y, 5 + rnorm(10, mean=0, sd=1))                    # adding the y values for B
coef(summary(lm(y~x*group)))                                 # model w/ A as reference level
#               Estimate Std. Error    t value     Pr(>|t|)
# (Intercept)  5.9802513 0.51218827 11.6758849 3.056083e-09
# x            0.7980242 0.08161474  9.7779420 3.750885e-08
# groupB      -0.2107658 0.77806193 -0.2708856 7.899425e-01
# x:groupB    -0.9141179 0.12543254 -7.2877257 1.819064e-06
group = relevel(group, ref="B")                              # changing reference to B
coef(summary(lm(y~x*group)))                                 # the second model
#               Estimate Std. Error    t value     Pr(>|t|)
# (Intercept)  5.7694855 0.58569919  9.8505950 3.385481e-08
# x           -0.1160937 0.09524891 -1.2188456 2.405689e-01
# groupA       0.2107658 0.77806193  0.2708856 7.899425e-01
# x:groupA     0.9141179 0.12543254  7.2877257 1.819064e-06

The p-value for the test of the interaction is the last column, last row in both models. Note that the p-value is the same. The 'main effect' of x is different between the two models, though. That is for the main effect of x in the reference level, which is changed between the two models. It is significant in group A, but not in group B. Be careful, though! You cannot conclude that there is 'no relationship' for group B just because the relationship is not significant.

$\endgroup$
6
  • $\begingroup$ What about an ANOVA with M1 = lm(y ~ group * x) and M2 = lm(y ~ group + I(x * (group == "B")))? Wouldn't that test the OP's hypothesis in one analysis step? $\endgroup$
    – dipetkov
    Commented Mar 14 at 18:54
  • 1
    $\begingroup$ I'm not sure if that's simpler, @dipetkov. I gather the OP has (at least) 3 questions: relationship in A, in B, & do they differ. So they need 3 p-values. I do this via 2 models. You also have 2 models. You can test the relationship in B without releveling & refitting the model, but it's more complicated. I teach how to do it in class, but then I show how you can get the same answer by just releveling & refitting, & students always prefer that ;-). $\endgroup$ Commented Mar 14 at 19:04
  • $\begingroup$ (Trying to explain myself better) I assumed the OP's interest is "To determine whether a relationship appears to be present in one group, but not in the other." That is: x:betaA != 0 & x:betaB == 0. I'm wondering if this (comlpex) hypothesis be expressed with one test. I can see that it can be tested separately with first x:betaA != 0 and then x:betaB == 0. $\endgroup$
    – dipetkov
    Commented Mar 14 at 20:15
  • $\begingroup$ But this is also not trivial: (a) we can't use alpha = 0.05 for both and then claim alpha = 0.05 for the compound hypothesis; (b) Only x:betaB == 0 is the usual null of "parameter = constant". On the other hand, I no longer think that the anova I suggested works for this either. $\endgroup$
    – dipetkov
    Commented Mar 14 at 20:16
  • 1
    $\begingroup$ @dipetkov, I see. I'm not sure if it could be done in a single test. But even if it could, say the answer was 'no', now what? You wouldn't know if that's because the relationships don't differ, or b/c both have a relationship, etc. $\endgroup$ Commented Mar 14 at 20:44
0
$\begingroup$

If you have exactly the same number of estimates, I believe both $R^2$ and adjusted $R^2$ would produce similar results. To my knowledge, the adjusted $R^2$ penalizes the inflation of the $R^2$ that comes from increasing the number of predictors. Given the two equations are equivalent, you should be fine by going with the regular $R^2$.

**** OLDER RESPONSE **** Sorry, I misunderstood the question. Disregard the response below:

The question is a bit vague. I'm assuming you are using R. Then,

    mod1 <- lm(y ~ x1 + x2 + x3, data=patients)
    mod2 <- lm(y ~ x1 + x2 + x3, data=controls)
    anova(mod1, mod2)

I hope this helps.

$\endgroup$
6
  • 2
    $\begingroup$ Could you explain how this answers the question about goodness of fit? $\endgroup$
    – whuber
    Commented Mar 16, 2018 at 15:47
  • $\begingroup$ Maybe I misunderstood @RobMcC 's question, but it seems to me that he needs to know if the equations are different. It is very hard to evaluate without a more detailed example. $\endgroup$ Commented Mar 16, 2018 at 15:56
  • 1
    $\begingroup$ There's a more fundamental issue here concerning what an ANOVA of two models using two different sets of data even means, how to interpret it, and how it might be related to the question. I am trying to suggest that your answer looks problematic and requires further explanation, regardless of how you might understand the question. $\endgroup$
    – whuber
    Commented Mar 16, 2018 at 16:37
  • $\begingroup$ Many thanks for your answer, but isn't the anova here effectively examining whether there is a difference in slope as opposed to a difference in goodness of fit? $\endgroup$
    – RobMcC
    Commented Mar 17, 2018 at 16:13
  • $\begingroup$ @RobMcC: you normally test the difference of F using anova(). For example, if you had mod1 with x1 and mod2 with x2 and x3, the anova() would test the hypothesis that either x2 or x3 are significantly different from zero: mod1 <- lm(y ~ x1, data=p) mod2 <- lm(y ~ x1+x2+x3. data=p) $\endgroup$ Commented Mar 17, 2018 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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