1

我试图在Stata中同时估算两个变量:说y和x。然后我想为他们执行线性回归。

我使用的代码是:

mi set mlong
mi register imputed y x

mi impute regress y a b c, add(10)
mi impute regress x a b c, add(10)
mi estimate: regress y x

我遇到了一个错误:“估计样本在 m=1 和 m=11 之间变化”。有人可以帮我吗?谢谢!

4

1 回答 1

0

我更喜欢使用链式方程。下面的代码应该可以工作(请注意,可以跳过第 1 部分,因为我只使用它来生成合适的模拟数据集):

* Part 1

clear all
set seed 0945 
set obs 50
gen y0 = _n 
gen y = runiform()
sort y
gen x0 = _n
gen x = runiform()
sort x
replace y = . in 1
replace y = . in 5
replace y = . in 10
replace y = . in 15
replace y = . in 20
replace y = . in 25
replace y = . in 30
replace y = . in 35
replace y = . in 40
replace y = . in 45
replace y = . in 50
sort y
replace x = . in 1
replace x = . in 5
replace x = . in 10
replace x = . in 15
replace x = . in 20
replace x = . in 25
replace x = . in 30
replace x = . in 35
replace x = . in 40
replace x = . in 45
replace x = . in 50
gen a = _n 
sort x
gen b = _n 
gen c = _n 

* Part 2

mi set mlong
mi register imputed y x

mi impute chained (regress) y x = a b c, add(10)
mi estimate, dots: regress y x
于 2016-04-19T07:57:09.043 回答