# \dontshow{
require(ergm)
set.seed(21093)
a1<-network::as.network(matrix(c(rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3),
rbinom(10, 1,.3)),
nrow=10,ncol=10))
network::set.vertex.attribute(a1,"var.1",rbinom(10,1,.3))
a<-ergm(a1~edges+nodeifactor("var.1")+nodeofactor("var.1"))
vif.ergm(a)
# }
set.seed(21093)
library(ergm)
data("faux.mesa.high")
my.ergm2<-ergm(faux.mesa.high~edges+
nodecov("Grade")+
nodefactor("Race")+
nodefactor("Sex")+
nodematch("Grade")+
nodematch("Sex")+
nodematch("Race"))
vif.ergm(my.ergm2)
#to compute the tolerance instead of the VIF
tol<-1/(vif.ergm(my.ergm2))
#to compute R squared
r.sq<-1-tol
Run the code above in your browser using DataLab