[R-sig-eco] Changing the reference level of a factor
Marcelino de la Cruz
marcelino.delacruz at upm.es
Tue May 18 15:00:41 CEST 2010
Hi Manuel,
You must assign the releveled factor to something. Try this
nidprop$treatment <- relevel(nidprop$treatment, ref="c")
modelo1 <- lm(hight ~ treatment, data = nidprop)
summary(modelo1)
Cheers,
Marcelino
At 14:11 18/05/2010, Manuel Spínola wrote:
>Dear list members,
>
>I am trying to change the reference level of a
>factor but when I run a model with the lm
>function the new order it does not taking place
>(I still have the old order of the levels).
>
> > relevel(nidprop$treatment, ref="c", data=nidprop)
>[1] a a a a b b b b c c c c
>Levels: c a b
>
> > modelo1 = lm(hight ~ treatment, data = nidprop)
>
> > summary(modelo1)
>
>Call:
>lm(formula = hight ~ treatment, data = nidprop)
>
>Residuals:
> Min 1Q Median 3Q Max
>-1.6052 -1.0626 -0.0950 0.9228 3.0768
>
>Coefficients:
> Estimate Std. Error t value Pr(>|t|)
>(Intercept) 37.9140 0.7368 51.461 1.98e-12 ***
>treatment[T.b] -0.2298 1.0419 -0.221 0.8304
>treatment[T.c] -3.1133 1.0419 -2.988 0.0153 *
>---
>Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
>Residual standard error: 1.474 on 9 degrees of freedom
>Multiple R-squared: 0.552, Adjusted R-squared: 0.4525
>F-statistic: 5.545 on 2 and 9 DF, p-value: 0.02696
>
>
>Any idea why?
>
>Best,
>
>Manuel Spínola
>
>--
>Manuel Spínola, Ph.D.
>Instituto Internacional en Conservación y Manejo de Vida Silvestre
>Universidad Nacional
>Apartado 1350-3000
>Heredia
>COSTA RICA
>mspinola at una.ac.cr
>mspinola10 at gmail.com
>Teléfono: (506) 2277-3598
>Fax: (506) 2237-7036
>
>_______________________________________________
>R-sig-ecology mailing list
>R-sig-ecology at r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
________________________________
Marcelino de la Cruz Rot
Departamento de Biología Vegetal
E.U.T.I. Agrícola
Universidad Politécnica de Madrid
28040-Madrid
Tel.: 91 336 54 35
Fax: 91 336 56 56
marcelino.delacruz at upm.es
_________________________________
More information about the R-sig-ecology
mailing list