S Weave Example
S Weave Example
This section demonstrate how it works for rare-event logit models estimated by the function from the Zellig package. First we generate some fake data and dichotomize one of the variables: > > > > covvar <- matrix(c(1, 0.6, 0.6, 0.6, 1, 0.6, 0.6, 0.6, 1), nr = 3) means <- c(20, 25, 30) data <- as.data.frame(mvrnorm(100, means, covvar)) data$V1 <- ifelse(data$V1 > 20, 1, 0)
This data is not rare-event data, but is simply used to show how the script will generate a nice latex table from a zelig regression object. Next we run the rare-event logit model: > model <- zelig(V1 ~ V2 + V3, data = data, model = "relogit")
A Then the relogitTable function is used to create a L TEXtable from the above object:
> relogitTable(model)
\begin{tabular}{lD{.}{.}{3}} \toprule & \multicolumn{ 1 }{ c }{ Model 1 } \\ \midrule (Intercept) & -51.068 ^* \\ & ( 11.763 ) \\ V2 & 0.957 ^* \\ & ( 0.425 ) \\ V3 & 0.910 ^* \\ & ( 0.339 ) \\ \midrule $N$ & \multicolumn{1}{c}{100 }\\ $AIC$ & \multicolumn{1}{c}{103.815} \bottomrule \end{tabular} Which produces the following table: Model 1 (Intercept) V2 V3 N AIC 51.068 (11.763) 0.957 (0.425) 0.910 (0.339) 100 103.815
This section demonstrate how to use the the ergmTable function with ergm objects from the statnet package. First we generate a random network with twenty nodes: > net <- rgraph(20) Then we estimate a simple exponential random graph model with terms for edges, out- and in-stars and triangles: > erg <- ergm(net ~ edges + istar(1:2) + ostar(1:2) + triangle, + eval.loglik = TRUE) The ergmTable function generates the following output from the above object: > ergmTable(erg)
\begin{tabular}{lD{.}{.}{2}} \toprule & \multicolumn{ 1 }{ c }{ Model 1 } \\ \midrule edges & 1.52 \\ & ( 2.22 )\\ istar1 & -0.21 \\ & ( 1.24 )\\ istar2 & -0.09 \\ & ( 0.10 )\\ ostar1 & -0.14 \\ & ( 1.24 )\\ ostar2 & -0.21 \\ & ( 0.13 )\\ triangle & 0.09 \\ & ( 0.05 ) \\ \midrule $AIC$ & \multicolumn{1}{c}{534.05}\\ $BIC$ & \multicolumn{1}{c}{557.69} \bottomrule \end{tabular} Which produces the following table: Model 1 edges istar1 istar2 ostar1 ostar2 triangle AIC BIC 1.52 (2.22) 0.21 (1.24) 0.09 (0.10) 0.14 (1.24) 0.21 (0.13) 0.09 (0.05) 534.05 557.69
2.1
Multiple Models
Both functions also work with multiple models, here it will be demonstrated for exponential random graph models. First we estimate three models, that increase in complexity: > erg1 <- ergm(net ~ edges, eval.loglik = TRUE) > erg2 <- ergm(net ~ edges + istar(1:2) + ostar(1:2), eval.loglik = TRUE)
> erg3 <- ergm(net ~ edges + istar(1:2) + ostar(1:2) + triangle, + eval.loglik = TRUE) The ergmTable function produces the following output: > ergmTable(erg1, erg2, erg3)
\begin{tabular}{lD{.}{.}{2}@{\hspace{2em}}D{.}{.}{2}@{\hspace{2em}}D{.}{.}{2}} \toprule & \multicolumn{ 1 }{ c }{ Model 1 } & \multicolumn{ 1 }{ c }{ Model 2 } & \multicolumn{ 1 edges & 0.04 & 1.42 ^* & 1.83 ^* \\ & ( 0.10 ) & ( 0.34 ) & ( 0.38 )\\ istar1 & & -1.76 ^* & -0.96 ^*\\ & & ( 0.34 ) & ( 0.38 )\\ istar2 & & 0.02 & -0.06 \\ & & ( 0.06 ) & ( 0.08 )\\ ostar1 & & 1.06 ^* & 0.28 \\ & & ( 0.34 ) & ( 0.38 )\\ ostar2 & & -0.09 & -0.25 \\ & & ( 0.09 ) & ( 0.14 )\\ triangle & & & 0.09 \\ & & & ( 0.05 ) \\ \midrule $AIC$ & \multicolumn{1}{c}{528.62} & \multicolumn{1}{c}{534.59} & \multicolumn{1}{c}{534.40 $BIC$ & \multicolumn{1}{c}{532.56} & \multicolumn{1}{c}{554.29} & \multicolumn{1}{c}{558.04} \end{tabular} Which produces the following table: Model 1 edges istar1 istar2 ostar1 ostar2 triangle AIC BIC 528.62 532.56 534.59 554.29 0.04 (0.10) Model 2 1.42 (0.34) 1.76 (0.34) 0.02 (0.06) 1.06 (0.34) 0.09 (0.09) Model 3 1.83 (0.38) 0.96 (0.38) 0.06 (0.08) 0.28 (0.38) 0.25 (0.14) 0.09 (0.05) 534.40 558.04