[R] interpret significance from the contr.poly() function
Ista Zahn
izahn at psych.rochester.edu
Thu Feb 3 15:25:17 CET 2011
By fitting some kind of model. contr.poly doesn't fit a model or test
significance, it just sets contrasts. Here is an example
data(mtcars)
> mtcars$carb <- factor(mtcars$carb)
> contrasts(mtcars$carb) <- contr.poly(n=levels(mtcars$carb))
> contrasts(mtcars$carb)
.L .Q .C ^4 ^5
1 -0.5976143 0.5455447 -0.3726780 0.1889822 -0.06299408
2 -0.3585686 -0.1091089 0.5217492 -0.5669467 0.31497039
3 -0.1195229 -0.4364358 0.2981424 0.3779645 -0.62994079
4 0.1195229 -0.4364358 -0.2981424 0.3779645 0.62994079
6 0.3585686 -0.1091089 -0.5217492 -0.5669467 -0.31497039
8 0.5976143 0.5455447 0.3726780 0.1889822 0.06299408
> mt.mod <- lm(mpg ~ carb, data=mtcars)
> summary(mt.mod)
Call:
lm(formula = mpg ~ carb, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-7.243 -3.325 0.000 2.360 8.557
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 19.0888 1.3373 14.274 8.18e-14 ***
carb.L -7.2101 3.6566 -1.972 0.0594 .
carb.Q 3.4101 3.2378 1.053 0.3019
carb.C -2.2938 3.4567 -0.664 0.5128
carb^4 -4.1155 3.3132 -1.242 0.2253
carb^5 -0.1224 2.6213 -0.047 0.9631
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.905 on 26 degrees of freedom
Multiple R-squared: 0.4445, Adjusted R-squared: 0.3377
F-statistic: 4.161 on 5 and 26 DF, p-value: 0.006546
Best,
Ista
On Thu, Feb 3, 2011 at 8:36 AM, Asan Ramzan <asanramzan at yahoo.com> wrote:
> Hello R-help
> I don’t know how to interpret significance from the contr.poly() function . From
> the example below
> : how can I tell if data has a significant Linear/quadratic/cubic trend?
>> contr.poly(4, c(1,2,4,8))
> .L .Q .C
> [1,] -0.51287764 0.5296271 -0.45436947
> [2,] -0.32637668 -0.1059254 0.79514657
> [3,] 0.04662524 -0.7679594 -0.39757328
> [4,] 0.79262909 0.3442576 0.05679618
>>
>> diff(contr.poly(4, c(1,2,4,8))[,1])
> [1] 0.1865010 0.3730019 0.7460038
> Thanks
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org
More information about the R-help
mailing list