-2

我已经使用mcreg包的戴明回归计算了回归参数:

dem.reg <- mcreg(x, y, method.reg="Deming")
printSummary(dem.reg)

有谁知道我如何计算估计的标准误差?

4

1 回答 1

-1

根据mcr包描述,标准错误似乎不能直接使用。因此,在这种情况下,您必须按照此处此处描述的原则重新计算和重写特定函数

如果我们以mcreg函数描述中的例子为例,我们有:

# requirements
library("mcr")
data(creatinine,package="mcr")
x <- creatinine$serum.crea
y <- creatinine$plasma.crea

# Deming regression fit.
# The confidence intercals for regression coefficients
# are calculated with analytical method
model1<- mcreg(x,y,error.ratio=1,method.reg="Deming", method.ci="analytical",
               mref.name = "serum.crea", mtest.name = "plasma.crea", na.rm=TRUE)

# Results
printSummary(model1)
getCoefficients(model1)
plot(model1)

它给出了以下输出和图形:

# ------------------------------------------
#   
#   Reference method: serum.crea
# Test method:     plasma.crea
# Number of data points: 108
# 
# ------------------------------------------
#   
#   The confidence intervals are calculated with analytical method.
# Confidence level: 95%
# Error ratio: 1
# 
# ------------------------------------------
#   
#   DEMING REGRESSION FIT:
#   
#   EST         SE        LCI        UCI
# Intercept -0.05891341 0.04604315 -0.1501984 0.03237162
# Slope      1.05453934 0.03534361  0.9844672 1.12461148
# NULL

戴明回归结果

所以你有你的截距和斜率,如图所示,你只需要编写standard.error如下的计算代码:

f.reg <- function(x){
  y <- x * 1.05453934 - 0.05891341 
  return(y)
}
y.hat <- f.reg(x)
n.items <- length(y.hat)
# please note that y has 'NA' values so you have to filter them 
standard.error <- sqrt(sum((y[ !is.na(y)]-y.hat[ !is.na(y)])^2)/n.items)
# > standard.error
# [1] 0.1566329
于 2016-01-26T14:03:16.683 回答