CIplot: Plot Analytic Confidence Intervals

Description Usage Arguments Value Author(s) Examples

View source: R/f_convenience_CIplot.R

Description

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

Usage

1
2
3
4
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)

Arguments

x

A psychonetrics model.

matrices

Vector of strings indicating the matrices to plot CIs for

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

Value

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

Author(s)

Sacha Epskamp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
### 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")

psychonetrics documentation built on Oct. 26, 2021, 1:06 a.m.