Generalized Linear Models (sg16.5: STB-18) ------------------------- ^glm^ depvar [cases] varlist [weights] [if] [in], ^f(^[^gau^|^bin^|^poi^|^gam^|^ivg^|^nb]^) ^l(^[^l^|^p^|^c^|^pow^]^)^ [^g^] [^sc(d^|^c^|^n)^] [^k(.)^] [^le(.)^] [^o(.)^] [^ex(.)^] [^eform^] [^disp(.)^] [^it(.)^] [^lt(.)^] where ^f^ indicates the error or family distribution, and ^l^ is the link. The user has a choice of the following distributions and links: ^gau^ = Gaussian; must be specified with power link ^l(pow) p(1)^ = identity (standard OLS linear regression) ^l(pow)^ = identity : p(1) is default power link ^l(pow) p(0)^ = lognormal ^bin^ = binomial, either ^bernoulli^ [0,1] or ^grouped^. The ^g^ option must be specified to use the grouped version. ^l(l)^ = logit link (canonical) ^l(p)^ = probit link ^l(c)^ = complementary log-log link (cloglog) ^l(pow) p(.)^ = binomial power ^poi^ = Poisson; log link default (canonical) ^l(pow) p(0)^ = alternative canonical log link ^l(pow) p(1)^ = identity link :also simply ^l(pow) ^gam^ = gamma; inverse link default (canonical) ^l(pow) p(-1)^ = alternative canonical inverse link ^l(pow) p(0)^ = log link ^ivg^ = inverse gaussian; inverse quadratic link default (canonical) ^l(pow) p(-2)^ = alternative canonical link (preferred) ^l(pow) p(0)^ = log link ^nb^ = negative binomial (bernoulli or extended count/continuous) ^l(pow) p(0)^ = log link (preferred method) The link option must be specified for Gaussian and binomial distributions (family) when modeling the canonical form. Except for binomial errors, power links are required to model all noncanonical links. Power links have been fully implemented for each distribution. With the exception of the binomial and negative binomial distributions, all canonical links may be modeled using the power link option. The default power link is identity, 1. Square links are called by ^p(2)^ ; square root links by ^p(.5)^. [^cases^] is a variable used for grouped binomial model denominators with the ^g^ option. For such models, the response variable (numerator) must be the first variable called after ^glm^, and [cases] the second. [^fweights^] allows prior frequency weight variable; [^aweights^], when appropriate, calculate analytic weights. ^if^ expression of ^in^ range options may be used. ^sc(.)^ option is used to override the default scale. sc(d) scales by deviance dispersion, sc(c) by chi2 dispersion, and sc(n) is used to allow noscaling of standard errors. ^k(.)^ option is used only with negative binomial models, with ^k(1)^ as the default. The k-constant is entered into the variance and deviance functions. Typical values for the k parameter range from .01 to 2. Negative binomial models are normally used with overdispersed poisson models. The strategy is to optimally adjust k so that the deviance-based dispersion approximates the value of 1.0. If the Deviance p>chi2 is greater than .05, the estimates are significant, and the Deviance is not too disparate from the Chi2 statistic, then the model is well fit and the variates significantly explain the response. An offset/exposure variable may be introduced in a manner similar to Poisson. ^disp(.)^ option is used to add a multiplicative value to the variance function. The default is 1. Models using this method are members of the Quasi-likelihood family; be aware of limitations. The option is useful when adjusting for slight or moderately overdispersed binomial proportion (group) and Poisson count data. ^ex(.)^ allows specification of an exposure variable. ^o(.)^ allows specification of an offset variable. ^eform^ allows exponentiated coefficients to be displayed following binomial and poisson regression. Other statistical results are appropriately adjusted. For logistic regression, exponentiation results in odds ratios; for poisson regression the result is incidence rate ratios. ^le(.)^ allows specification of the percent confidence interval. ^it(.)^ allows specification of the number of iteration. This is useful when there is a problem with convergence. ^lt(.)^ allows specification of a convergence threshold for the iterative change in deviance. Default is .0001. Output includes Chi2 and scaled deviance summary statistics, their chi2 significance, and corresponding dispersion value. Gaussian, gamma, and inverse Gaussian errors are default scaled by the deviance-based dispersion; however the user may request a Chi2 dispersion scale by the option ^sc(c)^ or no scaling by ^sc(n)^. Binomial, Poisson, and negative binomial models default to a noscale, the latter because variance adjustmnent is taken up by the ^k(.)^ option. The resultant linear predictors, ^eta^, fitted values, ^mu^, and residuals may be obtained using the ^gpredict^ command. Type ^help gpredict^ for help regarding proper use. Examples -------- Standard linear regression (Gaussian) ^ glm age start numb, f(gau) l(pow) Logistic regression, showing odds ratios: Bernoulli response ^ glm kyph age start numb, f(bin) l(l) eform Complementary loglog, showing exponentiated coefficients, grouped data ^ glm infec cases cd4 cd8, f(bin) l(c) eform g Poisson regression, canonical log link showing incidence rate ratios with exposure variable ^ glm injuries XYZowned, f(poi) ex(n) eform Poisson regression, identity link ^ glm age start numb, f(poi) l(pow) p(1)^ or ^ glm age start numb, f(poi) l(pow) Gamma regression, canonical link with frequency weight variable ^ glm age start [fw=numb], f(gam) Gamma regression, log link, noscale (noncensored exponential regression) ^ glm age start numb, f(gam) l(pow) p(0) sc(n) Negative binomial, log link with k=1.1 ^ glm age start numb, f(nb) l(pow) p(0) k(1.1) References: ----------- Hilbe, J. 1993. ^Generalized linear models^, Stata Technical Bulletin, Vol 11:sg16. Hilbe, J. 1993. ^Generalized linear models using power links^, Stata Technical Bulletin, Vol 12:sg16.1. Hilbe, J. 1993. ^GLM: A unified power-link based program including the ^negative binomial^, Stata Technical Bulletin, Vol 14:sg16.2 HIlbe, J. 1993. ^Quasi-likelihood modeling with an enhanced glm command^, Stata Technical Bulletin, Vol 15:sg16.3 McCullagh, P. and J. A. Nelder. 1989. ^Generalized Linear Models^. 2d ed. Chapman & Hall. Nelder, J. (unpublished manuscript draft), ^Generalized linear models with ^negative binomial or beta-binomial errors^. Author and support: ------------------- Joseph Hilbe email: atjmh@@asuvm.inre.asu.edu Department of Sociology, & fax : 602-860-1446 Dept. of Decision & Information Sciences, Statistics Arizona State University Tempe, AZ 85287 Also see -------- STB: sg16.5 (STB-18)