glm.cons: Fitting Generalized Linear Models with constraint on the...

glm.consR Documentation

Fitting Generalized Linear Models with constraint on the coefficients signs

Description

glm.cons is an adaptation of function glm2 from package {glm2} in which the least squares estimation is replaced by a regression with signs constraint on the coefficients using function nnnpls from package {nnls}.

Usage

glm.cons(
  formula,
  family = stats::gaussian(),
  data,
  weights,
  subset,
  na.action,
  start = NULL,
  etastart,
  mustart,
  offset,
  control = list(...),
  model = TRUE,
  method = "glm.fit.cons",
  cons = -1,
  cons.inter = 1,
  x = FALSE,
  y = TRUE,
  contrasts = NULL,
  ...
)

Arguments

formula

as for glm

family

as for glm

data

as for glm

weights

as for glm

subset

as for glm

na.action

as for glm

start

as for glm

etastart

as for glm

mustart

as for glm

offset

as for glm

control

as for glm

model

as for glm

method

the method used in fitting the model. The default method "glm.fit.cons" uses function nnnpls from package nnls instead of lm.fit to impose the sign of the coefficients. As in glm, the alternative method "model.frame" returns the model frame and does no fitting.

cons

type of constraint. Default is -1 for negative coefficients on the predictors. The other option is 1 for positive coefficients on the predictors.

cons.inter

type of constraint for the intercept. Default is 1 for positive intercept, suitable for Gaussian family. The other option is -1 for negative intercept, suitable for binomial family.

x

as for glm

y

as for glm

contrasts

as for glm

...

as for glm

Value

The value returned by glm.cons has exactly the same structure as the value returned by glm and glm.2.

References

Marschner, I.C. (2011) glm2: Fitting generalized linear models with convergence problems. The R Journal, 3(2), 12-15.

See Also

glm, glm2

Examples

## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm.cons(counts ~ outcome + treatment, family = poisson())
glm.D93.ngl <- glm.cons(counts ~ outcome + treatment, family = poisson(),
   method="glm.fit.cons")
summary(glm.D93)
summary(glm.D93.ngl)

zetadiv documentation built on June 11, 2022, 1:12 a.m.

Related to glm.cons in zetadiv...