The following nls
code throws the following error Convergence failure: singular convergence (7)
for fm2
(for Data2
). But the same code for similar dataset works fine (fm1
for Data1
). Any help to figure out this problem will be highly appreciate. Thanks
Works Fine for this Data Set
Data1 <-
structure(list(D = c(0L, 0L, 0L, 0L, 5L, 5L, 5L, 5L,
10L, 10L, 10L, 10L, 15L, 15L, 15L, 15L, 20L, 20L, 20L, 20L),
Y = c(11.6, 9.3, 10.7, 9.2, 7.8, 8, 8.6, 7.9, 7.7,
7.6, 7.5, 7.5, 7.2, 7.3, 7, 6.5, 6.3, 5.7, 5.6, 6)), .Names = c("D",
"Y"), class = "data.frame", row.names = c(NA, 20L))
fm1 <-
nls(
formula=Y~w*(1-(i*D/(100*(1+i*D/A))))
, data=Data1
, start=list(w=13, i=3, A=80)
, algorithm="port"
)
Does not Work for this Data Set
Data2 <-
structure(list(D = c(0L, 0L, 0L, 0L, 5L, 5L, 5L, 5L,
10L, 10L, 10L, 10L, 15L, 15L, 15L, 15L, 20L, 20L, 20L, 20L),
Y = c(10.8, 10.7, 8.4, 8.5, 8, 8, 8, 7.9, 7.9, 7.2,
7.8, 7.2, 6.6, 6.5, 6.5, 6.4, 2.2, 4.5, 4.2, 6.2)), .Names = c("D",
"Y"), class = "data.frame", row.names = 21:40)
fm2 <-
nls(
formula=Y~w*(1-(i*D/(100*(1+i*D/A))))
, data=Data2
, start=list(w=13, i=3, A=80)
, algorithm="port"
)
I think its having problems with your parameterization. We can take advantage of linearlity by letting B be i/A, .lin1 = w and .lin2 = i*w in which case .lin1 and .lin2 enter linearly and using
alg=plinear
only the non-linear parameter needs a starting value:From the result w = .lin1; i*w = .lin2 (so i = .lin2 / .lin1) and B = i/A (so A = i/B).
REVISED Improved the formulation.