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