I want to fit a linear model to electricity prices with a seasonal dummy. So "DK.days" contains the days of every year for a period of 10 years.
head(DK.days)
[1] "2007-01-01" "2007-01-02" "2007-01-03" "2007-01-04" "2007-01-05" "2007-01-06"
This is the rest of the code.
month <- as.numeric(format(DK.days, "%m"))
MD <- t(sapply(month, "==", c(1:12,0)))+0
MD <- MD[,-13]
dimnames(MD) <- list(NULL, c("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Noe", "Dec"))
> head(MD)
Jan Feb Mar Apr May June July Aug Sep Oct Noe Dec
[1,] 1 0 0 0 0 0 0 0 0 0 0 0
[2,] 1 0 0 0 0 0 0 0 0 0 0 0
So, I've created a monthly dummy and I want to transform the matrix to a seasonal matrix. This is how the seasons should be defined:
month.list <- list(c(3,4,5), c(6,7,8), c(9,10,11), c(12,1,2))
I have thought of merging the columns of the months, but I have struggled so far. I would be really thankful, if someone could help.