# NOT RUN {
library("zoo")
## 1. Mean-adjusted-returns model
# }
# NOT RUN {
library("magrittr")
single_return <- get_prices_from_tickers("AMZN",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo") %>%
get_rates_from_prices(quote = "Close",
multi_day = TRUE,
compounding = "continuous") %>%
returns(market_model = "mean_adj",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
# }
# NOT RUN {
## The result of the code above is equivalent to:
data(rates)
single_return <- returns(rates[, "AMZN"],
market_model = "mean_adj",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
## 2. Market-adjusted-returns model
# }
# NOT RUN {
library("magrittr")
rates_indx <- get_prices_from_tickers("^GSPC",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo") %>%
get_rates_from_prices(quote = "Close",
multi_day = TRUE,
compounding = "continuous")
single_return <- get_prices_from_tickers("AMZN",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo") %>%
get_rates_from_prices(quote = "Close",
multi_day = TRUE,
compounding = "continuous") %>%
returns(regressor = rates_indx,
market_model = "mrkt_adj",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
# }
# NOT RUN {
## The result of the code above is equivalent to:
data(rates, rates_indx)
single_return <- returns(rates = rates[, "AMZN", drop = FALSE],
regressor = rates_indx,
market_model = "mrkt_adj",
estimation_method = "ols",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
## 3. Single-index market model
# }
# NOT RUN {
library("magrittr")
rates_indx <- get_prices_from_tickers("^GSPC",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo") %>%
get_rates_from_prices(quote = "Close",
multi_day = TRUE,
compounding = "continuous")
single_return <- get_prices_from_tickers("AMZN",
start = as.Date("2019-04-01"),
end = as.Date("2020-04-01"),
quote = "Close",
retclass = "zoo") %>%
get_rates_from_prices(quote = "Close",
multi_day = TRUE,
compounding = "continuous") %>%
returns(regressor = rates_indx,
market_model = "sim",
estimation_method = "ols",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
# }
# NOT RUN {
## The result of the code above is equivalent to:
data(rates, rates_indx)
single_return <- returns(rates = rates[, "AMZN", drop = FALSE],
regressor = rates_indx,
market_model = "sim",
estimation_method = "ols",
estimation_start = as.Date("2019-04-01"),
estimation_end = as.Date("2020-03-13"))
# }
Run the code above in your browser using DataLab