Exercise SAOM AdvancedSocialNetworkAnalysis Background Inthisexercise,IwantyoutousesomeofthedataIpresentedinthefirstsession.Thedataisabouta friendshipnetworkinaDutchschoolclass.ThedatawerecollectedbetweenSeptember2003andJune 2004. There are 26 students who were followed over their first year at secondary school during which friendshipnetworksaswellasotherdatawereassessedatfourtimepointsatintervalsofthreemonths. Therewere17girlsand9boysintheclass,aged11-13atthebeginningoftheschoolyear.Networkdata were assessed by asking students to indicate up to twelve classmates which they considered good friends. Ultimately, I want you to run a network dynamics (only) model that replicates Model 0 (Table 1) in Snijdersetal.(2010).Thequestioniswhatdrivesnetworkchangeinthisschoolclass? Moreinformation http://www.stats.ox.ac.uk/~snijders/siena/tutorial2010_data.htm Data http://www.stats.ox.ac.uk/~snijders/siena/klas12b.zip YoucanfindthedatainthedatafolderthatIpreparedforthisworkshop. Exercise1 - - - - - - - Load the network datasets klas12b-net-1.dat, klas12b-net-2.dat, klas12bnet-3.dat and klas12b-net-4.dat fromthedatafolder. read.table(...)isagoodstart Transformthedata.frameobjectsyoujustgeneratedinmatrixobjectsandsavethesematrices as net1, net2, net3 and net4. Usethecommandas.matrix(...) Thenetworksarecodedasfollows:Friendship:0=no,1=yes,9=missing,10=notamember of the classroom (structural zero). In RSiena network values can only be 0,1,10,11 (structural ones). Therefore,youneedtodealwiththemissingcode9.Here,itmakessensetosetitto“structural zero”. a) Youcansubsetanetworkwiththissyntax:net1[net1==9] b) Youcanassignwhateverisontherightsidetowhateverisontheleftside oranarrow:a <- 10 Therefore,youneedtodealwiththemissingcode9.Here,itmakessensetosetitto“structural zero”. Next, load some additional data saved in klas12b-demographics.The fileklas12bdemographics.datcontainsthefollowingfourvariablessavedinfourcolumns. § Sex(1=girl,2=boy) § Age(years) § Ethnicity(1=Dutch,2=other,0=missing) § Religion(1=Christian,2=non-religious,3=non-Christianreligion,0=missing) Generateanewobjectsex.dwhichholdsthefirstcolumnofthedata.frameyoujustloaded. Youcanselectthefirstcolumnofadata.framecalleddatawithdata[,1] Lastly,loadthedyadiccovariatesavedinklas12-b-primary.dat.Thisfilecontains variablesindicatingiftwostudentswenttothesameprimaryschool.Savethisdataasamatrix andcallitprimary.d § Sameprimaryschool:0=no,1=yes. Great,ifyoumadeitsofarandhavesometimelefttrytoplotthenetworksrepresentedbythe matricesnet1, net2, net3, net4. Usegplot(...)toplotanetworkinmatrixformat Exercise2 - - - - - BeforeyoucanrunaRSienaanalyses,youneedtocreateasienaDependentobjectwhereyou declarethesequenceofnetworks(net1… net4)asdependentvariable.Callthisnewobject friendship Checkthecodeweusedinthelabsessionforthesyntaxyouneedtouse. Ifyoudonotknowthedimensionsofthenetworksyoucanfindthatoutwithe.g. dim(net1) Wewanttousesex.dasindependentvariable.Createaconstantcovariate(coCovar)object forsex.dandcallitsex Look-upthecodeweusedinthelabsessiontodosimilarthings. Wealsowanttouseprimary.dasindependentvariable.Remember,primary.d isa matrix(youshouldhavetransformeditintothisformat).Createaconstantdyadiccovariate (coDyadCovar)objectforprimary.dandcallitprimary Thesyntaxtodothisisverysimilartotheonewhenyoucreateaconstantcovariate. Great,nowwehavealldependentandindependentvariableobjectsthatweneed.Youjust needtoputitalltogetherandcreateasienaDataobjectandcallityourData. Again,checkoutthecodeweusedinthelab.Youjustneedtoaddalldependentand independentvariablestotheargumentslist. ThecommandyouneedtouseissienaDataCreate Finally,createasienaEffectsobjetfromthissienaDataobjectandcallityourEff ThesimplecommandisgetEffects(…) Exercise3 - - - - - - Wearenearlytheretorunamodel.Everythingisinplace. Now, the only thing left to do is to specify the model you want to estimate. You do this by altering the yourEff object you just created. The best way to include an effect is using includeEffects(…) Okay,wewanttoreplicatemodel0intable1ofSnijdersetal.(2010) Thereareabunchofnetworkeffectsyouneedtoinclude.Theshortnamesfortheseeffectsare: recip, transTrip, transTies, cycle3, inPopSqrt, outPopSqrt, outActSqrt. Youcanincludealloftheseeffectsinonego.Seehowwedidthisinthelabsession. Next,includeegoX, altX, and sameX effectsfor sex.Remember,egoXjustmodels thatindividualswithahighscoreonXsendmoretiesandaltXmodelsthatindivdiualswitha highscoreonXreceivemoreties.AndsameXmodelsthattiesbetweentwoindividualswho havethesamevalueonXaremorelikelytoform/maintainties. Weusedtheseeffectsalreadyinthelabsession.Basically,youjustneedtoinclude themintheargslistofinlcudeEffects(…)andspecifyinteraction1 = “sex” Lastly,letusincludeasimpledyadiccovariateeffectofprimary.Withthiseffectwewantto modelthattiesmightbemorelikelytoform/maintainedwhentwoindividualsalreadywentto thesameprimaryschooltogether.Wedidnotusesuchaneffectinthelabsessionbefore.This istherelevantsyntax.Thegeneralformisalwaysthesame.Youjustneedtoknowtheshort nameofaneffect(here:X)andspecifyitfurtherwithinteraction1(andsometimesalso interaction2). yourEff <- includeEffects(yourEff, X, interaction1 = "primary") Yeah!!Andnow…runthemodel yourAlgorithm <- sienaAlgorithmCreate(projname ='Exercise') yourAns <- siena07(yourAlgorithm, data = yourData, effects = yourEff) LookatyourresultsyourAnsandbeexcitedthatyoujustreplicatedSnijdersetal.(2010)! Yeah
© Copyright 2026 Paperzz