Learn R Programming

psychonetrics (version 0.17.8)

CIplot: Plot Analytic Confidence Intervals

Description

Function to plot analytic confidence intervals (CI) of matrix elements estimated in psychonetrics.

Usage

CIplot(x, matrices, alpha_ci = 0.05, alpha_color = c(0.05,
                   0.01, 0.001, 1e-04), labels, labels2, labelstart,
                   print = TRUE, major_break = 0.2, minor_break = 0.1,
                   split0, prop0, prop0_cex = 1, prop0_alpha = 0.95,
                   prop0_minAlpha = 0.25, time)

Value

A single ggplot2 object, or a list of ggplot2 objects for each matrix requested.

Arguments

x

A psychonetrics model.

matrices

Vector of strings indicating the matrices to plot CIs for. For ri_clpm / ri_clpn models these may also be block names such as "omega_zeta_within" or "omega_zeta_between"; see Details.

time

Only for ri_clpm / ri_clpn models: the wave (an index or a column name of the design matrix) whose block should be plotted. When omitted, every wave is plotted in its own panel. See Details.

alpha_ci

The alpha level used for the CIs

alpha_color

A vector of alphas used for coloring the CIs

labels

The labels for the variables associated with the rows of a matrix.

labels2

The labels for the variables associated with the columns of a matrix. Defaults to the value of labels for square matrices.

labelstart

The value to determine if labels are printed to the right or to the left of the CI

print

Logical, should the plots also be printed? Only works when one matrix is used in 'matrices'

major_break

Numeric indicating the step size between major breaks

minor_break

Numeric indicating the step size between minor breaks

split0

Logical only used for results of aggregate_bootstraps. When set to TRUE, the displayed intervals are based on occasions when the parameter was not estimated to be zero, and an extra box is added indicating the number of times a parameter is estimated to be zero. Defaults to TRUE when model selection is used and FALSE otherwise.

prop0

Logical only used for results of aggregate_bootstraps, should boxes indicating the proportion of times parameters were estimated to be zero be added to the plot? Defaults to the value of split0.

prop0_cex

Only used for results of aggregate_bootstraps. Size of the boxes indicating number of times a parameter was set to zero.

prop0_alpha

Only used for results of aggregate_bootstraps. Transparency of the boxes indicating number of times a parameter was set to zero.

prop0_minAlpha

Only used for results of aggregate_bootstraps. Minimal transparency of the *lines* of plotted intervals as the proportion of times an edge was not included goes to 0.

Author

Sacha Epskamp

Details

RI-CLPM / RI-CLPN models. A model made with ri_clpm or ri_clpn is built on the lvm framework, so each of its model matrices spans all waves at once (the within-person components of every wave, followed by the random intercepts). Plotting such a matrix would mix the temporal effects, the contemporaneous relations of every wave and the between-person relations into a single unreadable figure. For these models CIplot therefore works on the blocks, addressed with the same matrix names that panelvar and panelgvar use: "beta" (temporal), "omega_zeta_within" / "sigma_zeta_within" / ... (contemporaneous) and "omega_zeta_between" / ... (between-person), plus "nu_within" (wave-specific intercepts) and "nu_between" (random-intercept means). The default matrices for these models is the temporal, within-person and between-person block, mirroring the panelvar default.

Use time to plot one wave; without it every wave gets its own plot, titled with the matrix name and the wave. Waves whose parameters were equated by ri_clpm_stationary are collapsed into a single plot, so a stationary structure yields one panel rather than several identical ones. Node labels are the plain variable names of the design matrix rather than the internal latent names. Partial directed correlations are not available here, because the RI-CLPM has no PDC parameters and hence no standard errors for them; use getmatrix(x, "PDC", time = ) for the point estimates.

Examples

Run this code
# \donttest{
### Example from ?ggm ###
# Load bfi data from psych package:
library("psychTools")
data(bfi)

# Also load dplyr for the pipe operator:
library("dplyr")

# Let's take the agreeableness items, and gender:
ConsData <- bfi %>% 
  select(A1:A5, gender) %>% 
  na.omit # Let's remove missingness (otherwise use Estimator = "FIML)

# Define variables:
vars <- names(ConsData)[1:5]

# Let's fit an empty GGM:
mod0 <- ggm(ConsData, vars = vars)

# Run the model:
mod0 <- mod0 %>% runmodel

# Labels:
labels <- c(
  "indifferent to the feelings of others",
  "inquire about others' well-being",
  "comfort others",
  "love children",
  "make people feel at ease")

# Plot the CIs:
CIplot(mod0,  "omega", labels = labels, labelstart = 0.2)

### Example from ?gvar ###
library("dplyr")
library("graphicalVAR")

beta <- matrix(c(
  0,0.5,
  0.5,0
),2,2,byrow=TRUE)
kappa <- diag(2)
simData <- graphicalVARsim(50, beta, kappa)

# Form model:
model <- gvar(simData)

# Evaluate model:
model <- model %>% runmodel

# Plot the CIs:
CIplot(model,  "beta")
# }

Run the code above in your browser using DataLab