Announcement

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

  • SPSS to Stata

    Dear Statalist,

    I'm currently trying to replicate a piece of analysis originally done on SPSS in Stata 17 (Mac OS); specifically, a repeated-measures ANOVA.

    The original SPSS code is:

    Code:
    GLM confrontT1 confrontT3 WITH changeconfrontCOVID  
    /WSFACTOR=toename_confront_speed 2 Polynomial    
      /METHOD=SSTYPE(3)    
       /EMMEANS=TABLES(toename_confront_speed) WITH(changeconfrontCOVID=-30)COMPARE ADJ(LSD)    
       /EMMEANS=TABLES(toename_confront_speed) WITH(changeconfrontCOVID=0)COMPARE ADJ(LSD)    
       /EMMEANS=TABLES(toename_confront_speed) WITH(changeconfrontCOVID=30)COMPARE ADJ(LSD)  
     /PRINT=DESCRIPTIVE ETASQ    
     /CRITERIA=ALPHA(.05)  
     /WSDESIGN=toename_confront_speed    
     /DESIGN=changeconfrontCOVID.
    The variables confrontT1 and confrontT3 are measures of intention to confront individuals who violate a social norm measured at time 1 and 3; changeconfrontCOVID is a control variable about perceptions a Covid-related norm.

    The analysis was done on a dataset in wide format. I first reshaped the dataset into long format. The variables "confrontT1" and "confrontT3" are now "confrontT", "real_id" is an individual identifier, and "t" is time. The variable changeconfrontCOVID is a non-integer ranging from -100 to 100. A sample of the long format dataset is below,

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double confrontT float real_id byte t double changeconfrontCOVID
      5  3 1 -29.5
      4  3 3 -29.5
      6  5 1    18
      6  5 3    18
    4.5  7 1     .
      1  7 3     .
      6 19 1  -7.5
      7 19 3  -7.5
    1.5 21 1    30
    1.5 21 3    30
      5 23 1   -65
    3.5 23 3   -65
      1 24 1  22.5
      1 24 3  22.5
      4 32 1    62
    end
    Based on the Stata documentation, I believe the correct syntax should be:

    Code:
    anova confrontT c.changeconfrontCOVID / i.real_id | c.changeconfrontCOVID t c.changeconfrontCOVID#t, repeat(t)
    However, I get the error message

    invalid interaction specification;
    '|' requires a factor variable on each side
    If I remove the factor-variable operators and type real_id | changeconfrontCOVID, I get the following error message

    changeconfrontCOVID: factor variables may not contain noninteger values
    I was wondering if you could tell me how to work around this issue. I would be grateful for any help.

    Best regards,
    Miguel Fonseca
Working...
X