很老的笔记,总结一下。
供需求函数
这是供需求函数,我们肯定不能直接用去跑回归。 因为我们首先不知道这是代表供给还是需求函数,实际上谁也不是。
解得:
我们知道,当和线性相关,就是内生了(陈强 2014)。
这个时候我们需要引入 工具变量,假设是天气。
工具变量的两个条件:
- 在供给方程中,天气影响的,因此1。
- 和都不像相关,天气是外生的,除了自身,不受到其他变量决定。
重新写供给函数
所以,
这里涉及到 2SLS
第一步,
第二步,
然后就可以回归了。
矩估计
- 一矩:
- 二矩:
如果我们假设,有两个未知数,因此我们需要两个假设,和,并使用两个方程去估计,就是我们的矩。 通常我们用样本矩来猜测,
因此任意的都可以叫做矩估计。
这里我们使用第二个假设,
我们用样本估计,来估计总体估计!!!
样本矩除了,还有要估计。
这里假设、 。
因此用样本估计估计总体估计时, 我们假设在大样本的情况下,
注意这里是一个数,所以可以分离。
所以
这里有比较简单的推导方法。
第一个方程是
同理
full rank 就是矩估计的条件
能够作为工具变量的变量数量不能少于内生变量的数量。
弱工具变量检验
Shea’s partial
假设,其中只有是内生的,工具变量为。 做回归 和。 其中和分别衡量了和除了以外的其他波动。 再做,如果大,说明不是弱工具变量。
过度识别检验
的数量超过内生的数量。 只有这样,否则不满足 因此,我们假设有K个,r个是内生的,有 m个,因此回归,
如果得到的大,或者说比较于而大的话,那么的条件就不满足了。 因此要求尽可能低,即P值要小。
GMM
GMM是过度识别的时候使用,因为。 这个时候不能等于0了,无解,但是可以使其平方最小。
一步还是两步
一步是满足同方差假设的,所以还是用两步吧。
弱工具变量容易有偏
强工具变量
弱工具变量
library(tidyverse)
beta_cb1 <- 1:100
beta_cb2 <- 1:100
a <- data_frame(
mu = rnorm(100),
v = rnorm(100),
z = rnorm(100)
)
## Warning: `data_frame()` is deprecated as of tibble 1.1.0.
## Please use `tibble()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
for (i in 1:100){
b <-
as.data.frame(resample_bootstrap(a)) %>%
mutate(
x1 = 0.5*z + 0.2*mu + 0.1*v,
x2 = 0.01*z + 0.2*mu + 0.1*v,
y1 = 1 + 2*x1 + mu,
y2 = 1 + 2*x2 + mu
) %>%
summarise(
beta1 = sum(z*y1)/sum(z*x1),
beta2 = sum(z*y2)/sum(z*x2)
)
beta_cb1[i] <- b[1,1]
beta_cb2[i] <- b[1,2]
}
data_frame(
beta1 = beta_cb1 %>% unlist(),
beta2 = beta_cb2 %>% unlist()
) %>%
gather() %>%
ggplot(aes(x = value, y = ..density..,col = key)) +
geom_freqpoly() +
labs(
x = "预测的beta值,真实为2",
y = "频率",
subtitle = "弱工具变量在小样本下很容易不对称,有偏",
title = "弱工具变量比较"
) +
theme_minimal() +
theme(text = element_text(family = "STKaiti"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): Windows字体数据
## 库里没有这样的字体系列
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): Windows字体数据
## 库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): Windows字体数据
## 库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows字体数据库里没有这样的字体系列
陈强. 2014. 高级计量经济学及Stata应用.第2版. 高等教育出版社.