Description Usage Arguments Value Author(s) References Examples
View source: R/check.ordered.to.pa.R
Receives a BN structure and a data set, then verifies if there are ordered variables. In a positive case return TRUE.
1 | check.ordered.to.pa(bn.structure, data.to.work)
|
bn.structure |
is a BN structure learned from data used to identify if the variable is endogenous or exogenous when building the PA model. |
data.to.work |
is a data set containing the variables of the BN. |
a data frame with ordered variables.
Elias Carvalho
HAYES, A F; PREACHER, K J. Statistical mediation analysis with a multicategorical independent variable. British Journal of Mathematical and Statistical Psychology, v. 67, n. 3, p. 451-470, 2014.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Clean environment
closeAllConnections()
rm(list=ls())
# Set enviroment
# setwd("~/your working directory")
# Load packages
library(bnpa)
# Load the dataset
data(dataQualiN) # Pre-Loaded
# Build the BN structure
bn.structure<-bnlearn::hc(dataQualiN)
# Show the BN structure learned
bnlearn::graphviz.plot(bn.structure)
# Tranforms variables A and B in ordered factor
dataQualiN$A <- as.ordered(dataQualiN$A)
dataQualiN$B <- as.ordered(dataQualiN$B)
# Generates a list with variables to be ordered and exogenous variables
cat.var.to.use.in.pa <- bnpa::check.ordered.to.pa(bn.structure, dataQualiN)
# Show the variables
cat.var.to.use.in.pa
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.