gofN | R Documentation |
gofN()
performs a simulation to obtain Pearson residuals for the
multivariate linear model for ERGM parameters, which can then be
used for a variety of diagnostics and diagnostic plots developed by
\insertCiteKrCo22t;textualergm.multi.
gofN(
object,
GOF = NULL,
subset = TRUE,
control = control.gofN.ergm(),
save_stats = FALSE,
...
)
## S3 method for class 'gofN'
x[i, j, ..., drop = FALSE]
## S3 method for class 'gofN'
augment(x, ...)
## S3 method for class 'gofN'
summary(object, by = NULL, ...)
object |
an |
GOF |
a one-sided |
subset |
argument for the |
control |
See |
save_stats |
If |
... |
additional arguments to functions ( |
x |
a |
i |
for the indexing operator, index of statistics to be kept in the subset. |
j |
for the indexing operator, index of networks to be kept in the subset. |
drop |
whether the indexing operator should drop attributes and return simply a list. |
by |
a numeric or character vector, or a formula whose RHS gives an expression in terms of network attributes, used as a grouping variable for summarizing the values. |
An object of class gofN
: a named list containing a list
for every statistic in the specified GOF
formula with the
following elements vectors of length equal to the number of
subnetworks:
observed |
For completely observed networks, their value of the statistic. For partially observed networks, the expected value of their imputations under the model. |
fitted |
Expected value of the statistic under the model. |
var |
Variance of the statistic under the model. |
var.obs |
Conditional variance under imputation statistic. |
pearson |
The Pearson residual computed from the above. |
stats , stats.obs |
If |
In addition, the following attr
-style attributes are included:
nw |
The observed multinetwork object. |
subset |
A logical vector giving the subset of networks that were used. |
control |
Control parameters passed. |
[
: Extract a subset of statistics for which goodness-of-fit had been computed.
augment(gofN)
: a method for constructing a tibble
of network attributes augmented with goodness of fit information. Columns include:
the attributes of each of the networks
.stat_name
name of the simulated statistic
.stat_id
index of the simulated statistic in the gofN
object
.network_id
index of the network in the networks for which gofN
was run (excluding those not in the subset)
.fitted
predicted value for the statistic
.observed
either the observed (for completely observed networks) or the predicted conditional on observed (for partially observed networks) value of the statistic
.pearson
the standardised Pearson residual
.var
, .var.obs
estimated unconditional and average conditional variance of the statistic
.weight
inverse of the variance of the residual
summary(gofN)
: A simple summary function.
plot.gofN()
and autoplot.gofN()
for plotting gofN
objects to make residual plots; ergm::gof()
for single-network
goodness-of-fit simulations in ergm
data(samplk)
monks <- Networks(samplk1, samplk2, samplk3,samplk1, samplk2, samplk3,samplk1, samplk2, samplk3)
fit <- ergm(monks~N(~edges+nodematch("group")))
fit.gof <- gofN(fit) # GOF = original model
summary(fit.gof)
plot(fit.gof)
fit.gof <- gofN(fit, GOF=~triangles)
summary(fit.gof)
plot(fit.gof)
samplk1[1,]<-NA
samplk2[,2]<-NA
monks <- Networks(samplk1, samplk2, samplk3,samplk1, samplk2, samplk3,samplk1, samplk2, samplk3)
fit <- ergm(monks~N(~edges+nodematch("group")))
fit.gof <- gofN(fit) # GOF = original model
summary(fit.gof)
plot(fit.gof)
fit.gof <- gofN(fit, GOF=~triangles)
summary(fit.gof)
plot(fit.gof)
plot(fit.gof, against=~log(.fitted)) # Plot against transformed fitted values.
### If 'ggplot2' and 'ggrepel' are installed, illustrate the autoplot() method.
if(require("ggplot2") && requireNamespace("ggrepel")){
autoplot(fit.gof)
}
# Default is good enough in this case, but sometimes, we might want to set it higher. E.g.,
## Not run:
fit.gof <- gofN(fit, GOF=~edges, control=control.gofN.ergm(nsim=400))
## End(Not run)
### If 'generics' is installed, illustrate the augment() method.
if(require("generics")){
augment(fit.gof)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.