[R] A question on dummy variable

Bert Gunter gunter.berton at gene.com
Tue Jan 11 22:10:11 CET 2011


R does not use dummy variables. Models and contrasts are specified in
more natural, model formula based ways. See

?arima

 and/or CRAN's Time Series task view for numerous packages that fit time series.

-- Bert

On Tue, Jan 11, 2011 at 12:18 PM, Christofer Bogaso
<bogaso.christofer at gmail.com> wrote:
> Dear all, I would like to ask one question related to statistics, for
> specifically on defining dummy variables. As of now, I have come across 3
> different kind of dummy variables (assuming I am working with Seasonal
> dummy, and number of season is 4):
>
>> dummy1 <- diag(4)
>> for(i in 1:3) dummy1 <- rbind(dummy1, diag(4))
>> dummy1 <- dummy1[,-4]
>>
>> dummy2 <- dummy1
>> dummy2[dummy2 == 0] = -1/(4-1)
>>
>> dummy3 <- dummy1 - 1/4
>>
>> head(dummy1)
>     [,1] [,2] [,3]
> [1,]    1    0    0
> [2,]    0    1    0
> [3,]    0    0    1
> [4,]    0    0    0
> [5,]    1    0    0
> [6,]    0    1    0
>> head(dummy2)
>           [,1]       [,2]       [,3]
> [1,]  1.0000000 -0.3333333 -0.3333333
> [2,] -0.3333333  1.0000000 -0.3333333
> [3,] -0.3333333 -0.3333333  1.0000000
> [4,] -0.3333333 -0.3333333 -0.3333333
> [5,]  1.0000000 -0.3333333 -0.3333333
> [6,] -0.3333333  1.0000000 -0.3333333
>> head(dummy3)
>      [,1]  [,2]  [,3]
> [1,]  0.75 -0.25 -0.25
> [2,] -0.25  0.75 -0.25
> [3,] -0.25 -0.25  0.75
> [4,] -0.25 -0.25 -0.25
> [5,]  0.75 -0.25 -0.25
> [6,] -0.25  0.75 -0.25
> Now I want to know which type of dummy definition is called Centered dummy
> and why it is called so? Is it equivalent to use any of the above
> definitions (atleast 2nd and 3rd?) It would really be very helpful if
> somebody point any suggestion and clarification.
>
> Thanks and regards,
>
>        [[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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml



More information about the R-help mailing list