Compare two linear regressions each modeling a different correlation

16 views
Skip to first unread message

Christoph Ruehlemann

unread,
Jun 12, 2023, 3:10:06 AM6/12/23
to statforli...@googlegroups.com
Hi All,

I'm uncertain how to establish the difference, if any, of two linear models each representing a different correlation. Consider, for example, this toy data, where z is the grouping variable:

df <- data.frame(
  x = c(1:10, 1:10),
  y = c(1,2,3,4,5,2,3,4,6,8,
        1,2,1,3,1,4,2,3,1,5),
  z = c(rep("A",10), rep("B",10))
)

The two models in questions are:

lm1 <- lm(df$y[df$z=="A"] ~ df$x[df$z=="A"])
lm2 <- lm(df$y[df$z=="B"] ~ df$x[df$z=="B"])

I seem to know that anova can be used to determine whether two models representing the same data are different:

anova(lm1, lm2)
Analysis of Variance Table

Response: df$y[df$z == "A"]
                  Df Sum Sq Mean Sq F value   Pr(>F)   
df$x[df$z == "A"]  1 24.546 24.5455  13.043 0.006866 **
Residuals          8 15.055  1.8818                    
---
Signif. codes:  0***0.001**0.01*0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In anova.lmlist(object, ...) :
  models with response ‘"df$y[df$z == \"B\"]"’ removed because response differs from model 1

But can anova be used to see if two correlations of essentially different data are significantly different? Are there alternative and better ways?


Many thanks in advance

Christoph


--
Albert-Ludwigs-Universität Freiburg
Projekt-Leiter DFG-Forschungsprojekt "Multimodale Turn-Abschlusssignale"

ἰχθύς
Reply all
Reply to author
Forward
0 new messages