为什么我在 R 中非线性回归的线性算法出现错误?



我有一个包含 X 和 Y 值的 2 元素列表,我想用 R 进行非线性回归。

NP  delta_f_norm
3.125E-08   1.305366836
6.25E-08    0
0.000000125 3.048361059
0.00000025  2.709158322
0.0000005   2.919379441
0.000001    42.8860945
0.000002    49.75418233
0.000004    50.89313017
0.000008    50.18050031
0.000016    49.67195257
0.000032    48.89396054
0.000064    48.00787709
0.0000006   16.50229042
0.0000007   8.906829316
0.0000008   14.2697833
2.74E-08    -0.913767771
4.11E-08    -0.942489364
6.17E-08    0.586660918
9.24E-08    -0.080955695
1.387E-07   1.672777115
2.081E-07   0.880006555
3.121E-07   13.23952061
4.682E-07   44.73003305
7.023E-07   57.11640257
1.0535E-06  54.09032726
1.5802E-06  58.71029183
2.3704E-06  56.85467325
3.5556E-06  57.83003606
5.3333E-06  53.71761902
0.000008    53.55511726

我导入纯文本数据,规范化 Y 值并更改 x 值的比例:

install.packages("tidyverse")
library(tidyverse)
# load in the data points, make sure the working directory is set correctly
# I have already trimmed data manually, so it is just tab separated, x values in the left
# column, y values in the right, with the first line containing the name of the variable 
bind_curve <- read_tsv("MST_data.txt")
view(bind_curve)
# normalize curve to max
# as fractional occupancy of binding sites
bind_curve$delta_f_norm <- bind_curve$delta_f_norm/max(bind_curve$delta_f_norm)
#change units to nanomolar
bind_curve$NP <- bind_curve$NP*1e06

# due to the way the plinear algorithm works, y values cannot be zero, so we have to change them to very small values
for (i in 1:nrow(bind_curve))
{
if (bind_curve[i,2] == 0)
{
bind_curve[i,2] <- 1e-10
}
}

# here Ka is the apparent Kd and n is the hill coeficient, the parameters were
# guestimated by looking at the data
view(bind_curve)
hill_model <- nls((delta_f_norm ~ 1/(((Ka/NP)^n)+1)), data = bind_curve, start = list(Ka=700, n=2), algorithm = "plinear")
summary(hill_model)

这将给出以下错误:

Error in chol2inv(object$m$Rmat()) : 
element (2, 2) is zero, so the inverse cannot be computed

这毫无意义,因为元素 (2,2( 在导入时为 0,但我专门用一个小的非零值覆盖了它以允许反转。在创建非线性模型之前检查数据框甚至显示值不为 0,那么为什么要报告它是 0?这是bind_curve存在于 2 个不同命名空间中的问题吗?这是我能想到的唯一可能的方式。

好的,当我更改 NP 数据上的单位(700 对 0.7(时,我忘记在最初的 Ka 猜测中转换单位,所以显然我的起始值离得很远,这一定是导致它失败的原因。我不明白这与数据中的 0 值有什么关系,但无论它是什么固定的。

模组可以删除此帖子。我是个白痴:p