extracting values from an aovp object in Lmperm

Go To StackoverFlow.com

0

I have the following object M, from which I need to extract the fstatistic. It is a model generated by the function summaryC of a model generated by aovp, both functions from package lmPerm. I have tried hints for extracting values from normal linear models and from the functions in attr, extract and getElement, but without success.

Anybody could give me a hint?

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

there it goes a reproducible example to play with:

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=""))
2012-04-03 21:31
by Agus camacho


0

as the str output from your example shows, M is a list of two lists, the second one contains what you want. Hence list extraction via [[ does the trick:

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

If this is not what you want, please comment.

2012-05-22 12:37
by Henrik
Thanks henrik! It was exactly that. I Did not see your answer before - Agus camacho 2012-06-01 21:19
Ads