[R] Testing for significant differences between groups in multiple linear regression
Janka Vanschoenwinkel
janka.vanschoenwinkel at uhasselt.be
Fri Jan 23 10:46:56 CET 2015
Dear R-colleagues,
I am looking for a way to test whether one regression has significant
different coefficients and overall results for 10 groups (grouping variable
is "irr").
*What I have*
The regression is:
Depend = temp + temp² + perc + perc² + conti è split up for multiple groups
of irr
*Dataset = Alldata (real dataset has over 50000 IDs)*
*ID*
*irr *
*(= grouping variable)*
*temp*
*perc*
*conti*
*Depend*
*w*
1
1
10
34
26
8
23
2
1
11
36
27
6
58
3
1
26
57
45
3
76
4
2
23
68
24
2
4
5
2
6
26
8
1
323
6
2
3
17
56
6
45
7
3
17
39
17
5
57
I can obtain the different regression coefficients for the different groups
with the following code (other codes are possible as wel).
datairrigation <- split(Alldata, Alldata$irr)
model.per.irrigation <- lapply(datairrigation, function (x) {
lm(Depend~ temp + temp² + perc + perc² + conti,
weights=w, data = x)
})
OR I can do it manually by splitting all the data in subsets (and then I
also receive the R²…)
*What I don’t have*
However, now I don’t know how to compare those regressions to test whether
they differ significantly over all the groups.
(Preferably, I would like to test the coefficients individually (temp(group
1) = temp(group2)) and the regression as a whole between the groups.)
*Note*
I know that one way to test differences in significance between groups, is
to use dummy variables of that group, in the regression. Yet, this is no
option for my model because it only allows exogenous variables in the
regression (and irrigation is an endogenous variable because the farmer can
decide himself if he irrigates or not).
Thank you very much in advance! I really appreciate your help!
Janka
P Please consider the environment before printing this e-mail
[[alternative HTML version deleted]]
More information about the R-help
mailing list