Description Usage Arguments Details Value Note Author(s) References See Also Examples
This is generic function fits a nonlinear mixed-effects model using robust methods described in Riazoshams et al (2015), allowed to be correlated and/or have unequal variances.
1 2 3 4 5 6 7 | nlr(formula, data = parent.frame(), start = getInitial(formula, data),
control = nlr.control(minlanda=1 / 2 ^ 10,
maxiter=25 * length(start)), weights = NULL, robustobj = NULL,
robustform = c("hampel", "huber", "bisquare",
"andrew", "halph huber", "hampel 2", "least square"),
varianceform = NULL, tau = NULL, correlation = NULL,
covariance = NULL, ...)
|
formula |
can be a nl.form object of the nonlinear function model, or a model formula with the response on the left of a ~ operator and an expression involving parameters and covariates on the right. See |
data |
an optional data frame or list of data with the response and predictor as name of variable. In heterogeneous case if it include response variable values of heterogenous variance function it asume variance function is function of predictor H(x_i,τ), otherwise it assume is a function of predictor H(f(x_i,θ),τ). |
start |
list of starting value parameter, name of parameters must be represented as names of variable in the list. |
control |
nlr.control, include controles for nlr, see |
weights |
User optional matrix of variance covariance matrix of error, a general weight that can be used by user, but if correlation, covariace or varianceform argument given, then will be ignored. |
robustobj |
=NULL, optional |
robustform |
nl.form object of robust function used for downgrading. functions("hampel","huber","bisquare","andrew","halph huber","hampel 2","least square"). |
varianceform |
NULL, |
tau |
NULL, list or data.frame of initial values for heterogeneous variance function parameter. the stored value in vardnc object of nl.form will be stored. |
correlation |
autocorrelated error, form of corStruct but not in nlme, is extra arguments to any of "nl.forms". |
covariance |
optional covariance matrix of errors. If given Generalized estimates will be calculated. |
... |
Any extra arguments to any function sources, such as nonlinear regression model, heteroscedastic variance function, robust loss function or optimization object function. |
nlr is non-linear robust inference. It is mostly gradient and hessian based. The classic estimates also is avilable.
Output depends on the method called as:
Nonlinear Least Square Estimate(NLLS): nl.fitt
object.
Generalized NLLS: nl.fitt.gn
object.
Robust Estimate: nl.fitt.rob
object.
Generalized Robust Estimate: nl.fitt.rgn
object.
Thic is the global function of nlr
package. You can fitt models both with classic and robust methods. Besides homogeneous variance of error, heteroscedastic and autocorrelated error can be fited by this function.
nlr
is optimized for derivative based computation, but deribative free methods are provided for nonlinear regressions that derivative does not exist. In contrast derivative free method in this package are slow.
This package requires tseries
package to be installed, under ubuntu if facing with error that can not install "curl" ot "libcurl" package, run these command in terminal:
sudo apt-get install libcurl4-openssl-dev
deb http://security.ubuntu.com/ubuntu/ precise-security restricted main multiverse universe deb http://us.archive.ubuntu.com/ubuntu/ precise-updates restricted main multiverse universe
sudo apt-get update sudo apt-get install libcurl4-gnutls-dev
after all we can install tseries in R.
Hossein Riazoshams, May 2014. Email: riazihosein@gmail.com URL http://www.riazoshams.com/nlr/
Riazoshams H, Midi H, and Ghilagaber G, 2018,. Robust Nonlinear Regression, with Application using R, Joh Wiley and Sons.
nl.form
, nl.fitt
, nl.fitt.gn
, nl.fitt.rob
, nl.fitt.rgn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Chicken fitt without hetroscedasticity
d<-list(xr=Weights$Date, yr=Weights$Weight)
fitt.chicken1 <- nlr(nlrobj1[[2]],data=d,control=nlr.control(method = "OLS",trace=TRUE))
fitt.chicken1$parameters
plot(fitt.chicken1)
## Chicken fitt with hetroscedasticity
# RME by default
fitt.chicken2<-nlr(formula=nlrobj1
[[14]],data=d,start=list(p1=2300,p2=42,p3=.11),
robustform ="hampel",
tau=list
(sg=.09,landa=1),varianceform=nlrobjvarmdls1[[1]],
control=nlr.control(tolerance=1e-3))
fitt.chicken2$parameters
fitt.chicken2$hetro$parameters
plot(fitt.chicken2)
# autocorrelated case
xr = trade.ir[, 1]
yr = trade.ir[, 2]
a1 <- nlr( nlrobj5[[18]],data=list(xr = xr, yr = yr),
correlation=list(StructName="corAR1"))
a1$parameters
plot(a1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.