Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with collect, unable to grab number of observations

    Hello all, I am having difficulties collecting the number of observations for my models. Any help would be greatly appreciated.

    Code:
    . collect clear
    
    . collect N=_N OR=_r_b SE=_r_se Lower=_r_lb Upper=_r_ub Pvalue=_r_p,:xtgee injury age,fam(bin) link(logit) eform corr(exc) i(teamclu
    > ster) exp(exphours) robust
    
    Iteration 1: tolerance = .00925955
    Iteration 2: tolerance = .00010796
    Iteration 3: tolerance = 1.629e-06
    Iteration 4: tolerance = 2.645e-08
    
    GEE population-averaged model                        Number of obs    =  1,775
    Group variable: teamcluster                          Number of groups =    129
    Family: Binomial                                     Obs per group:  
    Link:   Logit                                                     min =      1
    Correlation: exchangeable                                         avg =   13.8
                                                                      max =     43
                                                         Wald chi2(1)     =  45.82
    Scale parameter = 1                                  Prob > chi2      = 0.0000
    
                                (Std. err. adjusted for clustering on teamcluster)
    ------------------------------------------------------------------------------
                 |               Robust
          injury | Odds ratio   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   1.420585    .073675     6.77   0.000     1.283282     1.57258
           _cons |   .0000174   .0000131   -14.48   0.000     3.93e-06    .0000765
    ln(exphours) |          1  (exposure)
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds (conditional on zero random effects).
    
    . 
    . collect dims
    
    Collection dimensions
    Collection: default
    -----------------------------------------
                       Dimension   No. levels
    -----------------------------------------
    Layout, style, header, label
                          cmdset   1         
                           coleq   1         
                         colname   45        
                   program_class   2         
                          result   50        
                     result_type   3         
                         rowname   43        
    
    Style only
                    border_block   4         
                       cell_type   4         
    -----------------------------------------
    
    . collect levelsof result,
    
    Collection: default
     Dimension: result
        Levels: Lower N N_g OR Pvalue R SE Upper _r_b _r_ci _r_df _r_lb _r_p _r_se _r_ub _r_z _r_z_abs chi2 chi2_dev chi2_dis chi2type
                cmd cmdline corr depvar deviance df_m df_pear dif dispers estat_cmd family g_avg g_max g_min ivar link marginsnotok
                model offset p phi predict properties rank rc scale tol vce vcetype
    
    . collect label list result, all
    
      Collection: default
       Dimension: result
           Label: Result
    Level labels:
           Lower  
               N  Number of observations
             N_g  Number of groups
              OR  
          Pvalue  
               R  Estimated working correlation matrix
              SE  
           Upper  
            _r_b  Coefficient
           _r_ci  __LEVEL__% CI
           _r_df  df
           _r_lb  __LEVEL__% lower bound
            _r_p  p-value
           _r_se  Std. error
           _r_ub  __LEVEL__% upper bound
            _r_z  z
        _r_z_abs  |z|
            chi2  χ²
        chi2_dev  χ² test of deviance
        chi2_dis  χ² test of deviance dispersion
        chi2type  Type of model χ² test
             cmd  Command
         cmdline  Command line as typed
            corr  Correlation structure
          depvar  Dependent variable
        deviance  Deviance
            df_m  Model DF
         df_pear  DF for Pearson χ²
             dif  Achieved tolerance
         dispers  Deviance dispersion
       estat_cmd  Program used to implement estat
          family  Distribution family
           g_avg  Average group size
           g_max  Largest group size
           g_min  Smallest group size
            ivar  Group variable
            link  Link function
    marginsnotok  Predictions disallowed by margins
           model  Model
          offset  Linear offset variable
               p  Model test p-value
             phi  Scale parameter
         predict  Program used to implement predict
      properties  Command properties
            rank  Rank of VCE
              rc  Return code
           scale  Scale parameter
             tol  Target tolerance
             vce  SE method
         vcetype  SE method
    
    . collect layout (colname) (result[N OR SE Lower Upper Pvalue])
    
    Collection: default
          Rows: colname
       Columns: result[N OR SE Lower Upper Pvalue]
       Table 1: 2 x 5
    
    --------------------------------------------------------
              |       OR       SE    Lower    Upper   Pvalue
    ----------+---------------------------------------------
    age       | 1.420585  .073675 1.283282  1.57258 1.29e-11
    Intercept | .0000174 .0000131 3.93e-06 .0000765 1.70e-47
    --------------------------------------------------------
    
    . collect style cell result, nformat(%6.3f)
    
    . collect preview
    
    ------------------------------------------
              |    OR    SE Lower Upper Pvalue
    ----------+-------------------------------
    age       | 1.421 0.074 1.283 1.573  0.000
    Intercept | 0.000 0.000 0.000 0.000  0.000
    ------------------------------------------
    
    .
    I don't know what I am doing wrong. I've tried removing the _ before the N but with no success and instead I get the error
    Code:
    N not found
    ...


    Regards,

    Jean-Michel Galarneau

  • #2
    I think you want
    Code:
    collect N=e(N) ...
    to access the number of observations from the returned estimates e() described by the output of xtgee.

    In any event, _N would be the number of observations in your dataset, which need not be the number of observations on which the estimation was run.

    Comment


    • #3
      William, I'm not seeing how I can access these results and place them in the same table as the one produced by:
      Code:
      collect layout (colname) (result[N OR SE Lower Upper Pvalue])
      The code above has worked well for me to gather the OR,SE,CI's from a whole bunch of bivariate regressions into 1 table, I want to do the same thing but also collect the N (estimation sample) used in each estimation and so on. I've spent countless hours on this, read the manual from start to finish and I have to admit that the suite of collect commands is far from intuitive.



      J-M

      Comment

      Working...
      X