0

我有以下对象M,我需要从中提取fstatistic. 它是一个模型生成的函数summaryC,一个模型生成的aovp函数,两个函数都来自封装lmPerm。我尝试了从正常线性模型和函数中提取值的提示,attr但没有成功。extractgetElement

任何人都可以给我一个提示?

> str(M)
List of 2
 $ Error: vegetation: NULL
 $ Error: Within    :List of 11
  ..$ NA           : NULL
  ..$ terms        :Classes 'terms', 'formula' length 3 Temp ~ depth
  .. .. ..- attr(*, "variables")= language list(Temp, depth)
  .. .. ..- attr(*, "factors")= int [1:2, 1] 0 1
  .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. ..$ : chr [1:2] "Temp" "depth"
  .. .. .. .. ..$ : chr "depth"
  .. .. ..- attr(*, "term.labels")= chr "depth"
  .. .. ..- attr(*, "order")= int 1
  .. .. ..- attr(*, "intercept")= int 1
  .. .. ..- attr(*, "response")= int 1
  .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  ..$ residuals    : Named num [1:498] -46.9 -43.9 -46.9 -38.9 -41.9 ...
  .. ..- attr(*, "names")= chr [1:498] "3" "4" "5" "6" ...
  ..$ coefficients : num [1:4, 1:4] -2.00 -1.00 -1.35e-14 1.00 2.59 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:4] "depth1" "depth2" "depth3" "depth4"
  .. .. ..$ : chr [1:4] "Estimate" "Std. Error" "t value" "Pr(>|t|)"
  ..$ aliased      : Named logi [1:4] FALSE FALSE FALSE FALSE
  .. ..- attr(*, "names")= chr [1:4] "depth1" "depth2" "depth3" "depth4"
  ..$ sigma        : num 29
  ..$ df           : int [1:3] 4 494 4
  ..$ r.squared    : num 0.00239
  ..$ adj.r.squared: num -0.00367
  ..$ **fstatistic**   : Named num [1:3] 0.395 3 494
  .. ..- attr(*, "names")= chr [1:3] "value" "numdf" "dendf"
  ..$ cov.unscaled : num [1:4, 1:4] 0.008 -0.002 -0.002 -0.002 -0.002 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:4] "depth1" "depth2" "depth3" "depth4"
  .. .. ..$ : chr [1:4] "depth1" "depth2" "depth3" "depth4"
  ..- attr(*, "class")= chr "summary.lmp"
   - attr(*, "class")= chr "listof"

那里有一个可重复的例子:

Temp=1:100
depth<- rep( c("1","2","3","4","5"), 100)
vegetation=rep( c("1","2"), 50)
df=data.frame(Temp,depth,vegetation)

M=summaryC(aovp(Temp~depth+Error(vegetation),df, perm=""))
4

1 回答 1

0

正如str您的示例的输出所示,M是两个列表的列表,第二个包含您想要的内容。因此,通过列表提取可以[[解决问题:

> M[[2]][["fstatistic"]]
   value    numdf    dendf 
  0.3946   3.0000 494.0000 

如果这不是您想要的,请发表评论。

于 2012-05-22T12:37:07.147 回答