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 glmout

Quantlet: glmfit
Description: helper function for doglm.

Reference(s):

Link:
Usage: glmfit(x,y{,opt})
Input:
x n x p matrix, the predictor variables.
y n x 1 vector, the response variables. (In the case of replicated data, the number of replications should be given in opt.wx and y should contain the sums of all responses for a replication.)
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.code text string, the short code for the model (e.g. "bilo" for logit or "noid" for ordinary PLM).
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 in linear predictor. If not given, set to 0.
opt.name string, prefix for the output. If not given, "glm" is used.
opt.title string, title for the output. If not given, a default is set.
opt.xvars p x 1 string vector, variable names for the output. Note, that only up to 11 characters are used.
Output:
glmfitOutput or opt.name+"Output" display, containing estimation result in the left panel and a plot of the index x*b{+off} vs. y (vs. y./wx for binomials) and a plot of th index vs. the link function.
glmfitout or opt.name+"out" string vector, global, containing estimation result in the left panel as text.
glmfit or opt.name list, global variable with the components:
glmfit.b p x 1 vector, estimated coefficients.
glmfit.bv p x p matrix, estimated covariance matrix for b.
glmfit.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")
n=100
b=1|2
p=rows(b)
x=2.*uniform(n,p)-1
y=x*b+normal(n)./2
glmfit(x,y)

Result:
You should choose "normal" distribution for Y and identity
link function. A ordinary least squares regression
is fitted.  'glmfit' contains the estimation results. A
graphical display containing these results appears at the end.



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