gnlmod | R Documentation |
Non-linear regression (nls
) selfStart
model generalized to use exponential family
error
distributions.
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, ...)
formula |
Model formula for a |
data |
Data for formula. |
family |
Error distribution of the exponential
|
wts |
Prior weights |
... |
Other parameters passed to |
object |
|
newdata |
New independent data for prediction. |
type |
Type of predicted values; only |
dispersion |
The dispersion parameter for the family
used. Either a single numerical value of |
correlation |
logical; if |
Function combines three R functions for fitting non-linear models with exponential family errors:
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.
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).
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.
Function returns the nlm
result object, but
it is amended with glm
object related to
family
.
McCullagh, P & Nelder, J.A. (1989) Generalized Linear Models, 2nd ed. Chapman & Hall.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.