Skip to content
Prev 327558 / 398502 Next

linear fit function with NA values

Hi

Thanks for your hints. I would like to describe my problem better and give an examle of the data that I use.

I conduct the event study and I need to create abnormal returns for the daily stock prices. I have for each stock returns from time period of 8 years. For some days I don't have the data for many reasons. in excel file they are just empty cells but I convert my data into 'zoo' and then it is transformed into NA. I get something like this

return


       ATI        AMU
-1   0.734     9.003
0    0.999     2.001
1    3.097     -1.003
2        NA        NA
3        NA     3.541

median
      ATI        AMU
-1   3.224     -2.003
0    2.999     -1.301
1    1.3        -1.003
2    4.000     2.442
3       -10     4.511

I want to regress first column return with first column median and second column return with second column median. when I do 
OLS<-lapply(seq_len(ncol(return)),function(i) {lm(return[,i]~median[,i])})
I get an error message. I would like my function to omit the NAs and for example for ATI returns to take into account only the values for -1,0,1 and regress it against the same values from ATI in median which means it would also take only (3.224, 2.999, 1.3)

Is it possible to do it?

Thanks a lot 

W dniu 2013-07-27 17:33:30 u?ytkownik arun <smartpink111 at yahoo.com> napisa?: