[R] Generating abnormal returns in R
drsenne
dr_senne at pandora.be
Sat Mar 10 18:46:51 CET 2012
Hello
This is my first post on this forum and I hope someone can help me out.
I have a datafile (weeklyR) with returns of +- 100 companies.
I acquired this computing the following code:
library("tseries");
tickers = c("GSPC" , "BP" , "TOT" , "ENI.MI" , "VOW.BE" , "CS.PA" ,
"DAI.DE" , "ALV.DE" , "EOAN.DE" , "CA.PA" , "G.MI" , "DE" , "EXR.MI" ,
"MUV2.BE" , "UG.PA" , "PRU.L", "VOD.L" , "DPB.BE" , "REP.MC" , "RWE.BE" ,
"AGN.AS" , "FTE.PA" , "EAD" , "LGEN.L" , "CNP.PA" , "ULVR.L" , "TKA.BE" ,
"RIO.L" , "NOK" , "SGO.PA" , "RNO.PA" , "VIE.PA" , "BAYN.DE" , "SAN.PA" ,
"DG.PA" , "SSE.L" , "GSK.L" , "EN.PA" , "LYB" , "MLSNP.PA" , "IBE.MC" ,
"EURS.PA" , "AH.AS" , "VIV.PA" , "TIT.MI" , "VOLV-B.ST" , "ABI.BR" ,
"LHA.DE" , "OML.L" , "CNA.L" , "CON.DE" , "PHG" , "AZN.L" , "SBRY.L" ,
"BA.L" , "BT-A.L" , "AF.PA" , "430021.VI" , "SL.L" , "ERIC-A.ST" , "CDI.PA"
, "AAL.L" , "ALO.PA" , "DELB.BR" , "HOT.BE" , "GAS.MC" , "SU.PA" , "OR.PA" ,
"FNC.MI" , "MRW.L" , "MAP.MC" , "ML.PA" , "IMT.L" , "EBK.DE" , "PP.PA" ,
"ACN" , "BTI" , "CRG.IR" , "CPG.L" , "BN.PA" , "NG.L" , "T7L.BE" , "HEIA.AS"
, "ACS.MC" , "LG.PA" , "STAN.L" , "ALU.PA" , "FRE.MU" , "SW.PA" , "WOS.L" ,
"AKZA.AS" , "HEN.MU")
for( series in tickers ){
print(series)
close <-
get.hist.quote(instrument=series,retclass="zoo",quote="AdjClose",compression="d",
start="2000-1-1", end="2011-12-31",quiet=TRUE)
if(series==tickers[1]){ pricedata = close }else{ pricedata = merge(
pricedata , close ) }
}
colnames(pricedata) = tickers
# Avoid a missing because of trade halt for that stock
pricedata = na.approx(pricedata)
weeklyR = diff(log(pricedata))
time(weeklyR) = as.Date(time(weeklyR))
print(weeklyR)
save(weeklyR , file = "weeklyR.Rdata")
write.zoo(weeklyR,file="weeklyR.csv",quote=T,sep=",", na = "NA", dec = "." ,
row.names = F,col.names = T)
Now I need to make a market model in R so i can generate abnormal returns
from these stocks. As market index I would like to use the GSPC. I also need
to consider abnormal returns calculated over a sixty-trading-day window.
Can this be done in R? Is it difficult to write this code?
Any help would be much appreciated!
thanks
drsenne
--
View this message in context: http://r.789695.n4.nabble.com/Generating-abnormal-returns-in-R-tp4462541p4462541.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list