5
$\begingroup$

I first summarize the analysis of some papers that I want to imitate. The regression looks like:

Y2(subjects) = Y2(friends) + Y1(subjects) + Y1(friends) + Z(subjects)

Where subjects refers to focal people and friends refers to those subjects connect to. Some one may be a subject in a relationship and a friend in another. For this question, just skip the validity of this model.

The idea is to use the outcome variable of friends at time 2, Y2(friends), to explain outcome variable of subjects at that time (Y2(subjects)), controlling for outcomes of both subjects and friends at time 1. Other covariates of subjects may be included, but it's not the main consideration.

Following this model, I think the data should be in the wide format, which looks like:

SubjID FrID Y1Subj Y1Fr Y2Subj Y2Fr Z

The authors apply the generalized estimating equation in their analysis. However, I don't know how to perform GEE with the wide data format (let's say PROC GENMOD in SAS), if that's the case. Can you tell if I'm missing some thing (e.g., reconstruction of data in some way so that GEE can be used)?

$\endgroup$
3
  • $\begingroup$ Do you mean transforming data from wide format to long format? $\endgroup$
    – Randel
    Commented Jul 27, 2013 at 0:00
  • $\begingroup$ I think the question is: Does that regression model imply a wide data format? If yes, how can we do GEE analysis with that format, or more specifically, what does GEE programming look like in this case? If no (i.e., that regression model can come with long data format), how does that long format look like? $\endgroup$
    – NonSleeper
    Commented Jul 27, 2013 at 1:26
  • $\begingroup$ I think long format is common for GEE analysis, verified from here , "in order to use proc genmod to perform our analyses, we have to reshape our data from wide to long." $\endgroup$
    – Randel
    Commented Jul 27, 2013 at 4:21

1 Answer 1

5
$\begingroup$

PROC GENMOD requires data in long format. Data can be reshaped from wide to long format with PROC TRANSPOSE:

For example:

DATA data_wide; 
  INPUT id cpdvar20 cpdvar21 cpdvar22 cpdvar23 ; 
CARDS; 
1 10 13 21 23
2 11 19 18 18
3 12 18 24 27
; 
RUN; 

PROC TRANSPOSE DATA = data_wide out = data_long;
   BY id;
RUN;

/* Add column for year */
DATA data_long;
  SET data_long (rename = (col1=cpdvar));
  year = INPUT(substr(_name_, 7), 5.);
  DROP _name_;
RUN; 

PROC PRINT DATA = data_wide;
RUN;

proc print DATA = data_long;
RUN;

Obs id  cpdvar20 cpdvar21 cpdvar22 cpdvar23
1   1   10       13       21       23
2   2   11       19       18       18
3   3   12       18       24       27

Obs id  cpdvar  year
1   1   10      20
2   1   13      21
3   1   21      22
4   1   23      23
5   2   11      20
6   2   19      21
7   2   18      22
8   2   18      23
9   3   12      20
10  3   18      21
11  3   24      22
12  3   27      23
```
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.