[R] non-linear regression
Katharine Mullen
kate at few.vu.nl
Fri Dec 11 00:55:06 CET 2009
You did not provide the data or a way of generating it.
I would guess that Excel finds the same solution (the same residual sum-of
squares) as nls but that it uses a weak convergence criterion and/or does
not give you information regarding why it terminates.
Regarding the step size: you can set the minimum step size factor via the
minFactor argument of control.
qx.suav <- function(id,A,B,C,D,E,F,G,H,K)
(A^((id+B)^C)+(D*exp(-E*(log(id)-log(F))^2))+(G*H^id)/(1+(K*G*H^id)))
## make noisy data from model
id <- 1:1000
tx.br <- qx.suav(id,A=0.0006347,B=0.0453814,C=0.1353538,D=0.1353538,
E=0.0002127,F=38.5448420,G=0.0000115,H=1.1109286,
K=0.382070638)
set.seed(1)
tx.br <- tx.br + rnorm(length(tx.br),0,.0001)
HP <- nls(tx.br~qx.suav(id,A,B,C,D,E,F,G,H,K),
data=data.frame(id=id,tx.br=tx.br),
trace=TRUE,nls.control(maxiter=5000,warnOnly=TRUE),
algorithm='port',
start=list(A=0.0006347,B=0.0453814,C=0.1353538,D=0.1353538,
E=0.0002127,F=38.5448420,G=0.0000115,H=1.1109286,
K=0.382070638),
lower=list(A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,K=0))
matplot(cbind(fitted(HP), tx.br),type="l")
On Thu, 10 Dec 2009, AneSR wrote:
>
> I have a non-linear regression with 8 parameters to solve .... however it
> does not converge ... easily solves the excel ... including the initial
> estimates used in the R were found in the excel ... Another question is how
> to establish the increments of R by the parameters in the search ..
>
>
> qx.suav<-function(id,A,B,C,D,E,F,G,H,K){(A^((id+B)^C)+(D*exp(-E*(log(id)-log(F))^2))+(G*H^id)/(1+(K*G*H^id)))}
> HP<-nls(tx.br~qx.suav(id,A,B,C,D,E,F,G,H,K),data=data.frame(id=id,tx.br=tx.br),
> trace=TRUE,nls.control(maxiter=5000),algorithm='port',start=list(A=0.0006347,B=0.0453814,C=0.1353538,D=0.1353538,E=0.0002127,F=38.5448420,G=0.0000115,H=1.1109286,K=0.382070638),lower=list(A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,K=0))
> summary(HP)
>
> How to solve this problem in R?
>
> Ane
> --
> View this message in context: http://n4.nabble.com/non-linear-regression-tp959977p959977.html
> Sent from the R help mailing list archive at Nabble.com.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list