首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R ELISA分析4PL中R^2和P值的确定

R ELISA分析4PL中R^2和P值的确定
EN

Stack Overflow用户
提问于 2020-01-08 19:51:02
回答 1查看 576关注 0票数 0

我试图模拟使用R的图形垫ELISA分析,但我有一点困难,获得一个P-值和一个R^2值。

我遵循了教程:http://weightinginbayesianmodels.github.io/poctcalibration/calib_tut4_curve_ocon.html#unweighted-nonlinear-regression-in-r

它使用一个名为"minpack.lm“的包获得了我所需的大部分信息,但是我不知道如何从这里获取R^2和P值。

代码语言:javascript
复制
  ODCalc1 <- c(.007, .072, .328, .988, 1.534, 1.983)
  ODCalc2 <- c(.006, .074, .361, .858, 1.612, 1.993)
  ODCalc <- (ODCalc1 + ODCalc2)/2

  concentration <- log10(c(1, 36, 180, 540, 1080, 1800))

  ocon <- data.frame(10^(concentration), "rep", ODCalc, stringsAsFactors = F)
  ocon$X.rep. <- as.numeric(ocon$X.rep.)
  ocon$X.rep. <- 1
  names(ocon) <- c("conc", "rep", "od")

  # Plot the O'Connell data
  par(mfrow = c(1, 2), cex.main = 1, mar = c(4, 4, 1, 2), oma = c(0.5, 0.5, 2.5, 0))
  plot(ocon$conc, ocon$od, pch = 21, bg = "grey", ylab = "Response (od)", 
       xlab = "Concentration")
  grid()
  # Plot on the log(x) scale
  plot(log(ocon$conc), ocon$od, pch = 21, bg = "grey", ylab = "Response (od)", 
       xlab = "log(concentration)")
  grid()
  title("O'Connell's ELISA: concentration on absolute (left) and log (right) scales",
        outer = T)

  par(mfrow = c(1, 1))

  # ------------ Function: 4PL curve function ---------------------------------  
  M.4pl <- function(x, small.x.asymp, inf.x.asymp, inflec, hill){
    f <- small.x.asymp + ((inf.x.asymp - small.x.asymp)/
                            (1 + (x / inflec)^hill))
    return(f)
  }
  # ------------- end ---------------------------------------------------------

  start.ocon <- c(small.x.asymp = 0.1, inf.x.asymp = 1, inflec = 3000, hill = -1)
  library(minpack.lm)
  uw.4pl <- nlsLM(od ~ M.4pl(conc, small.x.asymp, inf.x.asymp, inflec, hill), 
                  data = ocon,
                  start = start.ocon)
  data.4pl <- summary(uw.4pl)

  bottom.4pl <- data.4pl$parameters[1,1]
  top.4pl <- data.4pl$parameters[2,1]
  IC50.4pl <- data.4pl$parameters[3,1]
  HillSlope.4pl <- abs(data.4pl$parameters[4,1])

  RSS.p <- sum(residuals(uw.4pl)^2)
  TSS <- sum((ocon$od - mean(ocon$od))^2)
  r.squared <- 1-(RSS.p/TSS) # is this the proper way to get an r^2 value? It does not match what graphpad has which is an issue.

  # I have also read this should work, but since the model is a linear model instead of a Sigmoidal, 4PL, X is log (concentration) model
  model <- lm(concentration ~ poly(ODCalc, degree = 4, raw=T))
  summary(model) # R^2 is not the correct value I am looking for.

  # Not sure if sample data is needed but these were the values we were using to produce the values below
  sample.od.values1 <- c(0.275, 1.18, 0.085, 0.054, 0.119)
  sample.od.values2 <- c(0.263, 1.149, 0.068, 0.062, 0.109)
  sample.od.values <- (sample.od.values1+sample.od.values2)/2

证明这些方法的值是相同的:

底.4pl= 0.01657

top.4pl = 3.002

HillSlope = 1.222

R^2 = 0.9978

R^2(调整后)= 0.9969

P-值= 0.5106

谢谢您的任何有用的提示!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-08 23:37:40

由于R^2测量线性关联,它通常用于线性回归,但忽略了这似乎给出了您想要的数字,或者至少是接近这些数字的数字。对于调整后的R平方公式,请参阅https://en.wikipedia.org/wiki/Coefficient_of_determination#Adjusted_R2,对于p值,我假设您是在寻找p值,假设第一个系数为零。

代码语言:javascript
复制
RSS <- deviance(uw.4pl); RSS
## [1] 0.001514624

coef(uw.4pl) # coefficients/parameters
## small.x.asymp   inf.x.asymp        inflec          hill 
##    0.01654996    3.00261439 1033.53324214   -1.22171740 

R2 <- cor(ocon$od, fitted(uw.4pl))^2; R2
## [1] 0.9995529

n <- nobs(uw.4pl)    
p <- length(coef(uw.4pl))
adjR2 <- 1 - (1-R2) * (n - 1) / (n - p - 1); adjR2
## [1] 0.9977645

pvalue <- coef(summary(uw.4pl))[1, 4]; pvalue
## [1] 0.5486584
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59652913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档