I'm trying to use nls()
, but I keep getting the error
Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates
and I'm not sure where the problem is.
Code below:
TI <- c(0.5, 2, 5, 10, 30)
prices <- cbind(zi, TI)
prices = as.data.frame(prices)
lnz_i <- function(TI, Alpha, Beta, Sigma) -TI*(Alpha*(1 - exp(-Beta*TI)) / (Beta) - (Sigma^2/2)*(1 - exp(-Beta*TI)) / (Beta)^2) - 0.02*(1 - exp(-Beta*TI)) / (Beta)
nls(zi ~ lnz_i(TI, Alpha, Beta, Sigma), start = c(Alpha = 0.02, Beta = 0.3, Sigma = 0.06), data = prices)
Any help is greatly appreciated.