Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一月对于股价的影响是否显著高于二月 #13

Closed
JiaxiangBU opened this issue Oct 21, 2019 · 1 comment
Closed

一月对于股价的影响是否显著高于二月 #13

JiaxiangBU opened this issue Oct 21, 2019 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@JiaxiangBU
Copy link
Owner

$$y=\beta_1Jan + \beta_2Feb$$

  1. H0: beta_1=beta_2,想知道一月对于股价的影响是否显著高于二月
  2. beta0+beta1是一月的平均价格
  3. beta0+beta1是二月的平均价格

所以就是看 $\hat r_{Jan}$$\hat r_{Feb}$ 孰高孰低。

用 boostrap 的方法,

重复抽样 Jan,建立若干个子样本,算均值,因此可以得到一个均值分布
Feb 类似。

然后去比较两个均值分布的差异。

下面是仿真代码

set.seed(123)
# 初始股价 5 块
# xxxx-12-31
p0 <- 5
# 股价收益率
r <- rnorm(31+30)/100
c <- p0 * (1+r)
p_jan <- p[1:31]
p_feb <- p[32:(31+30)]
p_jan_bar <- map_dbl(1:30, ~mean(p_jan[sample(1:31,10)])) # 每个子样本设定10个,可以修改
p_feb_bar <- map_dbl(1:30, ~mean(p_feb[sample(1:30,10)])) # 每个子样本设定10个,可以修改
data.frame(p = c(p_jan_bar,p_feb_bar), is_feb = c(rep(FALSE, 30), rep(TRUE, 30))) %>% 
    lm(p ~ is_feb, data = .) %>% 
    broom::tidy()

结果是显著的。

@JiaxiangBU
Copy link
Owner Author

# A tibble: 2 x 5
  term        estimate std.error statistic   p.value
  <chr>          <dbl>     <dbl>     <dbl>     <dbl>
1 (Intercept)   4.99     0.00302   1655.   2.96e-137
2 is_febTRUE    0.0270   0.00427      6.32 3.99e-  8

@JiaxiangBU JiaxiangBU added the documentation Improvements or additions to documentation label Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant