Time Series_1_BRKA Case
Berkshire Hathaway (The most expensive stock ever in the world)
1.1 Download data
require(quantmod)
data_env <- new.env()
getSymbols(Symbols = 'BRK-A',env = data_env)
brka_close <- do.call(merge, eapply(data_env, Cl))


1.2 Overview
1.2.1 Returns
Method 1
library(fImport)
yield <- returns(brka_close)
head(yield)

Method 2
library(zoo)
# unit in percentage terms
yield_simple <- diff(brka_close) / lag(brka_close, k = -1) * 100
# coredate method: indicate we only care about price column, not the date
summary(coredata(yield_simple))

The biggest single-day loss is 14.90%, we can find out the date by:
yield_simple[which.min(yield_simple)]

1.2.2 Distribution of returns
hist(yield_simple, breaks = 100,
main = 'Histogram of Simple Returns', xlab = '%')

1.2.3 Simple VaR calculation
To determine the 1-day 99% VaR:
quantile(yield_simple,na.rm = T, probs = 0.01)

Thus, the prob. that yield below 3.6894% on any given day is only 1%. If that day comes, 3.6894% is the minimum amount we will lose.
1.3 Modeling the price
require(forecast)
mod <- auto.arima(yield, stationary = T, seasonal = F, ic = 'aic')

AR(2) process didn't appear in the result below, which indicates that historic returns don't depend on earlier periods, i.e.,it depends on stochastic terms.

#compute confidence interval
tsdiag(mod)
Time series diagnosis below, firstly there were volatility clusters in standard residuals throughout time, secondly no autocorrelations exisit within residuals in ACF test, thirdly, Ljung-Box show p-values small to reject null hypothesis.

Time Series_1_BRKA Case的更多相关文章
- C#中,switch case语句中多个值匹配一个代码块的写法
switch (num) { case 1: Response.Write("1"); break; case 2: case 3: Response.Write("2| ...
- Android Studio快捷键switch case 轻松转换为if else
Android Studio快捷键switch case 轻松转换为if else 今天碰到的问题,没有找到资料,后面找到了方法,这个记下来,转载请注明出处:http://www.cnblogs.co ...
- 你真的会玩SQL吗?Case也疯狂
你真的会玩SQL吗?系列目录 你真的会玩SQL吗?之逻辑查询处理阶段 你真的会玩SQL吗?和平大使 内连接.外连接 你真的会玩SQL吗?三范式.数据完整性 你真的会玩SQL吗?查询指定节点及其所有父节 ...
- java中的switch case
switch-case语句格式如下 switch(变量){ case 变量值1: //; break; case 变量值2: //...; break; ... case default: //... ...
- sql case when...then...else...end 选择判断
达到的需求为: 吓数收回日期为空:当接单日期不等于空和当天减接单日期大于3天时,为1,否则为0:当接单日期为空.最大发织交期不等于空和当天减去最大发织交期大于3天时,为1,否则为0:当接单日期和发织交 ...
- C# 中Switch case 返回不止用break
Switch(temp) { case "A": //跳出循环 break; case "B": //返回值 return var; case "C& ...
- SQL --- Case when 的使用方法
1. Case具有两种格式.简单Case函数和Case搜索函数. --简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE '其他' E ...
- 2.3switch case 语句注意事项。
#include<stdio.h> int main() { void action1(int, int),action2(int, int); char ch; , b=; ch = g ...
- sh4.case语句
case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构.case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令.case语句格式如下: ...
随机推荐
- C++ STL之栈stack和queue的使⽤
写在最前面,本文摘录于柳神笔记: (1)栈 stack 在头⽂件 #include 中,是数据结构⾥⾯的栈-以下是常⽤⽤法: (2)队列 queue 在头⽂件 #include 中,是数据结构⾥⾯的队 ...
- PHPStorm 使用 Xdebug
一.下载xdebug xdebug官网:https://xdebug.org/download.php 在选择下载哪个版本的xdebug的时候需要注意了,下面有两种方法,让你准确的下载自己环境对应的x ...
- Jmeter_请求原件之参数化txt
把数据存放在TXT上进行参数化,然后运行 用于注册,登录等不同的用例 1.登录接口地址: http://test.lemonban.com/futureloan/mvc/api/member/logi ...
- 【SSM 验证码】登录验证码
LoginController /** * 登陆方法 */ @ResponseBody @RequestMapping("login2") public Map<String ...
- POJ 3258 River Hopscotch(二分答案)
嗯... 题目链接:http://poj.org/problem?id=3258 一道很典型的二分答案的题目,和跳石头太像了!! 这道题的题目很显然,求最小中的最大值,注意这道题石头的位置不是从小到大 ...
- nyoj 82
题目:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=82 2018-06-23 23:44:05 p.s.自己省错题了: 描述 一个叫ACM的 ...
- Jmeter-maven-plugin github 版本插件变更历史
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md
- linux mysql 查看数据库大小
SELECT CONCAT(TRUNCATE(SUM(data_length)//,),'MB') AS data_size, CONCAT(TRUNCATE(SUM(max_data_length) ...
- MUI - 上拉加载不执行
mui('#pullrefresh').pullRefresh().refresh(true); if($(".list-item").length == countDataSum ...
- nginx 的precontent阶段的ngx_http_try_files_module模块与mirrors模块介绍
指令介绍 Syntax: try_files file ... uri; try_files file ... =code; Default: — Context: server, location ...