トップ 差分 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

easystats

*disclaimer
306258

R
R.package

easystats

https://github.com/easystats
https://qiita.com/ocean_f/items/f1074f8cc05241dc28eb


 インストール

install.packages("easystats", repos = "https://easystats.r-universe.dev")


 GLMMなどの妥当性評価





モデルパフォーマンス

model_performance(modelER3f)

## # Indices of model performance
## 
## AIC      |      BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Score_log | Score_spherical
## ---------------------------------------------------------------------------------------------------
## 1357.583 | 1378.366 |      0.819 |      0.532 | 0.612 | 4.957 | 1.000 |    -2.501 |           0.055

R2: r2()

r2(modelER3f)

# R2 for Mixed Models

  Conditional R2: 0.912
     Marginal R2: 0.233
  • Conditionalは Mixed Modelsの寄与率
  • Marginal は固定要因のみの寄与率

多重共線性: check_collinearity()



正規性: check_normality()


check_normality(modelER3f)

 OK: residuals appear as normally distributed (p = 0.730).

  • 結果を plot()
    • パッケージ「see」が必要。
      • 依存パッケージも必要
package ‘effectsize’ successfully unpacked and MD5 sums checked
package ‘insight’ successfully unpacked and MD5 sums checked
package ‘parameters’ successfully unpacked and MD5 sums checked
package ‘see’ successfully unpacked and MD5 sums checked

library(see)
nom <- check_normality(modelER3f)
plot(nom)

過分散: check_overdispersion()

  • ポアソン分布のみ

ゼロ過剰: check_zeloinflation()

  • ポアソン分布の場合のみ


 結果の報告 report()

  • モデルをreport()に入れるだけで、どう報告すればよいか全部書いてくれる。
report(both.model.glm)

We fitted a linear model (estimated using ML) to predict IPSyn13 with year and mode
 (formula: IPSyn13 ~ year + mode). The model's explanatory power is substantial (R2 =
0.29). The model's intercept, corresponding to year = 1 and mode = spoken
, is at 52.42 (95% CI [50.83, 54.01], t(390) = 64.56, p < .001). Within this model:

  - The effect of year [2] is statistically significant and positive (beta = 6.35, 95% CI
[4.32, 8.38], t(390) = 6.14, p < .001; Std. beta = 0.64, 95% CI [0.44, 0.85])
  - The effect of year [3] is statistically significant and positive (beta = 9.57, 95% CI
[7.56, 11.58], t(390) = 9.34, p < .001; Std. beta = 0.97, 95% CI [0.76, 1.17])
  - The effect of mode [written] is statistically significant and negative (beta = -6.80,
95% CI [-8.47, -5.13], t(390) = -7.98, p < .001; Std. beta = -0.69, 95% CI [-0.85,
-0.52])

Standardized parameters were obtained by fitting the model on a standardized version of
the dataset. 95% Confidence Intervals (CIs) and p-values were computed using a Wald
t-distribution approximation.

report_table()

report_table(both.model.glm)

Parameter      | Coefficient |         95% CI | t(390) |      p | Std. Coef. | Std. Coef. 95% CI |     Fit
----------------------------------------------------------------------------------------------------------
(Intercept)    |       52.42 | [50.83, 54.01] |  64.56 | < .001 |      -0.20 |    [-0.36, -0.04] |        
year [2]       |        6.35 | [ 4.32,  8.38] |   6.14 | < .001 |       0.64 |    [ 0.44,  0.85] |        
year [3]       |        9.57 | [ 7.56, 11.58] |   9.34 | < .001 |       0.97 |    [ 0.76,  1.17] |        
mode [written] |       -6.80 | [-8.47, -5.13] |  -7.98 | < .001 |      -0.69 |    [-0.85, -0.52] |        
               |             |                |        |        |            |                   |        
AIC            |             |                |        |        |            |                   | 2801.84
BIC            |             |                |        |        |            |                   | 2821.72
R2             |             |                |        |        |            |                   |    0.29
Sigma          |             |                |        |        |            |                   |    8.41

 インストール

install.packages("performance")

library(performance)