data <- read.csv("C:/Users/jayde/Downloads/6_Portfolios_2x3_CSV.zip", header = TRUE, fill = TRUE, stringsAsFactors = FALSE)
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## line 1 appears to contain embedded nulls
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
## : embedded nul(s) found in input
data <- data[!is.na(data[,1]), ]
head(data)
## [1] ""
## [2] "s\x88\xc1s\037\fW4\x96|V\xf9\xdd\xc9Kyk\x87x\xfb\xac\xd5:\xe8\021\xfeq\001\xbe\t\xe6\x81\xee\xe2\xb3i\xe5(oŻ<'\006\xfb\027 \xecIi\t\xcep\xecB\035\xf4\024-k5O\xf1\xcc&ƪJi\xb1\xd9\xdd\xd2\xfc\xc5w\xc3D3\x88-w\xb1\x83\xad\xbd\034\x99\xc9\001t\xb6\xfdY\xe7\020ͼ\x8cߴf\xdf\xdc}ԩ\x9b\xea\xa6\006sZV>\xc9\xdaL\xb3y\003\xb9O\xab\025\xb3|E\fZ\x96y떪\x85\xea\u009a\xe4\xaf\037\x86\031l[=/v\x89\021o\035\xb8\xaf\xaaJ\xdc˷\xe3N\xab\xe8-\u05cdX\xe3"
## [3] ""
## [4] ""
## [5] ""
## [6] ""
library(readr)
data <- read_csv("C:/Users/jayde/Downloads/6_Portfolios_2x3_CSV.zip")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
## Rows: 8898 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): This file was created using the 202601 CRSP database.
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(data)
## # A tibble: 6 × 1
## `This file was created using the 202601 CRSP database.`
## <chr>
## 1 It contains value- and equal-weighted returns for portfolios formed on ME and…
## 2 The portfolios are constructed at the end of June. BEME is book value at the…
## 3 divided by ME at the end of December of the prior year.
## 4 Annual returns are from January to December.
## 5 Missing data are indicated by -99.99 or -999.
## 6 The break points include utilities and include financials
half <- nrow(data)/2
first_half <- data[1:half,]
second_half <- data[(half+1):nrow(data),]
stats <- function(x){
c(
Mean = mean(x),
SD = sd(x),
Skewness = skewness(x),
Kurtosis = kurtosis(x)
)
}
equity_return <- 0.6*50000 + 0.4*(-30000)
equity_return
## [1] 18000
rf_return <- 5000
rf_return
## [1] 5000
risk_premium <- equity_return - rf_return
risk_premium
## [1] 13000