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 glmest glmstat glmlld glmlink glminvlink

Quantlet: glmcore
Description: fits a generalized linear model E[y|x] = G(x*b). This is the core routine for GLM estimation. It assumes that all input variables are given in the right manner. No preparation of data is performed. A more convenient way to estimate a GLM is to call the function glmest.

Reference(s):

Link:
Usage: {b,bv,it,ret} = glmcore(code,x,y,wx,off,ctrl)
Input:
code text string, the short code for the model (e.g. "bilo" for logit or "noid" for ordinary LS).
x n x p matrix, the predictor variables.
y n x 1 or n x 2 or n x 3 matrix, either the response values, or sums of response values in 1st column and sums of a function of response values in the 2nd column (e.g. sums of y^2 or log(y)). (In the case of replicated data, the number of replications should be given in wx, y[,1] contains the sums of all responses for a replication, y[,2] contains sums of y^2 or log(y) for a replication.)
wx n x 1 vector or scalar, weights. Set wx=1 to ignore.
off n x 1 vector or scalar, offset. Set off=0 to ignore.
ctrl 6 x 1 vector or scalar, contains control parameters shf (default=0), miter (default=10), cnv (default=0.0001), fscor (default=0), pow (default=0, power for power link), nbk (default=1, parameter for negative binomial). Alternatively, one can give here shf only. Set to 0 to use the defaults. The parameters correspond to the optional parameters which can be given in glminit. They are all ignored when not applicable.
Output:
b p x 1 vector, estimated coefficients.
bv p x p matrix, estimated covariance matrix for b. Not yet corrected for dispersion!
it integer, number of iterations needed.
ret scalar, return code: 0 o.k., 1 maximal number of iterations reached (if applicable), -1 missing values have been encountered.

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
;==========================
lf = glmcore("bilo",x,y,1,0,1)
b~lf.b

Result:
A logit fit for E[y|x,t] is computed. lf.b contains the
coefficients for the linear part. The example gives the
true b together with the GLM estimate lf.b.



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