我使用带有mcreg
包的deming回归计算了回归参数:
dem.reg <- mcreg(x, y, method.reg="Deming")
printSummary(dem.reg)
有谁知道如何计算估算的标准误差?
答案 0 :(得分:-1)
根据mcr
包描述,标准错误似乎无法直接获得。因此,在这种情况下,您必须按照here和here
如果我们采用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
所以你有拦截&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