gnlmod: Generalized Non-Linear Regression Analysis

gnlmodR Documentation

Generalized Non-Linear Regression Analysis

Description

Non-linear regression (nls) selfStart model generalized to use exponential family error distributions.

Usage

gnlmod(formula, data, family = gaussian, wts, ...)

## S3 method for class 'gnlmod'
predict(object, newdata, type = "response", ...)

## S3 method for class 'gnlmod'
summary(object, dispersion = NULL, correlation = FALSE, ...)

Arguments

formula

Model formula for a selfStart nls model.

data

Data for formula.

family

Error distribution of the exponential family.

wts

Prior weights

...

Other parameters passed to nlm that performs the actual regression.

object

gnlmod result object.

newdata

New independent data for prediction.

type

Type of predicted values; only "response" implemented.

dispersion

The dispersion parameter for the family used. Either a single numerical value of NULL (the default), when it is inferred from the object.

correlation

logical; if TRUE, the correlation matrix of the estimated parameters is returned and printed.

Details

Function combines three R functions for fitting non-linear models with exponential family errors:

  1. Non-linear regression is defined by selfStart like in nls. In addition to defining the nonlinear function, these also provide initial values and derivatives of model parameters.

  2. family functions are used to define the error distribution allowing use of other than least squares models. The family functions provide the log-likelihood function for fitting, and allows finding the partial derivatives of model parameters for the log-likelihood function (see McCullagh & Nelder 1989, p. 41).

  3. The log-likelihood function (with partial derivatives) is optimized with nlm.

The result is mostly similar to glm object, and can be handled with many glm method functions, except those that assume linear fit.

Value

Function returns the nlm result object, but it is amended with glm object related to family.

References

McCullagh, P & Nelder, J.A. (1989) Generalized Linear Models, 2nd ed. Chapman & Hall.

Examples

## Compare to vegan species-area models
require(vegan) || stop("needs vegan")
data(sipoo, sipoo.map)
S <- specnumber(sipoo)
## Arrhenius model in vegan with least squares
nls(S ~ SSarrhenius(area, k, z), sipoo.map)
## Assume Poisson error
(mod <- gnlmod(S ~ SSarrhenius(area, k, z), sipoo.map, family=poisson))
## Arrhenius should be identical to Poisson glm with log-link
glm(S ~ log(area), sipoo.map, family=poisson) # (Intercept) = log(k)
## some method functions
fitted(mod)
predict(mod)
predict(mod, newdata = list(area = seq(1, 250, len=31)))
summary(mod)


jarioksa/natto documentation built on March 28, 2024, 12:45 a.m.