如何确定使用非线性模型的算法的自启动值?

问题描述 投票:0回答:1
    df<- structure(list(Soil = c("CK", "CK", "CK", "CK", "CK", "CK", "CK", 
     "CK", "CK", "CK"), Glucose = c(8, 8, 8, 8, 8, 8, 8, 8, 8, 8), 
    time = c(1, 2, 3, 4, 5, 6, 7, 11, 17, 25), Cm = c(15.4736, 
    94.2992, 185.12, 256.23442, 303.35844, 392.46562, 502.13602, 
    916.64004, 1783.48684, 2182.39564), SE = c(6.1485851640845, 
    4.46286587743795, 5.33779226272434, 6.63454913615082, 4.16790687036061, 
    8.07906960980036, 14.3868919006156, 48.1716294796013, 49.2841788358089, 
    72.1220406233768), max = c(21.6221851640845, 98.7620658774379, 
    190.457792262724, 262.868969136151, 307.526346870361, 400.5446896098, 
    516.522911900616, 964.811669479601, 1832.77101883581, 2254.51768062338
    ), min = c(9.32501483591551, 89.836334122562, 179.782207737276, 
    249.599870863849, 299.190533129639, 384.3865503902, 487.749128099384, 
    868.468410520398, 1734.20266116419, 2110.27359937662)), class = c("grouped_df", 
    "tbl_df", "tbl", "data.frame"), row.names = c(NA, -10L), groups = structure(list(
    Soil = "CK", Glucose = 8, .rows = structure(list(1:10), ptype = integer(0), class = 
    c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
     ), row.names = c(NA, -1L), .drop = TRUE))

我有这个数据,我想用selt起始值做一个分解模型但是它显示错误,如何解决这个问题?另外,我们怎么知道这个模型很合适。

fit3 <- nls(Cm ~ SSasympOrig(time, Co,logk),data = df)
summary(fit3)
exp(coef(fit3)["logk"])

我收到这个错误,

> fit3 <- nls(Cm ~ SSasympOrig(time, Co,logk),data = df)
Error in nls(y ~ 1 - exp(-exp(lrc) * x), data = xy, start = list(lrc = lrc),  : 
  singular gradient
r regression data-modeling non-linear-regression decomposition
1个回答
0
投票

也许这个模型不太适合。尝试使用

log(Cm)
代替
Cm
。在那种情况下它会收敛。

fit.log <- nls(log(Cm) ~ SSasympOrig(time, Co, logk), df)

如果您愿意更改模型,另一种可能性是使用

SSlogis
。这似乎更合适。

fit.logis <- nls(Cm ~ SSlogis(time, Asym, xmid, scale), df)
plot(Cm ~ time, df)
lines(fitted(fit.logis) ~ time, df, col = "red")

© www.soinside.com 2019 - 2024. All rights reserved.