[R] Error in chol.default

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu Jul 16 18:27:06 CEST 2020


Hello,
I am trying to fit a Richards model to some cumulative incidence data
of infection. I got this example:
```
rich = function(p, x) {
  a = p["curvature"]
  k = p["finalPop"]
  r = p["growthRate"]
  y = r * x * (1-(x/k)^a)
  return(y)
}
ricky = function(p, x, y) p$r * x * (1-(x/p$k)^p$a) -y
# values
Y <- c(41,   41,   41,   41,   41,   41,   45,   62,  121,  198,  275,
 288,  859, 1118)
X <- 1:14
a = 1
k = 83347
r = 40
fit = rich(c(curvature=a, finalPop=k, growthRate=r), X)
plot(Y ~ X,
     col = "red", lwd = 2,
     main = "Richards model",
     xlab = expression(bold("Days")),
     ylab = expression(bold("Cases")))
points(X, fit, type = "l", lty = 2, lwd = 2)
library("minpack.lm")
o <- nls.lm(par = list(a=a, k=k, r=r), fn = ricky, x = X, y = Y)
summary(o)
```
When I run the optimization (given that I can't find parameters that
fit the data by eyeball), I get the error:
```
Error in chol.default(object$hessian) :
  the leading minor of order 1 is not positive definite
```
What is this about?
Thank you




-- 
Best regards,
Luigi



More information about the R-help mailing list