全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
8420 8
2015-05-03
如题:
    在做一个对数线性模型,模型部分都比较顺利,到后边拟合优度检验时候,出现gof或者estat gof无法显示,求解?
    已经检查过gof的安装,这个没有问题,help文件中的例子也能做出来,但是我现在用的模型做不出,烦请各位帮忙看下!
附件列表
2.png

原图尺寸 8.98 KB

2.png

1.png

原图尺寸 20.73 KB

1.png

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-5-3 20:31:29
有gof命令吗?为什么帮助不是你写的那样

Title

    [R] estat gof -- Pearson or Hosmer-Lemeshow goodness-of-fit test


Syntax

        estat gof [if] [in] [weight] [, options]

    gof_options           Description
    --------------------------------------------------------------------------------------------------------------
    Main
      group(#)            perform Hosmer-Lemeshow goodness-of-fit test using # quantiles
      all                 execute test for all observations in the data
      outsample           adjust degrees of freedom for samples outside estimation sample
      table               display table of groups used for test
    --------------------------------------------------------------------------------------------------------------
    fweights are allowed; see weight.
    estat gof is not appropriate after the svy prefix.


Menu for estat

    Statistics > Postestimation > Reports and statistics


Description

    estat gof reports the Pearson goodness-of-fit test or the Hosmer-Lemeshow goodness-of-fit test.

    estat gof requires that the current estimation results be from logistic, logit, or probit.  For estat gof
    after poisson, see [R] poisson postestimation.  For estat gof after sem, see [SEM] estat gof.


Options

        +------+
    ----+ Main +--------------------------------------------------------------------------------------------------

    group(#) specifies the number of quantiles to be used to group the data for the Hosmer-Lemeshow
        goodness-of-fit test.  group(10) is typically specified.  If this option is not given, the Pearson
        goodness-of-fit test is computed using the covariate patterns in the data as groups.

    all requests that the statistic be computed for all observations in the data, ignoring any if or in
        restrictions specified by the estimation command.

    outsample adjusts the degrees of freedom for the Pearson and Hosmer-Lemeshow goodness-of-fit tests for samples
        outside the estimation sample.  See Samples other than the estimation sample in [R] estat gof.

    table displays a table of the groups used for the Hosmer-Lemeshow or Pearson goodness-of-fit test with
        predicted probabilities, observed and expected counts for both outcomes, and totals for each group.


Examples

    Setup
        . webuse lbw

    Fit logistic regression to predict low birth weight
        . logistic low age lwt i.race smoke ptl ht ui

    Perform goodness-of-fit test
        . estat gof

    Same as above, but use 10 quantiles
        . estat gof, group(10)

    Same as above, but display table of groups used for test
        . estat gof, group(10) table

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-3 21:08:05
estat不能省啊
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-3 21:42:36
蓝色 发表于 2015-5-3 20:31
有gof命令吗?为什么帮助不是你写的那样

Title
非常感谢蓝色版主!
我用的是Treiman在《量化数据分析》第十二章中的那个例子,在做这个模型时候,他的例题do文件和log文件都给了出来,在那里确实gof是可以跑出来的。但是他的do文件在我这里却弄不出来,而且,我也试过estat gof,弄不出来结果。我一会儿把那个也截下图,请版主帮忙再看下
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-3 21:45:42
/*********************************************************************
2) Get goodness-of-fit statistics for Table 12.2, shown in Table 12.3.
**********************************************************************/

*Define s=stratification, t=technology, and p=political integration.

infile s t p count using tab12_2.raw , clear
list /*Confirm that I have read in the data correctly*/

*Estimate the baseline model (Table 12.3, Model 1).

xi : glm count i.t i.p i.s , family(poisson)

/*Create a scalar: baseline deviance (bd).  I will use this to get the
ratio of the deviance for each subsequent model to the deviance for
the baseline model.*/

scalar bd = e(deviance)

/*Get goodness-of-fit statistics for this model.  Since I am going to
invoke the same commands many times, I have written an -ado- file -gof.ado-,
to get all the statistics I need for Table 12.3 that are not shown in the
Stata output.*/

gof

*Now I get the corresponding statistics for the remaining models (Table 12.3).

/*Note that Stata now has a built in BIC function.  However, for our purposes
the BIC estimates from the -glm- command are misleading because they treat
the number of cells in the table rather than the total number of cases used
in the analysis as the sample.  However, it is possible to override the
default count.  For the first two models in the next set of models estimated,
I have used the -glm- postestimation command, -estat- to estimate BIC,
substituting the correct N, the number of cases in the table rather than the
number of cells.  -estat- yields estimates of BIC that are different from
the estimates I derive from -gof- (which follow the formula provided by
Raftery 1995).  However, as you can see, the difference between BICs for the
two models are identical regardless of which version of BIC is estimated.*/

*First get the total number of cases in the table.;

egen freq = total(count)
tab freq  

*Then estimate BIC as a -glm- postestimation command for the first two models.

xi : glm count i.t i.p*i.s , family(poisson)
estat ic , n(92)
gof
xi : glm count i.p i.t*i.s , family(poisson)
estat ic , n(92)
gof
xi : glm count i.s i.t*i.p , family(poisson)
gof
xi : glm count i.t*i.p i.t*i.s , family(poisson)
gof
xi : glm count i.t*i.p i.p*i.s , family(poisson)
gof
xi : glm count i.t*i.s i.p*i.s , family(poisson)
gof
xi : glm count i.t*i.p i.t*i.s i.p*i.s , family(poisson)
gof
附件列表
3.png

原图尺寸 17.91 KB

3.png

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-5-3 21:47:09
rudi 发表于 2015-5-3 21:08
estat不能省啊
嗯,谢谢层主的回复。
我这里也加上了estat,同样也是不行的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群