2016-08-22 72 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

你解決了這個問題很好。感謝報告。 –