[R] Test individual slope for each factor level in ANCOVA

li li hannah.hlx at gmail.com
Thu Mar 16 02:43:55 CET 2017


Hi all,
   Consider the data set where there are a continuous response variable, a
continuous predictor "weeks" and a categorical variable "region" with five
levels "a", "b", "c",
"d", "e".
  I fit the ANCOVA model as follows. Here the reference level is region "a"
and there are 4 dummy variables. The interaction terms (in red below)
represent the slope
difference between each region and  the baseline region "a" and the
corresponding p-value is for testing whether this slope difference is zero.
Is there a way to directly test whether the slope corresponding to each
individual factor level is 0 or not, instead of testing the slope
difference from the baseline level?
  Thanks very much.
      Hanna






> mod <- lm(response ~ weeks*region,data)> summary(mod)
Call:
lm(formula = response ~ weeks * region, data = data)

Residuals:
     Min       1Q   Median       3Q      Max
-0.19228 -0.07433 -0.01283  0.04439  0.24544

Coefficients:
                Estimate Std. Error t value Pr(>|t|)
(Intercept)    1.2105556  0.0954567  12.682  1.2e-14 ***
weeks         -0.0213333  0.0147293  -1.448    0.156
regionb       -0.0257778  0.1349962  -0.191    0.850
regionc       -0.0344444  0.1349962  -0.255    0.800
regiond       -0.0754444  0.1349962  -0.559    0.580
regione       -0.1482222  0.1349962  -1.098    0.280    weeks:regionb
-0.0007222  0.0208304  -0.035    0.973
weeks:regionc -0.0017778  0.0208304  -0.085    0.932
weeks:regiond  0.0030000  0.0208304   0.144    0.886
weeks:regione  0.0301667  0.0208304   1.448    0.156    ---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.1082 on 35 degrees of freedom
Multiple R-squared:  0.2678,	Adjusted R-squared:  0.07946
F-statistic: 1.422 on 9 and 35 DF,  p-value: 0.2165

	[[alternative HTML version deleted]]



More information about the R-help mailing list