Description Usage Arguments Details Value Author(s) See Also Examples
Given a nonlinear model expressed as an expression of the form
lhs ~ formula_for_rhs
and a start vector where parameters used in the model formula are named,
attempts to find the minimum of the residual sum of squares using the
Nash variant (Nash, 1979) of the Marquardt algorithm, where the linear
sub-problem is solved by a qr method. The resulting solution is fed
into the nls()
function in an attempt to get the nls class solution.
1 2 |
formula |
This is a modeling formula of the form (as in |
start |
A named parameter vector. For our example, we could use start=c(b1=1, b2=2.345, b3=0.123) |
trace |
Logical |
data |
A data frame containing the data of the variables in the formula. This data may, however, be supplied directly in the parent frame. |
lower |
Lower bounds on the parameters. If a single number, this will be applied to all
parameters. Default |
upper |
Upper bounds on the parameters. If a single number, this will be applied to all
parameters. Default |
control |
A list of controls for the algorithm. These are as for |
... |
Any data needed for computation of the residual vector from the expression rhsexpression - lhsvar. Note that this is the negative of the usual residual, but the sum of squares is the same. |
wrapnlsr
first attempts to solve the nonlinear sum of squares problem by using
nlsmnq
, then takes the parameters from that method to call nls
.
An object of type nls.
John C Nash <nashjc@uottawa.ca>
Function nls()
, packages optim
and optimx
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | cat("See more examples in nlmrt-package.Rd\n")
cat("kvanderpoel.R test of wrapnlsr\n")
# require(nlsr)
x<-c(1,3,5,7)
y<-c(37.98,11.68,3.65,3.93)
pks28<-data.frame(x=x,y=y)
fit0<-try(nls(y~(a+b*exp(1)^(-c*x)), data=pks28, start=c(a=0,b=1,c=1),
trace=TRUE))
print(fit0)
cat("\n\n")
fit1<-nlxb(y~(a+b*exp(-c*x)), data=pks28, start=c(a=0,b=1,c=1), trace = TRUE)
print(fit1)
cat("\n\nor better\n")
fit2<-wrapnlsr(y~(a+b*exp(-c*x)), data=pks28, start=c(a=0,b=1,c=1),
lower=-Inf, upper=Inf, trace = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.