从R中的黄土回归结果中提取残留标准误差

问题描述

我正在尝试从黄土回归模型的输出摘要中提取残差标准误差。

> summary(fit.loess[[i]])
Call:
loess(formula = dfcpm[,ncol(dfcpm)] ~ dfcpm[,i],data = dfcpm,span = 0.5,degree = 1,normalize = FALSE,family = "gaussian")

Number of Observations: 88 
Equivalent Number of Parameters: 4.7 
Residual Standard Error: 21.7 
Trace of smoother matrix: 5.53  (exact)

Control settings:
  span     :  0.5 
  degree   :  1 
  family   :  gaussian
  surface  :  interpolate     cell = 0.2
  normalize:  FALSE
 parametric:  FALSE
drop.square:  FALSE 

现在,我要提取该模型的残差标准误差。我如何提取它?我无法在模型对象的任何位置(即21.7)找到该值。

> names(fit.loess[[i]])
 [1] "n"         "fitted"    "residuals" "enp"       "s"         "one.delta" "two.delta" "trace.hat"
 [9] "divisor"   "robust"    "pars"      "kd"        "call"      "terms"     "xnames"    "x"        
[17] "y"         "weights" 

解决方法

它是s返回中的loess元素。

> lo <- loess(mpg ~ wt,data=mtcars)
> print(lo)
#Call:
#loess(formula = mpg ~ wt,data = mtcars)
#
#Number of Observations: 32 
#Equivalent Number of Parameters: 5 
#Residual Standard Error: 2.711 
> lo$s
#[1] 2.711351

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...