This is an example of a basic sequence of commands for estimating a basic model by function siena07()
of {RSiena}
. With a lot of use of help pages; this can be skipped as you like. Note that lines starting with # are comment lines, not commands. Sometimes in the following, some R commands are given preceded by #; this is to illustrate what could be done without executing it now.
What is your current working directory?
#getwd()
If you wish it to be different, change it by
# setwd()
If you have internet access, you can download the data from the Siena website (“Data sets” tab) http://www.stats.ox.ac.uk/~snijders/siena/s50_data.zip and unzip it in your working directory. The data description is at http://www.stats.ox.ac.uk/~snijders/siena/s50_data.htm
Then you can read the data files by the commands (this can be replaced by using the internal data set, see below)
# friend.data.w1 <- as.matrix(read.table("s50-network1.dat"))
# friend.data.w2 <- as.matrix(read.table("s50-network2.dat"))
# friend.data.w3 <- as.matrix(read.table("s50-network3.dat"))
# drink <- as.matrix(read.table("s50-alcohol.dat"))
# smoke <- as.matrix(read.table("s50-smoke.dat"))
But without internet access, the data can be obtained from within RSiena (see below), because this is an internal data set.
library(RSiena)
With
?RSiena#> starting httpd help server ... done
you get to see the basic operation.
Now we use the internally available s50 data set.
Look at its description:
?s50
3 waves, 50 actors
Look at the start and end of the first wave matrix:
head(s501)
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
#> 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0
#> 2 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
#> 3 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
#> 4 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
#> 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 6 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
#> V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37 V38 V39 V40
#> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 5 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
#> 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> V41 V42 V43 V44 V45 V46 V47 V48 V49 V50
#> 1 0 0 0 0 0 0 0 0 0 0
#> 2 0 0 0 0 0 0 0 0 0 0
#> 3 0 0 0 0 0 0 0 0 0 0
#> 4 0 0 0 0 0 0 0 0 0 0
#> 5 0 0 0 0 0 0 0 0 0 0
#> 6 0 0 0 0 0 0 0 0 0 0
tail(s501)
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
#> 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37 V38 V39 V40
#> 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> V41 V42 V43 V44 V45 V46 V47 V48 V49 V50
#> 45 0 0 0 0 0 1 1 0 0 0
#> 46 0 0 0 0 1 0 0 0 1 0
#> 47 0 0 0 0 0 0 0 0 0 0
#> 48 0 0 0 0 0 1 0 0 1 0
#> 49 0 0 0 0 0 1 0 1 0 0
#> 50 0 0 0 0 0 0 0 0 0 0
and at the alcohol variable
s50a#> V1 V2 V3
#> 1 3 1 3
#> 2 2 2 2
#> 3 2 3 3
#> 4 2 3 2
#> 5 3 3 4
#> 6 4 4 4
#> 7 4 4 3
#> 8 4 5 4
#> 9 2 2 2
#> 10 4 5 4
#> 11 5 5 5
#> 12 5 5 5
#> 13 3 2 2
#> 14 3 4 3
#> 15 4 4 5
#> 16 4 5 4
#> 17 2 4 4
#> 18 4 3 3
#> 19 3 5 5
#> 20 2 3 3
#> 21 1 1 3
#> 22 3 2 3
#> 23 4 4 2
#> 24 3 3 3
#> 25 3 4 4
#> 26 4 4 3
#> 27 2 2 3
#> 28 2 2 4
#> 29 3 3 3
#> 30 1 3 4
#> 31 4 4 4
#> 32 4 2 4
#> 33 3 4 3
#> 34 2 2 2
#> 35 3 3 4
#> 36 4 4 4
#> 37 2 2 3
#> 38 3 3 4
#> 39 2 2 3
#> 40 1 1 1
#> 41 4 3 4
#> 42 4 5 5
#> 43 2 2 4
#> 44 5 5 5
#> 45 2 2 2
#> 46 2 2 2
#> 47 2 2 2
#> 48 2 3 4
#> 49 1 2 3
#> 50 1 2 3
Now define the objects with the same names as above (this step is superfluous if you read the data already).
s501
friend.data.w1 <- s502
friend.data.w2 <- s503
friend.data.w3 <- s50a
drink <- s50s smoke <-
Now the data must be given the specific roles of variables in an RSiena analysis.
Look at the help page:
?sienaDependent
First create a 50 * 50 * 3 array composed of the 3 adjacency matrices
array( c( friend.data.w1, friend.data.w2, friend.data.w3 ),
friendshipData <-dim = c( 50, 50, 3 ) )
and next give this the role of the dependent variable:
sienaDependent(friendshipData) friendship <-
What did we construct?
friendship#> Type oneMode
#> Observations 3
#> Nodeset Actors (50 elements)
We also must prepare the objects that will be the explanatory variables.
We use smoking for wave 1 as a constant actor covariate:
coCovar( smoke[ , 1 ] ) smoke1 <-
A variable actor covariate is defined for drinking:
varCovar( drink ) alcohol <-
(That for smoke we only use the first wave is purely for the purpose of illustrating constant actor covariates.)
Put the variables together in the data set for analysis
?sienaDataCreate sienaDataCreate( friendship, smoke1, alcohol ) mydata <-
and check what we have
mydata#> Dependent variables: friendship
#> Number of observations: 3
#>
#> Nodeset Actors
#> Number of nodes 50
#>
#> Dependent variable friendship
#> Type oneMode
#> Observations 3
#> Nodeset Actors
#> Densities 0.046 0.047 0.05
#>
#> Constant covariates: smoke1
#> Changing covariates: alcohol
You can get an outline of the data set with some basic descriptives from
print01Report( mydata, modelname="s50")
This creates an output file s50.txt in your current working directory. Note that if an existing file has this name, it will be overwritten!
For the model specification we need to create the so-called effects object:
getEffects( mydata ) myeff <-
This contains all the effects that are available given the structure of this data set. They can be seen from
effectsDocumentation(myeff)
For a precise description of all effects, see Chapter 12 in the RSiena manual. A basic specification of the structural effects is as follows:
?includeEffects includeEffects( myeff, transTrip, cycle3)
myeff <-#> effectName include fix test initialValue parm
#> 1 transitive triplets TRUE FALSE FALSE 0 0
#> 2 3-cycles TRUE FALSE FALSE 0 0
and this is put together with some covariate effects:
includeEffects( myeff, egoX, altX, simX, interaction1 = "alcohol" )
myeff <-#> effectName include fix test initialValue parm
#> 1 alcohol alter TRUE FALSE FALSE 0 0
#> 2 alcohol ego TRUE FALSE FALSE 0 0
#> 3 alcohol similarity TRUE FALSE FALSE 0 0
includeEffects( myeff, simX, interaction1 = "smoke1" )
myeff <-#> effectName include fix test initialValue parm
#> 1 smoke1 similarity TRUE FALSE FALSE 0 0
myeff#> effectName include fix test initialValue parm
#> 1 constant friendship rate (period 1) TRUE FALSE FALSE 4.69604 0
#> 2 constant friendship rate (period 2) TRUE FALSE FALSE 4.32885 0
#> 3 outdegree (density) TRUE FALSE FALSE -1.46770 0
#> 4 reciprocity TRUE FALSE FALSE 0.00000 0
#> 5 transitive triplets TRUE FALSE FALSE 0.00000 0
#> 6 3-cycles TRUE FALSE FALSE 0.00000 0
#> 7 smoke1 similarity TRUE FALSE FALSE 0.00000 0
#> 8 alcohol alter TRUE FALSE FALSE 0.00000 0
#> 9 alcohol ego TRUE FALSE FALSE 0.00000 0
#> 10 alcohol similarity TRUE FALSE FALSE 0.00000 0
Now create an object with algorithm settings. There are a lot of options for the algorithm. The most important ones are explained in Sections 6.3.3 and 6.4 of the Siena manual. Often you can just accept the default choices, but it is good to specify the name for the output file (which you may replace by any name you prefer)
?sienaAlgorithmCreate sienaAlgorithmCreate( projname = 's50' )
myalgorithm <-#> If you use this algorithm object, siena07 will create/use an output file s50.txt .
The file s50.txt already exists (created by print01Report); the following estimations will append new results to this file.
The function siena07 is the workhorse of the package; it carries out the estimation.
?siena07 siena07( myalgorithm, data = mydata, effects = myeff)
ans <-
ans#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#>
#> Rate parameters:
#> 0.1 Rate parameter period 1 6.6302 ( 1.1174 )
#> 0.2 Rate parameter period 2 5.2624 ( 0.8712 )
#>
#> Other parameters:
#> 1. eval outdegree (density) -2.7399 ( 0.1147 ) 0.0122
#> 2. eval reciprocity 2.4467 ( 0.2166 ) 0.0435
#> 3. eval transitive triplets 0.6696 ( 0.1435 ) 0.0621
#> 4. eval 3-cycles -0.0934 ( 0.3026 ) 0.0644
#> 5. eval smoke1 similarity 0.2059 ( 0.2085 ) 0.0120
#> 6. eval alcohol alter -0.0165 ( 0.0706 ) 0.0376
#> 7. eval alcohol ego 0.0569 ( 0.0815 ) 0.0401
#> 8. eval alcohol similarity 0.7319 ( 0.3127 ) 0.0017
#>
#> Overall maximum convergence ratio: 0.1198
#>
#>
#> Total of 2253 iteration steps.
This gives results from a random starting point, and these will allways be different - hopefully, in unimportant ways. To use a fixed starting point, so that you will always get the same results (if also the same vector of initial parameters was used), use the “seed” parameter:
# myalgorithm <- sienaAlgorithmCreate( projname = 's50', seed=435123 )
For checking convergence, look at the ‘Overall maximum convergence ratio’ mentioned above, under the parameter estimates.
This can also be shown by requesting
$tconv.max
ans#> [,1]
#> [1,] 0.1197705
If this is less than 0.25, convergence is good. If convergence is inadequate, estimate once more, using the result obtained as the “previous answer” from which estimation continues:
siena07( myalgorithm, data = mydata, effects = myeff, prevAns=ans)
ans <-
ans#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#>
#> Rate parameters:
#> 0.1 Rate parameter period 1 6.6425 ( 1.1965 )
#> 0.2 Rate parameter period 2 5.2239 ( 0.8895 )
#>
#> Other parameters:
#> 1. eval outdegree (density) -2.7440 ( 0.1300 ) -0.0170
#> 2. eval reciprocity 2.4528 ( 0.2176 ) 0.0122
#> 3. eval transitive triplets 0.6729 ( 0.1490 ) 0.0087
#> 4. eval 3-cycles -0.1071 ( 0.3014 ) 0.0050
#> 5. eval smoke1 similarity 0.2111 ( 0.2162 ) 0.0384
#> 6. eval alcohol alter -0.0154 ( 0.0712 ) 0.0228
#> 7. eval alcohol ego 0.0577 ( 0.0730 ) 0.0135
#> 8. eval alcohol similarity 0.7417 ( 0.3071 ) 0.0165
#>
#> Overall maximum convergence ratio: 0.1172
#>
#>
#> Total of 2753 iteration steps.
If convergence is good, you can look at the estimates. More extensive results are given by requesting
summary(ans)
#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#>
#> Rate parameters:
#> 0.1 Rate parameter period 1 6.6425 ( 1.1965 )
#> 0.2 Rate parameter period 2 5.2239 ( 0.8895 )
#>
#> Other parameters:
#> 1. eval outdegree (density) -2.7440 ( 0.1300 ) -0.0170
#> 2. eval reciprocity 2.4528 ( 0.2176 ) 0.0122
#> 3. eval transitive triplets 0.6729 ( 0.1490 ) 0.0087
#> 4. eval 3-cycles -0.1071 ( 0.3014 ) 0.0050
#> 5. eval smoke1 similarity 0.2111 ( 0.2162 ) 0.0384
#> 6. eval alcohol alter -0.0154 ( 0.0712 ) 0.0228
#> 7. eval alcohol ego 0.0577 ( 0.0730 ) 0.0135
#> 8. eval alcohol similarity 0.7417 ( 0.3071 ) 0.0165
#>
#> Overall maximum convergence ratio: 0.1172
#>
#>
#> Total of 2753 iteration steps.
#>
#> Covariance matrix of estimates (correlations below diagonal)
#>
#> 0.017 -0.017 -0.007 0.005 -0.004 0.000 0.000 -0.007
#> -0.596 0.047 0.010 -0.026 0.001 0.000 0.000 -0.003
#> -0.350 0.316 0.022 -0.039 0.001 0.000 -0.002 -0.006
#> 0.120 -0.404 -0.860 0.091 -0.003 0.000 0.003 0.016
#> -0.139 0.025 0.040 -0.043 0.047 0.005 0.004 -0.011
#> 0.015 -0.011 -0.044 0.010 0.308 0.005 -0.001 -0.002
#> -0.019 -0.011 -0.157 0.125 0.233 -0.266 0.005 0.001
#> -0.175 -0.040 -0.125 0.170 -0.173 -0.100 0.065 0.094
#>
#> Derivative matrix of expected statistics X by parameters:
#>
#> 288.912 230.041 528.396 166.823 27.452 26.147 32.254 22.560
#> 131.229 143.010 273.598 90.711 13.670 9.406 8.699 10.243
#> 354.663 317.745 1176.871 373.509 29.823 77.379 82.513 24.132
#> 175.640 166.907 573.574 191.248 16.956 28.662 27.379 10.227
#> 26.342 21.868 55.773 17.610 36.468 -48.218 -41.793 5.754
#> 30.059 36.181 90.741 30.109 -45.244 319.418 193.327 1.895
#> 29.665 27.134 99.037 30.856 -41.676 214.387 301.458 -0.333
#> 22.529 19.025 33.659 10.023 6.084 1.723 0.702 14.610
#>
#> Covariance matrix of X (correlations below diagonal):
#>
#> 491.206 428.420 1206.029 387.762 48.218 87.133 88.634 38.501
#> 0.927 434.918 1165.943 381.192 45.322 85.914 78.304 35.662
#> 0.821 0.843 4395.111 1422.658 138.251 259.720 261.583 84.531
#> 0.810 0.846 0.993 466.751 44.329 85.785 83.985 26.691
#> 0.319 0.318 0.306 0.301 46.581 -64.280 -56.867 8.668
#> 0.186 0.195 0.185 0.188 -0.446 446.660 352.703 5.724
#> 0.198 0.186 0.195 0.193 -0.413 0.827 407.473 6.536
#> 0.414 0.407 0.304 0.294 0.303 0.065 0.077 17.610
Still more extensive results are given in the output file s50.txt in the current directory.
Note that by putting an R command between parentheses (….), the result will also be printed to the screen. Next add the transitive reciprocated triplets effect, an interaction between transitive triplets and reciprocity, and estimate again, going on from the previous answer (that is what `prevAns’ means)
includeEffects( myeff, transRecTrip))
(myeff <-#> effectName include fix test initialValue parm
#> 1 transitive recipr. triplets TRUE FALSE FALSE 0 0
#> effectName include fix test initialValue parm
#> 1 constant friendship rate (period 1) TRUE FALSE FALSE 4.69604 0
#> 2 constant friendship rate (period 2) TRUE FALSE FALSE 4.32885 0
#> 3 outdegree (density) TRUE FALSE FALSE -1.46770 0
#> 4 reciprocity TRUE FALSE FALSE 0.00000 0
#> 5 transitive triplets TRUE FALSE FALSE 0.00000 0
#> 6 transitive recipr. triplets TRUE FALSE FALSE 0.00000 0
#> 7 3-cycles TRUE FALSE FALSE 0.00000 0
#> 8 smoke1 similarity TRUE FALSE FALSE 0.00000 0
#> 9 alcohol alter TRUE FALSE FALSE 0.00000 0
#> 10 alcohol ego TRUE FALSE FALSE 0.00000 0
#> 11 alcohol similarity TRUE FALSE FALSE 0.00000 0
siena07( myalgorithm, data = mydata, effects = myeff, prevAns=ans))
(ans1 <-#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#>
#> Rate parameters:
#> 0.1 Rate parameter period 1 6.1978 ( 1.0091 )
#> 0.2 Rate parameter period 2 5.0170 ( 0.8282 )
#>
#> Other parameters:
#> 1. eval outdegree (density) -2.9397 ( 0.1498 ) 0.0877
#> 2. eval reciprocity 2.9160 ( 0.2744 ) 0.0949
#> 3. eval transitive triplets 0.8695 ( 0.1448 ) -0.0134
#> 4. eval transitive recipr. triplets -0.9586 ( 0.2349 ) -0.0034
#> 5. eval 3-cycles 0.6490 ( 0.2779 ) 0.0430
#> 6. eval smoke1 similarity 0.1627 ( 0.2163 ) 0.0268
#> 7. eval alcohol alter -0.0245 ( 0.0741 ) 0.0236
#> 8. eval alcohol ego 0.0462 ( 0.0775 ) 0.0027
#> 9. eval alcohol similarity 0.7208 ( 0.2990 ) -0.0440
#>
#> Overall maximum convergence ratio: 0.5322
#>
#>
#> Total of 2679 iteration steps.
If necessary, repeat the estimation, starting from the new result:
siena07( myalgorithm, data = mydata, effects = myeff, prevAns=ans1))
(ans1 <-#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#>
#> Rate parameters:
#> 0.1 Rate parameter period 1 6.2646 ( 1.0403 )
#> 0.2 Rate parameter period 2 5.0471 ( 0.8122 )
#>
#> Other parameters:
#> 1. eval outdegree (density) -2.9369 ( 0.1585 ) 0.0029
#> 2. eval reciprocity 2.8940 ( 0.2794 ) 0.0184
#> 3. eval transitive triplets 0.8840 ( 0.1644 ) -0.0212
#> 4. eval transitive recipr. triplets -0.9122 ( 0.2789 ) -0.0017
#> 5. eval 3-cycles 0.5652 ( 0.2826 ) 0.0072
#> 6. eval smoke1 similarity 0.1652 ( 0.2138 ) 0.0046
#> 7. eval alcohol alter -0.0270 ( 0.0730 ) 0.0128
#> 8. eval alcohol ego 0.0487 ( 0.0760 ) 0.0464
#> 9. eval alcohol similarity 0.7191 ( 0.3046 ) -0.0178
#>
#> Overall maximum convergence ratio: 0.2556
#>
#>
#> Total of 2677 iteration steps.
This might still not have an overall maximum convergence ratio less than 0.25. If not, you could go on once more.
Inspect the file s50.txt in your working directory and understand the meaning of its contents.
Parameters can be tested by dividing the estimate by its standard error, and referring this to a standard normal distribution (with the usual critical value of 1.96, rounded to 2.0).
This can be done also in the following way, e.g., for homophily with respect to alcohol consumption:
?Multipar.RSienaMultipar.RSiena(ans1, 9)
#> Tested effects:
#> friendship: alcohol similarity
#> chi-squared = 5.57, d.f. = 1; one-sided Z = 2.36; two-sided p = 0.018.
Multi-parameter test are also possible. To have a joint test of the three effects of alcohol:
?Multipar.RSienaMultipar.RSiena(ans1, 7:9)
#> Tested effects:
#> friendship: alcohol alter
#> friendship: alcohol ego
#> friendship: alcohol similarity
#> chi-squared = 6.13, d.f. = 3; p = 0.105.
Focusing on alcohol similarity, the effect is significant; diluting the effects of alcohol by also considering ego and alter, the three effects simultaneously are not significant.
Drop the effect of smoke1 similarity and estimate the model again. Do this by the function setEffects() using the <
Change the three effects of alcohol to the single effect of alcohol similarity, and estimate again.
Now we redefine the role of alcohol drinking as a dependent behaviour variable.
Once again, look at the help file
?sienaDependent
now paying special attention to the ‘type’ parameter.
sienaDependent( drink, type = "behavior" ) drinking <-
Put the variables together in the data set for analysis:
sienaDataCreate( friendship, smoke1, drinking )
NBdata <-
NBdata#> Dependent variables: friendship, drinking
#> Number of observations: 3
#>
#> Nodeset Actors
#> Number of nodes 50
#>
#> Dependent variable friendship
#> Type oneMode
#> Observations 3
#> Nodeset Actors
#> Densities 0.046 0.047 0.05
#>
#> Dependent variable drinking
#> Type behavior
#> Observations 3
#> Nodeset Actors
#> Range 1 - 5
#>
#> Constant covariates: smoke1
Define the effects object for this data set, and give the model specification:
getEffects( NBdata )
NBeff <-effectsDocumentation(NBeff)
includeEffects( NBeff, transTrip, transRecTrip )
NBeff <-#> effectName include fix test initialValue parm
#> 1 transitive triplets TRUE FALSE FALSE 0 0
#> 2 transitive recipr. triplets TRUE FALSE FALSE 0 0
includeEffects( NBeff, egoX, egoSqX, altX, altSqX, diffSqX,
NBeff <-interaction1 = "drinking" )
#> effectName include fix test initialValue parm
#> 1 drinking alter TRUE FALSE FALSE 0 0
#> 2 drinking squared alter TRUE FALSE FALSE 0 0
#> 3 drinking ego TRUE FALSE FALSE 0 0
#> 4 drinking squared ego TRUE FALSE FALSE 0 0
#> 5 drinking diff. squared TRUE FALSE FALSE 0 0
includeEffects( NBeff, egoX, altX, simX, interaction1 = "smoke1" )
NBeff <-#> effectName include fix test initialValue parm
#> 1 smoke1 alter TRUE FALSE FALSE 0 0
#> 2 smoke1 ego TRUE FALSE FALSE 0 0
#> 3 smoke1 similarity TRUE FALSE FALSE 0 0
NBeff#> name effectName include fix test
#> 1 friendship constant friendship rate (period 1) TRUE FALSE FALSE
#> 2 friendship constant friendship rate (period 2) TRUE FALSE FALSE
#> 3 friendship outdegree (density) TRUE FALSE FALSE
#> 4 friendship reciprocity TRUE FALSE FALSE
#> 5 friendship transitive triplets TRUE FALSE FALSE
#> 6 friendship transitive recipr. triplets TRUE FALSE FALSE
#> 7 friendship smoke1 alter TRUE FALSE FALSE
#> 8 friendship smoke1 ego TRUE FALSE FALSE
#> 9 friendship smoke1 similarity TRUE FALSE FALSE
#> 10 friendship drinking alter TRUE FALSE FALSE
#> 11 friendship drinking squared alter TRUE FALSE FALSE
#> 12 friendship drinking ego TRUE FALSE FALSE
#> 13 friendship drinking squared ego TRUE FALSE FALSE
#> 14 friendship drinking diff. squared TRUE FALSE FALSE
#> 15 drinking rate drinking (period 1) TRUE FALSE FALSE
#> 16 drinking rate drinking (period 2) TRUE FALSE FALSE
#> 17 drinking drinking linear shape TRUE FALSE FALSE
#> 18 drinking drinking quadratic shape TRUE FALSE FALSE
#> initialValue parm
#> 1 4.69604 0
#> 2 4.32885 0
#> 3 -1.46770 0
#> 4 0.00000 0
#> 5 0.00000 0
#> 6 0.00000 0
#> 7 0.00000 0
#> 8 0.00000 0
#> 9 0.00000 0
#> 10 0.00000 0
#> 11 0.00000 0
#> 12 0.00000 0
#> 13 0.00000 0
#> 14 0.00000 0
#> 15 0.70571 0
#> 16 0.84939 0
#> 17 0.32237 0
#> 18 0.00000 0
For including effects also for the dependent behaviour variable, see:
?includeEffects
We now have to mention the name of the dependent behavior variable; it did not need to be mentioned before, because the default name is the first in the data set, which is friendship.
includeEffects( NBeff, avAlt, name="drinking",
NBeff <-interaction1 = "friendship" )
#> effectName include fix test initialValue parm
#> 1 drinking average alter TRUE FALSE FALSE 0 0
NBeff#> name effectName include fix test
#> 1 friendship constant friendship rate (period 1) TRUE FALSE FALSE
#> 2 friendship constant friendship rate (period 2) TRUE FALSE FALSE
#> 3 friendship outdegree (density) TRUE FALSE FALSE
#> 4 friendship reciprocity TRUE FALSE FALSE
#> 5 friendship transitive triplets TRUE FALSE FALSE
#> 6 friendship transitive recipr. triplets TRUE FALSE FALSE
#> 7 friendship smoke1 alter TRUE FALSE FALSE
#> 8 friendship smoke1 ego TRUE FALSE FALSE
#> 9 friendship smoke1 similarity TRUE FALSE FALSE
#> 10 friendship drinking alter TRUE FALSE FALSE
#> 11 friendship drinking squared alter TRUE FALSE FALSE
#> 12 friendship drinking ego TRUE FALSE FALSE
#> 13 friendship drinking squared ego TRUE FALSE FALSE
#> 14 friendship drinking diff. squared TRUE FALSE FALSE
#> 15 drinking rate drinking (period 1) TRUE FALSE FALSE
#> 16 drinking rate drinking (period 2) TRUE FALSE FALSE
#> 17 drinking drinking linear shape TRUE FALSE FALSE
#> 18 drinking drinking quadratic shape TRUE FALSE FALSE
#> 19 drinking drinking average alter TRUE FALSE FALSE
#> initialValue parm
#> 1 4.69604 0
#> 2 4.32885 0
#> 3 -1.46770 0
#> 4 0.00000 0
#> 5 0.00000 0
#> 6 0.00000 0
#> 7 0.00000 0
#> 8 0.00000 0
#> 9 0.00000 0
#> 10 0.00000 0
#> 11 0.00000 0
#> 12 0.00000 0
#> 13 0.00000 0
#> 14 0.00000 0
#> 15 0.70571 0
#> 16 0.84939 0
#> 17 0.32237 0
#> 18 0.00000 0
#> 19 0.00000 0
Define an algorithm with a new project name
sienaAlgorithmCreate( projname = 's50_NB' )
myalgorithm1 <-#> If you use this algorithm object, siena07 will create/use an output file s50_NB.txt .
Estimate again, using the second algorithm right from the start:
siena07( myalgorithm1, data = NBdata, effects = NBeff) NBans <-
You may improve convergence (considering the overall maximum convergence ratio) by repeated estimation in the same way as above.
Look at results:
NBans#> Estimates, standard errors and convergence t-ratios
#>
#> Estimate Standard Convergence
#> Error t-ratio
#> Network Dynamics
#> 1. rate constant friendship rate (period 1) 6.3401 ( 1.0099 ) 0.0641
#> 2. rate constant friendship rate (period 2) 5.0294 ( 0.8884 ) -0.0077
#> 3. eval outdegree (density) -2.8204 ( 0.2695 ) 0.0442
#> 4. eval reciprocity 2.8257 ( 0.3282 ) 0.0488
#> 5. eval transitive triplets 0.8942 ( 0.1456 ) 0.0622
#> 6. eval transitive recipr. triplets -0.5091 ( 0.2244 ) 0.0671
#> 7. eval smoke1 alter 0.0692 ( 0.1595 ) -0.0742
#> 8. eval smoke1 ego -0.0082 ( 0.1804 ) -0.0169
#> 9. eval smoke1 similarity 0.2462 ( 0.2582 ) 0.0711
#> 10. eval drinking alter -0.0611 ( 0.1381 ) -0.0297
#> 11. eval drinking squared alter -0.1128 ( 0.1404 ) 0.0161
#> 12. eval drinking ego 0.0381 ( 0.1236 ) -0.0537
#> 13. eval drinking squared ego 0.2246 ( 0.1421 ) 0.0301
#> 14. eval drinking diff. squared -0.1044 ( 0.0625 ) 0.0298
#>
#> Behavior Dynamics
#> 15. rate rate drinking (period 1) 1.3139 ( 0.3292 ) -0.0354
#> 16. rate rate drinking (period 2) 1.8187 ( 0.4616 ) 0.0084
#> 17. eval drinking linear shape 0.4041 ( 0.2232 ) -0.0426
#> 18. eval drinking quadratic shape -0.5635 ( 0.3041 ) -0.0452
#> 19. eval drinking average alter 1.2385 ( 0.7757 ) -0.0487
#>
#> Overall maximum convergence ratio: 0.1693
#>
#>
#> Total of 3827 iteration steps.
Make a nicer listing of the results:
siena.table(NBans, type="html", sig=TRUE)
This produces an html file in your working directory; siena.table can also produce a LaTeX file.
Replace the average alter effect by average similarity (avSim) or total similarity (totSim) and estimate the model again.
Add the effect of smoking on drinking and estimate again.
Read Sections 13.3 and 13.4 of the Siena Manual, download scripts SelectionTables.R
and InfluenceTables.R
from the Siena website, and make plots of the selection table and influence table for drinking.