【问题标题】:Why am I getting an error with plinear algorithm for non-linear regression in R?为什么我在使用 R 中的非线性回归的 plinear 算法时出现错误?
【发布时间】:2020-01-13 22:12:32
【问题描述】:

我有一个包含 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,那么为什么它报告它是?这是 bind_curve 存在于 2 个不同的命名空间中的问题吗?这是我认为会发生这种情况的唯一可能方式。

【问题讨论】:

    标签: r non-linear-regression


    【解决方案1】:

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

    模组可以删除这篇文章。我是个白痴:p

    【讨论】:

      猜你喜欢
      • 2020-07-10
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 2015-10-08
      • 2011-08-05
      • 2012-03-14
      • 2021-08-01
      • 2012-01-12
      相关资源
      最近更新 更多