[R] Algorithm = "port" convergence codes
Nakamura
rbt501 at york.ac.uk
Tue Oct 7 17:04:09 CEST 2008
Hello all,
I am fitting a Gamma distribution to some data I have using nls(). The
function obviously runs into issues when using a 0 as a parameter value. I
understand the line alg = "port" can be used to set the lower bounds to
prevent this from happening. When I run the code I get the following:
Algorithm "port", convergence message: relative convergence (4). I have
attempted changing the starting parameter values and the paramter estimates
appear robust.
The R help file mentions the code is "0" for converence. Should I be
concerned here that nls() is returning a local optimum here, or is this
quite normal?
Thanks in advance!
Rob
PS Please try to ignore the fact a distribution is being fitted to too few
data points!
##Code
Acancellata.caughtintraps = c(6,2,1,2,0,0,0,0,0,0,0)
Acancellata.released = 1250
distances = c(2,3,4,5,7.5,10,12.5,15,17.5,20,25)
totalseedscaught = sum(Acancellata.caughtintraps)
Pcatch = totalseedscaught/Acancellata.released
## Calculate cumulative seed numbers reaching each distance
cumsumcaught <- rev(cumsum(rev(Acancellata.caughtintraps)))
i = numeric(11)
i <- distances
## Gamma distribution
gamma.nls <- nls(cumsumcaught ~ Pcatch*Acancellata.released*
pgamma(distances,shape=a,scale=c,lower.tail=FALSE),
## 'alg="port"' is required for lower bounds ##
alg="port",
start = list(a=5,c=1),
lower=list(a=0.1,b=0.1))
print(gamma.nls)
print(summary(gamma.nls))
## Output
[1] "Gamma"
Nonlinear regression model
model: cumsumcaught ~ Pcatch * Acancellata.released * pgamma(distances,
shape = a, scale = c, lower.tail = FALSE)
data: parent.frame()
a c
7.5731 0.4399
residual sum-of-squares: 4.176
Algorithm "port", convergence message: relative convergence (4)
Formula: cumsumcaught ~ Pcatch * Acancellata.released * pgamma(distances,
shape = a, scale = c, lower.tail = FALSE)
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 7.5731 2.3786 3.184 0.0111 *
c 0.4399 0.1415 3.109 0.0125 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6812 on 9 degrees of freedom
Algorithm "port", convergence message: relative convergence (4)
--
View this message in context: http://www.nabble.com/Algorithm-%3D-%22port%22-convergence-codes-tp19860224p19860224.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list