class_docstr: Test reliability.py.
  Compare against real-statistics.com
docstr: Test function cronbach_alpha.
  Compare results with the R package psych.
  Note that this function returns slightly different results when
  missing values are present in data.
docstr_tok: ["Test","function","cronbach_alpha",".","Compare","results","with","the","R","package","psych",".","Note","that","this","function","returns","slightly","different","results","when","missing","values","are","present","in","data","."]
code: def test_cronbach_alpha(self):
      """Test function cronbach_alpha.
      Compare results with the R package psych.
      Note that this function returns slightly different results when
      missing values are present in data.
      """
      df = read_dataset("cronbach_alpha")
      alpha, ci = cronbach_alpha(
          data=df, items="Items", scores="Scores", subject="Subj"
      )
      assert round(alpha, 3) == 0.592
      assert ci[0] == 0.195
      assert ci[1] == 0.840
      # With missing values
      df.loc[2, "Scores"] = np.nan
      cronbach_alpha(
          data=df, items="Items", scores="Scores", subject="Subj"
      )
      # In R = psych:alpha(data, use="complete.obs")
      cronbach_alpha(
          data=df,
          items="Items",
          scores="Scores",
          subject="Subj",
          nan_policy="listwise",
      )
      # Wide format
      data = read_dataset("cronbach_wide_missing")
      alpha, _ = cronbach_alpha(data=data)
      assert round(alpha, 2) == 0.73
      alpha, _ = cronbach_alpha(data=data, nan_policy="listwise")
      assert round(alpha, 2) == 0.80
  
file_path: pingouin/pingouin/tests/test_reliability.py
imports: import pytest
  import numpy
  import pandas
  from unittest import TestCase
  from pingouin.reliability import cronbach_alpha, intraclass_corr
  from pingouin import read_dataset
label_desc: Use image node_id 1 for calling the TestReliability obj's underlying member method code with example usage: obj.test_cronbach_alpha() without return types