Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error with clchi2 (clustered chi-squared test) command

    Hello,

    I am trying to assess the relationship between two categorical variables in a clustered dataset, but I keep coming across an error that states 'type mismatch / r(109).' I have tried multiple combinations of destringing and restringing the variables of interest, but I continue to get the same error display. Does anyone have any suggestions? I have pasted the exact code I am running below. d_sex is the sex of the individuals in my sample, studyarea is the study area they are from, and hc_hid is the household ID for the individuals. Multiple individuals in my sample came from the same household, which is why I want to account for clustering in this chi squared analysis.

    . clchi2 d_sex studyarea, cluster(hc_hid)
    type mismatch
    r(109);

  • #2
    cltest is from SSC (FAQ Advice #12). You probably have one or more strings among your list of variables. For anything specific, copy and paste the result of

    Code:
    dataex  d_sex studyarea hc_hid in 1/10
    Otherwise, see both

    Code:
    help destring
    help encode

    Comment


    • #3
      Thank you so much Andrew. I needed to use the encode command for hc_hid instead of destring. I am now able to run the test.

      Comment

      Working...
      X