[R-SIG-Finance] seasonal dummy lm equation

Matthieu Stigler matthieu.stigler at gmail.com
Wed Oct 21 08:39:00 CEST 2009


Give you a very "manual" to solve your problem, there are sure more
elegent way to do that.

Please provide completely reproducible code examples:
###data
[see below]
n<-nrow(dummymatrix)

X<-runif(n)
Y<-rnorm(n)
trend<-1:n

###your reg
reg<-lm(Y~ X+ trend+0+ dummymatrix)

###select less significant (from p values)
maxP<-which.max(summary(reg)$coefficients[-c(1,2),4])

#exclude it:
reg2<-lm(Y~ X+ trend+0+ dummymatrix[,-maxP])

There should be better way to handle seasonal dummies, already using
them as factors:
dummies<-factor(rep(1:12, 16))[1:n]
lm(Y~ X+ trend+0+ dummies)

#here if you add an intercept, first dummy will be dropped automatically:
lm(Y~ X+ trend+1+ dummies)


Hope this helps


2009/10/20 karla hernandez villafuerte <karlavhv142 at hotmail.com>:
>
> Dear people:
>
>
>
> I want to use the next seasonal dummy matrix:
>
>
>
> d2=ts(c(1,0,0,0,0,0,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d3= ts(c(0,1,0,0,0,0,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d4= ts(c(0,0,1,0,0,0,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d5= ts(c(0,0,0,1,0,0,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d6= ts(c(0,0,0,0,1,0,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d7= ts(c(0,0,0,0,0,1,0,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d8= ts(c(0,0,0,0,0,0,1,0,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d9= ts(c(0,0,0,0,0,0,0,1,0,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d10= ts(c(0,0,0,0,0,0,0,0,1,0,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d11= ts(c(0,0,0,0,0,0,0,0,0,1,0,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d12=ts(c(0,0,0,0,0,0,0,0,0,0,1,0),start=c(1990,2),end=c(2006,1),frequency=12)
> d1=ts(c(0,0,0,0,0,0,0,0,0,0,0,1),start=c(1990,2),end=c(2006,1),frequency=12)
>
> dummymatrix=cbind(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12)
>
>
>
> in a times series equation:
>
>
>
> lm(Y~ X+ trend+ 0+ dummy, data=dat)
>
>
>
> but I want that the program excludes automatically the dummy which is less significant to explain the behavior of Y.
>
>
>
> I will be very grateful if someone has a idea to help me.
>
>
>
>
>
> Thank you very much!
>
>
>
> Karla Hernández
>
>
>
> _________________________________________________________________
> ¿Te gustaría escuchar la mejor música en internet y gratis? Disfrútala aquí
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list