边距预测结果误差r(198)

时间:2016-08-22 11:13:40

标签: stata

我需要估算xtoprobit估算后的输出。

但我跑步的时候已经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
}

1 个答案:

答案 0 :(得分:0)

请在此处学习rest calls以获取有关好问题的建议。您的示例无法重现,因为我们无法访问您的数据。此外,完整代码包含许多几乎肯定无关紧要的细节,并使用无法解释的用户编写的程序(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. 检查代码是否显示完全您键入的内容。