我有一些数据我正在尝试绘制适合ggplot。我正在使用带自启动四参数logisitic回归pip
的nls。它可以使用nls很好地拟合公式,它给出了系数但是当我尝试将它传递给geom_smooth时,它给了我一个(SSfpl)
。
我的数据如下:
computation failed in 'stat_smooth()': singular matrix 'a' in solve
我的代码如下所示。
dput(SODat)
structure(list(Treatment = structure(1:6, .Label = c(".0032uM",
".016uM", ".08uM", ".4uM", "2uM", "10uM"), class = "factor"),
Peak = c(1028.06247583425, 1466.14079105711, 1007.51610918954,
1171.03478670369, 1204.37248245019, 1042.44546803658), Area1 = c(902.715126326407,
818.917775151066, 1003.80586032706, 1268.82827952821, 1479.87729958222,
1321.77972824089), SS1 = c(131.573938723728, 90.0065951864569,
111.723312483588, 147.027334638628, 195.159502773361, 173.819528362056
), Conc_nm = c(3.2, 16, 80, 400, 2000, 10000), logconc_nm = c(0.505149978319906,
1.20411998265592, 1.90308998699194, 2.60205999132796, 3.30102999566398,
4)), .Names = c("Treatment", "Peak", "Area1", "SS1", "Conc_nm",
"logconc_nm"), class = "data.frame", row.names = 2:7)
我的绘图代码看起来像这样:
val=NULL # EC50
vallog=NULL# logEC50
allDR=NULL
vertline=NULL
for (i in 2:4){
currentfit=tryCatch(nls(SODat[,i] ~ SSfpl(logconc_nm,A,B,xmid,scal),dat=testdat),error=function(e) 0)
if(typeof (currentfit)=='list'){
vallog[i]= summary(currentfit)$coefficients[3]
val[i]=10^summary(currentfit)$coefficients[3]}
else{
vallog[i]=0
val[i]=0
}
}
vallog=vallog[-c(1:2)]
val=val[-c(1:2)]
**** ****问题 有谁知道为什么它能够适应nls而不是在ggplot中绘图?在这个例子中,拟合可能相当弱。所以这才是我唯一的解释。