楼主: supersteven
4327 20

[编程问题求助] 循环语句那里出了错误,请帮忙看看,谢谢 [推广有奖]

11
ywh19860616 发表于 2014-4-29 08:49:06
sorry,没有仔细看下面的。
没有数据,我也不知道这个问题。
一份耕耘,一份收获。

12
supersteven 发表于 2014-4-29 08:58:19
ywh19860616 发表于 2014-4-29 08:49
sorry,没有仔细看下面的。
没有数据,我也不知道这个问题。
能否把邮箱或qq告诉我,我把数据传给你,请帮我看看。
精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

13
supersteven 发表于 2014-4-29 09:15:37
数据已经上传,请运行以下两个,都遇到问题,谢谢帮忙。gen kz=.forvalues i=2003(1)2012{
forvalues j=1(1)17{
cap drop resid
logit psize  cf_ts div_ts ch_ts cs Q_w if  (year==`i' & ind0==`j')
predict zscore if e(sample), xb
replace kz = zscore if e(sample)
cap drop zscore
}
}

gen kz1=.
forvalues i=2003(1)2012{
forvalues j=1(1)17{
cap drop resid
discrim lda  cf_ts div_ts ch_ts cs Q_w if  (year==`i' & ind0==`j'), group(psize)
predict zscore if e(sample), dscore
replace kz1 = zscore if e(sample)
cap drop zscore
}
}


数据.zip
下载链接: https://bbs.pinggu.org/a-1539579.html

3.89 MB

本附件包括:

  • 数据.dta

精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

14
ywh19860616 发表于 2014-4-29 09:25:04
supersteven 发表于 2014-4-29 09:15
数据已经上传,请运行以下两个,都遇到问题,谢谢帮忙。gen kz=.forvalues i=2003(1)2012{
forvalues j=1( ...
ind0是什么?
另外,你的数据很多是超过9位数的,建议利用long型读入,要不现在这样读入是不精确的。
一份耕耘,一份收获。

15
supersteven 发表于 2014-4-29 09:36:06
ywh19860616 发表于 2014-4-29 09:25
ind0是什么?
另外,你的数据很多是超过9位数的,建议利用long型读入,要不现在这样读入是不精确的。
...
已经重发数据,刚才发错文件了,不好意思。

数据.zip

4.75 MB

本附件包括:

  • 数据.dta

精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

16
ywh19860616 发表于 2014-4-29 09:47:26
supersteven 发表于 2014-4-29 09:36
已经重发数据,刚才发错文件了,不好意思。
数据名修改为tempdata, 请核对一下,predict之后你想得到什么,下面例子我用score
包含
       pr            probability of a positive outcome; the default
      xb            linear prediction
      stdp          standard error of the prediction
    * dbeta         Pregibon (1981) Delta-Beta influence statistic
    * deviance      deviance residual
    * dx2           Hosmer and Lemeshow (2000) Delta chi-squared influence statistic
    * ddeviance     Hosmer and Lemeshow (2000) Delta-D influence statistic
    * hat           Pregibon (1981) leverage
    * number        sequential number of the covariate pattern
    * residuals     Pearson residuals; adjusted for number sharing covariate pattern
    * rstandard     standardized Pearson residuals; adjusted for number sharing covariate pattern
      score         first derivative of the log likelihood with respect to xb


  1. use tempdata,clear

  2. gen kz1=.
  3. forvalues i=2003/2012 {
  4. forvalues j=1/17 {
  5. cap drop resid
  6. capture noisily logit psize cf_ts div_ts ch_ts cs Q_w if  (year==`i' & ind0==`j')
  7. quietly if !_rc {
  8. predict zscore if e(sample), score
  9. replace kz1 = zscore if e(sample)
  10. cap drop zscore
  11. }
  12. }
  13. }
复制代码
一份耕耘,一份收获。

17
ywh19860616 发表于 2014-4-29 09:51:06
supersteven 发表于 2014-4-29 09:36
已经重发数据,刚才发错文件了,不好意思。
  1. gen kz1=.
  2. forvalues i=2003/2012 {
  3. forvalues j=1/17 {
  4. cap drop resid
  5. capture noisily discrim lda cf_ts div_ts ch_ts cs Q_w if  (year==`i' & ind0==`j'), group(psize)
  6. quietly if !_rc {
  7. predict zscore if e(sample), dscore
  8. replace kz1 = zscore if e(sample)
  9. cap drop zscore
  10. }
  11. }
  12. }
复制代码
运行中间有些出错是你自身数据导致的,和程序无关。
一份耕耘,一份收获。

18
supersteven 发表于 2014-4-29 09:54:52
predict 后,我想要的是logit回归后因变量的拟合值。
精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

19
supersteven 发表于 2014-4-29 09:58:34
主要是哪方面的问题?
精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

20
supersteven 发表于 2014-4-29 10:09:57
ywh19860616 发表于 2014-4-29 09:51
运行中间有些出错是你自身数据导致的,和程序无关。
非常感谢你,如有机会见面,我请你吃饭,我在大连,来大连联系我,qq:116005175.
精,去粗而取之,诚,心神体贯之,精诚所至,金石为开

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-24 08:53