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的更多相关文章

  1. C#中,switch case语句中多个值匹配一个代码块的写法

    switch (num) { case 1: Response.Write("1"); break; case 2: case 3: Response.Write("2| ...

  2. Android Studio快捷键switch case 轻松转换为if else

    Android Studio快捷键switch case 轻松转换为if else 今天碰到的问题,没有找到资料,后面找到了方法,这个记下来,转载请注明出处:http://www.cnblogs.co ...

  3. 你真的会玩SQL吗?Case也疯狂

    你真的会玩SQL吗?系列目录 你真的会玩SQL吗?之逻辑查询处理阶段 你真的会玩SQL吗?和平大使 内连接.外连接 你真的会玩SQL吗?三范式.数据完整性 你真的会玩SQL吗?查询指定节点及其所有父节 ...

  4. java中的switch case

    switch-case语句格式如下 switch(变量){ case 变量值1: //; break; case 变量值2: //...; break; ... case default: //... ...

  5. sql case when...then...else...end 选择判断

    达到的需求为: 吓数收回日期为空:当接单日期不等于空和当天减接单日期大于3天时,为1,否则为0:当接单日期为空.最大发织交期不等于空和当天减去最大发织交期大于3天时,为1,否则为0:当接单日期和发织交 ...

  6. C# 中Switch case 返回不止用break

    Switch(temp) { case "A": //跳出循环 break; case "B": //返回值 return var; case "C& ...

  7. SQL --- Case when 的使用方法

    1. Case具有两种格式.简单Case函数和Case搜索函数. --简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE '其他' E ...

  8. 2.3switch case 语句注意事项。

    #include<stdio.h> int main() { void action1(int, int),action2(int, int); char ch; , b=; ch = g ...

  9. sh4.case语句

    case ... esac 与其他语言中的 switch ... case 语句类似,是一种多分枝选择结构.case 语句匹配一个值或一个模式,如果匹配成功,执行相匹配的命令.case语句格式如下: ...

随机推荐

  1. Cisco AP-如何识别思科胖瘦AP

    思科的胖瘦AP识别的方式不止一种,这里简单的总结一些我了解到的方式: 1.根据思科AP的型号 这个和思科不同时期的产品有关系,老一点的和新一些的AP命名上存在差别,这里简单举例: 类型1:AIR-LA ...

  2. express session 实现登录

    https://www.cnblogs.com/mingjiatang/p/7495321.html Express + Session 实现登录验证   1. 写在前面 当我们登录了一个网站,在没有 ...

  3. Jedis实现频道的订阅,取消订阅

     第一步:创建一个发布者 package work; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; i ...

  4. A10131013 Battle Over Cities (25分)

    一.技术总结 这一题是考查图的知识,题目的意思要理解清楚,就是考查统计图中连通块的数量,也就是没有一个结点后. 怎么删除该结点,并且统计连通块的数量成为问题解决的关键,这里可以当访问到结点时,直接返回 ...

  5. C/S的接口测试工具

    Postman概述: Postman是一个接口测试工具,在做接口测试的时候,Postman相当于一个客户端,它可以模拟用户发起的各类HTTP请求,将请求数据发送至服务端,获取对应的响应结果,从而验证响 ...

  6. NFS网络文件共享系统!

    NFS是运行在应用层上的协议,其默认的端口为2049,它适用于linux与linux之间,也适用于linux与unix之间,亦可适用于linux与windows之间 nfs优缺点优点 节省本地硬盘的存 ...

  7. JAVA语言实现简单登录界面

    程序设计思想: 使用Math.random()方法循环生成6个97~122之间的随机整数(对应ASCII码值‘a’~‘z’),将其转化为char型变量,连接成为一个6位字符串作为验证码输出,提示用户输 ...

  8. HashMap中推荐使用entrySet方式遍历Map类集合KV而不是keySet方式遍历

    我们先来做一个测试 public class HashMapTest { private HashMap<String, String> map = new HashMap<> ...

  9. 吴裕雄--天生自然TensorFlow2教程:全连接层

    out = f(X@W + b) out = relut(X@W + b) import tensorflow as tf x = tf.random.normal([4, 784]) net = t ...

  10. 使用tag标签是SEO优化的重要性是什么?

    使用tag标签是SEO优化的重要性是什么? tag标签是一种SEO技术,在网站优化的过程中,更准确.更具体地用关键词对文章进行分类,对SEO优化具有重要的作用. 但是,很多新人站长在发表文章时不太注意 ...