0

I´ve a question concerning the a regression analysis in r.

#Datei einlesen
residual <- read.csv2("E:***Input-R_Renditen.csv",header=TRUE,sep=";")

#Firmen
alist <- list()
for (a in 2:11){
    #Länge Gesamtzeit
t <- 243
tx <- t-59

#Länge Regression
reglist <- list()
for (i in 1:tx){
    j <- i+59
    c <- i+54

    #RegressionsVariable
    r <- residual[i:j,a]
    rm <- residual[i:j,12]
    smb <- residual[i:j,13]
    hml <- residual[i:j,14]
    rf <- residual[i:j,15]

    #Überschussrendite
    er <- r-rf
    erm <- rm-rf

    #Regression
    reg <- lm(er~erm+smb+hml)
    reglist[[i]] <- coef(reg)
    }
alist[[a]] <- reglist
}

I want to insert a dummy/categorical variable into the regression. Let me call the dummy "d", d should have the the value 1 for i to j-6 and the value 0 for j-5 to j.

I cannot include this in my table, which is read, because for every new regression i, the dummy differs. I tried it with ifelse, but I got the error, that the lengths of d differs from others for the regression.

4

0 回答 0