全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1402 2
2018-01-16
financial data 课本上的一道题目,参考答案给出的code有几条看不懂,也不太确定解题思路…
用R解Binomial二项式分布问题
题目:Assume that McDonald's log returns are normally distributed with mean and standard deviation equal to their estimates and that you have been made the following proposition by a friend: If at any point within the next 20 trading days, the price of McDonald's falls below 85 dollars, you will be paid $100, but if it does not, you have to pay him $1. The current price of McDonald's is at the end of the sample data, $93.07. Are you willing to make the bet? (Use 10,000 iterations in your simulation and use the command set.seed(2015) to ensure your results are the same as the answer key)
参考解答给出的code是:
> niter = 10000
> value = matrix(niter)
> set.seed(2015)
> for (i in 1:niter)
+ {
+ logR = rnorm(20,mean = mean(logReturn),sd = sd(logReturn))
+ prices = 93.07 * exp(cumsum(logR))
+ ind = (min(prices) < 85)
+ value[i] = 100*ind - (1 - ind)
+ }
> mu = mean(value)
> mu
[1] 0.0605
> mu + c(-1,1)* sqrt(mu*(1-mu)/niter)*qnorm(0.975)
[1] 0.05583 0.06517
请问其中的prices = 93.07 * exp(cumsum(logR)), 这一步的含义是什么?(为什么用93.07*exp(cumsum(logR)?)
value[i]是在求期望值吗?
题目要求里的setseed.(2015)又是什么意思/作用?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-1-16 16:46:36
日收益率符合对数正太,股价的估算就要这样换算。
set.seed()是为了指定随机数的产生,确保你的结果与书本上的一样。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-1-17 09:06:37
思考一下下面两个问题你就明白了,
如果昨天的收盘价是93.07,今天的对数收益率是10%,如何计算今天的价格;
如果明天的对数收益率也是10%,如何计算明天的价格
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群