/* this program simulates a simple peer influence model on two dimensions. It starts with a random distribution of oppinions, and each person changes their oppinion as a weighted function of their own oppinion and the other people's oppinion. User inputs the network, the relative size of the self weight, and the number of itterations. Author: Moody Date: Feb 23, 2000 */ proc iml; %include 'c:\moody\sas\programs\modules\rangrp.mod'; %include 'c:\moody\sas\programs\modules\pajwrite.mod'; %include 'c:\moody\sas\programs\modules\pajpart.mod'; *blk={.95 .05 .0001, .05 .10 .005, .0001 .005 .10}; *grpsz={5, 25, 25}; blk={.95 .05, .05 .02}; grpsz={10,100}; net=rangrp(blk,grpsz); grp=net[,1]; net=net[,2:ncol(net)]; net=(net+net`)>0; mattrib net format=1.0; *print net; op=j(nrow(net),2,0); op=rannor(op); /* two vector oppinion set */ start peerinf(y,w,alpha,n); opstk1=y[,1]; opstk2=y[,2]; do i=1 to n; op_i=alpha*(w*y)+(1-alpha)*y; opstk1=opstk1||op_i[,1]; opstk2=opstk2||op_i[,2]; y=op_i; end; return(opstk1||opstk2); finish; samegrp=j(nrow(net),ncol(net),0); do i=1 to nrow(samegrp); do j=1 to nrow(samegrp); samegrp[i,j]=(grp[i]=grp[j]); end; end; /*** assign group weight here ****/ grpwt=4; netv=choose(net=1&samegrp=1,net*grpwt,net); /* increase within group ties by grpwt */ *mattrib netv format=1.0; *print netv; netw=netv; do i=1 to nrow(net); netw[i,]=netw[i,]/netw[i,+]; end; netw=choose(netw=.,0,netw); /*** LINE THAT RUNS THE PEER INFLUENCE PROCEDURE ****/ opvars=peerinf(op,netw,.8,7); /* OPINION,WEIGHT, ALPHA, T */ /****************************************************/ opset=grp||opvars; create outd from opset [colname={grp x0 x1 x2 x3 x4 x5 x6 x7 y0 y1 y2 y3 y4 y5 y6 y7}]; append from opset; id=1:nrow(net); id=id`; file 'c:\moody\classes\soc884\examples\peerinf1.net'; call pajwrite(net,id,2); file 'c:\moody\classes\soc884\examples\peerinf1.clu'; call pajpart(grp); quit; symbol1 value=circle height=2; proc gplot; plot y0*x0=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y1*x1=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y2*x2=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y3*x3=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y4*x4=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y5*x5=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y6*x6=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; plot y7*x7=grp /haxis = -1.2 to 1.2 by .2 vaxis = -1.2 to 1.2 by .2; run;