. * nwrem tutorial 1: a first relational event model on a phone-call log . * Requires the core nwcommands and the package nwrem. . * Run from this folder; the data are in ../data (events and actor attributes). . . nwrem version nwrem version 1.0.8, 26oct2026 core package nwcommands : installed (development copy, no distribution date) native plugin : none (Mata only) compared with : R relevent 1.2-1 license : GNU GPL-3 . . * --- the event data: one row per call, with the time it happened --- . import delimited "../data/calls_events.csv", clear (encoding automatically selected: ISO-8859-1) (3 vars, 439 obs) . list in 1/5 +--------------------------------+ | sender receiver eventtime | |--------------------------------| 1. | 72 50 1220733470 | 2. | 43 51 1221102974 | 3. | 43 51 1221784293 | 4. | 43 22 1221785882 | 5. | 43 55 1221787264 | +--------------------------------+ . count 439 . display "span in days: " (eventtime[_N] - eventtime[1]) / 86400 span in days: 42.125949 . . * --- declare the events as an event network --- . * The log mentions 54 of the 84 students; the other 30 never call or are called. . * They still are possible senders and receivers, so we add them as isolates. . 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') . nwset (1 networks) -------------------- calls . . * --- a model of activity: do busy senders and popular receivers keep their roles? --- . nwrem calls, nodsnd nidrec ------------------------------------------------------------ Relational event model (ordinal partial likelihood, MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -3.12e+03 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- nodsnd | 10.57478 .3530761 29.95 0.000 9.882761 11.26679 nidrec | 11.32606 .3391393 33.40 0.000 10.66136 11.99077 ------------------------------------------------------------ . . * --- a model of history: do people call those they called, or who called them? --- . nwrem calls, frpsndsnd frrecsnd ------------------------------------------------------------ Relational event model (ordinal partial likelihood, MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -2.27e+03 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- frpsndsnd | 6.254331 .1453025 43.04 0.000 5.969544 6.539119 frrecsnd | 2.034655 .1400245 14.53 0.000 1.760212 2.309098 ------------------------------------------------------------ . display "events: " e(N) ", actors: " e(nodes) ", log likelihood: " %9.2f e(ll) events: 439, actors: 84, log likelihood: -2274.05 . display "effect of inertia on the odds: x" %6.1f exp(_b[frpsndsnd] * 0.1) " per 10 percentage points" effect of inertia on the odds: x 1.9 per 10 percentage points . . * --- both together --- . nwrem calls, nodsnd nidrec frpsndsnd frrecsnd ------------------------------------------------------------ Relational event model (ordinal partial likelihood, MLE) Network: calls Actors: 84 Events: 439 Log likelihood: -2.12e+03 ------------------------------------------------------------ ------------------------------------------------------------ calls | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- nodsnd | 5.392451 .4376142 12.32 0.000 4.534743 6.25016 nidrec | .9485414 .5809882 1.63 0.103 -.1901745 2.087257 frpsndsnd | 5.782841 .1612638 35.86 0.000 5.46677 6.098913 frrecsnd | 1.640027 .1538415 10.66 0.000 1.338504 1.941551 ------------------------------------------------------------ .