help for xglm                                                    (Roger Newson)

Extended version of glm

xglm [ varlist ] [if] [in] [weight] [, glm_options ]

where glm_options is a list of options used by glm.


xglm is an extended version of glm, designed mostly for use with the parmby module of the parmest package, downloadable from SSC.


xglm currently saves only 2 extra results, e(depvarsum) and e(msum), containing the sum of the dependent variable specified in e(depvar) and the sum of the binomial total specified in e(m), respectively, limited to the estimation sample specified in e(sample). This allows users of the parmby module of the parmest package to output these sums to the output dataset (or resultsset) as an additional variable. This is especially useful for models with a binomial or Poisson variance function, because the user can then use these extra variables to produce diagnostic variables, such as the number of events or non-events per estimated parameter, which can then inform the user regarding whether the Central Limit Theorem is likely to work for a binomial or Poisson generalized linear model in an estimation sample of the size available.


The following example illustrates the use of e(depvarsum) to store an event count in a parmby resultsset containing the parameters of 2 logistic regression models of non-US origin with respect to repair record, one in even-numbered models, one in odd-numbered models. In the resultsset, the diagnostic indicator variable epparm contains the number of events or nonevents (whichever is smaller) per estimated parameter. The values of this diagnostic variable are well below 5, indicate that the Central Limit Theorem will not work very well for the parameter estimates. Note that the number of estimated parameters is stored in e(df_m), because we are using the noconst option, and the variable baseline, to cause the baseline odds to be displayed by glm with the eform option.


.sysuse auto, clear .gene byte odd=mod(_n,2) .lab var odd "Oddness of model sequence number" .lab def odd 0 "Even" 1 "Odd" .lab val odd odd .gene byte baseline=1 .lab var baseline "Baseline" .describe

Estimation and diagnostics:

.parmby "xglm foreign baseline i.rep78, family(bin) link(logit) eform noconst robust", eform omit escal(df_m N depvarsum) rename(es_1 Nparm es_2 N es_3 Nforeign) by(odd) norestore .gene enevents=min(Nforeign,N-Nforeign) .gene nepparm=enevents/Nparm .lab var enevents "Events or non-events" .lab var nepparm "Events or non-events per parameter" .describe .by odd: list parm N Nparm Nforeign enevents nepparm omit estimate min* max* p


Roger Newson, National Heart and Lung Institute, Imperial College London, UK. Email: r.newson@imperial.ac.uk

Saved results

xglm saves in e() all results saved by glm, and also the following:

Scalars e(depvarsum) sum of dependent variable in estimation sample e(msum) sum of binomial trials e(m) in estimation sample

Also see

Manual: [R] glm

Help: [R] glm parmest, parmby if installed