如何在Stata中同时输入两个变量?

如何在Stata中同时输入两个变量?,stata,imputation,Stata,Imputation,我试图在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之间变化”。有人能帮我吗?谢谢 我更喜欢使用链式方程式。下面的代码应该可以工作(请注意,第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之间变化”。有人能帮我吗?谢谢

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


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


请注意,x和y有不同数量的缺失值。Gee,a在这里真的很有帮助。hotdeck是一种方法:请注意,x和y有不同数量的缺失值。Gee,a在这里真的很有帮助。hotdeck是一种方法:
* 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