如何计算deming回归中的估计标准误差?

时间:2016-01-26 13:22:16

标签: r statistics regression standard-error

我使用带有mcreg包的deming回归计算了回归参数:

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

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

1 个答案:

答案 0 :(得分:-1)

根据mcr包描述,标准错误似乎无法直接获得。因此,在这种情况下,您必须按照herehere

所述的原则重新计算和重写特定函数

如果我们采用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

Deming regression results

所以你有拦截&amp;斜率,写入图形,您只需编写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