R_str の変更点 - アールメカブ

アールメカブ


R_str の変更点


[[Rの備忘録]]

*str()関数でオブジェクトの構造を見る. [#a819bf05]
*str()関数でオブジェクトの構造を見る. [#s1e5a0da]

例えば lm オブジェクトであれば
例えば lm オブジェクトであれば,まずオブジェクトの構造を確認する.

>str(summary(alice.g.lm))
 List of 11
 $ call         : language lm(formula = log(alice.g$Types) 
                                        ~ log(alice.g$Tokens))
 $ terms        :Classes 'terms', 'formula' length 3 
              log(alice.g$Types) ~ log(alice.g$Tokens)
  .. ..- attr(*, "variables")= language  
 list(log(alice.g$Types), log(alice.g$Tokens))
  .. ..- attr(*, "factors")= int [1:2, 1] 0 1
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:2] "log(alice.g$Types)" 
 "log(alice.g$Tokens)"
  .. .. .. ..$ : chr "log(alice.g$Tokens)"
  .. ..- attr(*, "term.labels")= chr 
 "log(alice.g$Tokens)"
  .. ..- attr(*, "order")= int 1
  .. ..- attr(*, "intercept")= int 1
  .. ..- attr(*, "response")= int 1
  .. ..- attr(*, ".Environment")=<R_GlobalEnv> 
  .. ..- attr(*, "predvars")= language 
 list(log(alice.g$Types), log(alice.g$Tokens))
  .. ..- attr(*, "dataClasses")= Named chr [1:2] 
                       "numeric" "numeric"
  .. .. ..- attr(*, "names")= chr [1:2] 
 "log(alice.g$Types)" "log(alice.g$Tokens)"
 $ residuals    : Named num [1:40] -0.09344 -0.01558
                  0.01508  0.00604 -0.00784 ...
  ..- attr(*, "names")= chr [1:40] "1" "2" "3" "4" ...
 $ coefficients : num [1:2, 1:4]  1.81553  0.59876
                             0.04097  0.00442 44.31240 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "(Intercept)" "log(alice.g$Tokens)"
  .. ..$ : chr [1:4] "Estimate" "Std. Error" "t value" 
                   "Pr(>|t|)"
 $ aliased      : Named logi [1:2] FALSE FALSE
  ..- attr(*, "names")= chr [1:2] "(Intercept)" 
 "log(alice.g$Tokens)"
 $ sigma        : num 0.0241
 $ df           : int [1:3] 2 38 2
 $ r.squared    : num 0.998
 $ adj.r.squared: num 0.998
 $ fstatistic   : Named num [1:3] 18362     1    38
  ..- attr(*, "names")= chr [1:3] "value" "numdf"
    "dendf"
 $ cov.unscaled : num [1:2, 1:2]  2.8898 -0.3103
                          -0.3103  0.0336
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "(Intercept)"
                 "log(alice.g$Tokens)"
  .. ..$ : chr [1:2] "(Intercept)"
                  "log(alice.g$Tokens)"
 - attr(*, "class")= chr "summary.lm"
<

の出力から調整済み &mathml(R^2); を取り出すには

 summary(alice.g.lm)$adj.r.squared

とすればよい.