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 glmest glmcore glmstat

Macro: glminit
Description: glminit checks the validity of input and performs the initial calculations for an GLM fit. The output is ready to be used with glmcore.

Link:
Usage: {xr,yr,wxr,offr,ctrl} = glminit(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. Binomial y[i] may have (integer) values between 0 and opt.wx[i] or opt.wx (if opt.wx is scalar).
opt optional, a list with optional input. The macro "glmopt" can be used to set up this parameter. The order of the list elements is not important. Parameters which are not given are replaced by defaults (see below).
opt.wx scalar or n x 1 vector, prior weights. For binomial models usually the binomial index vector. 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.miter integer, maximal number of iterations. The default is 10.
opt.cnv integer, 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 optional, power for power link.
opt.nbk scalar, extra parameter k for negative binomial distribution. If not given, set to 1 (geometric distribution).
Output:
xr nr x p matrix, the predictor variables, eventually reduced up to replications.
yr nr x 1 or nr x 2 or nr 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 and 3rd column (e.g. sums of y^2 or log(y), see glmll). (In the case of replicated data, the number of replications should be given in wx, yr[,1] contains the sums of all responses for a replication, yr[,2:3] contains sums of e.g. y^2 or log(y) for a replication.)
wxr nr x 1 vector or scalar, prior weights.
offr nr x 1 vector or scalar, offset.
ctrl 6 x 1 integer vector or scalar, contains control parameters shf, miter, cnv, fscor, pow, nbk or shf alone. Defaults for miter, cnv, fscor, pow, nbk are 10, 0.0001, 0, 0 (logarithm link) and 1.

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,"norepl",1)
{x,y,wx,off,ctrl}=glminit("bilo",x,y,opt)
lf=glmcore("bilo",x,y,wx,off,ctrl)
b~lf.b
Result:
A logit fit for E[y|x,t] is computed. The options "shf" for
information during the iteration and "norepl" for not to
search for replications are set. lf.b contains the 
coefficients for the linear part. The example gives the 
true b together with the GLM estimate lf.b.

Library: glm
See also: glmopt glmest glmcore glmstat

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

Author: Marlene Mueller, 970523
(C) MD*TECH Method and Data Technologies, 28.6.1999