LogLikelihood {modnets} | R Documentation |
Log-likelihood functions and Likelihood Ratio Tests for moderated networks
Description
Computes log-likelihood, AIC, and BIC for a whole network, or for each node in the network. Also compares two or more networks using a likelihood ratio test (LRT).
Usage
modLL(
net0,
net1 = NULL,
nodes = FALSE,
lrt = NULL,
all = FALSE,
d = 4,
alpha = 0.05,
orderBy = NULL,
decreasing = TRUE
)
SURll(
net0,
net1 = NULL,
nodes = FALSE,
lrt = NULL,
all = FALSE,
d = 4,
alpha = 0.05,
s = "res",
orderBy = NULL,
decreasing = TRUE,
sysfits = FALSE
)
modTable(
net0,
nodes = FALSE,
orderBy = TRUE,
d = 4,
alpha = 0.05,
decreasing = TRUE,
names = NULL,
rmsea = FALSE
)
SURtable(
net0,
nodes = FALSE,
orderBy = TRUE,
d = 4,
alpha = 0.05,
decreasing = TRUE,
names = NULL,
rmsea = FALSE,
s = "res"
)
Arguments
net0 |
Output from one of the main |
net1 |
For |
nodes |
Logical. Determines whether to compute omnibus or nodewise
statistics and tests. If |
lrt |
Logical. Determines whether to conduct an LRT or not. If
|
all |
Logical. If |
d |
Number of decimal places to round outputted statistics to. |
alpha |
Alpha level for LRTs. Defaults to .05. |
orderBy |
Can be one of |
decreasing |
Logical. Determines whether to organize output from highest
to lowest, or vice versa, in accordance with the value of |
s |
Character string indicating which type of residual covariance matrix
to compute for SUR models. Options include |
sysfits |
Logical, only relevant to |
names |
Character vector containing the names of the models being
compared. Only relevant to the |
rmsea |
Logical. Relevant to |
Details
Fits LRT to a list of network models to compare them all against each other.
Obtain all possible LRTs comparing a list of SUR models. Can include tests
comparing RMSEA values. The nodes
argument determines whether to
perform these computations in an omnibus or nodewise fashion.
One key thing to note is that when using modTable
or
SURtable
, the LRT column indicates the number of times that
each network was selected over others with respect to the pairwise LRTs.
Value
A table or list of results depending on which function is used.
See Also
Examples
data <- na.omit(psychTools::msq[, c('hostile', 'lonely', 'nervous', 'sleepy', 'depressed')])
##### Use modLL() for GGMs
ggm1 <- fitNetwork(data[, -5])
ggm2 <- fitNetwork(data, covariates = 5)
ggm3 <- fitNetwork(data, moderators = 5)
modLL(ggm1)
modLL(ggm2)
modLL(ggm1, ggm2)
modLL(ggm1, ggm2, nodes = TRUE)
modLL(list(ggm1 = ggm1, ggm2 = ggm2))
modLL(list(GGM1 = ggm1, GGM2 = ggm2), nodes = TRUE)
ggms <- list(ggm1, ggm2, ggm3)
modLL(ggms)
modTable(ggms)
modTable(ggms, names = c("GGM1", "GGM2", "GGM3"))
names(ggms) <- c("GGM1", "GGM2", "GGM3")
modTable(ggms)
modLL(ggms)
##### Use SURll() for SUR networks
sur1 <- fitNetwork(data[, -5], lags = TRUE)
sur2 <- fitNetwork(data, covariates = 5, lags = TRUE)
sur3 <- fitNetwork(data, moderators = 5, lags = TRUE)
SURll(sur1)
SURll(sur2)
SURll(sur1, sur2)
SURll(sur1, sur2, nodes = TRUE)
SURll(list(SUR1 = sur1, SUR2 = sur2), nodes = TRUE)
surs <- list(sur1, sur2, sur3)
SURll(surs)
SURtable(surs, names = c('SUR1', "SUR2", "SUR3"))
names(surs) <- c("SUR1", "SUR2", "SUR3")
SURll(surs)
SURtable(surs)