2012-04-03 62 views
0

我有以下对象M,从中我需要提取fstatistic。它是由aovp生成的模型的函数summaryC生成的模型,这两个函数都来自程序包lmPerm。我试图从正常线性模型和attr,extractgetElement中的函数中提取数值,但没有成功。从Lmperm中的aovp对象中提取值

有人可以给我一个提示吗?

> 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="")) 

回答

0

从你的榜样输出str显示,M是两个列表的列表,第二个包含你想要什么。通过[[因此一览抽取的伎俩:

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

如果这不是你想要的,请评论。

+0

谢谢henrik!正是这样。我以前没有看到你的答案。 – 2012-06-01 21:19:19