Transcription of glm — Generalized linear models - Stata
1 Title glm Generalized linear models Description Quick start Menu Syntax Options Remarks and examples Stored results Methods and formulas Acknowledgments References Also see Description glm fits Generalized linear models . It can fit models by using either IRLS (maximum quasilikelihood). or Newton Raphson (maximum likelihood) optimization, which is the default. See [U] 27 Overview of Stata estimation commands for a description of all of Stata 's estimation commands, several of which fit models that can also be fit using glm. Quick start model of y as a function of x when y is a proportion glm y x, family(binomial).
2 Logit model of y events occurring in 15 trials as a function of x glm y x, family(binomial 15) link(logit). Probit model of y events as a function of x using grouped data with group sizes n glm y x, family(binomial n) link(probit). model of discrete y with user-defined family myfamily and link mylink glm y x, family(myfamily) link(mylink). Bootstrap standard errors in a model of y as a function of x with a gamma family and log link glm y x, family(gamma) link(log) vce(bootstrap). Menu Statistics > Generalized linear models > Generalized linear models (GLM).
3 1. 2 glm Generalized linear models Syntax . glm depvar indepvars if in weight , options options Description model family(familyname) distribution of depvar; default is family(gaussian). link(linkname) link function; default is canonical link for family() specified model 2. noconstant suppress constant term exposure(varname) include ln(varname) in model with coefficient constrained to 1. offset(varname) include varname in model with coefficient constrained to 1. constraints(constraints) apply specified linear constraints asis retain perfect predictor variables mu(varname) use varname as the initial estimate for the mean of depvar init(varname) synonym for mu(varname).
4 SE/Robust vce(vcetype) vcetype may be oim, robust, cluster clustvar, eim, opg, bootstrap, jackknife, hac kernel, jackknife1, or unbiased vfactor(#) multiply variance matrix by scalar #. disp(#) quasilikelihood multiplier scale(x2 | dev | #) set the scale parameter Reporting level(#) set confidence level; default is level(95). eform report exponentiated coefficients nocnsreport do not display constraints display options control columns and column formats, row spacing, line width, display of omitted variables and base and empty cells, and factor-variable labeling Maximization ml use maximum likelihood optimization; the default irls use iterated, reweighted least-squares optimization of the deviance maximize options control the maximization process; seldom used fisher(#) use the Fisher scoring Hessian or expected information matrix (EIM).
5 Search search for good starting values noheader suppress header table from above coefficient table notable suppress coefficient table nodisplay suppress the output; iteration log is still displayed collinear keep collinear variables coeflegend display legend instead of statistics glm Generalized linear models 3. familyname Description gaussian Gaussian (normal). igaussian inverse Gaussian binomial varnameN | #N Bernoulli/binomial poisson Poisson nbinomial #k | ml negative binomial gamma gamma linkname Description identity identity log log logit logit probit probit cloglog cloglog power # power opower # odds power nbinomial negative binomial loglog log log logc log-complement indepvars may contain factor variables; see [U] Factor variables.
6 Depvar and indepvars may contain time-series operators; see [U] Time-series varlists. bayes, bootstrap, by, collect, fmm, fp, jackknife, mfp, mi estimate, nestreg, rolling, statsby, stepwise, and svy are allowed; see [U] Prefix commands. For more details, see [BAYES] bayes: glm and [FMM] fmm: glm. vce(bootstrap), vce(jackknife), and vce(jackknife1) are not allowed with the mi estimate prefix; see [MI] mi estimate. Weights are not allowed with the bootstrap prefix; see [R] bootstrap. aweights are not allowed with the jackknife prefix; see [R] jackknife.
7 Vce(), vfactor(), disp(), scale(), irls, fisher(), noheader, notable, nodisplay, and weights are not allowed with the svy prefix; see [SVY] svy. fweights, aweights, iweights, and pweights are allowed; see [U] weight. noheader, notable, nodisplay, collinear, and coeflegend do not appear in the dialog box. See [U] 20 estimation and postestimation commands for more capabilities of estimation commands. Options . model family( familyname) specifies the distribution of depvar; family(gaussian) is the default. link(linkname) specifies the link function; the default is the canonical link for the family().
8 Specified (except for family(nbinomial)).. model 2. noconstant, exposure(varname), offset(varname), constraints(constraints); see [R] Esti- mation options. constraints(constraints) is not allowed with irls. 4 glm Generalized linear models asis forces retention of perfect predictor variables and their associated, perfectly predicted observations and may produce instabilities in maximization; see [R] probit. This option is allowed only with option family(binomial) with a denominator of 1. mu(varname) specifies varname as the initial estimate for the mean of depvar.
9 This option can be useful with models that experience convergence difficulties, such as family(binomial) models with power or odds-power links. init(varname) is a synonym.. SE/Robust vce(vcetype) specifies the type of standard error reported, which includes types that are derived from asymptotic theory (oim, opg), that are robust to some kinds of misspecification (robust), that allow for intragroup correlation (cluster clustvar), and that use bootstrap or jackknife methods (bootstrap, jackknife); see [R] vce option. In addition to the standard vcetypes, glm allows the following alternatives: vce(eim) specifies that the EIM estimate of variance be used.
10 Vce(jackknife1) specifies that the one-step jackknife estimate of variance be used.. vce(hac kernel # ) specifies that a heteroskedasticity- and autocorrelation-consistent (HAC). variance estimate be used. HAC refers to the general form for combining weighted matrices to form the variance estimate. There are three kernels built into glm. kernel is a user-written program or one of nwest | gallant | anderson # specifies the number of lags. If # is not specified, N 2 is assumed. If you wish to specify vce(hac .. ), you must tsset your data before calling glm.