由drm库装配的Michaelis-Menten:"解析错误:"

时间:2018-01-22 15:31:30

标签: r distribution curve-fitting nonlinear-optimization

这是我的代码:

model.drm <- drm (v ~ cluster(S), data = data, fct = MM.2())

这是莱茵衣藻(Chlamydomonas reinhardtii)中光系统II的光饱和曲线。我想使用Michaelis-Menten分布模型找到最适合我的曲线。我用这种方式尝试了 drm()命令:

Error in parse(text = paste(paste(rep("c(", nrep - 1), collapse = ""),  : 
  <text>:2:39: unexpected ')'
1:  mu[(1+( 1  * (i - 1))),] %*% 
2: mu[( 2 + ( 1  * (i - 1))),drop=FALSE,])
                                         ^
In addition: Warning message:
In cbind(mu[, 2:(nclass - 1)], 1) - mu[, seq(nclass - 1)] :
  longer object length is not a multiple of shorter object length
Timing stopped at: 0 0 0 

当我运行此代码时,拟合的计算开始,但是它被我不理解的错误打断了:

{{1}}

虽然我会继续尝试自己解决问题,但如果有人能帮助我更快地修复它或找到另一种方法来执行分析,我将非常感激。

提前致谢!

1 个答案:

答案 0 :(得分:0)

感谢朋友的帮助,请点击答案:

data <-data.frame(matrix(0,nrow = 9,ncol = 2))
data[,1] <- c(0,15,41,81,146,211,438,958,1733)
data[,2] <-c(0.000000,5.7013061,13.2662515,26.0874534,42.2710547,55.6050052,75.597474,112.6755999,109.45890071)
rownames(data) <- c("E0_TAP","E3_TAP","E4_TAP","E5_TAP","E6_TAP","E7_TAP","E8_TAP","E10_TAP","E12_TAP")
colnames(data) <- c('S','v')

data <- t(data)  #traspose
data1 <- cbind(data,data) #duplicate
data1 <- cbind(data1,data1) # quadruplicate
data <- as.data.frame(t(data1)) #transpose 
model.drm <- drm (v ~ cluster(S), data = data, fct = MM.2()) #fitting analysis
S <- data[,1]
v <- data[,2]
mml <- data.frame(S = seq(0, max(S)+9000, length.out = 200)) 
mml$v <- predict(model.drm, newdata = mml)
s <- mml[,1]
v <- mml[,2]
plot(s,v)
lines(s,v,lty=2,col="red",lwd=3)

coeff <- as.data.frame(coef(summary(model.drm)))

问题来自数据集本身。为了绕过错误,需要对数据进行n次提升。我认为拥有更多的实验复制品会更好,而不是克隆同一个。

请发表评论!