我正在尝试使用这样的 Chapman-Richards 函数对嵌套数据进行建模: https ://image.slideserve.com/575351/testing-eichhorn-s-rule35-n.jpg
我的原始数据如下所示:
structure(list(Site = c(1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4,
4), Height = c(2.4, 11.3, 20.5, 27.4, 32, 34.9, 2.45, 7.45, 13.05,
17.7, 20.75, 22.8), Volume = c(12, 220, 605, 991, 1288, 1495,
11, 106, 283, 473, 619, 723)), row.names = c(NA, -12L), class = c("tbl_df",
"tbl", "data.frame"))
我创建了一个增长模型:
model <- function(data){
nls(Volume~ a * (Height^b), data=data, start=c(Volume=200, Height=5,a=1,b=1))
}
当我嵌套数据以为每个嵌套创建模型时:
Silver %>% group_by(Site_class) %>% nest() %>%
mutate(mod= map(.x=data, model))
我收到以下错误:
fitting parameters ‘a’, ‘b’ without any variables
Error in numericDeriv(form[[3L]], names(ind), env) :
Missing value or an infinity produced when evaluating the model
Called from: numericDeriv(form[[3L]], names(ind), env)
我知道数据的变化可能很小。
如果我尝试 alg="plinear",我会收到以下错误:
fitting parameters ‘a’, ‘b’ without any variables
Error in qr.solve(QR.B, cc) : singular matrix 'a' in solve
Called from: qr.solve(QR.B, cc)
我已尝试将其更改为 robustbase::nlrob 以防万一效果更好。
这会将错误代码更改为:
Error in parse(text = x, keep.source = FALSE) :
<text>:2:0: unexpected end of input
1: ~
^
Called from: parse(text = x, keep.source = FALSE)
有谁知道是什么导致了我这个问题或如何解决它?非常感谢!