Hi everyone I need to calculate abnormal returns for different events applying event study methodology. I must create a market model in order to perform the analysis. I apply regression analysis to get OLS estimators. I have a problem to create a linear regression which I could repeat for each column in two different data frames (one with explainatory and one with explaning variables). It means that I want to regress column 1 from first data frame with column 1 from second data frame,, clumn two with column two etc. I tried to use the following code:#x is matrix containing stock returns y is matrix containing market index i<-1:length(x) t[i] <- lapply(t[i], lm(x[,1]~y[,i])) but it is not working. Could anybody help me? Thanks a lot Iza
Sure. Read the Posting Guide, and provide a reproducible example with sample
data.
I suspect the basic idea will be to merge the data frames and then setup the
model to refer to the desired columns.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
"iza.ch1" <iza.ch1 at op.pl> wrote:>Hi everyone
>
>I need to calculate abnormal returns for different events applying
>event study methodology. I must create a market model in order to
>perform the analysis. I apply regression analysis to get OLS
>estimators.
>
>I have a problem to create a linear regression which I could repeat for
>each column in two different data frames (one with explainatory and one
>with explaning variables). It means that I want to regress column 1
>from first data frame with column 1 from second data frame,, clumn two
>with column two etc. I tried to use the following code:#x  is matrix
>containing stock returns
>y is matrix containing market index                           
>i<-1:length(x)
>t[i] <- lapply(t[i], lm(x[,1]~y[,i]))
>
>but it is not working.
>
>Could anybody help me?
>
>Thanks a lot
>
>Iza
>
>______________________________________________
>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.
Hi,
set.seed(28)
dat1<- as.data.frame(matrix(sample(1:20,100,replace=TRUE),ncol=10))
set.seed(49)
dat2<- as.data.frame(matrix(sample(40:80,100,replace=TRUE),ncol=10))
?lapply(seq_len(ncol(dat1)),function(i) {lm(dat2[,i]~dat1[,i])})
A.K.
----- Original Message -----
From: iza.ch1 <iza.ch1 at op.pl>
To: r-help at r-project.org
Cc: 
Sent: Saturday, July 20, 2013 7:55 PM
Subject: [R] Linear regression repeat for each column
Hi everyone
I need to calculate abnormal returns for different events applying event study
methodology. I must create a market model in order to perform the analysis. I
apply regression analysis to get OLS estimators.
I have a problem to create a linear regression which I could repeat for each
column in two different data frames (one with explainatory and one with
explaning variables). It means that I want to regress column 1 from first data
frame with column 1 from second data frame,, clumn two with column two etc. I
tried to use the following code:#x? is matrix containing stock returns
y is matrix containing market index? ? ? ? ? ? ? ? ? ? ? ? ? 
i<-1:length(x)
t[i] <- lapply(t[i], lm(x[,1]~y[,i]))
but it is not working.
Could anybody help me?
Thanks a lot
Iza
______________________________________________
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.