Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Actor-partner Interdependence Model data structure (redo)
From
Nick Cox <[email protected]>
To
[email protected]
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 <[email protected]> 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 <[email protected]
(mailto:[email protected])> 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/