Announcement

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

  • Difference in Before and After responses over/between Gender

    I and a colleague collected before and after responses of from students in our classes to examine the impact of a documentary. We also collected demographic information from these students and coded them. We have 20 questions (with before and after responses) and 6 demographic variables (V1 – V6).

    I have calculated the differences in the before and after responses for each question as Q*diff. For example Q1diff = Q1A - Q1B (where Q1A is the response after watching the documentary & Q1B is the response before watching the documentary)

    I am planning to examine differences in before and after responses for each group of each demographic variable. For example,

    Q1:
    1. Is there a significant difference in the before and after responses from group1 (25 and under) and group2 (26 and over)?
    2. Is there a significant difference in the before and after responses from group1 (Female) and group2 (Male)?
    3. Is there a significant difference in the before and after responses from group1 (2 years or less), group2 (3 to 5 years), group2 (6 to 10 years), and group4 (More than 10 years)?
    4. Is there a significant difference in the before and after responses from group1 (deg from some area of business) and group2 (other than business)?
    .
    .
    .
    .
    .
    And so on for all questions Q1 - Q20.

    If I examine differences in before and after responses for all 20 questions over 6 demographic variables, it will be a total of 120 statistical tests.

    I would be extremely grateful if I could get some help for the following:

    1. To examine the above, should I perform a ttest with unequal variances i.e. ttest Q1diff, by(age) unequal? Or should I perform a one way ANOVA i.e. oneway Q1diff V1Age, tabulate, then use pwmean Q1diff over(V1age) mcompare(tukey) effects? The latter seems more appropriate for Q1.3. listed above.

    2. Whichever one I end up using, how can I automate 120 statistical tests and export the results of ttest, [oneway and pwmean] commands in 2 separate excel workbooks?


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(V1Age V2Gend V3Exp Q1B Q2B Q3B Q4B Q5B Q1A Q2A Q3A Q4A Q5A) float(Q1diff Q2diff Q3diff Q4diff Q6diff)
    0 0 0 4 1 1 1 3 5 1 5 1 3 1  0  4  0  1
    1 1 4 4 4 1 4 3 4 1 2 4 2 0 -3  1  0  2
    1 1 3 4 2 4 1 2 4 2 2 4 3 0  0 -2  3  0
    0 1 1 2 1 3 5 1 5 1 5 5 5 3  0  2  0  0
    . 1 1 3 4 3 4 3 4 2 4 3 4 1 -2  1 -1  0
    0 0 1 2 5 2 3 2 5 3 2 4 4 3 -2  0  1  1
    1 1 2 2 4 2 3 3 4 2 2 3 4 2 -2  0  0  0
    0 0 1 3 4 5 4 4 5 5 5 5 5 2  1  0  1  0
    1 1 1 3 2 2 2 2 3 3 3 3 3 0  1  1  1  1
    1 1 3 4 2 4 4 3 5 1 4 5 5 1 -1  0  1  0
    1 1 4 3 3 3 3 3 3 3 3 3 3 0  0  0  0  0
    1 1 2 4 2 4 4 3 4 2 5 3 4 0  0  1 -1  1
    1 1 4 4 1 4 4 4 4 1 4 4 4 0  0  0  0  1
    1 1 4 5 1 5 3 4 5 1 5 5 5 0  0  0  2  0
    1 0 4 5 1 2 2 3 5 2 2 4 3 0  1  0  2 -1
    1 1 1 3 3 2 3 3 3 4 3 4 3 0  1  1  1 -1
    0 1 2 4 2 3 1 3 4 2 4 4 4 0  0  1  3 -1
    0 0 1 4 2 4 3 3 5 2 4 3 3 1  0  0  0  0
    end
    label values V1Age agelabel
    label def agelabel 0 "25 or under", modify
    label def agelabel 1 "26 or over", modify
    label values V2Gend gendlabel
    label def gendlabel 0 "Female", modify
    label def gendlabel 1 "Male", modify
    label values V3Exp explabel
    label def explabel 1 "2 years or less", modify
    label def explabel 2 "3 to 5 years", modify
    label def explabel 3 "6 to 10 years", modify
    label def explabel 4 "More than 10 years", modify

  • #2
    You didn't get a quick answer. You may want to try to break your problem into smaller pieces. Also, only post the minimum needed to demonstrate your problem.

    I'd start by seeing which tools are used in your discipline. Many times, identical estimators have different names in different disciplines (e.g., a panel regression with appropriate panels can be the same as an anova).

    As for automating, it will depend on the specific test. Some may let you do it with the by statements. If not, you'll need a loop. You can write from a loop into a new variable to save the results.
    That is, (not efficient), you can always do:

    g b=.
    g se=.
    g group=" "
    local i 0
    foreach var in Q1 Q2 {
    local i=`i' + 1
    *test using `var'A and `var'B
    * then find the output (look at ereturn or return). You may need to put the results into a local, call them b and se, and
    replace b=`b' in `i'/`i'
    replace se=`se' in `i'/`i'
    replace group=`var' in `i'/`i'
    }


    You can add another loop over the demographics or whatever and another variable to keep your demographics conditions.

    Comment


    • #3
      Dear Prof. Bromiley,

      Thank you for all your suggestions. I will do as you suggest.

      I will use the code and let you know asap.

      I greatly appreciate your help on this!

      --Sunita

      Comment


      • #4
        Dear Prof. Bromiley,

        Thank you very much for pointing me in the right direction.

        I figured out the tests that need to be done. Now, my main issue is with exporting the results. There should be a different excel file for each Q1diff - Q20diff. Each of these excel files should have 7 tabs, named V1Age, V2Gend, V3 Exp...and so on.

        I started with the export excel command, but, I got stuck with tab names.

        I would be very grateful for your help.

        --Sunita

        Comment

        Working...
        X