/* this program runs a simple peer influence model on the graduate student network. Two variables are constructed: a peer influence variable on advice and on friendship. Relations are treated as valued and symetric (with symetric counting as 2 and asym as 1) author: moody date: Feb 26, 2001 */ libname in1 'c:\moody\classes\soc884\examples\'; data a; set in1.osugrd; id=_n_; /* set id = row number */ run; proc means; run; proc iml; use work.a; read all var{id} into id; read all var{SATISFIED} into satisfied; read all var("BF1":"BF94") into bfrnd; /* best friend adjacency matrix */ read all var("help1":"help94") into help; /* helping adjacency matrix */ /* delete people with missing values on satisfied */ misloc=loc(satisfied=.); keep=setdif(id,misloc); id=id[keep,]; satisfied=satisfied[keep,]; bfrnd=bfrnd[keep,keep]; help=help[keep,keep]; bfrnd=bfrnd*bfrnd`; /* symetric = 2 if sym, 1 if asymetric */ help=help*help`; /* normalize so row sum = 1 */ wbfrnd=bfrnd; whelp=help; do i=1 to nrow(bfrnd); wbfrnd[i,]=wbfrnd[i,]/wbfrnd[i,+]; whelp[i,]=whelp[i,]/whelp[i,+]; end; wbfrnd=choose(wbfrnd=.,0,wbfrnd); whelp=choose(whelp=.,0,whelp); peer_bf=wbfrnd*satisfied; peer_h=whelp*satisfied; outv=id||peer_bf||peer_h; create pdat from outv [colname={id peer_bf peer_h}]; append from outv; quit; data b; merge a pdat (in=indat); by id; if indat; run; proc freq; tables cohortn; run; data b; set b; y00=0; if cohortn=2000 then y00=1; y99=0; if cohortn=1999 then y99=1; y98=0; if cohortn=1998 then y98=1; y97=0; if cohortn=1997 then y97=1; run; proc univariate noprint; histogram satisfied / kernal (k=normal c = .9 w=2.5 color=green) midpoints = 1 to 10 by 1; inset mean="Mean" (3.2) N="N" (2.0) std="Std Dev" (3.2) / pos=nw; run; proc reg; model satisfied = female nonwhite y00 y99 y98 y97 peer_bf peer_h /stb; model satisfied = female nonwhite y00 y99 y98 y97 /stb; run; /* because it is not really a continuous variable, you should not use OLS. Let's try a logit just to check the robustness of the finding */ proc logistic descending; model satisfied = female nonwhite y00 y99 y98 y97 peer_bf peer_h; run;