. * nwdynam tutorial 2: effects, covariates and comparing models . * Requires the core nwcommands and the package nwdynam. . * Run from this folder; the data are in ../data. . . * --- declare the events (see tutorial 1) --- . import delimited "../data/calls_actors.csv", clear (encoding automatically selected: ISO-8859-2) (3 vars, 84 obs) . tempfile actors . save `actors' file /var/folders/hx/2zp2k5ps2y7d_6hx015fcr1h0000gn/T//S_10699.000001 saved as .dta format . import delimited "../data/calls_events.csv", clear (encoding automatically selected: ISO-8859-1) (3 vars, 439 obs) . levelsof sender, local(a) clean 1 2 5 7 8 11 16 20 21 23 24 27 29 30 31 32 36 37 42 43 44 46 47 51 55 58 62 64 66 67 68 70 71 72 . levelsof receiver, local(b) clean 1 3 4 6 8 9 11 12 14 16 20 21 22 23 24 25 27 30 31 32 33 34 35 36 42 43 44 45 46 50 51 54 55 58 60 61 63 64 66 67 68 70 > 71 74 76 77 . local all : list a | b . local miss . forvalues i = 1/84 { 2. if !`: list i in all' local miss `miss',`i' 3. } . local miss = substr("`miss'", 2, .) . nwset sender receiver, directed eventtime(eventtime) name(calls) . nwaddnodes calls, nodenames(`miss') . . * --- put the actor attributes into the data, in the actor order of the network --- . nwload calls, xvars . gen long actor = real(subinstr(_nwnode, "n", "", 1)) . gen long row = _n . merge m:1 actor using `actors', keep(master match) nogenerate Result Number of obs ----------------------------------------- Not matched 0 Matched 84 ----------------------------------------- . sort row . list _nwnode actor floor gradetype in 1/4 +------------------------------------+ | _nwnode actor floor gradet~e | |------------------------------------| 1. | n1 1 3 5 | 2. | n2 2 5 1 | 3. | n3 3 5 2 | 4. | n4 4 2 2 | +------------------------------------+ . list _nwnode actor floor gradetype in 55/58 +------------------------------------+ | _nwnode actor floor gradet~e | |------------------------------------| 55. | 10 10 9 2 | 56. | 13 13 5 4 | 57. | 15 15 7 5 | 58. | 17 17 4 1 | +------------------------------------+ . tabulate floor floor | Freq. Percent Cum. ------------+----------------------------------- 1 | 10 11.90 11.90 2 | 10 11.90 23.81 3 | 9 10.71 34.52 4 | 15 17.86 52.38 5 | 14 16.67 69.05 6 | 1 1.19 70.24 7 | 5 5.95 76.19 8 | 12 14.29 90.48 9 | 8 9.52 100.00 ------------+----------------------------------- Total | 84 100.00 . . * --- the baseline choice model, then homophily on the floor of the dorm --- . nwdynam calls, inertia recip indeg ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -695.4608 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | 5.365619 .1937551 27.69 0.000 4.985866 5.745372 recip | 1.389441 .167288 8.31 0.000 1.061562 1.717319 indeg | -.1735184 .0909708 -1.91 0.056 -.3518179 .0047811 ------------------------------------------------------------ . estimates store base . nwdynam calls, inertia recip indeg same(floor) ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -694.8589 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | 5.405067 .1977618 27.33 0.000 5.017461 5.792673 recip | 1.365324 .1694666 8.06 0.000 1.033175 1.697472 indeg | -.1815237 .0915483 -1.98 0.047 -.3609551 -.0020922 same | -.1704123 .1564014 -1.09 0.276 -.4769534 .1361289 ------------------------------------------------------------ . estimates store samefloor . estimates table base samefloor, b(%9.3f) stats(ll N) ------------------------------------------------------------ Variable | base samefloor -------------+------------------------ inertia | 5.366 5.405 recip | 1.389 1.365 indeg | -0.174 -0.182 same | -0.170 -------------+------------------------ ll | -695.461 -694.859 N | 439 439 ------------------------------------------------------------ . lrtest samefloor base Likelihood-ratio test Assumption: base nested within samefloor LR chi2(1) = 1.20 Prob > chi2 = 0.2726 . . * --- closure effects --- . nwdynam calls, inertia recip indeg trans ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -695.4391 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | 5.353418 .2019691 26.51 0.000 4.957566 5.74927 recip | 1.399064 .1736959 8.05 0.000 1.058627 1.739502 indeg | -.1632543 .1032653 -1.58 0.114 -.3656505 .0391419 trans | -.0506873 .2438788 -0.21 0.835 -.5286809 .4273062 ------------------------------------------------------------ . nwdynam calls, inertia recip indeg nodetrans ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -695.4393 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | 5.362192 .1944804 27.57 0.000 4.981017 5.743367 recip | 1.398677 .1731295 8.08 0.000 1.05935 1.738005 indeg | -.1711 .0916169 -1.87 0.062 -.3506659 .0084658 nodetrans | -.0274378 .1325023 -0.21 0.836 -.2871376 .2322619 ------------------------------------------------------------ . . * --- recency: should an old call still count? --- . nwdynam calls, inertiawindow(604800) recip indeg ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -687.0629 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | 5.180362 .1899864 27.27 0.000 4.807996 5.552729 recip | 1.708492 .1880702 9.08 0.000 1.339881 2.077103 indeg | -.0787753 .0907875 -0.87 0.386 -.2567155 .0991649 ------------------------------------------------------------ . nwdynam calls, weightedinertia recip indeg ------------------------------------------------------------ Dynamic Network Actor Model - choice sub-model (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -921.2929 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- inertia | .2412274 .020603 11.71 0.000 .2008462 .2816087 recip | 2.862979 .1736488 16.49 0.000 2.522633 3.203324 indeg | .7373876 .0777766 9.48 0.000 .5849482 .8898269 ------------------------------------------------------------ . . * --- the rate model with a covariate --- . nwdynam calls, submodel(rate) indeg outdeg ------------------------------------------------------------ Dynamic Network Actor Model - rate sub-model, no intercept (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -1.75e+03 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- indeg | .5514472 .0663444 8.31 0.000 .4214147 .6814798 outdeg | .2637836 .028386 9.29 0.000 .208148 .3194193 ------------------------------------------------------------ . estimates store rate0 . nwdynam calls, submodel(rate) indeg outdeg ego(floor) ------------------------------------------------------------ Dynamic Network Actor Model - rate sub-model, no intercept (MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -1.64e+03 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- indeg | .5167077 .0637887 8.10 0.000 .3916841 .6417312 outdeg | .2622773 .028161 9.31 0.000 .2070829 .3174718 ego | -.4007556 .0306576 -13.07 0.000 -.4608434 -.3406678 ------------------------------------------------------------ . estimates store rate1 . lrtest rate1 rate0 Likelihood-ratio test Assumption: rate0 nested within rate1 LR chi2(1) = 224.58 Prob > chi2 = 0.0000 .