# [R] combining two different matrizes

ThomasH thomas.hufnagel1 at gmx.de
Wed Jun 5 23:56:16 CEST 2013

```Hello together,

this is ma first post, so please aplogize me if post this in the wrong
section.

I have problem concerning ma two matrizes.

After a regressione and so on, I got two matrizes

Matrixres contains the results of ma calculation.

Matrixr contains my detiene, which where Aldo used for the regression.

#Datei einlesen

#Aktientitel
alist <- list()
for (a in 2:11){

#Regression
#Länge Gesamtzeit
t <- 243
tx <- t-59

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

#RegressionsVariable
x = residual[i:j,a]
rm = residual[i:j,12]
smb = residual[i:j,13]
hml = residual[i:j,14]
rf = residual[i:j,15]

#Überschussrenditen
ex=x-rf
erm=rm-rf

#Regression
reg <- lm(ex~erm+smb+hml)
reglist[[i]] <- coef(reg)

#Berechnung Residuum
#Residual Berechnung
rx = residual[(j-5):j,a]
rrm = residual[(j-5):j,12]
rsmb = residual[(j-5):j,13]
rhml = residual[(j-5):j,14]
rrf = residual[(j-5):j,15]

rex = rx-rrf
rerm = rrm-rrf

#Berechnung
res <-
sum(rex-(reglist[[i]][2]*rerm+reglist[[i]][3]*rsmb+reglist[[i]][4]*rhml))/sd(rex-(reglist[[i]][2]*rerm+reglist[[i]][3]*rsmb+reglist[[i]][4]*rhml))
reglist[[i]] <- res
}

#Residuen auf alle Aktien
alist[[a]] <- reglist
}

#Matrix mit Residuen
matrixres <- do.call(cbind,alist)

#Spaltennamen/Zeilennamen
s<- names(residual)[2:11]
colnames(matrixres)<-s

#RenditeMatrix
matrixr <- do.call(cbind,residual[60:243,2:11])

Now I want to combines  the two matrizes in the following way:

Under every row of matrixres should stand the row of matrixr for excample:

Matrixres row1
Matrixr row1
Matrixres row2
Matrixr row 2

Can anybody help me? I was working on this problem the whole day, but have
no idea.

Thanks alot
Thomash

--
View this message in context: http://r.789695.n4.nabble.com/combining-two-different-matrizes-tp4668766.html
Sent from the R help mailing list archive at Nabble.com.

```