Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: glm
See also: glmopt glminit glmcore glmstat glmest doglm

Quantlet: glmest
Description: glmest fits a generalized linear model E[y|x] = G(x*b). This routine offers a convenient interface for GLM estimation. A check of the data is performed.

Reference(s):

Link:
Usage: myfit = glmest(code,x,y{,opt})
Input:
code text string, the short code for the model (e.g. "bilo" for logit or "noid" for ordinary PLM).
x n x p matrix, the predictor variables.
y n x 1 vector, the response variables.
opt optional, a list with optional input. "glmopt" can be used to set up this parameter. The order of the list elements is not important.
opt.weights string, type of weights. Can be "frequency" for replication counts, or "prior" (default) for prior weights in weighted regression.
opt.wx scalar or n x 1 vector, frequency or prior weights. If not given, set to 1.
opt.off scalar or n x 1 vector, offset. Can be used for constrained estimation. If not given, set to 0.
opt.shf integer, if exists and =1, some output is produced which indicates how the iteration is going on.
opt.norepl integer, if exists and =1, the data are assumed to have no replications in x. Otherwise, the data are searched for replications to fasten the algorithm.
opt.miter integer, maximal number of iterations. The default is 10.
opt.cnv scalar, convergence criterion. The default is 0.0001.
opt.fscor integer, if exists and =1, a Fisher scoring is performed (instead of the default Newton-Raphson procedure). This parameter is ignored for canonical links.
opt.pow scalar, power for power link. If not given, set to 0.
opt.nbk scalar, extra parameter k for negative binomial distribution. If not given, set to 1 (geometric distribution).
Output:
myfit.b p x 1 vector, estimated coefficients.
myfit.bv p x p matrix, estimated covariance matrix for coefficients.
myfit.stat list with components as computed by glmstat: serror (standard errors of coefficients), tvalue (t-values for coefficients), pvalue (p-values for coefficients), df (degrees of freedom), deviance (deviance), pearson (generalized pearson's chi^2), loglik (log-likelihood), dispersion (estimated dispersion =pearson/df), r2 ((pseudo) coefficient of determination), adr2 (adjusted (pseudo) coefficient of determination), aic (Akaike's AIC criterion), bic (Schwarz' BIC criterion), and it (number of iterations needed), ret (return code, 0 if everything went o.k., 1 if maximal number of iterations reached, -1 if missing values have been encountered), nr (number of replications found in x).

Example:
library("glm")
;==========================
;  simulate data
;==========================
n=100
b=1|2
p=rows(b)
x=2.*uniform(n,p)-1
y=( 1./(1+exp(-x*b)).>uniform(n) )
;==========================
;  GLM fit
;==========================
opt=glmopt("shf",1)
lf=glmest("bilo",x,y,opt)
b~lf.b
lf.stat.deviance

Result:
A logit fit for E[y|x] is computed. The option "shf" for
information during the iteration is set. lf.b contains the
coefficients for the linear part. The example gives the
true b together with the GLM estimate lf.b. The deviance
of the fitted model is shown as well.



Author: M. Mueller, 20010228
(C) MD*TECH Method and Data Technologies, 05.02.2006