#RSiena

#start with clean workspace 
rm(list=ls())
#load dataobjects
load("./data/descriptives/UU_net_array_sym.RData")
load("./data/descriptives/UUpub_dfv2.RData")
load("./data/descriptives/UU_dfv2.RData")
load("./data/soc_staff_cit.RData")
load("./data/names_staff_cit_v20221006.RData")

library(RSiena)
library(tidyverse)
names_staff_cit %>% 
  filter(gs_id %in% soc_df$gs_id) -> UU_staff_cit
save(UU_staff_cit, file="./data/descriptives/UU_staff_cit.RData")
#dependent
net <- sienaDependent(net_soc_array)
### Step 1: define data
#diversiteit egonet
div_net <- coCovar(as.numeric(soc_df$div.net))

#diversiteit ego
div_ego <- coCovar(as.numeric(soc_df$div.ego))

#gender
gender <- coCovar(soc_df$gender4)

#leeftijd
pub_first <- coCovar(soc_df$pub_first)

#total cites
soc_df$total_cites_num <- as.numeric(soc_df$total_cites)
total_cites <- coCovar(soc_df$total_cites_num)
#pubs: time-varying
pubsw1 <- pubsw2 <- pubsw3 <- pubsw4 <- NA
for (i in 1:length(soc_df$gs_id)) {
  pubsw1[i] <- nrow(UU_staff_cit[(UU_staff_cit$gs_id == soc_df$gs_id[i]) & UU_staff_cit$year>=2016 & UU_staff_cit$year<=2017,])
  pubsw2[i] <- nrow(UU_staff_cit[(UU_staff_cit$gs_id == soc_df$gs_id[i]) & UU_staff_cit$year>=2018 & UU_staff_cit$year<=2019,])
  pubsw3[i] <- nrow(UU_staff_cit[(UU_staff_cit$gs_id == soc_df$gs_id[i]) & UU_staff_cit$year>=2020 & UU_staff_cit$year<=2022,])
}

pub_df <- as.matrix(data.frame(pubsw1, pubsw2, pubsw3))
pubs <- varCovar(pub_df)

1 Model 1: Diversity of the egonet

mydata1 <- sienaDataCreate(net, div_net)
### Step 2: create effects structure
myeff1 <- getEffects(mydata1)
#effectsDocumentation(myeff2)
### Step 3: get initial description
print01Report(mydata1, modelname = "./data/results/UU_init1")
### Step4: specify model
myeff1 <- includeEffects(myeff1, absDiffX,interaction1="div_net")
##   effectName              include fix   test  initialValue parm
## 1 div_net abs. difference TRUE    FALSE FALSE          0   0
### Step5 estimate
myAlgorithm <- sienaAlgorithmCreate(projname = "UU_init1")
## If you use this algorithm object, siena07 will create/use an output file UU_init1.txt .
(ans1 <- siena07(myAlgorithm, data = mydata1, effects = myeff1))
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.4223  ( 0.1644   )             
##   0.2      Rate parameter period 2  1.0347  ( 0.3302   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -1.3275  ( 0.4102   )   0.0524    
##   2.  eval div_net abs. difference -0.0297  ( 0.0138   )   0.0615    
## 
## Overall maximum convergence ratio:    0.0636 
## 
## 
## Total of 2028 iteration steps.
# (the outer parentheses lead to printing the obtained result on the screen) if necessary, estimate
# further
#(ans <- siena07(myAlgorithm, data = mydata, effects = myeff, prevAns = ans))
summary(ans1)
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.4223  ( 0.1644   )             
##   0.2      Rate parameter period 2  1.0347  ( 0.3302   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -1.3275  ( 0.4102   )   0.0524    
##   2.  eval div_net abs. difference -0.0297  ( 0.0138   )   0.0615    
## 
## Overall maximum convergence ratio:    0.0636 
## 
## 
## Total of 2028 iteration steps.
## 
## Covariance matrix of estimates (correlations below diagonal)
## 
##        0.168       -0.003
##       -0.558        0.000
## 
## Derivative matrix of expected statistics X by parameters:
## 
##       10.984      400.939
##      184.518    18296.141
## 
## Covariance matrix of X (correlations below diagonal):
## 
##       13.976      514.933
##        0.654    44385.088

2 Model 2: Diversity of the egonet with structural effects

mydata2 <- sienaDataCreate(net, div_net)
### Step 2: create effects structure
myeff2 <- getEffects(mydata2)
#effectsDocumentation(myeff2)
### Step 3: get initial description
print01Report(mydata2, modelname = "./data/results/UU_init2")
### Step4: specify model
myeff2 <- includeEffects(myeff2, degPlus) #popularity
##   effectName     include fix   test  initialValue parm
## 1 degree act+pop TRUE    FALSE FALSE          0   1
myeff2 <- includeEffects(myeff2, transTriads) #number of transitive patterns in i's relationships
##   effectName        include fix   test  initialValue parm
## 1 transitive triads TRUE    FALSE FALSE          0   0
myeff2 <- includeEffects(myeff2, absDiffX,interaction1="div_net")
##   effectName              include fix   test  initialValue parm
## 1 div_net abs. difference TRUE    FALSE FALSE          0   0
### Step5 estimate
myAlgorithm <- sienaAlgorithmCreate(projname = "UU_init2")
## If you use this algorithm object, siena07 will create/use an output file UU_init2.txt .
(ans2 <- siena07(myAlgorithm, data = mydata2, effects = myeff2))
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.5206  ( 0.2079   )             
##   0.2      Rate parameter period 2  1.3095  ( 0.4961   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -2.5787  ( 0.8291   )   0.0412    
##   2.  eval transitive triads        1.6350  ( 0.7979   )   0.0372    
##   3.  eval degree act+pop           0.1636  ( 0.1281   )   0.0231    
##   4.  eval div_net abs. difference -0.0270  ( 0.0137   )   0.0054    
## 
## Overall maximum convergence ratio:    0.0896 
## 
## 
## Total of 2003 iteration steps.
# (the outer parentheses lead to printing the obtained result on the screen) if necessary, estimate
# further
#(ans <- siena07(myAlgorithm, data = mydata, effects = myeff, prevAns = ans))
summary(ans2)
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.5206  ( 0.2079   )             
##   0.2      Rate parameter period 2  1.3095  ( 0.4961   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -2.5787  ( 0.8291   )   0.0412    
##   2.  eval transitive triads        1.6350  ( 0.7979   )   0.0372    
##   3.  eval degree act+pop           0.1636  ( 0.1281   )   0.0231    
##   4.  eval div_net abs. difference -0.0270  ( 0.0137   )   0.0054    
## 
## Overall maximum convergence ratio:    0.0896 
## 
## 
## Total of 2003 iteration steps.
## 
## Covariance matrix of estimates (correlations below diagonal)
## 
##        0.687        0.047       -0.091       -0.004
##        0.072        0.637       -0.035       -0.001
##       -0.861       -0.342        0.016        0.000
##       -0.314       -0.053        0.067        0.000
## 
## Derivative matrix of expected statistics X by parameters:
## 
##       15.583        5.181      254.584      534.655
##        4.979        4.810      113.869      159.992
##       98.436       43.257     1923.663     3204.643
##      257.095       72.194     3920.624    20382.787
## 
## Covariance matrix of X (correlations below diagonal):
## 
##       22.608        9.011      394.282      777.675
##        0.619        9.376      229.255      245.892
##        0.902        0.815     8444.013    12369.349
##        0.719        0.353        0.592    51779.331

3 Model 3: div ego en div net

mydata3 <- sienaDataCreate(net, div_net, div_ego)
### Step 2: create effects structure
myeff3 <- getEffects(mydata3)
#effectsDocumentation(myeff3)
### Step 3: get initial description
print01Report(mydata3, modelname = "./data/results/UU_init3")
### Step4: specify model
myeff3 <- includeEffects(myeff3, degPlus) #popularity
##   effectName     include fix   test  initialValue parm
## 1 degree act+pop TRUE    FALSE FALSE          0   1
myeff3 <- includeEffects(myeff3, transTriads) #number of transitive patterns in i's relationships
##   effectName        include fix   test  initialValue parm
## 1 transitive triads TRUE    FALSE FALSE          0   0
myeff3 <- includeEffects(myeff3, absDiffX,interaction1="div_net")
##   effectName              include fix   test  initialValue parm
## 1 div_net abs. difference TRUE    FALSE FALSE          0   0
myeff3 <- includeEffects(myeff3, sameX,interaction1="div_ego")
##   effectName   include fix   test  initialValue parm
## 1 same div_ego TRUE    FALSE FALSE          0   0
### Step5 estimate
myAlgorithm <- sienaAlgorithmCreate(projname = "UU_init3")
## If you use this algorithm object, siena07 will create/use an output file UU_init3.txt .
(ans3 <- siena07(myAlgorithm, data = mydata3, effects = myeff3))
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.5151  ( 0.2024   )             
##   0.2      Rate parameter period 2  1.2970  ( 0.4799   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -2.8112  ( 0.9382   )   0.0234    
##   2.  eval transitive triads        1.5653  ( 0.8515   )   0.0093    
##   3.  eval degree act+pop           0.1640  ( 0.1414   )   0.0279    
##   4.  eval div_net abs. difference -0.0250  ( 0.0141   )   0.0108    
##   5.  eval same div_ego             0.2767  ( 0.4894   )   0.0365    
## 
## Overall maximum convergence ratio:    0.0497 
## 
## 
## Total of 2353 iteration steps.
# (the outer parentheses lead to printing the obtained result on the screen) if necessary, estimate
# further
#(ans <- siena07(myAlgorithm, data = mydata, effects = myeff, prevAns = ans))

4 Model 4: all covariates with structural effects

mydata4 <- sienaDataCreate(net, div_net, div_ego, gender, pub_first, pubs, total_cites)
### Step 2: create effects structure
myeff4 <- getEffects(mydata4)
#effectsDocumentation(myeff3)
### Step 3: get initial description
print01Report(mydata4, modelname = "./data/results/UU_init4")
### Step4: specify model
myeff4 <- includeEffects(myeff4, degPlus) #popularity
##   effectName     include fix   test  initialValue parm
## 1 degree act+pop TRUE    FALSE FALSE          0   1
myeff4 <- includeEffects(myeff4, transTriads) #number of transitive patterns in i's relationships
##   effectName        include fix   test  initialValue parm
## 1 transitive triads TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, absDiffX,interaction1="div_net")
##   effectName              include fix   test  initialValue parm
## 1 div_net abs. difference TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, sameX,interaction1="div_ego")
##   effectName   include fix   test  initialValue parm
## 1 same div_ego TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, sameX,interaction1="gender")
##   effectName  include fix   test  initialValue parm
## 1 same gender TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, egoPlusAltX,interaction1="pub_first") #if you are older, you will get more collaboration within department 
##   effectName            include fix   test  initialValue parm
## 1 pub_first ego and alt TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, egoPlusAltX,interaction1="total_cites") #if you are older, you will get more collaboration within department 
##   effectName              include fix   test  initialValue parm
## 1 total_cites ego and alt TRUE    FALSE FALSE          0   0
myeff4 <- includeEffects(myeff4, egoPlusAltX, interaction1 = "pubs") #if you have many pubs, you will probably publish more per year?
##   effectName       include fix   test  initialValue parm
## 1 pubs ego and alt TRUE    FALSE FALSE          0   0
### Step5 estimate
myAlgorithm <- sienaAlgorithmCreate(projname = "UU_init4")
## If you use this algorithm object, siena07 will create/use an output file UU_init4.txt .
(ans4 <- siena07(myAlgorithm, data = mydata4, effects = myeff4))
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.5919  ( 0.2477   )             
##   0.2      Rate parameter period 2  1.3016  ( 0.4480   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -3.1638  ( 0.9011   )   -0.1348   
##   2.  eval transitive triads        1.6301  ( 0.8368   )   -0.1402   
##   3.  eval degree act+pop           0.1360  ( 0.1417   )   -0.1374   
##   4.  eval div_net abs. difference -0.0242  ( 0.0133   )   -0.1033   
##   5.  eval same div_ego             0.2191  ( 0.4741   )   -0.1412   
##   6.  eval same gender              0.2422  ( 0.4302   )   -0.0666   
##   7.  eval pub_first ego and alt    0.0179  ( 0.0199   )    0.1355   
##   8.  eval total_cites ego and alt  0.0000  ( 0.0000   )   -0.1445   
##   9.  eval pubs ego and alt         0.8094  ( 0.4273   )   -0.1171   
## 
## Overall maximum convergence ratio:    0.1827 
## 
## 
## Total of 2641 iteration steps.
# (the outer parentheses lead to printing the obtained result on the screen) if necessary, estimate
# further
#(ans <- siena07(myAlgorithm, data = mydata, effects = myeff, prevAns = ans))
summary(ans4)
## Estimates, standard errors and convergence t-ratios
## 
##                                    Estimate   Standard   Convergence 
##                                                 Error      t-ratio   
## 
## Rate parameters: 
##   0.1      Rate parameter period 1  0.5919  ( 0.2477   )             
##   0.2      Rate parameter period 2  1.3016  ( 0.4480   )             
## 
## Other parameters: 
##   1.  eval degree (density)        -3.1638  ( 0.9011   )   -0.1348   
##   2.  eval transitive triads        1.6301  ( 0.8368   )   -0.1402   
##   3.  eval degree act+pop           0.1360  ( 0.1417   )   -0.1374   
##   4.  eval div_net abs. difference -0.0242  ( 0.0133   )   -0.1033   
##   5.  eval same div_ego             0.2191  ( 0.4741   )   -0.1412   
##   6.  eval same gender              0.2422  ( 0.4302   )   -0.0666   
##   7.  eval pub_first ego and alt    0.0179  ( 0.0199   )    0.1355   
##   8.  eval total_cites ego and alt  0.0000  ( 0.0000   )   -0.1445   
##   9.  eval pubs ego and alt         0.8094  ( 0.4273   )   -0.1171   
## 
## Overall maximum convergence ratio:    0.1827 
## 
## 
## Total of 2641 iteration steps.
## 
## Covariance matrix of estimates (correlations below diagonal)
## 
##        0.812        0.130       -0.090       -0.003       -0.157       -0.121       -0.005        0.000       -0.081
##        0.172        0.700       -0.038       -0.001       -0.048        0.005        0.002        0.000       -0.014
##       -0.704       -0.324        0.020        0.000        0.000        0.003        0.001        0.000       -0.007
##       -0.264       -0.051       -0.050        0.000        0.001        0.000        0.000        0.000        0.000
##       -0.369       -0.122       -0.003        0.122        0.225       -0.008        0.000        0.000        0.003
##       -0.311        0.014        0.055       -0.064       -0.040        0.185        0.000        0.000        0.007
##       -0.287        0.104        0.371       -0.027        0.003        0.035        0.000        0.000        0.002
##       -0.017        0.077        0.002        0.076       -0.175        0.075        0.541        0.000        0.000
##       -0.211       -0.038       -0.115        0.009        0.014        0.038        0.247        0.018        0.183
## 
## Derivative matrix of expected statistics X by parameters:
## 
##  1.707500e+01  5.026000e+00  2.688930e+02  6.173890e+02  2.600800e+01  2.064200e+01 -4.923270e+02  1.196568e+05  2.710100e+01
##  4.779000e+00  4.440000e+00  1.073280e+02  1.501020e+02  8.470000e+00  5.084000e+00 -2.280870e+02  5.267843e+04  9.411000e+00
##  1.035850e+02  4.350200e+01  1.974709e+03  3.569923e+03  1.643730e+02  1.186620e+02 -3.852396e+03  9.177115e+05  1.825970e+02
##  3.011520e+02  8.732400e+01  4.624091e+03  2.298131e+04  3.849290e+02  3.800650e+02 -7.402840e+03  1.537104e+06  4.514610e+02
##  1.308600e+01  4.696000e+00  2.179400e+02  3.981780e+02  2.992500e+01  1.582500e+01 -4.548220e+02  1.230208e+05  2.222700e+01
##  9.349000e+00  2.369000e+00  1.371500e+02  3.532990e+02  1.398000e+01  2.194900e+01 -2.551040e+02  5.459912e+04  1.430500e+01
## -2.291690e+02 -1.356970e+02 -5.045892e+03 -6.156208e+03 -4.153860e+02 -2.445460e+02  1.969863e+04 -4.498917e+06 -5.273470e+02
##  6.195011e+04  3.216710e+04  1.293768e+06  1.540487e+06  1.209733e+05  5.655805e+04 -4.500277e+06  1.993711e+09  1.338272e+05
##  1.405800e+01  5.801000e+00  2.543580e+02  4.785240e+02  2.264900e+01  1.624400e+01 -5.894430e+02  1.371955e+05  3.830800e+01
## 
## Covariance matrix of X (correlations below diagonal):
## 
##  2.196700e+01  8.277000e+00  3.729160e+02  7.595960e+02  3.399500e+01  2.530400e+01 -7.228110e+02  1.865815e+05  3.723200e+01
##  6.170000e-01  8.186000e+00  2.053630e+02  2.337560e+02  1.487800e+01  8.132000e+00 -4.344760e+02  1.077949e+05  1.790300e+01
##  9.030000e-01  8.140000e-01  7.772415e+03  1.186354e+04  6.071310e+02  3.985280e+02 -1.532150e+04  3.885040e+06  7.060330e+02
##  7.130000e-01  3.600000e-01  5.920000e-01  5.160993e+04  9.693990e+02  8.939060e+02 -1.975153e+04  4.957353e+06  1.195810e+03
##  8.480000e-01  6.080000e-01  8.050000e-01  4.990000e-01  7.316600e+01  3.868300e+01 -1.278434e+03  3.432997e+05  6.156700e+01
##  7.650000e-01  4.030000e-01  6.400000e-01  5.570000e-01  6.410000e-01  4.984100e+01 -7.926090e+02  1.813774e+05  4.218000e+01
## -6.730000e-01 -6.620000e-01 -7.580000e-01 -3.790000e-01 -6.520000e-01 -4.900000e-01  5.256816e+04 -1.206501e+07 -1.578561e+03
##  5.680000e-01  5.370000e-01  6.280000e-01  3.110000e-01  5.720000e-01  3.660000e-01 -7.500000e-01  4.917680e+09  3.926587e+05
##  7.900000e-01  6.230000e-01  7.970000e-01  5.240000e-01  7.160000e-01  5.940000e-01 -6.850000e-01  5.570000e-01  1.010100e+02
I1JTaWVuYQ0KDQpgYGB7cn0NCiNzdGFydCB3aXRoIGNsZWFuIHdvcmtzcGFjZSANCnJtKGxpc3Q9bHMoKSkNCmBgYA0KDQoNCmBgYHtyfQ0KI2xvYWQgZGF0YW9iamVjdHMNCmxvYWQoIi4vZGF0YS9kZXNjcmlwdGl2ZXMvVVVfbmV0X2FycmF5X3N5bS5SRGF0YSIpDQpsb2FkKCIuL2RhdGEvZGVzY3JpcHRpdmVzL1VVcHViX2RmdjIuUkRhdGEiKQ0KbG9hZCgiLi9kYXRhL2Rlc2NyaXB0aXZlcy9VVV9kZnYyLlJEYXRhIikNCmxvYWQoIi4vZGF0YS9zb2Nfc3RhZmZfY2l0LlJEYXRhIikNCmxvYWQoIi4vZGF0YS9uYW1lc19zdGFmZl9jaXRfdjIwMjIxMDA2LlJEYXRhIikNCg0KbGlicmFyeShSU2llbmEpDQpsaWJyYXJ5KHRpZHl2ZXJzZSkNCmBgYA0KDQpgYGB7cn0NCm5hbWVzX3N0YWZmX2NpdCAlPiUgDQogIGZpbHRlcihnc19pZCAlaW4lIHNvY19kZiRnc19pZCkgLT4gVVVfc3RhZmZfY2l0DQpgYGANCg0KYGBge3J9DQpzYXZlKFVVX3N0YWZmX2NpdCwgZmlsZT0iLi9kYXRhL2Rlc2NyaXB0aXZlcy9VVV9zdGFmZl9jaXQuUkRhdGEiKQ0KYGBgDQoNCg0KDQpgYGB7cn0NCiNkZXBlbmRlbnQNCm5ldCA8LSBzaWVuYURlcGVuZGVudChuZXRfc29jX2FycmF5KQ0KYGBgDQoNCg0KYGBge3J9DQojIyMgU3RlcC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