Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

R coding library(RSQLite) library(foreign) setwd(xxx) # reset the working directory to the folder which stores the data sets msf

R coding

library(RSQLite)

library(foreign)

setwd("xxx") # reset the working directory to the folder which stores the data sets

msf <- read.dta("msf.dta")

con <- dbConnect(SQLite(),":memory:")

dbWriteTable(con,"msf",msf,overwrite=TRUE)

command <- "SELECT tsymbol,ret

FROM msf

WHERE date BETWEEN '2005-01-01' AND '2013-12-31'

AND tsymbol IN ('stock1', 'stock2', 'SPY')"

result<-dbGetQuery(con,command)

y1<-result[result$tsymbol=='stock1',]$ret

y2<-result[result$tsymbol=='stock2',]$ret

x<-result[result$tsymbol=='SPY',]$ret

(I can't post the data, please use your own data or pick any stock name you want, I need the code that can be apply to this question to study)

1. Choose any two stocks in the database "msf.dta". Change the code above to get the stock ret data and S&P index ret.

2. Estimate each company's abnormal return and beta by CAPM model for the full sample.

3. For each company, randomly select 80% of observations to estimate abnormal returns and beta in the step 2. Repeat the iteration 20 times. Print the abnormal return and beta estimations for 20 samples as a matrix.

4. Compute the average of the abnormal return and beta estimations over 20 samples.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago