Announcement

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

  • #16
    Hello,

    My question also concerns crosstabulation of multiple variables. I have 20 binary (Y/N) variables of activities people engaged with in the last 12 months and I would like to descriptively display the patterns of engagement between the variables before proceeding to cluster analyses of the observations. In essence, I'd like to display the proportions in the same way as with a cross tabulation of two count variables (var1 a score of 0-10 of engaged pactivities and var2 a score of 0-10 of engaged ractivities), see the graph below.


    Click image for larger version

Name:	crosstab of count variables.jpg
Views:	1
Size:	120.7 KB
ID:	1532693


    I have tried mtab and mrtab, but wasn't unable to set it up as a two-way table. Same for tabstat. I keep running to r(198) problems misspecifying tabmult and tabout and tab2 work but the output shows only one activity at the time, e.g. pactivity1 vs. pactivity2-10 etc.

    Thank you in advance for your help.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float id byte(pactivity1 pactivity2 pactivity3 pactivity4 pactivity5 pactivity6 pactivity7 pactivity8 pactivity9 pactivity10 ractivity1 ractivity2 ractivity3 ractivity4 ractivity5 ractivity6 ractivity7 ractivity8 ractivity9 ractivity10)
    4712 1 1 0 1 0 0 1 1 1 1 0 1 1 1 0 0 1 1 1 1
    2624 1 0 1 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1 1 1
    3205 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0
    1628 1 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0
    5960 1 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1
     435 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 1 1 1
    4769 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    5044 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 1 0
    4371 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0
    5240 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
     699 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    3839 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1
    5326 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
    2175 1 1 0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1 0 1
    2561 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
    3236 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
    4800 1 1 1 0 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0
    2449 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0
    3796 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
    1927 1 1 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1
     795 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1
    5214 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
    3351 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1
    1007 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 1 0
    3934 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
    1386 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1
     822 1 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0
    4109 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
    1703 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
    1700 1 1 0 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 0
    end
    label values pactivity1 anyengagement
    label values pactivity2 anyengagement
    label values pactivity3 anyengagement
    label values pactivity4 anyengagement
    label values pactivity5 anyengagement
    label values pactivity6 anyengagement
    label values pactivity7 anyengagement
    label values pactivity8 anyengagement
    label values pactivity9 anyengagement
    label values pactivity10 anyengagement
    label values ractivity1 anyengagement
    label values ractivity2 anyengagement
    label values ractivity3 anyengagement
    label values ractivity4 anyengagement
    label values ractivity5 anyengagement
    label values ractivity6 anyengagement
    label values ractivity7 anyengagement
    label values ractivity8 anyengagement
    label values ractivity9 anyengagement
    label values ractivity10 anyengagement
    label def anyengagement 0 "Never", modify
    label def anyengagement 1 "One of or more", modify
    ------------------ copy up to and including the previous line ------------------

    Comment


    • #17
      There may be a simpler way to do this, but:

      Code:
      reshape long pactivity ractivity, i(id) j(activity_num)
      reshape long @activity, i(id activity_num) j(pr) string
      keep if activity == 1
      drop activity
      
      preserve
      keep if pr == "r"
      drop pr
      rename activity_num ractivity
      tempfile ractivities
      save `ractivities'
      
      restore
      keep if pr == "p"
      drop pr
      rename activity_num pactivity
      joinby id using `ractivities'
      
      tab pactivity ractivity

      Comment


      • #18
        Dear Clyde, thank you very much indeed for your prompt and helpful reply! Your code works beautifully!

        I'd also like to crosstabulate patterns of engagement within 10 "p"activities. Could you please send me some suggestions for that too?

        Do you know of any manual with useful (and ideally fairly straightforward) descriptive / exploratory analyses to conduct before cluster analysis or latent class analysis?

        Many thanks and regards.

        Last edited by Ursula Kowalska; 20 Jan 2020, 10:06.

        Comment

        Working...
        X