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语句格式如下: ...
随机推荐
- PyQt5日历控件及相关操作
1.日历控件QCalendarWidget控件import sys,mathfrom PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQ ...
- 无线客户端掉线(Disassociate and DeleteReason)
- [蓝桥杯2017初赛]Excel地址
题目描述 Excel单元格的地址表示很有趣,它使用字母来表示列号. 比如,A表示第1列,B表示第2列,Z表示第26列,AA表示第27列,AB表示第28列,BA表示第53列,.... 当然Excel的最 ...
- 【原】简单shell练习(五)
1.查询一个文件中某个单词出现的次数 # grep -o 'ts' ./test/txt |wc -l 2.统计当前文件夹下文件的个数 ls -l |grep "^-"|wc -l ...
- Fedora26安装Mysql实记(包含yum换源教程)
课程实验中有一项是安装Hive,这个过程中需要安装Mysql. 在安装Mysql耗费了好多时间,总是报错数据仓库同步失败什么的. 输入yum install mysql 就提示错误,连接不上数据源.该 ...
- linux修改文件的权限和修改文件所有者和所属组
文件设定法:chmod [who] [+][-][=] [mode] who 文件所有者:u 文件所属组:g 其他:o 所有人:a + 添加权限 - 减少权限 = 覆盖原来权限 权 ...
- [阿里移动推荐算法]比赛_快速入门_4_19_update_仅供参考,思维不要受局限
[这里只讲快速入门——即破题,正负样本不平衡.特征数量等问题就自己多看论文或者其他资料吧~~如果还有数据挖掘相关基础知识不了解的,建议看看<数据挖掘导论>] [以下是理解错误案例]:错误的 ...
- Omnisharp VsCode Attaching to remote processes
原文链接: https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes The C# extens ...
- ImageMagick PDF到JPG有时会导致黑色背景
convert -verbose -density 300 -quality 50 -background white -alpha remove 0.pdf 0.jpg magick convert ...
- Python爬取51job实例
用Python爬取51job里面python相关职业.工作地址和薪资. 51job上的信息 程序代码 from bs4 import BeautifulSoup from urllib.request ...