Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在R中非线性回归的线性算法会出错?_R_Non Linear Regression - Fatal编程技术网

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

为什么在R中非线性回归的线性算法会出错?,r,non-linear-regression,R,Non Linear Regression,我有一个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

我有一个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)

这是没有意义的,因为元素(2,2)在导入时是0,但我特别用一个小的非零值重写它,以允许反转。在创建非线性模型之前对数据帧的检查甚至显示该值不是0,那么为什么它报告为0呢?当bind_曲线存在于两个不同的名称空间或其他地方时,这是一个问题吗?这是我认为这会发生的唯一可能的方式。

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

国防部可以删除这篇文章。我是个白痴:p

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