Learn R Programming

exametrika (version 1.1.0)

BNM: Bayesian Network Model

Description

performs Bayesian Network Model with specified graph structure

Usage

BNM(
  U,
  Z = NULL,
  w = NULL,
  na = NULL,
  g = NULL,
  adj_file = NULL,
  adj_matrix = NULL
)

Value

nobs

Sample size. The number of rows in the dataset.

testlength

Length of the test. The number of items included in the test.

crr

correct response ratio

TestFitIndices

Overall fit index for the test.See also TestFit

adj

Adjacency matrix

\
param

Learned Parameters

CCRR_table

Correct Response Rate tables

Arguments

U

U is either a data class of exametrika, or raw data. When raw data is given, it is converted to the exametrika class with the dataFormat function.

Z

Z is a missing indicator matrix of the type matrix or data.frame

w

w is item weight vector

na

na argument specifies the numbers or characters to be treated as missing values.

g

Specify a graph object suitable for the igraph class.

adj_file

specify CSV file where the graph structure is specified.

adj_matrix

specify adjacency matrix.

Details

This function performs a Bayesian network analysis on the relationships between items. This corresponds to Chapter 8 of the text. It uses the igraph package for graph visualization and checking the adjacency matrix. You need to provide either a graph object or a CSV file where the graph structure is specified.

Examples

Run this code
# \donttest{
# Create a Directed Acyclic Graph (DAG) structure for item relationships
# Each row represents a directed edge from one item to another
DAG <-
  matrix(
    c(
      "Item01", "Item02", # Item01 influences Item02
      "Item02", "Item03", # Item02 influences Item03
      "Item02", "Item04", # Item02 influences Item04
      "Item03", "Item05", # Item03 influences Item05
      "Item04", "Item05" # Item04 influences Item05
    ),
    ncol = 2, byrow = TRUE
  )

# Convert the DAG matrix to an igraph object for network analysis
g <- igraph::graph_from_data_frame(DAG)
g

# Create adjacency matrix from the graph
# Shows direct connections between items (1 for connection, 0 for no connection)
adj_mat <- as.matrix(igraph::as_adjacency_matrix(g))
print(adj_mat)

# Fit Bayesian Network Model using the specified adjacency matrix
# Analyzes probabilistic relationships between items based on the graph structure
result.BNM <- BNM(J5S10, adj_matrix = adj_mat)
result.BNM
# }

Run the code above in your browser using DataLab