2016-08-22 44 views
0

我需要估计xtoprobit估计后的输出。如果需要的话边距预测结果误差r(198)

但我有r(198)当我运行,

margins, at(HealthStatus=(1(1)4)) predict(outcome(1)) 

运行后,

xtoprobit Ages HealthStatus ChildSex Family1 Family2 FatherPresent MotherPresent FatherEducation MotherEducation Location Income, iterate(0) 

完整的语法:

set more off 
local dir "/Users/user/Documents/STATISTICS/" 
local datasave "Output/" 
local slash "/" 

********FLS1 & FLS2************ 

forvalues i=1/2 { 
    local p = "FLS`i'" 
    foreach j of local p { 
    if "`j'" == "FLS1" { 
     use `dir'`datasave'FLS`i'`slash'merge0, clear 
    } 
    else { 
     merge m:m pidlink using `dir'`datasave'FLS`i'`slash'merge0 
     keep if _merge==3 
     drop _merge 
    } 
    } 
} 
duplicates drop pidlink, force 
drop hhid* 
save `dir'`datasave'respFLS12, replace 

forvalues i=1/2 { 
    use `dir'`datasave'respFLS12, clear 
    merge m:m pidlink using `dir'`datasave'FLS`i'`slash'merge_panel 
    keep if _merge==3 
    drop _merge hhid* 
    duplicates drop pidlink, force 
    gen year = `i' 
    save `dir'`datasave'FLS`i', replace 
} 

forvalues i=1/2 { 
    local p = "FLS`i'" 
    foreach j of local p { 
    if "`j'" == "FLS1" { 
     use `dir'`datasave'FLS`i', clear 
    } 
    else { 
     append using `dir'`datasave'FLS`i' 
    } 
    } 
} 

save `dir'`datasave'panel1, replace 

********FLS3 & FLS4************ 

forvalues i=3/4 { 
    local p = "FLS`i'" 
    foreach j of local p { 
    if "`j'" == "FLS3" { 
     use `dir'`datasave'FLS`i'`slash'merge0, clear 
    } 
    else { 
     merge m:m pidlink using `dir'`datasave'FLS`i'`slash'merge0 
     keep if _merge==3 
     drop _merge 
    } 
    } 
} 
duplicates drop pidlink, force 
drop hhid* 
save `dir'`datasave'respFLS34, replace 

forvalues i=3/4 { 
    use `dir'`datasave'respFLS34, clear 
    merge m:m pidlink using `dir'`datasave'FLS`i'`slash'merge_panel 
    keep if _merge==3 
    drop _merge hhid* 
    duplicates drop pidlink, force 
    gen year = `i' 
    save `dir'`datasave'FLS`i', replace 
} 

forvalues i=3/4 { 
    local p = "FLS`i'" 
    foreach j of local p { 
    if "`j'" == "FLS3" { 
     use `dir'`datasave'FLS`i', clear 
    } 
    else { 
     append using `dir'`datasave'FLS`i' 
    } 
    } 
} 

save `dir'`datasave'panel2, replace 

********************************** 

forvalues i=1/2 { 
    use `dir'`datasave'panel`i', clear 
    encode pidlink, gen(id) 
    duplicates report id year 
    duplicates drop id year, force 
    xtset id year 

    xtoprobit Ages HealthStatus ChildSex Family1 Family2 FatherPresent MotherPresent FatherEducation MotherEducation Location Income, iterate(0) 
    margins, at(HealthStatus=(1(1)4)) predict(outcome(1)) 
    margins, at(HealthStatus=(1(1)4)) predict(outcome(2)) 
    margins, at(HealthStatus=(1(1)4)) predict(outcome(3)) 
    margins, at(HealthStatus=(1(1)4)) predict(outcome(4)) 

    margins, at(ChildSex =(0(1)1)) predict(outcome(1)) 
    margins, at(ChildSex =(0(1)1)) predict(outcome(2)) 
    margins, at(ChildSex =(0(1)1)) predict(outcome(3)) 
    margins, at(ChildSex =(0(1)1)) predict(outcome(4)) 

    margins, at(FatherPresent =(0(1)1)) predict(outcome(1)) 
    margins, at(FatherPresent =(0(1)1)) predict(outcome(2)) 
    margins, at(FatherPresent =(0(1)1)) predict(outcome(3)) 
    margins, at(FatherPresent =(0(1)1)) predict(outcome(4)) 

    margins, at(MotherPresent =(0(1)1)) predict(outcome(1)) 
    margins, at(MotherPresent =(0(1)1)) predict(outcome(2)) 
    margins, at(MotherPresent =(0(1)1)) predict(outcome(3)) 
    margins, at(MotherPresent =(0(1)1)) predict(outcome(4)) 

    margins, at(FatherEducation =(1(1)6)) predict(outcome(1)) 
    margins, at(FatherEducation =(1(1)6)) predict(outcome(2)) 
    margins, at(FatherEducation =(1(1)6)) predict(outcome(3)) 
    margins, at(FatherEducation =(1(1)6)) predict(outcome(4)) 

    margins, at(MotherEducation =(1(1)6)) predict(outcome(1)) 
    margins, at(MotherEducation =(1(1)6)) predict(outcome(2)) 
    margins, at(MotherEducation =(1(1)6)) predict(outcome(3)) 
    margins, at(MotherEducation =(1(1)6)) predict(outcome(4)) 

    margins, at(Location =(0(1)1)) predict(outcome(1)) 
    margins, at(Location =(0(1)1)) predict(outcome(2)) 
    margins, at(Location =(0(1)1)) predict(outcome(3)) 
    margins, at(Location =(0(1)1)) predict(outcome(4)) 

    outreg2 using `dir'`datasave'panel`i', excel replace 
    save `dir'`datasave'panel`i', replace 
} 

回答

0

请研究https://stackoverflow.com/help/mcve对好建议这里的问题。您的示例不可重复,因为我们无法访问您的数据。另外,完整的代码包含了许多几乎可以肯定不相关的细节,并使用不明原因的用户编写的程序(outreg2)。

r(198)表示语法错误,但没有这样的错误对我来说是显而易见的。相反,这种运行没有错误在Stata 14.1:

webuse tvsfpors, clear 
xtset school 
xtoprobit thk prethk 
margins, at(prethk = (0(1)6)) predict(outcome(1)) 

因此,建议:

  1. 你能在你的Stata运行,没有错误?如果不是,会发生什么?你使用的是哪个版本的Stata?

  2. 检查代码是否显示为刚好是键入的内容。

+0

1)编号同样的错误。但是,谢谢你,升级到14.1后,它能正常工作 – asingh

+0

你解决了这个问题很好。感谢报告。 –