\documentclass[xcolor=svgnames,beamer,10pt]{beamer}
% The parameter in [..] can be beamer or handout
% Based on file
% $Header: /cvsroot/latex-beamer/latex-beamer/solutions/generic-talks/generic-ornate-15min-45min.en.tex,v 1.4 2004/10/07 20:53:08 tantau Exp $
% This file is a solution template for:
% - Giving a talk on some subject.
% - The talk is between 15min and 45min long.
% - Style is ornate.
% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.

% When replacing figures, put a % at the end of the line
% to prevent a linebreak being read!

%\iffalse
%for transparencies:
\mode<beamer> {
%  \useoutertheme{split}
  \useoutertheme{infolones}
  \useinnertheme{rounded}
%  \usecolortheme{seahorse}  %whale % dolphin % crane
  \usecolortheme{crane}
  \setbeamercolor*{titlelike}{parent=structure}
  \setbeamertemplate{footline}{\hfill\insertframenumber\hspace*{2em}\\ \hfill}  % dit kan aan en uit!
  \setbeamertemplate{navigation symbols}{}  % no navigation symbols
  \setbeamercovered{invisible}
}
%\fi
%for handouts:
%\iffalse
\mode<handout> {
  \useoutertheme{infolones}  % gets rid of () in footer around \insertshortinstitute
   \usecolortheme{dove}
   \usepackage{pgfpages}
   \pgfpagesuselayout{2 on 1 with notes landscape}[a4paper, border shrink=4mm]
   \usepackage{fancybox}
   \fancypage{\setlength\footskip{0pt}}{\setlength\fboxsep{2ex}\setlength\footskip{0pt}\fbox}
}
%\fi


\usepackage{amsmath}
\usepackage{latexsym}


\usepackage{tikz}
\usetikzlibrary{shapes, arrows}
\usepackage{pgflibraryarrows}

\usepackage{pgflibrarysnakes}
\usetikzlibrary{snakes}
%\usepackage{colortbl}
%\usepackage{picins}
%\usepackage{fancybox}
\usepackage{pgf}


\tikzstyle{terminator} = [rectangle, draw, text centered, rounded corners, minimum height=2em]
\tikzstyle{process} = [rectangle, draw, text centered, minimum height=2em]
\tikzstyle{decision} = [diamond, draw, text centered, minimum height=2em]
\tikzstyle{data}=[trapezium, draw, text centered, trapezium left angle=60, trapezium right angle=120, minimum height=2em]
\tikzstyle{connector} = [draw, -latex']

% For handouts; see pgfmanual
%\usepackage{pgfpages}
%\pgfpagesuselayout{2 on 1}[border shrink=5mm]

\usepackage[english]{babel}
% or whatever

%\usepackage[latin1]{inputenc}
% or whatever
%\usepackage{epsfig}
\usepackage{times}
\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.


% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:


%\pgfdeclareimage{university-logo}{blue-small1}
\pgfdeclareimage[height=6mm]{university-logo}{blue1}
%\logo{\pgfuseimage{university-logo}}

\newcommand{\Reals}{\mbox{I}\hspace{-.07ex}\mbox{R}}
\newcommand{\E}{\mbox{E}}
\renewcommand{\P}{\mbox{P}}
\newcommand{\se}{\mbox{s.e. }}
\newcommand{\var}{\mbox{var}}
\newcommand{\cov}{\mbox{cov}}
\newcommand{\logit}{\mbox{logit}}
\newcommand{\uh}{\underline{h}}
\newcommand{\tuh}{\tilde{\uh}}
\newcommand{\neqsum}[3]
{\, \sum_{\stackrel{\scriptstyle #1 = 1}{\scriptstyle #2 \neq #3}}^g
\,}

\newcommand{\R}{{\sf R }}
\newcommand{\Rn}{{\sf R}}
\newcommand{\rs}{{\sf \siec RSiena}}
\newcommand{\SI}{{\sf \siec Siena }}
\newcommand{\RS}{{\sf \siec RSiena }}
\newcommand{\RST}{{\sf \siec  RSienaTest }}
\newcommand{\msi}{{\sf \siec multiSiena }}

\newcommand{\equat}[1]{$#1$}
\newcounter{savenumi}
\newcounter{savenumi2}
\newcounter{savenumi3}
\newcounter{savenumi4}

\newcommand{\fracd}[2]{\frac{\displaystyle #1}{\displaystyle #2}}
\newcommand{\sfn}[1]{\texttt{\textbf{#1}}}

% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command:

%\beamerdefaultoverlayspecification{<+->}
\renewcommand{\baselinestretch}{1.2}
%\definecolor{VC}{cmyk}{0.6,0,0,0}
\definecolor{VC}{named}{Khaki}
\definecolor{EC}{named}{DarkOrange}
\newcommand{\cc}{\color[named]{SeaGreen}}
\newcommand{\itc}{\color[rgb]{0.1,0.6,0.3}}  % itemcolor
\newcommand{\siec}{\color[named]{Sienna}} % Siena color (RawSiena dvipsnames)
\newcommand{\emec}{\color[rgb]{0.3,0.1,0.0}}  %  \color[named]{Emerald}}
\definecolor{c1}{named}{Salmon}
\definecolor{c2}{named}{DarkSlateBlue}
\definecolor{c3}{named}{Olive}

\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex}


\title
[]
%[Dynamics of Social Networks]
{Developments for RSiena -- 2022}

%\subtitle
%{Presentation Subtitle} % (optional)

\author
[]%[\copyright \  Tom A.B.\ Snijders]%[Author, Another] % (optional, use only with lots of authors)
{Tom A.B.\ Snijders }
% - Use the \inst{?} command only if the authors have different
%   affiliation.

\institute
[]
%[Oxford \& Groningen]
{
{
\vspace{-4ex}
\begin{minipage}{.2\textwidth}
\includegraphics[scale=0.07]{RUG_web_Wapen.jpg}
%\includegraphics[scale=0.45]{isi_emblem.jpg}
\end{minipage}
\hfill
\begin{minipage}{.5\textwidth}
\begin{center}
University of Oxford \\  University of Groningen
\end{center}
\end{minipage}
\hspace*{3em}
\hfill
\begin{minipage}{.1\textwidth}
\includegraphics[scale=0.5]{blue1.jpg}
\end{minipage}
\hspace*{2em}
}

}
% - Use the \inst command only if there are several affiliations.

\date[]{Duisterbelt, 2022}

% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:


\newcommand{\sx}{{\scriptstyle X}}
%\newcommand{\sz}{{\scriptstyle Z}}
\newcommand{\extraver}{{$\phantom{\Big(}$}}
\newcommand{\extraverr}{{$\phantom{\big(}$}}

\renewcommand{\th}[1]{$\theta_{#1}$}
\newcommand{\ga}[1]{$\gamma_{#1}$}
\newcommand{\be}[1]{$\beta_{#1}$}

\newcommand{\cdiamond}{{\color[named]{MidnightBlue}\diamond}}
\newcommand{\cbullet}{{\color[named]{MidnightBlue}$\bullet$}}
\newcommand{\cques}{{\color[named]{MidnightBlue}?`}}
\newcommand{\rast}{{\color[named]{Red}$\ast$}}
\newcommand{\gast}{{\color[named]{Green}$\ast$}}

\newcommand{\rtar}{{\itc $\Rightarrow$}}
\newcommand{\qques}{\raisebox{1.2ex}{\rotatebox{180}
                    {\color[named]{ForestGreen}\bf\large ?}}}
\newcommand{\excl}{{\color[named]{ForestGreen}\bf\large !}}
% or OliveGreen

\newcommand{\vit}{\theenumi}

\newcommand{\mcc}[2]{\multicolumn{#1}{c}{#2}}
\newcommand{\mcp}[2]{\multicolumn{#1}{c|}{#2}}

\newcommand{\equa}[1]{\[#1\]}

\definecolor{grey}{gray}{0.75}
\newcommand{\separationb}{\\[0.5ex]\hline\rule{0pt}{2ex}}
\newcommand{\separationg}{\\[0.5ex]\arrayrulecolor{grey}\hline\arrayrulecolor{black}
                         \rule{0pt}{2ex}}

\newenvironment*{enumerate1}{\begin{enumerate}}
{\setcounter{savenumi}{\value{enumi}}\end{enumerate}}

\newenvironment*{enumerate2}{\begin{enumerate}
\setcounter{enumi}{\value{savenumi}}}
{\setcounter{savenumi}{\value{enumi}}\end{enumerate}}

\newenvironment*{enumerate3}{\begin{enumerate}
\setcounter{enumi}{\value{savenumi2}}}
{\setcounter{savenumi}{\value{enumi}}\end{enumerate}}


\def\greying<#1>{%
  \temporal<#1>{\color{black!30}}{\color{black}}{\color{black!30}}}

\begin{document}


\titlepage

\section{Overview}
\begin{frame}
\frametitle{Overview }

Maintaining \RS is something I usually do in contact  with \\
a few others, who make specific contributions.

When I have submitted a new version, this is (normally) noted \\
in the News page of the website,\\
and in a message to \texttt{Siena$@$groups.io}


\url{https://github.com/snlab-nl/rsiena/blob/main/NEWS.md}

But it is nice to share it now with you.

\end{frame}

\begin{frame}

\tableofcontents

\end{frame}

\section{GitHub}

\begin{frame}
\frametitle{GitHub}

After the transition to GitHub (summer 2020),\\
I continue to rely on GitHub help from James Hollway.

GitHub makes collaboration, and contributions by varied people, much easier,\\
but few others are active in this respect.

The \RS website says we still are in a transition phase.

Loose ends:
\begin{itemize}
  \item[\rtar] Website (continued)
  \item[\rtar] \sfn{sienaBayes} now in \msi
  \item[\rtar] \RST still in existence on R-Forge
\end{itemize}

\end{frame}


\begin{frame}
\frametitle{Loose end: Website}

 Website is duplicated between
  \url{http://www.stats.ox.ac.uk/~snijders/siena/} and
  \url{https://github.com/snlab-nl/rsiena/wiki}, \\
  but I maintain only the former\\
  and nobody seems to do anything with the latter.
\medskip

\textbf{Last year's proposal:} carry on,\\
you are welcome to extend/modify the wiki.
\bigskip

\centerline{\alert{how do we carry on?}}

\end{frame}

\begin{frame}
\frametitle{Loose end: \msi }

Paper Koskinen-Snijders about \sfn{sienaBayes} recently accepted\\
in \emph{JRSS-A} (special issue `\textit{Networks in Society}')\\
There will be a script on the \SI website.

Function  \sfn{sienaBayes} is implemented in package \msi ,\\
available from the \SI downloads page.

Question: \alert{should it be integrated with \RS?}\\
This would lead to a very large package.
\bigskip


\RST is still on R-Forge, but not maintained.\\
{\scriptsize (note: extra functionality is  \sfn{sienacpp} and Simmelian effects)}

\end{frame}


\begin{frame}
\frametitle{CRAN}

Whenever there are enough important changes,\\
a new version is submitted to CRAN.

The past versions of \RS at CRAN:
\begin{enumerate}
  \item 1.3.14 (October, 2022)
  \item 1.3.0 (May, 2021)
  \item 1.2.23 (January, 2020)
\end{enumerate}

Submitting to CRAN is always something of a hassle, but useful.\\
For the last submission, Brian Ripley gave important support\\
to update the \texttt{configure} files.

\end{frame}


\section{Use of recent options}
\begin{frame}
\frametitle{Use of recent options }

Two important options, added in the past few years,\\
are not yet used a lot:

\begin{itemize}
  \item The GMoM for use of contemporaneous statistics \\
  (Viviana Amati).\\
    The hurdle for its use is the necessity to have an adequate fit.\\
    Work in progress!
  \item The model for continuous behavioral variables (Nynke Niezink).\\
    There still is a bug -- but where???\\
    Work in progress!
\end{itemize}

\alert{These situations still are unchanged (as far as \RS is concerned).}

\end{frame}


\section{New Effects}
\begin{frame}
\frametitle{New Effects }

Various new effects were implemented. A few highlights:
\begin{itemize}
  \item Contributions from Roberts Krause and Hellpap, Steffen Triebel.
  \item \texttt{avDeg}, see next page.
  \item elementary activity effects, see next next page\\
        \texttt{outAct\_ego, inAct\_ego, reciAct\_ego, toAny}
  \item \texttt{gwdspFB} effect added for two-mode networks.
  \item For effects \texttt{to}, \texttt{toBack}, \texttt{toRecip}, \texttt{mixedInXW},
    internal effect parameter 3 now specifies truncation (at 1) of the number of
    twosteps.
  \item Incoming tie influence weighted by dyadic covariate:\\
   \texttt{avInAltW}, \texttt{avWInAlt}, \texttt{totInAltW}, \texttt{totWInAlt}
  \item \texttt{recipRateInv}, \texttt{recipRateLog}
  \item Several new effects related to primary setting \\
        (see manual, only names are mentioned...)
\end{itemize}

\end{frame}

\begin{frame}
\frametitle{New effect \texttt{avDeg}}
\small

From the manual:\\
\texttt{
 {\em average out-degree} ($X$: av.\ degree) \texttt{(avDeg)}\\
 defined by the out-degree of $i$ multiplied by the
 average outdegree centered by the internal effect parameter~$p$\\[0.2em]
 $s^{\rm net}_{i\vit}(x) =  \sum_j x_{ij}\, \big( \frac 1n \sum_h  {x_{h+}} \,-\, p \big)=
                           x_{i+}\, \big( \frac 1n \sum_h x_{h+} \,-\, p \big) $ \, ;\\[0.2em]
  this effect is a network-by-period level effect \\
  and therefore is useful only  for multigroup data sets\\
   or for data sets with many periods;}
 \medskip

This was used in the Koskinen-Snijders paper about \sfn{sienaBayes}\\
(one-mode: friendship; two-mode: delinquency)\\
for representing feedback of the average level of classroom delinquency.
\medskip\pause

The estimated parameter was negative!\\
Interpreted as regression to the mean;

\centerline{\alert{`More research is needed to interpret this fully.'}}

\end{frame}


\begin{frame}
\frametitle{\large New Effects: \texttt{outAct\_ego, inAct\_ego, reciAct\_ego}  }

I wanted to have more ways of \\
expressing context-dependence of behavior in \RS.

First step: express dependence of network choices on ego's position.

First indicators of position: degrees.

However, interactions are not permitted with ego's outdegrees (\sfn{outAct})\\
and reciprocal degrees (\sfn{reciAct}).

The manual says that interaction possibilities are defined
by the \texttt{interactionType} of the effect.

\end{frame}

\begin{frame}
\frametitle{Interactions -- ego }

Interactions are defined by multiplying the change statistics.

The explanation of the condition for interactions is given \\
(not in the manual but) in \\

\small
\url{https://www.stats.ox.ac.uk/~snijders/siena/Siena_algorithms.pdf}.

All interactions are allowed if \texttt{interactionType="ego"}.

An effect is defined to be an \emph{ego} effect if it can be written as
\[
 s_{ik}^X(x,z) = \sum_j x_{ij}\, c_{ki}(x,z) \
\]
where $c_{ki}(x,z)$ is independent of $(x_{i1}, \dots, x_{in})$
and independent of $j$. \\
The change statistic then is
\[
  \Delta_{kij}^X(x,z) = c_{ki}(x,z) \ .
\]

\end{frame}

\begin{frame}
\frametitle{ New Effect: \texttt{outAct\_ego}  }

\small
The \texttt{outAct} effect
\[
s_i(x) =  \big(x_{i+}\big)^2
\]
is not an `ego' effect, and therefore cannot be used for interactions. \\
The change statistic is \ \
$
  \delta_{ij}(x)  \,=\, 2\, \big(  x_{i+} \,-\, x_{ij} \big) \,+\, 1 \ .
$

To allow interactions, an ego-type effect was created; it is an elementary effect\\
(see the manual, Section 5.1.3!), described as: \\[0.5em]

\texttt{\footnotesize
 {\em out-degree related activity ego effect} \texttt{(outAct\_ego)},
 	 defined as the elementary effect version of the half-centered
 squared out-degree of the actor,\\[-0.3em]
\[
 f^{\rm net,\, el}_{i\vit}(x) = \big(  x_{i+} - \bar x_{.+}\big)
 \text{  where  }
  \bar x_{.+} \,=\,  \frac{1}{Mn} \sum_{m=1}^M \sum_{i,j} x_{ij} \ ;
\]
 for internal effect param.\ $p=2$, it is defined by
 $f^{\rm net,\, el}_{i\vit}(x)  =   \sqrt{  x_{i+} - \bar x_{.+}} $ \ ; \\
 \alert{since this is an elementary effect, it can be used in interactions\\
 and in endowment and creation functions}} \\
 (but interactions will be elementary effects again).

\end{frame}

\begin{frame}
\frametitle{Elementary effects}

From the manual:

An elementary effect is a contribution to the creation or maintenance of a tie, \\
defined directly, i.e., without expressing it \\
based on the change in some evaluation function.

Thus, for adding a tie, this is added to the objective function,\\
and for removing a tie it is subtracted.

This is more general than the evaluation function,\\
and has lost the interpretation of `evaluation'.

It always has \texttt{interactionType="ego"}\\
(whether or not the condition mentioned is satisfied).

\end{frame}


\begin{frame}
\frametitle{\large New Effects: \texttt{inAct\_ego, reciAct\_ego}  }

For \texttt{inAct} and \texttt{reciAct} the same was done;\\
note that \texttt{inAct} is already an ego-type effect, \\
but the centering may be helpful (e.g., for interactions in \sfn{sienaBayes}) \\
and therefore not only  \texttt{(outAct\_ego)} and \texttt{reciAct\_ego} \\
but also \texttt{inAct\_ego} was created.

\end{frame}


\section{Other changes to \RS}
\begin{frame}
\frametitle{Other changes to \RS }

\begin{itemize}
  \item \texttt{sigmas} and \texttt{meansigmas} added to \sfn{sienaRI} object.
   \item Function \sfn{sienaRI} was made available also for two-mode networks
     (provided the number of second-mode nodes is smaller than the
	 number of actors = first-mode nodes), and corrected
	 for behavioral dependent variables.
  \item If \texttt{returnThetas} in the call of \sfn{siena07},
   not only theta values but also simulated estimation statistics
    during Phase 2 (deviations from targets) are returned.
   \item Function \sfn{includeInteraction} now also can modify the \texttt{initialValue}
     of an effect; and the order of parameters for this function was changed,
     bringing it in line with \sfn{setEffect}.
   \item And various corrections and minor improvements.
\end{itemize}
\end{frame}


\section{Some kind of effect sizes}
\begin{frame}
\frametitle{Some kind of effect sizes}

Issues treated here for effect sizes:

\begin{enumerate}
  \item Sometimes parameters are much smaller or larger than usual \\
  (e.g., 4-cycles).\\[0.4em]
  \rtar \ semi-standardized estimates
  \item In a model for network dynamics,\\
            how large are the separate contributions of each included effect?\\[0.4em]
  \rtar \ entropy-based measures.
\end{enumerate}

\end{frame}



\subsection{Semi-standardized parameter estimates}

\begin{frame}
\frametitle{Semi-standardized parameter estimates}

To compare parameters $\beta_k$ within an estimated model for network $x$,\\
consider the formulae
\[
\text{probability \ \   }  \pi_{ij}(\beta, x) \,=\, \frac{\exp\big(f_i(\beta, x^{(\pm ij)}) - f_i(\beta, x)\big)}
      {1 + \sum_{h \neq i} \exp\big(f_i(\beta, x^{(\pm ih)}) - f_i(\beta, x)\big)} \ ,
\]
\[
\text{change statistic \ \  } f_i(\beta, x^{(\pm ij)}) - f_i(\beta, x) \,=\,
 \sum_k \beta_k\, (1-2 \, x_{ij}) \, \delta_{ij,\, k}(x) \ .
\]

This shows that $\beta_k$ is multiplied by the `variable'
\[
(1-2 \, x_{ij}) \, \delta_{ij,\, k}(x) \ .
\]
Define
\[
   \delta_{ii,\, k}(x)\,=\, 0 \ .
\]


\end{frame}


\begin{frame}
In analogy to linear regression, \\
we can make the values $\beta_k$ comparable by considering
\begin{align*}
  \sigma_{ik}^2(x) \,=\,  & \
  \text{var} \Big\{ \delta_{ij,\, k}(x)\,(1 - 2\, x_{ij}) \ \big\vert  \
   i \text{ fixed } \Big\} \\ % \nonumber \\ \nonumber
  \,=\ &  \  \frac1n \sum_{j=1}^n \big( \delta_{ij,\, k}(x)\,(1 - 2\, x_{ij})\big)^2
    \,-\, \bigg( \frac1n \sum_{j=1}^n \delta_{ij,\, k}(x)\,(1 - 2\, x_{ij})\bigg)^2   \ ,
\end{align*}
the within-actor variance of this `variable'; and their average,
\[
  \sigma_{k}^2(x) \,=\, \frac1n \sum_i   \sigma_{ik}^2(x) \ .
\]
The semi-standardized parameter estimates is defined as the product
\[
    \sigma_k(x) \, \beta_k \ .
\]
This expresses the parameters $\beta_k$, for different $k$ and a given $x$, \\
on a common scale (for a given model).\\
The standard deviation is used here as a somewhat arbitrary,\\
but well-known measure of scale.

\end{frame}


\begin{frame}
\frametitle{Example: activities in Glasgow}

Two-mode network for Glasgow data for 14 activities:

{\scriptsize
\begin{center}
\begin{tabular}{llrrrr}
  \hline
& & daily & weekly & monthly  & less \\
  \hline
1  &  I listen to tapes or CDs          & \textbf{388} &  23 &   5 &  16 \\
2  &  I look around in the shops        &  \textbf{65} & 290 &  48 &  30 \\
3  &  I read comics, mags or books      & \textbf{186} & 121 &  65 &  60 \\
4  &  I go to sport matches             &  \textbf{30} & \textbf{113} &  90 & 200 \\
5  &  I take part in sports             & \textbf{218} & 117 &  30 &  68 \\
6  &  I hang round in the streets       & \textbf{216} &  64 &  26 & 125 \\
7  &  I play computer games             & \textbf{157} & 109 &  45 & 122 \\
8  &  I spend time on my hobby (e.g.\ art, an instrument) & \textbf{114} & 113 &  36 & 170 \\
9  &  I go to something like B.B., Guides or Scouts &  \textbf{36} &  \textbf{81} &   1 & 314 \\
10 &  I go to cinema                    &  \textbf{11} &  \textbf{81} & 269 &  71 \\
11 &  I go to pop concerts, gigs        &   \textbf{7} &   \textbf{6} &  \textbf{92} & 326 \\
12 &  I go to church, mosque or temple  &   \textbf{2} &  \textbf{52} &  \textbf{10} & 368 \\
13 &  I look after a pet animal         & \textbf{197} &  25 &   6 & 203 \\
14 &  I go to dance clubs or raves      &  \textbf{15} &  \textbf{44} & \textbf{104} & 266 \\
15 &  I do nothing much (am bored)      &  37 &  39 &  24 & 331 \\
   \hline
\end{tabular}
\footnotesize

Number of students participating in each of
a list of activities, summed over three waves,
for Glasgow data. Bold-faced are frequencies counted as a tie.
\end{center}
}

\end{frame}

\begin{frame}
\frametitle{Semi-standardized parameter estimates}


{\footnotesize
\centering
% Table based on sienaFit object G160_leisure.b3final , Tue Oct 04 15:13:08 2016
\begin{tabular}{l | r@{.}l r@{.}l r@{.}l r@{.}l  | }
\hline
\rule{0pt}{2ex}\relax
Effect &\multicolumn{2}{c}{$\hat\beta_k$}&\multicolumn{2}{c}{(s.e.)}
             & \multicolumn{2}{c}{$\sigma_k$} & \multicolumn{2}{c}{$\sigma_k\,\hat\beta_k$}
             \\[0.5ex]
\hline
\rule{0pt}{2ex}\relax
rate period 1  &   4 & 227 & (0 & 268)\\
rate period 2  &   4 & 047 & (0 & 278)\\
\hline
\rule{0pt}{2ex}\relax
outdegree                          & --5 & 891  & (0 & 660)  &   0 & 79  & --4 & 67 \\
outdegree - activity               &   0 & 637  & (0 & 088)  &   5 & 48  &   4 & 33  \\
indegree - popularity ($\sqrt{}$)  &   0 & 790  & (0 & 100)  &   6 & 74  &   4 & 29  \\
out-in degree assortativity        & --0 & 0184 & (0 & 0025) & 331 & 54  & --6 & 11  \\
4-cycles                           &   0 & 0389 & (0 & 0057) &  55 & 08  &   2 & 14  \\
\hline
\end{tabular}

$\hat\beta_k$: estimates; s.e.: standard errors;\\
$\sigma_k$: mean within-ego standard deviations of change statistics;\\
$\sigma_k\hat\beta_k$: their product.\\
}
\bigskip

\small
The order of magnitude of the semi-standardized parameter estimates is similar.
\end{frame}


\subsection{Entropy-based measures}
\begin{frame}
\frametitle{Entropy-based measures}

The uncertainty / variability \\
in the outcomes of categorical random variables\\
can be expressed by the \emph{entropy} (Shannon, 1948).

For a probability vector $p = (p_1, \ldots, p_K)$, entropy is defined as
\begin{equation}\label{entropy}
  H(p) \,=\, - \sum_{k=1}^K p_k {}\,^2\!\log(p_k) \ .
\end{equation}
Minimum 0 \ (if one category has $p_k = 1$, outcome is certain);\\
maximum  ${}^2\!\log(K)$ \ (if $p_k = 1/K$ for all $k$, totally random).

This can be transformed to the range $[0, \ 1 ]$ by
\[
    1 \,-\,  \frac{H(p)}{{}^2\!\log(K)}
\]
so that 0 means total uncertainty and 1 means total certainty.

\end{frame}

\begin{frame}
This can be applied to the probability vector
\[
     \pi_{i}(\beta, x) \,=\,
            \Big(  \pi_{i1}(\beta, x), \dots, \pi_{in}(\beta, x) \Big)
\]
of choices in the ministep for current network state $x$.

The degree of determination (certainty), or amount of information,\\
 in the outcome of the ministep for actor $i$,\\
 for current network state $x$, can be expressed by
\begin{equation}\label{uncertainty}
  R_H(i,\beta, x) \,=\,  1 - \frac{H(\pi_{i}(\beta, x))}{{}^2\!\log(K)} \ .
\end{equation}

For models with constant rate function, this can be averaged:
\begin{equation}\label{explained}
  R_H(\beta, x) \,=\, \frac1n \sum_i R_H(i,\beta, x) \ .
\end{equation}

\end{frame}

\begin{frame}

For network panel data we may average over waves:
\begin{equation}\label{explained.M}
  R_H(\beta) \,=\, \frac1M \sum_m R_H\big(\beta, x(t_m)\big) \ .
\end{equation}
Note that this refers to the ministeps, by an arbitrary actor,\\
taken when the network state is as observed.

This is a measure between 0 and 1:\\
1 if the outcome of the ministep for a given actor is certain;\\
0 if all actors choose a random change (all probabilities $1/n$).

This measure was proposed in Snijders \\
(\emph{Math\'{e}matiques et Sciences Humaines}, 2004).

Values generally will be low!

\end{frame}

\begin{frame}
\frametitle{Contributions to $R_H$}

For the contribution of an effect, or set of effects,\\
to the information about the outcome:\\
estimate the model twice,\\
giving parameter estimates $\hat\beta_1$ for  full model\\
and  $\hat\beta_2$ for restricted model, and consider the difference
\begin{equation}\label{explained.diff}
  R_H(\hat\beta_1) \,-\,  R_H(\hat\beta_2) \ .
\end{equation}
Note that this is not necessarily positive,\\
because the estimation method does not maximize $R_H(\hat\beta)$.

\end{frame}

\begin{frame}
\frametitle{Example: van de Bunt data}

As an example we consider the friendly relation for Van de Bunt's data set,
waves $t_1-t_4$.
\medskip

% Table based on sienaFit object vdb.ans3 , Wed Jan 08 18:38:59 2020
% Estimation date Wed Jan 08 18:26:34 2020
\footnotesize

\centering

\begin{tabular}{l  r@{.}l r@{.}l   }
\hline
\rule{0pt}{2ex}\relax
Effect &\multicolumn{2}{c}{par.}&\multicolumn{2}{c  }{(s.e.)}  \\[0.5ex]
\hline
\rule{0pt}{2ex}\relax
Rate 1 & 3 & 94 & (0 & 64)\\
Rate 2 & 4 & 71 & (0 & 81)\\
Rate 3 & 3 & 56 & (0 & 59)\\
\hline
\rule{0pt}{2ex}\relax
outdegree (density)  & --1 & 545$^{\ast\ast\ast}$ & (0 & 208)\\
reciprocity          &   2 & 111$^{\ast\ast\ast}$ & (0 & 272)\\
outdegree-popularity & --0 & 192$^{\ast\ast\ast}$ & (0 & 039)\\
transitive triplets  &   0 & 456$^{\ast\ast\ast}$ & (0 & 049)\\
sex alter            &   0 & 384$^\ast$           & (0 & 191)\\
sex ego              & --0 & 535$^\ast$           & (0 & 209)\\
same sex             &   0 & 156                  & (0 & 181)\\
program similarity   &   0 & 727$^{\ast\ast\ast}$ & (0 & 207)\\
\hline
\multicolumn{5}{l}{\footnotesize{$^\ast$ $p$ $<$ 0.05;
$^{\ast\ast}$ $p$ $<$ 0.01;
$^{\ast\ast\ast}$ $p$ $<$ 0.001;}}\\
\multicolumn{5}{l}{\footnotesize{Overall maximum convergence ratio 0.07.}}\\
\end{tabular}

\end{frame}

\begin{frame}

\small

The following table gives estimates and semi-standardized parameter estimates.

\begin{tabular}{l  r@{.}l r@{.}l  r@{.}l  r@{.}l  r@{.}l  }
\hline
\rule{0pt}{2ex}\relax
Effect &\multicolumn{2}{c}{$\hat\beta_k$}&\multicolumn{2}{c  }{($\text{s.e.}_k$)}
&\multicolumn{2}{c}{$\sigma_k$} & \multicolumn{2}{c}{$\sigma_k\,\hat\beta_k$}
 &\multicolumn{2}{c}{$t_k = \hat\beta_k/\text{s.e.}_k$}  \\[0.5ex]
\hline
\rule{0pt}{2ex}\relax
outdegree (density)  & --1 & 545$^{\ast\ast\ast}$ & (0 & 208)  &  0 & 58 & --0 & 90&   --7 & 44 \\
reciprocity          &   2 & 111$^{\ast\ast\ast}$ & (0 & 272)  &  0 & 32 &   0 & 68&     7 & 76 \\
outdegree-popularity & --0 & 192$^{\ast\ast\ast}$ & (0 & 039)  &  4 & 41 & --0 & 84&   --4 & 86 \\
transitive triplets  &   0 & 456$^{\ast\ast\ast}$ & (0 & 049)  &  1 & 55 &   0 & 70&     9 & 21 \\
sex alter            &   0 & 384$^\ast$           & (0 & 191)  &  0 & 42 &   0 & 16&     2 & 01 \\
sex ego              & --0 & 535$^\ast$           & (0 & 209)  &  0 & 22 & --0 & 12&   --2 & 56 \\
same sex             &   0 & 156                  & (0 & 181)  &  0 & 59 &   0 & 09&     0 & 86 \\
program similarity   &   0 & 727$^{\ast\ast\ast}$ & (0 & 207)  &  0 & 34 &   0 & 24&     3 & 52 \\
\hline
\multicolumn{5}{l}{\scriptsize{$^\ast$ $p$ $<$ 0.05;
$^{\ast\ast}$ $p$ $<$ 0.01;
$^{\ast\ast\ast}$ $p$ $<$ 0.001;}}\\
\end{tabular}

\footnotesize
Effect sizes for friendly relation between van de Bunt's students,
waves $t_1-t_4$.\hspace{1em} \protect\newline
$\hat\beta_k$: parameter estimate; s.e.: standard error; \protect\newline
$\sigma_k$: within-ego standard-deviation
of change statistic (averaged  over actors and waves) \protect\newline
$\sigma_k\,\hat\beta_k$: semi-standardized beta.

\end{frame}

\begin{frame}

%\small

The following table shows the degrees of determination (certainty), \\
by wave, for four models:


\begin{enumerate}
  \item the empty model, with only the outdegree effect;
  \item the purely structural model, with the effects of
        reciprocity, \\outdegree popularity, and transitive triplets;
  \item the model with only covariates,\\ with the three effects of sex
        and program similarity;
  \item the full model.
\end{enumerate}

{\small
%% Table based on sienaFit object vdb.ans4new , Thu Oct 06 09:02:50 2016
\begin{tabular}{l  r@{.}l r@{.}l  r@{.}l  r@{.}l }
\hline
\rule{0pt}{2ex}\relax
Model  & \multicolumn{2}{c  }{$t_1$}
   & \multicolumn{2}{c  }{$t_2$} & \multicolumn{2}{c  }{$t_3$} & \multicolumn{2}{c  }{$t_4$} \\[0.5ex]
\hline
\rule{0pt}{2ex}\relax
Empty model      &  0 & 02  &  0 & 02 &   0 & 02 &    0 & 02     \\
Structural model &  0 & 19  &  0 & 18 &   0 & 17 &    0 & 15     \\
Covariate model  &  0 & 05  &  0 & 05 &   0 & 05 &    0 & 04     \\
Full model       &  0 & 21  &  0 & 19 &   0 & 20 &    0 & 18     \\
\hline
\end{tabular}
}

We conclude that the structural influences are of much greater importance\\
in determining the network dynamics than the covariate influences.

\end{frame}


\subsection{Implementation in RSiena }
\begin{frame}
\frametitle{sienaRI}

These measures are implemented in the function \sfn{sienaRI}.

Consult the help page!

Also see Section 13.5 of the \rs \  manual and
script \texttt{vdB\_effsize.R} .

\end{frame}


\section{Effects in \RS -- coding aspects}
\subsection{Coding effects in R}
\begin{frame}
\frametitle{Effects in \RS -- coding aspects}

In the \sfn{data} directory of the source code

\url{https://github.com/snlab-nl/rsiena/blob/main/data}

 there is the file \sfn{allEffects.csv},

which in the \RS package is available as an \\
internal data frame used to construct effect objects:

\sfn{allEffects}

In \RS, you can request\\
\sfn{dim(allEffects)}\\
and view part of the variables in this data frame in the browser through\\
\sfn{effectsDocumentation()}

The \texttt{xxxxxx, yyyyyy, zzzzzz} are names of variables to be filled in;\\
the \texttt{$\sharp$} is the internal effect parameter to be filled in.

\end{frame}

\begin{frame}
\frametitle{effectGroups}

The first column of \sfn{allEffects} is the \sfn{effectGroup}. By\\
\sfn{unique(allEffects\$effectGroup)}\\
you can see that, currently, there are 59 effectGroups.

These are meaningfully ordered by row in \sfn{effectsDocumentation()}.

The  \sfn{effectGroup} is based on combining the type of dependent variable\\
\texttt{(oneMode -- symmetric -- bipartite -- behavior -- continuous)}\\
with the kind of explanatory variable \\
(type of dependent variable \& \texttt{actor covariate -- dyadic covariate})

This is done by \sfn{getEffects}, defined in the file\\
\url{https://github.com/snlab-nl/rsiena/blob/main/R/effects.r}\\
which calls internal function \sfn{createEffects} \\
for each  \sfn{effectGroup} separately, \\
handling all variables in the \sfn{Siena} data set.

\end{frame}

\begin{frame}
\frametitle{Creating new effects -- R}

The manual (Chapter 18) contains a tutorial about creating new effects.

If, for a new effect, you wish to create a new \sfn{effectGroup},  \\
you have to modify \sfn{getEffects} in \texttt{effects.r} accordingly, \\
and specify its rank order in \texttt{effectsDocumentation.r}.

But usually you can employ one of the existing effectGroups. \\
The \RS manual (Section 18.2) contains a note about \\
how various effectGroups handle two-mode networks differently.

\end{frame}


\subsection{Coding effects in C++}

\begin{frame}
\frametitle{Coding effects in C++}

The \sfn{EffectsFactory} takes the included effects\\
and constructs the computing machinery.

Note that for each effect, we need two things:
\begin{enumerate}
  \item its contribution to the objective function\\
       (exception: \texttt{gmom}-type effects);
  \item its estimation statistic for MoM.
\end{enumerate}


The next page shows the structure of the main effect classes.


\end{frame}


\begin{frame}
\frametitle{\large Effect classes in C++}

\footnotesize

\begin{center}
\begin{tikzpicture}%[scale=0.9]%[node distance = 2cm]
\tikzstyle{every path}=[very thick, -stealth',
           shorten <=2pt,shorten >=2pt, ->]
\node [process, fill=blue!20] at (0,-2)  (eff) {Effect};
\node [process, fill=blue!20] at (2.5, 0) (neteff) {NetworkEffect};
\node [process, fill=blue!20] at (2.5, -2) (beheff) {BehaviorEffect};
\node [process, fill=blue!20] at (2.5, -4) (conteff) {ContinuousEffect};
\node [process, fill=blue!20] at (7.5, 2) (covneteff) {CovariateDependentNetworkEffect};
\node [process, fill=blue!20] at (7.5, 1) (covneteff) {DyadicCovariateDependentNetworkEffect};
\node [process, fill=blue!20] at (7.5, 0) (mixneteff) {MixedNetworkEffect};
\node [process, fill=blue!20] at (7.5, -1) (genneteff) {GenericNetworkEffect};
\node at (5,-4.5) {$\bigotimes$};
\node at (5,-4) {$\bigotimes$};
\node at (5,-3.5) {$\bigotimes$};
\node at (5,-2.5) {$\bigotimes$};
\node at (5,-2) {$\bigotimes$};
\node at (5,-1.5) {$\bigotimes$};
\draw (eff) -- (1.4, 0);
\draw (eff) -- (1.4, -2);
\draw (eff) -- (1.2, -4);
\draw (neteff) -- (6.0, 0);
\draw (neteff) -- (5.9,-1);
\draw (neteff) -- (4.8, 1);
\draw (neteff) -- (5.1, 2);
\draw (beheff) -- (4.9, -2.5);
\draw (beheff) -- (4.9, -2);
\draw (beheff) -- (4.9, -1.5);
\draw (conteff) -- (4.9, -4.5);
\draw (conteff) -- (4.9, -4);
\draw (conteff) -- (4.9, -3.5);
\end{tikzpicture}
\bigskip

Structure of effect classes, without the further descendants
\end{center}


\end{frame}


\begin{frame}
\frametitle{NetworkEffect: change statistic}

The NetworkEffect class has a given \sfn{ego()}.

The contribution to the objective function for network effects\\
is defined by function \sfn{calculateContribution(alter)},\\
and calculations that are not specific to \texttt{alter}\\
are done in \sfn{preprocessEgo(int ego)} \\
{\footnotesize (called elsewhere, therefore \texttt{ego} is specified)}.

\sfn{calculateContribution(alter)} computes the \emph{change statistic}.


\end{frame}


\begin{frame}
\frametitle{NetworkEffect: estimation function}

More details are given in \sfn{Siena\_algorithms.pdf}.\\
Here only the case for effects depending only on the network is treated.

The statistic used for estimation is
\begin{equation}
    \sum_{m=2}^M s_{k}^X\big(x(t_m)\big) \ ,       \label{fitstatX}
\end{equation}
where $s_{k}^X$ is the sum of the effect over all actors, defined by
\begin{equation}
 s_{k}^X(x) = \sum_i s_{ik}^X(x) \ .        \label{fitstat0}
\end{equation}
and $s_{ik}^X$ is effect $k$ for actor $i$.

\end{frame}

\begin{frame}

The terms in (\ref{fitstat0}) are the function \sfn{egoStatistic()},
and these are computed for some (not all) effects as
\begin{equation} \label{egotie}
 \text{egoStatistic}(i) = \sum_j x_{ij}\,\text{tieStatistic}(i,j) \ .
\end{equation}
Effect-specific instances of \sfn{egoStatistic()} \underline{or} \sfn{tieStatistic()} \\
are defined in all functions defining specific effects.

It makes no sense to define \sfn{egoStatistic()} as well as \sfn{tieStatistic()}\\
for any specific effect, because (\ref{egotie}) is computed in \sfn{NetworkEffect.cpp},\\
and will be valid unless \sfn{egoStatistic()} is defined for the specific effect\\
(which then will avoid the use of \sfn{tieStatistic()}).

The endowment and creation effects will be computed by applying  \sfn{egoStatistic()}
to the network of lost or (respectively) newly created ties;\\
only if this is to be replaced by something else, \\
should \sfn{endowmentStatistic()} (or \sfn{creationStatistic()}) be defined.

\end{frame}

\subsection{Generic Effects}

\begin{frame}
\frametitle{Generic effects}

\small
 The class \sfn{GenericNetworkEffect} may be used
to specify an effect for a network variable $X$ if its change statistic is given by
\[
        f_{ij}(x)
\]
and the estimation statistic for the evaluation function by
\[
    \sum_{i, j} x_{ij} f^{0}_{ij}(x) \ ;
\]
with the appropriate modifications for the endowment and creation functions.
The functions $f_{ij}(x)$ and $f^0_{ij}(x)$
should be specified as instances of the
\sfn{AlterFunction} class and passed as parameters when creating the effect.

The distinction between $ f_{ij}$ and $ f^0_{ij}$ is made mainly to allow\\
possibilities for taking missing covariate data into account.

Composition of \sfn{AlterFunction}s is allowed, e.g., sum, product,
square root, which opens the possibility of simple general definitions.

This can be studied by looking for \texttt{GenericNetworkEffect} in \\
\scriptsize
\url{https://github.com/snlab-nl/rsiena/blob/main/src/model/effects/EffectFactory.cpp}


\end{frame}

\begin{frame}
\frametitle{Two examples}

Example of a \sfn{NetworkEffect}:

{\small
\url{https://github.com/snlab-nl/rsiena/blob/main/src/model/effects/AverageDegreeEffect.cpp}
}
\bigskip

Example of a  \sfn{GenericNetworkEffect}:

Search for \texttt{outAct\_ego} in

{\small
\url{https://github.com/snlab-nl/rsiena/blob/main/src/model/effects/EffectFactory.cpp}
}

and then

{\small
\url{https://github.com/snlab-nl/rsiena/blob/main/src/model/effects/generic/EgoOutDegreeFunction.cpp}
}

\end{frame}

\begin{frame}

\begin{center}
\includegraphics[scale=0.41]{Palio-de-SienaINT01.jpg}
\end{center}

\end{frame}

\begin{frame}

\begin{center}
\includegraphics[scale=0.7]{piazza-di-Siena.jpg}
\end{center}

\end{frame}

\end{document}