Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Actor-partner Interdependence Model data structure (redo) |

Date |
Sun, 29 Apr 2012 13:57:20 +0100 |

This alternative approach may be of interest. gen dyad = _n expand 2 sort dyad qui foreach v in delinq attach id { by dyad : replace ego`v' = alt`v'[1] if _n == 2 by dyad : replace alt`v' = ego`v'[1] if _n == 2 } Nick On Sun, Apr 29, 2012 at 12:51 AM, Carter Rees <carterrees@gmail.com> wrote: > Thank you Scott. This seems to do the trick and I should be able to tweak it as needed. > On Saturday, April 28, 2012 at 3:53 PM , Scott Merryman wrote: >> clear >> input egoid egodelinq egoattach altid altdelinq altattach >> 111 3 4 222 8 9 >> 444 5 1 333 2 7 >> end >> >> gen dyad = _n >> rename (egoid altid) (person1 person2) >> reshape long person,i(dy) >> order dy person egod altd egoa alta >> >> bys dy: replace egodel = altdel[_n-1] if _j ==2 >> bys dy: replace altdel = egodel[_n-1] if _j ==2 >> gen attachment = egoa if _j ==1 >> replace attach = alta if _j ==2 >> drop egoa alta _j >> l On Sat, Apr 28, 2012 at 1:30 PM, Carter Rees <carterrees@gmail.com (mailto:carterrees@gmail.com)> wrote: >> > I am trying to structure my data as a pairwise data set (see Kenny, >> > Kashy, Cook (2006) Dyadic Data Analysis) and then run a multilevel >> > APIM model. >> > >> > My data set is currently at the individual level as follows: >> > >> > egoid egodelinq egoattach altid altdelinq altattach >> > 111 3 4 222 8 9 >> > 444 5 1 333 2 7 >> > >> > What I would like it to look like (also individual level): >> > >> > dyad person egodelinq altdelinq attachment >> > 1 111 3 8 4 >> > 1 222 8 3 9 >> > 2 444 5 2 1 >> > 2 333 2 5 7 >> > >> > The outcome variable is friendship attachment level. The predictor >> > variables are ego delinquency and alter (friend) delinquency. Each >> > individual's outcome score is associated with both his or her own >> > predictor scores and his or her partner's scores. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Actor-partner Interdependence Model data structure (redo)***From:*Carter Rees <carterrees@gmail.com>

**Re: st: Actor-partner Interdependence Model data structure (redo)***From:*Scott Merryman <scott.merryman@gmail.com>

**Re: st: Actor-partner Interdependence Model data structure (redo)***From:*Carter Rees <carterrees@gmail.com>

- Prev by Date:
**Re: st: pseudo panels implementation in Stata** - Next by Date:
**RE: st: Parametric survival analysis with competing risks** - Previous by thread:
**Re: st: Actor-partner Interdependence Model data structure (redo)** - Next by thread:
**st: Re: st: Bootstrapping standard errors of regression coefficients whilst applying bysort command** - Index(es):