nagdmc loglinear

NAG DMC

Loglinear Regression: nagdmc loglinear
Purposenagdmc loglinear computes a loglinear regression model with p parameters and is a simplified
interface to nagdmc poisson reg using a log link function.

Declaration#include <nagdmc.h>void nagdmc loglinear reg(long rec1, long nvar, long nrec, long dblk, double data[],long nxvar, long xvar[], long yvar, double *dev,
long *df, double b[], double se[], double cov[],double model[], int *info);

Parameters1:

rec1 – longInput

On entry: the index in the data of the first data record used in the analysis.
Constraint: rec1 ≥ 0.
2:

nvar – long

Input

On entry: the number of variables in the data.
Constraint: nvar > 1.
3:

nrec – long

Input

On entry: the number of consecutive records, beginning at rec1, used in the analysis.
Constraint: nrec > 1.
4:

dblk – long

Input

On entry: the total number of records in the data block.
Constraint: dblk ≥ rec1 + nrec.
5:

data[dblk ∗ nvar] – double

Input

On entry: the data values for the jth variable (for j = 0, 1, . . . , nvar−1) are stored in data[i∗nvar+j],
for i = 0, 1, . . . , dblk − 1.
6:nxvar – long

Input

On entry: the number of independent variables. If nxvar = 0 then all variables in the data,
excluding yvar, are treated as independent variables.
Constraint: 0 ≤ nxvar < nvar.
7:

xvar[nxvar] – long

Input

On entry: the indices indicating the position in data in which values of the independent variables
are stored. If nxvar = 0 then xvar must be 0, and the indices of independent variables are given by
j = 0, 1, . . . , nvar − 1; j 6= yvar.
Constraints: if nxvar > 0, 0 ≤ xvar[i] < nvar, for i = 0, 1, . . . , nxvar − 1; otherwise xvar must be0.
8:yvar – long

Input

On entry: the index in data in which values of the dependent variable are stored.
Constraints: 0 ≤ yvar < nvar; if nxvar > 0, yvar 6= xvar[i], for i = 0, 1, . . . , nxvar − 1.
9:dev – double

OutputOn exit: the deviance from the fitted model.
10:

df – long *OutputOn exit: the degrees of freedom for the deviance.

nagdmc loglinear.1

nagdmc loglinear

NAG DMC11:b[p] – double
OutputOn exit: the parameter estimates. b[0] is the mean parameter. b[i] is the coefficient of the ith
variable included in the model, for i = 1, 2, . . . , p − 1. If nxvar > 0 then the order the independent
variables are added to the model is defined by xvar, otherwise the order is defined by indices in thedata.

12:

se[p] – double
On exit: the standard errors of the parameters in b.

13:

cov[p ∗ (p + 1)/2] – double
OutputOn exit: the first p ∗ (p + 1)/2 elements of cov contain the upper triangular part of the variancecovariance matrix of the p parameters in b. They are stored packed by column, i.e., the covariance
between the parameter estimate given in b[i] and the parameter estimate given in b[j], j ≥ i, isstored in cov[j(j + 1)/2 + i], for i = 0, 1, . . . , p − 1 and j = i, i + 1, . . . , p − 1.

14:

model[(3 ∗ p ∗ (p + 1))/2 + nvar + 14] – double
OutputOn exit: if not 0, information on the fitted model for use in the functions described in ‘See Also’.

15:

info – int *On exit: info gives information on the success of the function call:

OutputOutput−4: a model value has reached a boundary.
0: the function successfully completed its task.
i; i = 1, 2, . . . , 4, 6, 7, 8: the specification of the ith formal parameter was incorrect.
42: invalid value for response variable.
45: model has not converged.
57: there are no degrees of freedom for the error estimates.
58: the fit is exact, no error estimates.
59: more variables than observations.
98: there is an underlying computational problem (this is an unlikely error exit).
99: the function failed to allocate enough memory.

Notation
nrec
nxvar
xvar
yvarb

the number of observations, n.
the number of independent variables, p − 1.
the independent variables, X, excluding the mean.
the dependent variable, y.
the parameter estimates, β̂.

Description
See the description for nagdmc poisson reg.

References and Further Reading
Cook R D and Weisberg S (1982) Residuals and Influence in Regression Chapman and Hall.
McCullagh P and Nelder J A (1983) Generalized Linear Models Chapman and Hall.
Plackett R L (1974) The Analysis of Categorical Data Griffin.

See Also
nagdmc extr reg
nagdmc poisson reg
nagdmc predict reg
loglinear reg ex.ccomputes fitted values, residuals and leverages for a regression.
generalized linear model with Poisson errors.
computes predictions given a fitted regression model.
the example calling program.

nagdmc loglinear.2