Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 第一阶段为托比特分布的2SLS或IV_R - Fatal编程技术网

R 第一阶段为托比特分布的2SLS或IV

R 第一阶段为托比特分布的2SLS或IV,r,R,我想使用两阶段最小二乘法(2SLS),其中第一阶段将受益于Tobit规范 我交叉发布了这个,因为它不是一个纯粹的编码问题 我有一些样本数据如下: panelID= c(1:50) year= c(2005, 2010) country = c("A", "B", "C", "D", "E", "F", "G", "H", "I&

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

我交叉发布了这个,因为它不是一个纯粹的编码问题

我有一些样本数据如下:

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))
但我希望第一阶段是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)
tobit\u reg
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)