Package 'GGMnonreg'

Title: Non-Regularized Gaussian Graphical Models
Description: Estimate non-regularized Gaussian graphical models, Ising models, and mixed graphical models. The current methods consist of multiple regression, a non-parametric bootstrap <doi:10.1080/00273171.2019.1575716>, and Fisher z transformed partial correlations <doi:10.1111/bmsp.12173>. Parameter uncertainty, predictability, and network replicability <doi:10.31234/osf.io/fb4sa> are also implemented.
Authors: Donald Williams [aut, cre]
Maintainer: Donald Williams <[email protected]>
License: GPL-2
Version: 1.1.0
Built: 2024-11-11 03:44:59 UTC
Source: https://github.com/donaldrwilliams/ggmnonreg

Help Index


GGMnonreg: Non-Regularized Gaussian Graphical Models

Description

The goal of GGMnonreg is to estimate non-regularized graphical models. Note that the title is a bit of a misnomer, in that Ising and mixed graphical models are also supported. Graphical modeling is quite common in fields with wide data, that is, when there are more variables than observations. Accordingly, many regularization-based approaches have been developed for those kinds of data. There are key drawbacks of regularization when the goal is inference, including, but not limited to, the fact that obtaining a valid measure of parameter uncertainty is very (very) difficult.

More recently, graphical modeling has emerged in psychology, where the data are typically long or low-dimensional (Williams and Rast 2019; Williams et al. 2019). The primary purpose of GGMnonreg is to provide methods specifically for low-dimensional data

Supported Models

  • Gaussian graphical model. The following data types are supported.

    • Gaussian

    • Ordinal

    • Binary

  • Ising model

  • Mixed graphical model

Additional Methods

  • Expected network replicability (Williams 2020)

  • Compare Gaussian graphical models

  • Measure of uncertainty (Williams 2021)

  • Edge inclusion "probabilities"

  • Network visualization

  • Constrained precision matrix (the network, given an assumed graph)

  • Predictability (variance explained)

References

Williams DR (2020). “Learning to live with sampling variability: Expected replicability in partial correlation networks.” PsyArXiv. doi:10.31234/osf.io/fb4sa.

Williams DR (2021). “The Confidence Interval that Wasn’t: Bootstrapped “Confidence Intervals” in L1-Regularized Partial Correlation Networks.” PsyArXiv. doi:10.31234/osf.io/kjh2f, psyarxiv.com/kjh2f.

Williams DR, Rast P (2019). “Back to the basics: Rethinking partial correlation network methodology.” British Journal of Mathematical and Statistical Psychology. ISSN 0007-1102, doi:10.1111/bmsp.12173.

Williams DR, Rhemtulla M, Wysocki AC, Rast P (2019). “On nonregularized estimation of psychological networks.” Multivariate behavioral research, 54(5), 719–750. doi:10.1080/00273171.2019.1575716.


Data: Autism and Obssesive Compulsive Disorder

Description

A correlation matrix with 17 variables in total (autsim: 9; OCD: 8). The sample size was 213.

Usage

data("asd_ocd")

Format

A correlation matrix including 17 variables. These data were measured on a 4 level likert scale.

Details

Autism:

  • CI Circumscribed interests

  • UP Unusual preoccupations

  • RO Repetitive use of objects or interests in parts of objects

  • CR Compulsions and/or rituals

  • CI Unusual sensory interests

  • SM Complex mannerisms or stereotyped body movements

  • SU Stereotyped utterances/delayed echolalia

  • NIL Neologisms and/or idiosyncratic language

  • VR Verbal rituals

OCD

  • CD Concern with things touched due to dirt/bacteria

  • TB Thoughts of doing something bad around others

  • CT Continual thoughts that do not go away

  • HP Belief that someone/higher power put reoccurring thoughts in their head

  • CW Continual washing

  • CCh Continual checking CntCheck

  • CC Continual counting/repeating

  • RD Repeatedly do things until it feels good or just right

References

Jones, P. J., Ma, R., & McNally, R. J. (2019). Bridge centrality: A network approach to understanding comorbidity. Multivariate behavioral research, 1-15.

Ruzzano, L., Borsboom, D., & Geurts, H. M. (2015). Repetitive behaviors in autism and obsessive-compulsive disorder: New perspectives from a network analysis. Journal of Autism and Developmental Disorders, 45(1), 192-202. doi:10.1007/s10803-014-2204-9

Examples

data("asd_ocd")

# generate continuous
Y <- MASS::mvrnorm(n = 213,
                   mu = rep(0, 17),
                   Sigma = asd_ocd,
                   empirical = TRUE)

Data: 25 Personality items representing 5 factors

Description

This dataset and the corresponding documentation was taken from the psych package. We refer users to that package for further details (Revelle 2019).

Usage

data("bfi")

Format

A data frame with 25 variables and 2800 observations (including missing values)

Details

  • A1 Am indifferent to the feelings of others. (q_146)

  • A2 Inquire about others' well-being. (q_1162)

  • A3 Know how to comfort others. (q_1206)

  • A4 Love children. (q_1364)

  • A5 Make people feel at ease. (q_1419)

  • C1 Am exacting in my work. (q_124)

  • C2 Continue until everything is perfect. (q_530)

  • C3 Do things according to a plan. (q_619)

  • C4 Do things in a half-way manner. (q_626)

  • C5 Waste my time. (q_1949)

  • E1 Don't talk a lot. (q_712)

  • E2 Find it difficult to approach others. (q_901)

  • E3 Know how to captivate people. (q_1205)

  • E4 Make friends easily. (q_1410)

  • E5 Take charge. (q_1768)

  • N1 Get angry easily. (q_952)

  • N2 Get irritated easily. (q_974)

  • N3 Have frequent mood swings. (q_1099)

  • N4 Often feel blue. (q_1479)

  • N5 Panic easily. (q_1505)

  • o1 Am full of ideas. (q_128)

  • o2 Avoid difficult reading material.(q_316)

  • o3 Carry the conversation to a higher level. (q_492)

  • o4 Spend time reflecting on things. (q_1738)

  • o5 Will not probe deeply into a subject. (q_1964)

  • gender Males = 1, Females =2

  • education 1 = HS, 2 = finished HS, 3 = some college, 4 = college graduate 5 = graduate degree

References

Revelle W (2019). psych: Procedures for Psychological, Psychometric, and Personality Research. Northwestern University, Evanston, Illinois. R package version 1.9.12, https://CRAN.R-project.org/package=psych.


Extract Confidence Intervals from ggm_inference Objects

Description

Extract Confidence Intervals from ggm_inference Objects

Usage

## S3 method for class 'ggm_inference'
confint(object, ...)

Arguments

object

An object of class ggm_inference.

...

Currently ignored.

Value

A matrix including bootstrap confidence intervals.

Examples

#  data
Y <- ptsd

# eip
fit <- ggm_inference(Y, method = "spearman",
boot = TRUE, B = 100)

# cis
confint(fit)

Precision Matrix with Known Graph

Description

Compute the maximum likelihood estimate of the precision matrix, given a known graphical structure (i.e., an adjacency matrix). This approach was originally described in "The Elements of Statistical Learning" (see pg. 631, Hastie et al. 2009).

Usage

constrained(Sigma, adj)

Arguments

Sigma

Covariance matrix

adj

An adjacency matrix that encodes the constraints, where a zero indicates that element should be zero.

Value

A list containing the following:

  • Theta: Inverse of the covariance matrix (precision matrix), that encodes the conditional (in)dependence structure.

  • Sigma: Covariance matrix.

  • wadj: Weighted adjacency matrix, corresponding to the partial correlation network.

Note

The algorithm is written in c++, and should scale to high dimensions.

Note there are a variety of algorithms for this purpose. Simulation studies indicated that this approach is both accurate and computationally efficient (HFT therein, Emmert-Streib et al. 2019)

References

Emmert-Streib F, Tripathi S, Dehmer M (2019). “Constrained covariance matrices with a biologically realistic structure: Comparison of methods for generating high-dimensional Gaussian graphical models.” Frontiers in Applied Mathematics and Statistics, 5, 17.

Hastie T, Tibshirani R, Friedman J (2009). The elements of statistical learning: data mining, inference, and prediction. Springer Science \& Business Media.

Examples

# data
Y <- ptsd

# estimate graph
fit <- ggm_inference(Y, boot = FALSE)

# constrain to zero
constrained_graph <- constrained(cor(Y), fit$adj)

Data: Contingencies of Self-Worth Scale (CSWS)

Description

A dataset containing items from the Contingencies of Self-Worth Scale (CSWS) scale. There are 35 variables and 680 observations

Usage

data("csws")

Format

A data frame with 35 variables and 680 observations (7 point Likert scale)

Details

  • 1 When I think I look attractive, I feel good about myself

  • 2 My self-worth is based on God's love

  • 3 I feel worthwhile when I perform better than others on a task or skill.

  • 4 My self-esteem is unrelated to how I feel about the way my body looks.

  • 5 Doing something I know is wrong makes me lose my self-respect

  • 6 I don't care if other people have a negative opinion about me.

  • 7 Knowing that my family members love me makes me feel good about myself.

  • 8 I feel worthwhile when I have God's love.

  • 9 I can’t respect myself if others don't respect me.

  • 10 My self-worth is not influenced by the quality of my relationships with my family members.

  • 11 Whenever I follow my moral principles, my sense of self-respect gets a boost.

  • 12 Knowing that I am better than others on a task raises my self-esteem.

  • 13 My opinion about myself isn't tied to how well I do in school.

  • 14 I couldn't respect myself if I didn't live up to a moral code.

  • 15 I don't care what other people think of me.

  • 16 When my family members are proud of me, my sense of self-worth increases.

  • 17 My self-esteem is influenced by how attractive I think my face or facial features are.

  • 18 My self-esteem would suffer if I didn’t have God's love.

  • 19 Doing well in school gives me a sense of selfrespect.

  • 20 Doing better than others gives me a sense of self-respect.

  • 21 My sense of self-worth suffers whenever I think I don't look good.

  • 22 I feel better about myself when I know I'm doing well academically.

  • 23 What others think of me has no effect on what I think about myself.

  • 24 When I don’t feel loved by my family, my selfesteem goes down.

  • 25 My self-worth is affected by how well I do when I am competing with others.

  • 26 My self-esteem goes up when I feel that God loves me.

  • 27 My self-esteem is influenced by my academic performance.

  • 28 My self-esteem would suffer if I did something unethical.

  • 29 It is important to my self-respect that I have a family that cares about me.

  • 30 My self-esteem does not depend on whether or not I feel attractive.

  • 31 When I think that I’m disobeying God, I feel bad about myself.

  • 32 My self-worth is influenced by how well I do on competitive tasks.

  • 33 I feel bad about myself whenever my academic performance is lacking.

  • 34 My self-esteem depends on whether or not I follow my moral/ethical principles.

  • 35 My self-esteem depends on the opinions others hold of me.

  • gender "M" (male) or "F" (female)

Note

There are seven domains

FAMILY SUPPORT: items 7, 10, 16, 24, and 29.

COMPETITION: items 3, 12, 20, 25, and 32.

APPEARANCE: items 1, 4, 17, 21, and 30.

GOD'S LOVE: items 2, 8, 18, 26, and 31.

ACADEMIC COMPETENCE: items 13, 19, 22, 27, and 33.

VIRTUE: items 5, 11, 14, 28, and 34.

APPROVAL FROM OTHERS: items: 6, 9, 15, 23, and 35.

References

Briganti, G., Fried, E. I., & Linkowski, P. (2019). Network analysis of Contingencies of Self-Worth Scale in 680 university students. Psychiatry research, 272, 252-257.

Examples

data("csws")

Data: Depression and Anxiety (Time 1)

Description

A data frame containing 403 observations (n = 403) and 16 variables (p = 16) measured on the 4-point likert scale (depression: 9; anxiety: 7).

Usage

data("depression_anxiety_t1")

Format

A data frame containing 403 observations (n = 7466) and 16 variables (p = 16) measured on the 4-point likert scale.

Details

Depression:

  • PHQ1 Little interest or pleasure in doing things?

  • PHQ2 Feeling down, depressed, or hopeless?

  • PHQ3 Trouble falling or staying asleep, or sleeping too much?

  • PHQ4 Feeling tired or having little energy?

  • PHQ5 Poor appetite or overeating?

  • PHQ6 Feeling bad about yourself — or that you are a failure or have let yourself or your family down?

  • PHQ7 Trouble concentrating on things, such as reading the newspaper or watching television?

  • PHQ8 Moving or speaking so slowly that other people could have noticed? Or so fidgety or restless that you have been moving a lot more than usual?

  • PHQ9 Thoughts that you would be better off dead, or thoughts of hurting yourself in some way?

Anxiety

  • GAD1 Feeling nervous, anxious, or on edge

  • GAD2 Not being able to stop or control worrying

  • GAD3 Worrying too much about different things

  • GAD4 Trouble relaxing

  • GAD5 Being so restless that it's hard to sit still

  • GAD6 Becoming easily annoyed or irritable

  • GAD7 Feeling afraid as if something awful might happen

References

Forbes, M. K., Baillie, A. J., & Schniering, C. A. (2016). A structural equation modeling analysis of the relationships between depression,anxiety, and sexual problems over time. The Journal of Sex Research, 53(8), 942-954.

Forbes, M. K., Wright, A. G., Markon, K. E., & Krueger, R. F. (2019). Quantifying the reliability and replicability of psychopathology network characteristics. Multivariate behavioral research, 1-19.

Jones, P. J., Williams, D. R., & McNally, R. J. (2019). Sampling variability is not nonreplication: a Bayesian reanalysis of Forbes, Wright, Markon, & Krueger.

Examples

data("depression_anxiety_t1")
labels<- c("interest", "down", "sleep",
            "tired", "appetite", "selfest",
           "concen", "psychmtr", "suicid",
           "nervous", "unctrworry", "worrylot",
           "relax", "restless", "irritable", "awful")

Data: Depression and Anxiety (Time 2)

Description

A data frame containing 403 observations (n = 403) and 16 variables (p = 16) measured on the 4-point likert scale (depression: 9; anxiety: 7).

Usage

data("depression_anxiety_t2")

Format

A data frame containing 403 observations (n = 7466) and 16 variables (p = 16) measured on the 4-point likert scale.

Details

Depression:

  • PHQ1 Little interest or pleasure in doing things?

  • PHQ2 Feeling down, depressed, or hopeless?

  • PHQ3 Trouble falling or staying asleep, or sleeping too much?

  • PHQ4 Feeling tired or having little energy?

  • PHQ5 Poor appetite or overeating?

  • PHQ6 Feeling bad about yourself — or that you are a failure or have let yourself or your family down?

  • PHQ7 Trouble concentrating on things, such as reading the newspaper or watching television?

  • PHQ8 Moving or speaking so slowly that other people could have noticed? Or so fidgety or restless that you have been moving a lot more than usual?

  • PHQ9 Thoughts that you would be better off dead, or thoughts of hurting yourself in some way?

Anxiety

  • GAD1 Feeling nervous, anxious, or on edge

  • GAD2 Not being able to stop or control worrying

  • GAD3 Worrying too much about different things

  • GAD4 Trouble relaxing

  • GAD5 Being so restless that it's hard to sit still

  • GAD6 Becoming easily annoyed or irritable

  • GAD7 Feeling afraid as if something awful might happen

References

Forbes, M. K., Baillie, A. J., & Schniering, C. A. (2016). A structural equation modeling analysis of the relationships between depression,anxiety, and sexual problems over time. The Journal of Sex Research, 53(8), 942-954.

Forbes, M. K., Wright, A. G., Markon, K. E., & Krueger, R. F. (2019). Quantifying the reliability and replicability of psychopathology network characteristics. Multivariate behavioral research, 1-19.

Jones, P. J., Williams, D. R., & McNally, R. J. (2019). Sampling variability is not nonreplication: a Bayesian reanalysis of Forbes, Wright, Markon, & Krueger.

Examples

data("depression_anxiety_t2")
labels<- c("interest", "down", "sleep",
            "tired", "appetite", "selfest",
           "concen", "psychmtr", "suicid",
           "nervous", "unctrworry", "worrylot",
           "relax", "restless", "irritable", "awful")

Edge Inclusion "Probability"

Description

Compute the proportion of bootstrap samples that each relation was selected, corresponding to an edge inclusion "probability".

Usage

eip(Y, method = "pearson", B = 1000, progress = TRUE)

Arguments

Y

The data matrix of dimensions n (observations) by p (nodes).

method

Character string. Which type of correlation coefficients to be computed. Options include "pearson" (default), "kendall", "spearman", and "polychoric".

B

Integer. Number of bootstrap replicates (defaults to 1000).

progress

Logical. Should a progress bar be included (defaults to TRUE)?

Details

The order is the upper-triangular.

Value

An object of class eip, including a matrix of edge inclusion "probabilities".

Note

In the context of regression, this general approach was described in see Figure 6.4. see Figure 6.4, Hastie et al. (2015). In this case, the selection is based on classical hypothesis testing instead of L1-regularization.

References

Hastie T, Tibshirani R, Wainwright M (2015). Statistical Learning with Sparsity: The Lasso and Generalizations. CRC Press, Boca Raton. ISBN 978-1-4987-1217-0, doi:10.1201/b18401.

Examples

# data
Y <- ptsd

# eip
fit_eip <- eip(Y, method = "spearman")

# print
fit_eip

Expected Network Replicability

Description

Investigate network replicability for any kind of partial correlation, assuming there is an analytic solution for the standard error (e.g., Pearson's or Spearman's).

Usage

enr(net, n, alpha = 0.05, replications = 2, type = "pearson")

Arguments

net

True network of dimensions p by p.

n

Integer. The samples size, assumed equal in the replication attempts.

alpha

The desired significance level (defaults to 0.05). Note that 1 - alpha corresponds to specificity.

replications

Integer. The desired number of replications.

type

Character string. Which type of correlation coefficients to be computed. Options include "pearson" (default) and "spearman".

Value

An list of class enr including the following:

  • ave_power: Average power.

  • cdf: cumulative distribution function.

  • p_s: Power for each edge, or the probability of success for a given trial.

  • p: Number of nodes.

  • n_nonzero: Number of edges.

  • n: Sample size.

  • replication: Replication attempts.

  • var_pwr: Variance of power.

  • type: Type of correlation coefficient.

Note

This method was introduced in Williams (2020).

The basic idea is to determine the replicability of edges in a partial correlation network. This requires defining the true network, which can include edges of various sizes, and then solving for the proportion of edges that are expected to be replicated (e.g. in two, three, or four replication attempt).

References

Williams DR (2020). “Learning to live with sampling variability: Expected replicability in partial correlation networks.” PsyArXiv. doi:10.31234/osf.io/fb4sa.

Examples

# (1) define partial correlation network

# correlations from ptsd symptoms
cors <- cor(GGMnonreg::ptsd)

# inverse
inv <- solve(cors)

# partials
pcors <-  -cov2cor(inv)

# set values to zero
# (this is the partial correlation network)
pcors <- ifelse(abs(pcors) < 0.05, 0, pcors)


# compute ENR in two replication attempts
fit_enr <- enr(net = pcors,
               n = 500,
               replications = 2)


# intuition for the method:
# The above did not require simulation, and here I use simulation
# for the same purpose.

# location of edges
# (where the edges are located in the network)
index <- which(pcors[upper.tri(diag(20))] != 0)

# convert network a into correlation matrix
# (this is needed to simulate data)
diag(pcors) <- 1
cors_new <- corpcor::pcor2cor(pcors)

# replicated edges
# (store the number of edges that were replicated)
R <- NA

# simulate how many edges replicate in two attempts
# (increase 100 to, say, 5,000)
for(i in 1:100){

  # two replications
  Y1 <- MASS::mvrnorm(500, rep(0, 20), cors_new)
  Y2 <- MASS::mvrnorm(500, rep(0, 20), cors_new)

  # estimate network 1
  fit1 <- ggm_inference(Y1, boot = FALSE)

  # estimate network 2
  fit2 <- ggm_inference(Y2, boot = FALSE)

  # number of replicated edges (detected in both networks)
  R[i] <- sum(
    rowSums(
      cbind(fit1$adj[upper.tri(diag(20))][index],
            fit2$adj[upper.tri(diag(20))][index])
    ) == 2)
}


# combine simulation and analytic
cbind.data.frame(
  data.frame(simulation = sapply(seq(0, 0.9, 0.1), function(x) {
    mean(R > round(length(index) * x) )
  })),
  data.frame(analytic = round(fit_enr$cdf, 3))
)

# now compare simulation to the analytic solution
# average replicability (simulation)
mean(R / length(index))

# average replicability (analytic)
fit_enr$ave_pwr

Fisher Z Transformation

Description

Tranform correlations to Fisher's Z

Usage

fisher_r_to_z(r)

Arguments

r

correlation (can be a vector)

Value

Fisher Z transformed correlation(s)

Examples

fisher_r_to_z(0.5)

Fisher Z Back Transformation

Description

Back tranform Fisher's Z to correlations

Usage

fisher_z_to_r(z)

Arguments

z

Fisher Z

Value

Correlation (s) (backtransformed)

Examples

fisher_z_to_r(0.5)

Simulate a Partial Correlation Matrix

Description

Simulate a Partial Correlation Matrix

Usage

gen_net(p = 20, edge_prob = 0.3, lb = 0.05, ub = 0.3)

Arguments

p

number of variables (nodes)

edge_prob

connectivity

lb

lower bound for the partial correlations

ub

upper bound for the partial correlations

Value

A list containing the following:

  • pcor: Partial correlation matrix, encoding the conditional (in)dependence structure.

  • cors: Correlation matrix.

  • adj: Adjacency matrix.

  • trys: Number of attempts to obtain a positive definite matrix.

Note

The function checks for a valid matrix (positive definite), but sometimes this will still fail. For example, for larger p, to have large partial correlations this requires a sparse GGM (accomplished by setting edge_prob to a small value).

Examples

true_net <- gen_net(p = 10)

Get Graph

Description

Extract the necessary ingredients to visualize the conditional dependence structure.

Usage

get_graph(x)

Arguments

x

An object of class ggmnonreg

Value

A list including two matrices (the weighted adjacency and adjacency matrices)

Examples

# data
Y <- ptsd

# estimate graph
fit <- ggm_inference(Y, boot = FALSE)

# get info for plotting
get_graph(fit)

Compare Gaussian Graphical Models

Description

Establish whether each of the corresponding edges are significantly different in two groups

Usage

ggm_compare(Yg1, Yg2, method = "spearman", alpha = 0.05)

Arguments

Yg1

The data matrix of dimensions n (observations) by p (nodes) for group one.

Yg2

The data matrix of dimensions n (observations) by p (nodes) for group two.

method

Character string. Which type of correlation coefficients to be computed. Options include "pearson" (default), "kendall", "spearman", and "polychoric".

alpha

The desired significance level (defaults to 0.05). Note that 1 - alpha corresponds to specificity.

Value

An object of class ggm_compare including:

  • adj: Adjacency matrix, where a 1 indicates a difference.

  • wadj: Weighted adjacency matrix (partial correlation differences that were significantly different)

  • cis: Confidence intervals for the partial correlation differences.

Examples

# data

Yg1 <- na.omit(subset(bfi, gender == 1)[,1:10])
Yg2 <- na.omit(subset(bfi, gender == 2)[,1:10])

# compare relations
fit <- ggm_compare(Yg1, Yg2)

Gaussian graphical model: statistical inference

Description

Learn the conditional dependence structure with null hypothesis significance testing. This provides a valid measure of parameter uncertainty.

Usage

ggm_inference(
  Y,
  alpha = 0.05,
  control_precision = FALSE,
  boot = TRUE,
  B = 1000,
  cores = 1,
  method = "pearson",
  progress = TRUE
)

Arguments

Y

The data matrix of dimensions n (observations) by p (nodes).

alpha

The desired significance level (defaults to 0.05). Note that 1 - alpha corresponds to specificity.

control_precision

Logical. Should precision (i.e., 1 - false discovery rate) be controlled at the level alpha (defaults to FALSE) ?

boot

Logical. Should a non-parametric bootstrap be employed (defaults to TRUE)?

B

Integer. Number of bootstrap replicates (defaults to 1000).

cores

Integer. Number of cores to be used when executing in parallel (defaults to 1).

method

Character string. Which type of correlation coefficients to be computed. Options include "pearson" (default), "kendall", "spearman", and "polychoric".

progress

Logical. Should a progress bar be included (defaults to TRUE)?

Value

An object of class ggm_inference including:

  • wadj: Weighted adjacency matrix, corresponding to the partial correlation network.

  • adj: Adjacency matrix (detected effects).

  • pcors: Partial correlations.

  • n: Sample size.

  • p: Number of nodes.

  • Y: Data.

Examples

Y <- ptsd

fit <- ggm_inference(Y)

Data: 1994 General Social Survey

Description

A data frame containing 1002 rows and 7 variables measured on various scales, including binary and ordered cateogrical (with varying numbers of categories). There are also missing values in each variable

  • Inc Income of the respondent in 1000s of dollars, binned into 21 ordered categories.

  • DEG Highest degree ever obtained (none, HS, Associates, Bachelors, or Graduate)

  • CHILD Number of children ever had.

  • PINC Financial status of respondent's parents when respondent was 16 (on a 5-point scale).

  • PDEG Maximum of mother's and father's highest degree

  • PCHILD Number of siblings of the respondent plus one

  • AGE Age of the respondent in years.

Usage

data("gss")

Format

A data frame containing 1190 observations (n = 1190) and 6 variables (p = 6) measured on the binary scale (Fowlkes et al. 1988). The variable descriptions were copied from section 4, Hoff (2007)

References

Fowlkes EB, Freeny AE, Landwehr JM (1988). “Evaluating logistic models for large contingency tables.” Journal of the American Statistical Association, 83(403), 611–622. doi:10.1080/01621459.1988.10478640.

Hoff PD (2007). “Extending the rank likelihood for semiparametric copula estimation.” The Annals of Applied Statistics, 1(1), 265–283.

Examples

data("gss")

Data: ifit Intensive Longitudinal Data

Description

A data frame containing 8 variables and nearly 200 observations. There are two subjects, each of which provided data every data for over 90 days. Six variables are from the PANAS scale (positive and negative affect), the daily number of steps, and the subject id.

  • id Subject id

  • interested

  • disinterested

  • excited

  • upset

  • strong

  • stressed

  • steps steps recorded by a fit bit

Usage

data("ifit")

Format

A data frame containing 197 observations and 8 variables. The data have been used in (OLaughlin et al. 2020) and (Williams et al. 2019)

References

OLaughlin KD, Liu S, Ferrer E (2020). “Use of Composites in Analysis of Individual Time Series: Implications for Person-Specific Dynamic Parameters.” Multivariate Behavioral Research, 1–18. doi:10.1080/00273171.2020.1716673.

Williams DR, Liu S, Martin SR, Rast P (2019). “Bayesian Multivariate Mixed-Effects Location Scale Modeling of Longitudinal Relations among Affective Traits, States, and Physical Activity.” PsyArXiv. doi:10.31234/osf.io/4kfjp.

Examples

data("ifit")

Data: Interpersonal Reactivity Index (IRI)

Description

A dataset containing items from the Interpersonal Reactivity Index (IRI; an empathy measure). There are 28 variables and 1973 observations

Usage

data("iri")

Format

A data frame with 28 variables and 1973 observations (5 point Likert scale)

Details

  • 1 I daydream and fantasize, with some regularity, about things that might happen to me.

  • 2 I often have tender, concerned feelings for people less fortunate than me.

  • 3 I sometimes find it difficult to see things from the "other guy's" point of view.

  • 4 Sometimes I don't feel very sorry for other people when they are having problems.

  • 5 I really get involved with the feelings of the characters in a novel.

  • 6 In emergency situations, I feel apprehensive and ill-at-ease.

  • 7 I am usually objective when I watch a movie or play, and I don't often get completely caught up in it.

  • 8 I try to look at everybody's side of a disagreement before I make a decision.

  • 9 When I see someone being taken advantage of, I feel kind of protective towards them.

  • 10 I sometimes feel helpless when I am in the middle of a very emotional situation.

  • 11 I sometimes try to understand my friends better by imagining how things look from their perspective

  • 12 Becoming extremely involved in a good book or movie is somewhat rare for me.

  • 13 When I see someone get hurt, I tend to remain calm.

  • 14 Other people's misfortunes do not usually disturb me a great deal.

  • 15 If I'm sure I'm right about something, I don't waste much time listening to other people's arguments.

  • 16 After seeing a play or movie, I have felt as though I were one of the characters.

  • 17 Being in a tense emotional situation scares me.

  • 18 When I see someone being treated unfairly, I sometimes don't feel very much pity for them.

  • 19 I am usually pretty effective in dealing with emergencies.

  • 20 I am often quite touched by things that I see happen.

  • 21 I believe that there are two sides to every question and try to look at them both.

  • 22 I would describe myself as a pretty soft-hearted person.

  • 23 When I watch a good movie, I can very easily put myself in the place of a leading character

  • 24 I tend to lose control during emergencies.

  • 25 When I'm upset at someone, I usually try to "put myself in his shoes" for a while.

  • 26 When I am reading an interesting story or novel, I imagine how I would feel if the events in the story were happening to me.

  • 27 When I see someone who badly needs help in an emergency, I go to pieces.

  • 28 Before criticizing somebody, I try to imagine how I would feel if I were in their place.

  • gender "M" (male) or "F" (female)

Note

There are four domains

Fantasy: items 1, 5, 7, 12, 16, 23, 26

Perspective taking: items 3, 8, 11, 15, 21, 25, 28

Empathic concern: items 2, 4, 9, 14, 18, 20, 22

Personal distress: items 6, 10, 13, 17, 19, 24, 27,

References

Briganti, G., Kempenaers, C., Braun, S., Fried, E. I., & Linkowski, P. (2018). Network analysis of empathy items from the interpersonal reactivity index in 1973 young adults. Psychiatry research, 265, 87-92.

Examples

data("iri")

Plot enr Objects

Description

Plot the probability mass function for ENR.

Usage

plot_enr(x, iter = 1e+05, fill = "#009E73", alpha = 0.5, ...)

Arguments

x

An object of class enr.

iter

Integer. How many draws from the Poisson-binomial distribution (defaults to 1,000)?

fill

Which color to fill the density?

alpha

Numeric (between 0 and 1). The transparency for the density.

...

Currently ignored

Value

An object of class ggplot

Examples

# correlations
cors <- cor(GGMnonreg::ptsd)

# inverse
inv <- solve(cors)

# partials
pcors <-  -cov2cor(inv)

# set values to zero
pcors <- ifelse(abs(pcors) < 0.05, 0, pcors )

est <- enr(net = pcors, n = 500, replications = 2)

# plot
plot_enr(est)

Network Plot for graph Objects

Description

Visualize the conditional (in)dependence structure.

Usage

## S3 method for class 'ggmnonreg'
plot(
  x,
  layout = "circle",
  neg_col = "#D55E00",
  pos_col = "#009E73",
  edge_magnify = 1,
  node_size = 10,
  palette = 2,
  node_names = NULL,
  node_groups = NULL,
  ...
)

Arguments

x

An object of class graph obtained from get_graph.

layout

Character string. Which graph layout (defaults is circle) ? See gplot.layout.

neg_col

Character string. Color for the positive edges (defaults to a colorblind friendly red).

pos_col

Character string. Color for the negative edges (defaults to a colorblind friendly green).

edge_magnify

Numeric. A value that is multiplied by the edge weights. This increases (> 1) or decreases (< 1) the line widths (defaults to 1).

node_size

Numeric. The size of the nodes (defaults to 10).

palette

A character string sepcifying the palette for the groups. (default is Set3). See palette options here.

node_names

Character string. Names for nodes of length p.

node_groups

A character string of length p (the number of nodes in the model). This indicates groups of nodes that should be the same color (e.g., "clusters" or "communities").

...

Currently ignored.

Value

An object of class ggplot

Examples

# data
Y <- ptsd

# estimate graph
fit <- ggm_inference(Y, boot = FALSE)

# plot graph
plot(fit)

Network Predictability (R2)

Description

Network Predictability (R2)

Usage

predictability(x, ci = 0.95)

Arguments

x

An object of class ggm_inference

ci

Numeric. The confidence interval to be computed (defaults to 0.95).

Value

An object of class predictability, including a matrix of R2 for each node.

Note

Predictability is variance explained for each node in the network (Haslbeck and Waldorp 2018).

References

Haslbeck JM, Waldorp LJ (2018). “How well do network models predict observations? On the importance of predictability in network models.” Behavior Research Methods, 50(2), 853–861. ISSN 15543528, doi:10.3758/s13428-017-0910-x, 1610.09108, http://www.ncbi.nlm.nih.gov/pubmed/28718088.

Examples

# data
Y <- ptsd

# estimate graph
fit <- ggm_inference(Y, boot = FALSE)

# predictability
r2 <- predictability(fit)

# print
r2

Print ggmnonreg Object

Description

Print ggmnonreg Object

Usage

## S3 method for class 'ggmnonreg'
print(x, ...)

Arguments

x

An object of class ggmnonreg

...

Currently ignored

Value

No return value.


Data: Post-Traumatic Stress Disorder

Description

A dataset containing items that measure Post-traumatic stress disorder symptoms (Armour et al. 2017). There are 20 variables (p) and 221 observations (n).

Usage

data("ptsd")

Format

A dataframe with 221 rows and 20 variables

Details

  • Intrusive Thoughts

  • Nightmares

  • Flashbacks

  • Emotional cue reactivity

  • Psychological cue reactivity

  • Avoidance of thoughts

  • Avoidance of reminders

  • Trauma-related amnesia

  • Negative beliefs

  • Negative trauma-related emotions

  • Loss of interest

  • Detachment

  • Restricted affect

  • Irritability/anger

  • Self-destructive/reckless behavior

  • Hypervigilance

  • Exaggerated startle response

  • Difficulty concentrating

  • Sleep disturbance

References

Armour C, Fried EI, Deserno MK, Tsai J, Pietrzak RH (2017). “A network analysis of DSM-5 posttraumatic stress disorder symptoms and correlates in US military veterans.” Journal of anxiety disorders, 45, 49–59. doi:10.31234/osf.io/p69m7.


Cor: Post-Traumatic Stress Disorder (Sample # 1)

Description

A correlation matrix that includes 16 variables. The correlation matrix was estimated from 526 individuals (Fried et al. 2018).

Format

A correlation matrix with 16 variables

Details

  • Intrusive Thoughts

  • Nightmares

  • Flashbacks

  • Physiological/psychological reactivity

  • Avoidance of thoughts

  • Avoidance of situations

  • Amnesia

  • Disinterest in activities

  • Feeling detached

  • Emotional numbing

  • Foreshortened future

  • Sleep problems

  • Irritability

  • Concentration problems

  • Hypervigilance

  • Startle response

References

Fried EI, Eidhof MB, Palic S, Costantini G, Huisman-van Dijk HM, Bockting CL, Engelhard I, Armour C, Nielsen AB, Karstoft K (2018). “Replicability and generalizability of posttraumatic stress disorder (PTSD) networks: a cross-cultural multisite study of PTSD symptoms in four trauma patient samples.” Clinical Psychological Science, 6(3), 335–351.

Examples

data(ptsd_cor1)

Y <- MASS::mvrnorm(n = 526,
                   mu = rep(0, 16),
                   Sigma = ptsd_cor1,
                   empirical = TRUE)

Cor: Post-Traumatic Stress Disorder (Sample # 2)

Description

A correlation matrix that includes 16 variables. The correlation matrix was estimated from 365 individuals (Fried et al. 2018).

Format

A correlation matrix with 16 variables

Details

  • Intrusive Thoughts

  • Nightmares

  • Flashbacks

  • Physiological/psychological reactivity

  • Avoidance of thoughts

  • Avoidance of situations

  • Amnesia

  • Disinterest in activities

  • Feeling detached

  • Emotional numbing

  • Foreshortened future

  • Sleep problems

  • Irritability

  • Concentration problems

  • Hypervigilance

  • Startle response

References

Fried EI, Eidhof MB, Palic S, Costantini G, Huisman-van Dijk HM, Bockting CL, Engelhard I, Armour C, Nielsen AB, Karstoft K (2018). “Replicability and generalizability of posttraumatic stress disorder (PTSD) networks: a cross-cultural multisite study of PTSD symptoms in four trauma patient samples.” Clinical Psychological Science, 6(3), 335–351.

Examples

data(ptsd_cor2)
Y <- MASS::mvrnorm(n = 365,
                   mu = rep(0, 16),
                   Sigma = ptsd_cor2,
                   empirical = TRUE)

Cor: Post-Traumatic Stress Disorder (Sample # 3)

Description

A correlation matrix that includes 16 variables. The correlation matrix was estimated from 926 individuals (Fried et al. 2018).

Format

A correlation matrix with 16 variables

Details

  • Intrusive Thoughts

  • Nightmares

  • Flashbacks

  • Physiological/psychological reactivity

  • Avoidance of thoughts

  • Avoidance of situations

  • Amnesia

  • Disinterest in activities

  • Feeling detached

  • Emotional numbing

  • Foreshortened future

  • Sleep problems

  • Irritability

  • Concentration problems

  • Hypervigilance

  • Startle response

References

Fried EI, Eidhof MB, Palic S, Costantini G, Huisman-van Dijk HM, Bockting CL, Engelhard I, Armour C, Nielsen AB, Karstoft K (2018). “Replicability and generalizability of posttraumatic stress disorder (PTSD) networks: a cross-cultural multisite study of PTSD symptoms in four trauma patient samples.” Clinical Psychological Science, 6(3), 335–351.

Examples

data(ptsd_cor3)
Y <- MASS::mvrnorm(n = 926,
                   mu = rep(0, 16),
                   Sigma = ptsd_cor3,
                   empirical = TRUE)

Cor: Post-Traumatic Stress Disorder (Sample # 4)

Description

A correlation matrix that includes 16 variables. The correlation matrix was estimated from 965 individuals (Fried et al. 2018).

Format

A correlation matrix with 16 variables

Details

  • Intrusive Thoughts

  • Nightmares

  • Flashbacks

  • Physiological/psychological reactivity

  • Avoidance of thoughts

  • Avoidance of situations

  • Amnesia

  • Disinterest in activities

  • Feeling detached

  • Emotional numbing

  • Foreshortened future

  • Sleep problems

  • Irritability

  • Concentration problems

  • Hypervigilance

  • Startle response

References

Fried EI, Eidhof MB, Palic S, Costantini G, Huisman-van Dijk HM, Bockting CL, Engelhard I, Armour C, Nielsen AB, Karstoft K (2018). “Replicability and generalizability of posttraumatic stress disorder (PTSD) networks: a cross-cultural multisite study of PTSD symptoms in four trauma patient samples.” Clinical Psychological Science, 6(3), 335–351.

Examples

data(ptsd_cor4)
Y <- MASS::mvrnorm(n = 965,
                   mu = rep(0, 16),
                   Sigma = ptsd_cor4,
                   empirical = TRUE)

Data: Resilience Scale of Adults (RSA)

Description

A dataset containing items from the Resilience Scale of Adults (RSA). There are 33 items and 675 observations

Usage

data("rsa")

Format

A data frame with 28 variables and 1973 observations (5 point Likert scale)

Details

  • 1 My plans for the future are

  • 2 When something unforeseen happens

  • 3 My family understanding of what is important in life is

  • 4 I feel that my future looks

  • 5 My goals

  • 6 I can discuss personal issues with

  • 7 I feel

  • 8 I enjoy being

  • 9 Those who are good at encouraging are

  • 10 The bonds among my friends

  • 11 My personal problems

  • 12 When a family member experiences a crisis/emergency

  • 13 My family is characterised by

  • 14 To be flexible in social settings

  • 15 I get support from

  • 16 In difficult periods my family

  • 17 My judgements and decisions

  • 18 New friendships are something

  • 19 When needed, I have

  • 20 I am at my best when I

  • 21 Meeting new people is

  • 22 When I am with others

  • 23 When I start on new things/projects

  • 24 Facing other people, our family acts

  • 25 Belief in myself

  • 26 For me, thinking of good topics of conversation is

  • 27 My close friends/family members

  • 28 I am good at

  • 29 In my family, we like to

  • 30 Rules and regular routines

  • 31 In difficult periods I have a tendency to

  • 32 My goals for the future are

  • 33 Events in my life that I cannot influence

  • gender "M" (male) or "F" (female)

Note

There are 6 domains

Planned future: items 1, 4, 5, 32

Perception of self: items 2, 11, 17, 25, 31, 33

Family cohesion: items 3, 7, 13, 16, 24, 29

Social resources: items 6, 9, 10, 12, 15, 19, 27

Social Competence: items 8, 14, 18, 21, 22, 26,

Structured style: items 23, 28, 30

References

Briganti, G., & Linkowski, P. (2019). Item and domain network structures of the Resilience Scale for Adults in 675 university students. Epidemiology and psychiatric sciences, 1-9.

Examples

data("rsa")

Data: Sachs Network

Description

Protein expression in human immune system cells

Usage

data("Sachs")

Format

A data frame containing 7466 cells (n = 7466) and flow cytometry measurements of 11 (p = 11) phosphorylated proteins and phospholipids

@references Sachs, K., Gifford, D., Jaakkola, T., Sorger, P., & Lauffenburger, D. A. (2002). Bayesian network approach to cell signaling pathway modeling. Sci. STKE, 2002(148), pe38-pe38.

Examples

data("Sachs")

Data: Toronto Alexithymia Scale (TAS)

Description

A dataset containing items from the Toronto Alexithymia Scale (TAS). There are 20 variables and 1925 observations

Usage

data("tas")

Format

A data frame with 20 variables and 1925 observations (5 point Likert scale)

Details

  • 1 I am often confused about what emotion I am feeling

  • 2 It is difficult for me to find the right words for my feelings

  • 3 I have physical sensations that even doctors don’t understand

  • 4 I am able to describe my feelings easily

  • 5 I prefer to analyze problems rather than just describe them

  • 6 When I am upset, I don’t know if I am sad, frightened, or angry

  • 7 I am often puzzled by sensations in my body

  • 8 I prefer just to let things happen rather than to understand why they turned out that way

  • 9 I have feelings that I can’t quite identify

  • 10 Being in touch with emotions is essential

  • 11 I find it hard to describe how I feel about people

  • 12 People tell me to describe my feelings more

  • 13 I don’t know what’s going on inside me

  • 14 I often don’t know why I am angry

  • 15 I prefer talking to people about their daily activities rather than their feelings

  • 16 I prefer to watch “light” entertainment shows rather than psychological dramas

  • 17 It is difficult for me to reveal my innermost feelings, even to close friends

  • 18 I can feel close to someone, even in moments of silence

  • 19 I find examination of my feelings useful in solving personal problems

  • 20 Looking for hidden meanings in movies or plays distracts from their enjoyment

  • gender "M" (male) or "F" (female)

Note

There are three domains

Difficulty identifying feelings: items 1, 3, 6, 7, 9, 13, 14

Difficulty describing feelings: items 2, 4, 11, 12, 17

Externally oriented thinking: items 10, 15, 16, 18, 19

References

Briganti, G., & Linkowski, P. (2019). Network approach to items and domains from the Toronto Alexithymia Scale. Psychological reports.

Examples

data("tas")

Data: Women and Mathematics

Description

A data frame containing 1190 observations (n = 1190) and 6 variables (p = 6) measured on the binary scale.

Usage

data("women_math")

Format

A data frame containing 1190 observations (n = 1190) and 6 variables (p = 6) measured on the binary scale (Fowlkes et al. 1988). These data have been analyzed in Tarantola (2004) and in (Madigan and Raftery 1994). The variable descriptions were copied from (section 5.2 ) (section 5.2, Talhouk et al. 2012)

Details

  • 1 Lecture attendance (attend/did not attend)

  • 2 Gender (male/female)

  • 3 School type (urban/suburban)

  • 4 “I will be needing Mathematics in my future work” (agree/disagree)

  • 5 Subject preference (math/science vs. liberal arts)

  • 6 Future plans (college/job)

References

Fowlkes EB, Freeny AE, Landwehr JM (1988). “Evaluating logistic models for large contingency tables.” Journal of the American Statistical Association, 83(403), 611–622. doi:10.1080/01621459.1988.10478640.

Madigan D, Raftery AE (1994). “Model selection and accounting for model uncertainty in graphical models using Occam's window.” Journal of the American Statistical Association, 89(428), 1535–1546.

Talhouk A, Doucet A, Murphy K (2012). “Efficient Bayesian inference for multivariate probit models with sparse inverse correlation matrices.” Journal of Computational and Graphical Statistics, 21(3), 739–757. doi:10.1080/10618600.2012.679239.

Tarantola C (2004). “MCMC model determination for discrete graphical models.” Statistical Modelling, 4(1), 39–61. doi:10.1191/1471082x04st063oa.

Examples

data("women_math")