casallas / minpack.lm

R interface to the Levenberg-Marquardt nonlinear least-squares
Other
0 stars 0 forks source link

`confint` fails on `nlsLM` models fitted with `lower` or `upper` #1

Open casallas opened 10 years ago

casallas commented 10 years ago

Minimal example

require(minpack.lm)
require(graphics)

DNase1 <- subset(DNase, Run == 1)

scal.min <- -Inf
scal.max <- Inf
fm3DNase1 <- nlsLM(density ~ Asym/(1 + exp((xmid - log(conc))/scal)),
                data = DNase1,
                start = list(Asym = 3, xmid = 0, scal = 1), lower=c(Asym = -Inf, xmid = -Inf, scal = scal.min),
                upper = c(Asym = Inf, xmid = Inf, scal = scal.max))

confint(fm3DNase1)

Yields

Waiting for profiling to be done...
Error in rep_len(if (!is.null(lower)) as.double(lower) else Inf, length(defaultPars)) : 
  'pairlist' object cannot be coerced to type 'double'
casallas commented 10 years ago

This is a related error to something I'd reported earlier for R-source's nls

The accepted solution was wch/r-source@0b6a9fca177ea5764c9c36bd24eeacbf8320bb8b, which made me think that the real problem happened when creating the nls object wihin nlsLM

The possible solution could be to add something like r-source/src/library/stats/R/nls.R:620-622

I've created a patch at ef5917f97405e588a054f7ea73cecf329e1728ec but haven't tested it.

GitHubDoug commented 9 years ago

Hello; I am R beginner, but I am blocked by the issue you describe above. Is there a solution or work around? I tried to follow your patch but did not understand it.