nlr {gnlm} | R Documentation |
Nonlinear Normal, Gamma, and Inverse Gaussian Regression Models
Description
nlr
fits a user-specified nonlinear regression equation by least
squares (normal) or its generalization for the gamma and inverse Gauss
distributions.
Usage
nlr(y = NULL, mu = NULL, pmu = NULL, distribution = "normal",
wt = 1, delta = 1, envir = parent.frame(), print.level = 0,
typsize = abs(pmu), ndigit = 10, gradtol = 1e-05, stepmax = 10 *
sqrt(pmu %*% pmu), steptol = 1e-05, iterlim = 100, fscale = 1)
Arguments
y |
The response vector or an object of class, |
mu |
A function of |
pmu |
Vector of initial estimates of the parameters. If |
distribution |
The distribution to be used: normal, gamma, or inverse Gauss. |
wt |
Weight vector. |
delta |
Scalar or vector giving the unit of measurement for each
response value, set to unity by default. For example, if a response is
measured to two decimals, |
envir |
Environment in which model formulae are to be interpreted or a
data object of class, |
print.level |
Arguments controlling |
typsize |
Arguments controlling |
ndigit |
Arguments controlling |
gradtol |
Arguments controlling |
stepmax |
Arguments controlling |
steptol |
Arguments controlling |
iterlim |
Arguments controlling |
fscale |
Arguments controlling |
Details
A nonlinear regression model can be supplied as a formula where parameters
are unknowns in which case factor variables cannot be used and parameters
must be scalars. (See finterp
.)
The printed output includes the -log likelihood (not the deviance), the corresponding AIC, the parameter estimates, standard errors, and correlations.
Value
A list of class nlr
is returned that contains all of the
relevant information calculated, including error codes.
Author(s)
J.K. Lindsey
See Also
finterp
, fmr
,
glm
, glmm
,
gnlmm
, gnlr
,
gnlr3
, lm
, nls
.
Examples
x <- c(3,5,0,0,0,3,2,2,2,7,4,0,0,2,2,2,0,1,3,4)
y <- c(5.8,11.6,2.2,2.7,2.3,9.4,11.7,3.3,1.5,14.6,9.6,7.4,10.7,6.9,
2.6,17.3,2.8,1.2,1.0,3.6)
# rgamma(20,2,scale=0.2+2*exp(0.1*x))
# linear least squares regression
mu1 <- function(p) p[1]+p[2]*x
summary(lm(y~x))
nlr(y, mu=mu1, pmu=c(3,0))
# or
nlr(y, mu=~x, pmu=c(3,0))
# or
nlr(y, mu=~b0+b1*x, pmu=c(3,0))
# linear gamma regression
nlr(y, dist="gamma", mu=~x, pmu=c(3,0))
# nonlinear regression
mu2 <- function(p) p[1]+p[2]*exp(p[3]*x)
nlr(y, mu=mu2, pmu=c(0.2,3,0.2))
# or
nlr(y, mu=~b0+c0*exp(c1*x), pmu=list(b0=0.2,c0=3,c1=0.2))
# with gamma distribution
nlr(y, dist="gamma", mu=~b0+c0*exp(c1*x), pmu=list(b0=0.2,c0=3,c1=0.2))