0

我正在尝试从 relaimpo 包中的 calc.relimp 获得的结果中提取 lmg 信息。

当我查看我的结果时,我看到了

Response variable: DS[, 2] 
Total response variance: 107.5848 
Analysis based on 21985 observations 

3 Regressors: 
DS[, 33] DS[, 18] DS[, 23] 
Proportion of variance explained by model: 1.39%
Metrics are not normalized (rela=FALSE). 

Relative importance metrics: 

                 lmg
DS[, 33] 0.007041436
DS[, 18] 0.001038892
DS[, 23] 0.005823708

Average coefficients for different model sizes: 

                 1X        2Xs        3Xs
DS[, 33] -1.9229313 -2.3138967 -2.4784731
DS[, 18] -0.9155606 -0.8011497 -0.6107294
DS[, 23]  1.3592192  2.0488534  2.3525688

理想情况下,我想提取 33 0.00704、18 0.00103、23 0.00582,这样我就可以对 lmg 值进行更多分析。

谢谢您的帮助!

4

2 回答 2

1

relaimpo 还迎合了习惯于列出和 $ 提取器的用户,即以下内容也可以工作:

library(relaimpo)
ll <- calc.relimp(swiss)
ll$lmg ## instead of ll@lmg
于 2013-07-25T19:24:07.400 回答
0

您可以使用 function 查看calc.relimp()使用 function计算的对象的结构list()

lmg值存储在具有相同名称的列表元素中,可以选择为object@lmg.

这是使用此包中的数据的示例

library(relaimpo)
data(swiss)
ll<-calc.relimp(swiss)
str(ll)
Formal class 'relimplm' [package "relaimpo"] with 36 slots
  ..@ var.y      : num 156
  ..@ R2         : num 0.707
  ..@ R2.decomp  : num 0.707
  ..@ lmg        : Named num [1:5] 0.0571 0.1712 0.2601 0.1056 0.1128
  .. ..- attr(*, "names")= chr [1:5] "Agriculture" "Examination" "Education" "Catholic" ...
  .....
  ..@ car.diff   : num(0) 
  ..@ namen      : chr [1:6] "Fertility" "Agriculture" "Examination" "Education" ...
  ..@ nobs       : int 47
  ..@ ave.coeffs : num [1:5, 1:5] 0.194 -1.011 -0.862 0.139 1.786 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:5] "Agriculture" "Examination" "Education" "Catholic" ...
  .. .. ..$ : chr [1:5] "1X" "2Xs" "3Xs" "4Xs" ...
  ....

ll@lmg
 Agriculture      Examination        Education         Catholic Infant.Mortality 
  0.05709122       0.17117303       0.26013468       0.10557015       0.11276592 
于 2013-07-24T19:02:01.780 回答