2SLS或IV在第一阶段具有轨道分布

时间:2020-10-10 09:30:13

标签: r

我想使用两阶段最小二乘法(2SLS),其中第一阶段将受益于Tobit规范。

我将其交叉发布在stackexchange上,因为它不是纯粹的编码问题。

我有一些示例数据,如下:

panelID= c(1:50)
year= c(2005, 2010)
country = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
urban = c("A", "B", "C")
indust = c("D", "E", "F")
sizes = c(1,2,3,4,5)
n <- 2
library(AER)
library(data.table)
library(dplyr)
set.seed(123)
DT <- data.table(   country = rep(sample(country, length(panelID), replace = T), each = n),
                    year = c(replicate(length(panelID), sample(year, n))),
                    sales= round(rnorm(10,10,10),2),
                    industry = rep(sample(indust, length(panelID), replace = T), each = n),
                    urbanisation = rep(sample(urban, length(panelID), replace = T), each = n),
                    size = rep(sample(sizes, length(panelID), replace = T), each = n))
DT <- DT %>%
group_by(country) %>%
mutate(base_rate = as.integer(runif(1, 12.5, 37.5))) %>%
group_by(country, year) %>%
mutate(taxrate = base_rate + as.integer(runif(1,-2.5,+2.5)))
DT <- DT %>%
group_by(country, year) %>%
mutate(vote = sample(c(0,1),1), 
votewon = ifelse(vote==1, sample(c(0,1),1),0))

说我想跑步:

summary(ivreg(sales ~ taxrate + as.factor(industry) + as.factor(size) + as.factor(urbanisation) + as.factor(vote) | as.factor(votewon) + as.factor(industry) + as.factor(size) + as.factor(urbanisation) + as.factor(vote), data=DT))

但是,我希望第一阶段成为tobit规范?像这样:

tobit_reg <<- censReg(taxrate ~ as.factor(votewon) + as.factor(industry) + as.factor(size) + as.factor(urbanisation) + as.factor(vote), left=3, right=15, data=DT)
summary(tobit_reg)

我怎样才能将轨道回归作为2SLS的第一阶段?

我还要测试过度识别。

编辑:此帖子已在STACKEXCHANGE上答复

0 个答案:

没有答案