Title: | Contingency Measure-Based Networks for Binary Time Series |
---|---|
Description: | The ConNEcT approach investigates the pairwise association strength of binary time series by calculating contingency measures and depicts the results in a network. The package includes features to explore and visualize the data. To calculate the pairwise concurrent or temporal sequenced relationship between the variables, the package provides seven contingency measures (proportion of agreement, classical & corrected Jaccard, Cohen's kappa, phi correlation coefficient, odds ratio, and log odds ratio), however, others can easily be implemented. The package also includes non-parametric significance tests, that can be applied to test whether the contingency value quantifying the relationship between the variables is significantly higher than chance level. Most importantly this test accounts for auto-dependence and relative frequency.See Bodner et al.(2021) <doi: 10.1111/bmsp.12222>.Finally, a network can be drawn. Variables depicted the nodes of the network, with the node size adapted to the prevalence. The association strength between the variables defines the undirected (concurrent) or directed (temporal sequenced) links between the nodes. The results of the non-parametric significance test can be included by depicting either all links or only the significant ones. Tutorial see Bodner et al.(2021) <doi:10.3758/s13428-021-01760-w>. |
Authors: | Nadja Bodner [aut, cre], Eva Ceulemans [ctb, rev] |
Maintainer: | Nadja Bodner <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.7.27 |
Built: | 2025-02-19 05:00:37 UTC |
Source: | https://github.com/cran/ConNEcT |
During an attachment study, a mother and her child (middle childhood; age between eight and 12) were videotaped while working on a three-minutes stressful puzzle task. The interaction was coded in two-second intervals for the presence and absence of positive, negative, and task related behavior. The dataset contains seven variables and 90 time intervals.
AttachmentData
AttachmentData
A data frame with 90 rows and 7 variables:
mother's positive behavior
mother's negative behavior
mother is working on the task alone
mother and child are working on the task together
child's positive behavior
child's negative behavior
child is working on the task alone
Adinda Dujardin & Guy Bosmans [email protected]
Bodner, N., Bosmans, G., Sannen, J., Verhees, M., & Ceulemans, E. (2019). Unraveling middle childhood attachment-related behavior sequences using a micro-coding approach. PLOS ONE, 14(10), e0224372. https://doi.org/10.1371/journal.pone.0224372
Depict the relative frequencies (and conditional probabilities) of a binary time series in a barplot
## S3 method for class 'conData' barplot(height, plottype = "RelFreq", color = NULL, legend = TRUE, ...)
## S3 method for class 'conData' barplot(height, plottype = "RelFreq", color = NULL, legend = TRUE, ...)
height |
conData object |
plottype |
needs to be specified if 'RelFreq' only the relative frequency is depicted if 'All' both the relative frequency and the conditional probabilities are depicted |
color |
string of chars contanig as many colornames as variables in the object (default='gray') |
legend |
indicates whether you want to include a legend or not |
... |
parameters to be passed on to barplot |
barplot
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c(rep(c(0,0,0,1,1),20),rep(c(0,1,1,1,1),20)), ifelse(rnorm(200,0,1)<0.95,1,0), c(ifelse(rnorm(100,0,1)<0.7,1,0),ifelse(rnorm(100,0,1)<0.7,0,1)), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') fancy.col <- c('purple','slateblue','royalblue','cyan4', 'green3','olivedrab3') PersData <- conData(ExampleData) barplot(PersData, plottype='RelFreq', color=fancy.col) barplot(PersData, plottype='All', color=fancy.col) data(SymptomData) Sdata <- conData(SymptomData) FANCY= c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') barplot(Sdata,plottype='RelFreq', color = FANCY)
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c(rep(c(0,0,0,1,1),20),rep(c(0,1,1,1,1),20)), ifelse(rnorm(200,0,1)<0.95,1,0), c(ifelse(rnorm(100,0,1)<0.7,1,0),ifelse(rnorm(100,0,1)<0.7,0,1)), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') fancy.col <- c('purple','slateblue','royalblue','cyan4', 'green3','olivedrab3') PersData <- conData(ExampleData) barplot(PersData, plottype='RelFreq', color=fancy.col) barplot(PersData, plottype='All', color=fancy.col) data(SymptomData) Sdata <- conData(SymptomData) FANCY= c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') barplot(Sdata,plottype='RelFreq', color = FANCY)
Removes not binary columns from multivariate time series data and calculates a table of relative frequency and auto-dependency for each binary variable
conData(data)
conData(data)
data |
Binary time-points-by-variable matrix |
A conData-object including:
data
Binary data in time points to variable format.
probs
Table of relative frequency and auto-dependence for each variable.
varNames
The names of all variables.
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c( rep(c(0,0,0,1,1),20), rep(c(0,1,1,1,1),20) ), ifelse(rnorm(200,0,1)<0.95,1,0), c( ifelse(rnorm(100,0,1)<0.7,1,0), ifelse(rnorm(100,0,1)<0.7,0,1) ), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') conData(ExampleData) data(SymptomData) Sdata <- conData(SymptomData) Sdata$probs
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c( rep(c(0,0,0,1,1),20), rep(c(0,1,1,1,1),20) ), ifelse(rnorm(200,0,1)<0.95,1,0), c( ifelse(rnorm(100,0,1)<0.7,1,0), ifelse(rnorm(100,0,1)<0.7,0,1) ), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') conData(ExampleData) data(SymptomData) Sdata <- conData(SymptomData) Sdata$probs
Calculate contingency measure values of a (lagged) time series matrix
conMx(data, data2 = NULL, lag = 0, conFun)
conMx(data, data2 = NULL, lag = 0, conFun)
data |
Binary time-points-by-variable matrix |
data2 |
Second binary time-points-by-variable matrix (optional) |
lag |
Non-negative integer indicating how many time points the second variable is lagged (default 0) |
conFun |
Contingency measure function (calculating the contingency value between two binary vectors). Built in: funPropAgree, funClassJacc, funKappa, funCorrJacc, funOdds, funLogOdds, funPhiCC |
list with two elements:
value
Matrix of pairwise calculated contingency measures
para
Parameter settings lag
, funName
and varNames
conMx(cbind(c(1,0,1,0,1,0,1),c(1,1,1,1,0,0,0)),lag=1,conFun=funCorrJacc)
conMx(cbind(c(1,0,1,0,1,0,1),c(1,1,1,1,0,0,0)),lag=1,conFun=funCorrJacc)
Calculate the link strength between multiple behaviors and return them as a matrix (optionally discarting all non-significant links)
conNEcT( data, lag = 0, conFun, test = FALSE, typeOfTest = "permut", adCor = TRUE, nBlox = 10, nReps = 100, signLev = 0.05 )
conNEcT( data, lag = 0, conFun, test = FALSE, typeOfTest = "permut", adCor = TRUE, nBlox = 10, nReps = 100, signLev = 0.05 )
data |
Binary time-points-by-variable matrix |
lag |
Non-negative integer indicating how many time points the second variable is lagged (default 0) |
conFun |
Contingency measure function (calculating the contingency value between two binary vectors). Built in: funPropAgree, funClassJacc, funKappa, funCorrJacc, funOdds, funLogOdds, funPhiCC |
test |
Logic indicationg whether a significance test is executed (TRUE) or not (FALSE;default) |
typeOfTest |
String indicating whether a model-based ('model') or a permutation-based ('permut'; default) data generation approach is used. |
adCor |
Logic indicating the auto-dependence correction should be applied (TRUE; default) or not (FALSE) |
nBlox |
Number indicating the number of segments (default 10). Necessary for permutation-based test, accounting for auto-dependence (typeOfTest='permut'; adCor=TRUE) |
nReps |
Number of replicates/samples that is used to generate the test distribution |
signLev |
Significance level of the test (default 0.05) |
A conNEcT-object including
allLinks
Matrix of pairwise calculated contingency measures
signLinks
Matrix of pairwise calculated contingency measures containing only significant links
(others are set to 0)
pValue
P-values for the one-sided upper significance test
para
Parameter settings containing
lag
, test
,typeOfTest
,
adCor
, nBlox
, nReps
,
funName
, and varNames
probs
Table of relative frequency and auto-dependency
netdata=cbind(rep(c(1,1,1,1,1,0,0,0,0,0),100), rep(c(0,0,1,1,1,1,0,0,0,0),100)) conNEcT(netdata,lag=1,conFun=funKappa,test=TRUE,nBlox=5)
netdata=cbind(rep(c(1,1,1,1,1,0,0,0,0,0),100), rep(c(0,0,1,1,1,1,0,0,0,0),100)) conNEcT(netdata,lag=1,conFun=funKappa,test=TRUE,nBlox=5)
Compare different lags in a contingency profile
conProf(data, maxlag, conFun)
conProf(data, maxlag, conFun)
data |
Binary time-points-by-variable matrix |
maxlag |
Positive integer indicating how many lags should be investigated |
conFun |
Contingency measure function (calculating the contingency value between two binary vectors). Built in: funPropAgree, funClassJacc, funKappa, funCorrJacc, funOdds, funLogOdds, funPhiCC |
A conProf-object consisting of
value
Contingency matrices for different lags
para
Parameters including maxlag
, funName
and varNames
IntData <- cbind(rep(rep(c(0,0,1,0,1,0,1,0,0,0),each=5),times=5), rep(rep(c(1,0,0,0), each=10), times=25)) colnames(IntData) <- c('Var1','Var2') conProf(IntData,maxlag=10,conFun=funClassJacc)
IntData <- cbind(rep(rep(c(0,0,1,0,1,0,1,0,0,0),each=5),times=5), rep(rep(c(1,0,0,0), each=10), times=25)) colnames(IntData) <- c('Var1','Var2') conProf(IntData,maxlag=10,conFun=funClassJacc)
Test significance
conTest( data, lag = 0, conFun, typeOfTest = "permut", adCor = TRUE, nBlox = 10, nReps = 100 )
conTest( data, lag = 0, conFun, typeOfTest = "permut", adCor = TRUE, nBlox = 10, nReps = 100 )
data |
Binary time-points-by-variable matrix |
lag |
Non-negative integer indicating how much the second variable is lagged (default 0) |
conFun |
Contingency measure function (calculating the contingency value between two binary vectors). Built in: FunClassJacc, FunCorrJacc, FunKappa, FunOdds, FunLogOdds, FunPropAgree,FunPhiCC |
typeOfTest |
String indicating whether a model-based ('model') or a permutation-based ('permut'; default) data generation approach is used. |
adCor |
Logic indicating the auto-dependence correction should be applied (TRUE; default) or not (FALSE) |
nBlox |
Number indicating the number of segments (default 10). Necessary for permutation-based test, accounting for auto-dependence (typeOfTest='permut'; adCor=TRUE) |
nReps |
Number of replicates/samples that is used to generate the test distribution |
A conTest-object including
allLinks
Matrix of pairwise calculated contingency measures
percentile
Matrix of raw percentiles, situating the observed value in the sample distribution
pValue
Matrix of the p-values (upper one-sided significance test) calculated by subtracting the percentile from 1.
para
: Saving the parameter settings for
typeOfTest
, adCor
, nBlox
, nReps
, funName
, lag
, varNames
samples
Saved generated replicates/samples for each variable combination under $NameVariable1$NameVariable2
signdata=cbind(c(1,0,1,0,1,0,1,0),c(1,1,1,1,0,0,0,0),c(0,0,0,0,0,0,1,1)) colnames(signdata) <-c ('momangry', 'momsad','adoangry') conTest(data=signdata,lag=1,conFun=funClassJacc,typeOfTest='model', adCor=FALSE)
signdata=cbind(c(1,0,1,0,1,0,1,0),c(1,1,1,1,0,0,0,0),c(0,0,0,0,0,0,1,1)) colnames(signdata) <-c ('momangry', 'momsad','adoangry') conTest(data=signdata,lag=1,conFun=funClassJacc,typeOfTest='model', adCor=FALSE)
These data was collected during a nine-minutes problem-solving family interaction between two parents and their adolescent son or daughter During this interaction, the presence and absence of expressions of ‘anger’, ‘dysphoric’ feelings and ‘happiness‘ were coded for each family member in an event-basis way (i.e., noting when a certain behavior starts and when it stops). The codes were subsequently restructured into second-to-second interval data, resulting in a 540 seconds by nine variables binary dataset.
FamilyData
FamilyData
A data frame with 540 rows and 9 variables:
mother expressing anger
father expressing anger
adolescent expressing anger
mother expressing dysphoric feelings
father expressing dysphoric feelings
adolescent expressing dysphoric feelings
mother expressing happy feelings
father expressing happy feelings
adolescent expressing happy feelings
Lisa Sheeber [email protected]
Sheeber, L. B., Kuppens, P., Shortt, J. W., Katz, L. F., Davis, B., & Allen, N. B. (2012). Depression is associated with the escalation of adolescents’ dysphoric behavior during interactions with parents. Emotion, 12(5), 913–918. https://doi.org/10.1037/a0025784
Allen, N. B., Kuppens, P., & Sheeber, L. B. (2012). Heart rate responses to parental behavior in depressed adolescents. Biological Psychology, 90(1), 80–87. https://doi.org/10.1016/j.biopsycho.2012.02.013
Bodner, N., Kuppens, P., Allen, N. B., Sheeber, L. B., & Ceulemans, E. (2018). Affective family interactions and their associations with adolescent depression: A dynamic network approach. Development and Psychopathology, 30(4), 1459–1473. https://doi.org/10.1017/S0954579417001699
Calculate the classic Jaccard index between two vectors
funClassJacc(vec1, vec2)
funClassJacc(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the classic Jaccard index and
funName
name of the function
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funClassJacc(data1,data2)
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funClassJacc(data1,data2)
Calculate the corrected Jaccard index between two vectors
funCorrJacc(vec1, vec2)
funCorrJacc(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the corrected Jaccard index and
funName
name of the function
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funCorrJacc(data1,data2)
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funCorrJacc(data1,data2)
Calculate Cohen's kappa between two vectors
funKappa(vec1, vec2)
funKappa(vec1, vec2)
vec1 |
Vector of binary time series (NA not allowed) |
vec2 |
Vector of binary time series (equal length as vec1, NA not allowed) |
list with two elements
value
of the Cohen's kappa and
funName
name of the function
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funKappa(data1,data2)
data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funKappa(data1,data2)
Calculate the log odds ratio between two vectors
funLogOdds(vec1, vec2)
funLogOdds(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the log odds ratio and
funName
name of the function
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funLogOdds(data1,data2)
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funLogOdds(data1,data2)
Calculate the odds ratio between two vectors
funOdds(vec1, vec2)
funOdds(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the odds ratio and
funName
name of the function
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funOdds(data1,data2)
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funOdds(data1,data2)
Calculate the phi correllation coefficient index between two vectors
funPhiCC(vec1, vec2)
funPhiCC(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the phi correlation coefficient and
funName
name of the function
set.seed(1234) data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funPhiCC(data1,data2)
set.seed(1234) data1<-rep(c(1,0,1,1),25) data2<-ifelse(rnorm(100,0,1)<0.7,0,1) funPhiCC(data1,data2)
Calculate the proportion of agreement between two vectors
funPropAgree(vec1, vec2)
funPropAgree(vec1, vec2)
vec1 |
Vector of binary time series (no missing values) |
vec2 |
Vector of binary time series (equal length as vec1, no missing values) |
list with two elements
value
of the proportion of agreement and
funName
name of the function
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funPropAgree(data1,data2)
data1 <- rep(c(1,0,1,1),25) data2 <- ifelse(rnorm(100,0,1)<0.7,0,1) funPropAgree(data1,data2)
Retrieve (conditional) probabilities from binary time series
getProb(ts)
getProb(ts)
ts |
Binary time series vector |
List of three elements
p1
the prevalence p(X(t)=1) and
p1|1
and p1|0
the two auto-conditional probabilities p(X(t)=1|X(t-1)=1) & p(X(t)=1|X(t-1)=0)
getProb(c(1,0,1,0,1,0,1,1,1,1,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0))
getProb(c(1,0,1,0,1,0,1,1,1,1,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0))
Plot histogram matrix of the significance test
## S3 method for class 'conTest' hist(x, signLev = 0.05, ...)
## S3 method for class 'conTest' hist(x, signLev = 0.05, ...)
x |
Object of the class conTest |
signLev |
Significance level (default .05) |
... |
Graphical parameters to be passed to hist() |
Histogram matrix with sample distribution and value from observed data for each variable combination
data(SymptomData) test.result <- conTest(SymptomData[,c(2,6,8)],conFun=funClassJacc, typeOfTest='permut',nBlox=10,adCor=TRUE,nReps=100) hist(test.result)
data(SymptomData) test.result <- conTest(SymptomData[,c(2,6,8)],conFun=funClassJacc, typeOfTest='permut',nBlox=10,adCor=TRUE,nReps=100) hist(test.result)
Lag a matrix
lagthemats(data, lag)
lagthemats(data, lag)
data |
Binary time-points-by-variable matrix |
lag |
Non-negative integer indicating the number of time points the second variable is lagged (default 0) |
laggeddata
Matrix in which all variables are lagged lag
time points
lagthemats(cbind(c(1,0,1,0,1,0,1),c(1,1,1,1,0,0,0)),lag=2)
lagthemats(cbind(c(1,0,1,0,1,0,1),c(1,1,1,1,0,0,0)),lag=2)
This function generates a new time serie that is similar to the original one in relative frequency and auto-dependence, by drawing samples time point per time point from a Bernoulli distribution with the different conditional probabilities as parameter, depending on the state of the previous time point.
modelAD(vec)
modelAD(vec)
vec |
Time series vector |
Time series vector that is similar to the original one in relative frequency and auto-dependence
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) modelAD(ts)
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) modelAD(ts)
This function generates a new time serie that is similar to the original one in relative frequency, but not in auto-dependence by drawing from a Bernoulli distribution with the relative frequency as parameter.
modelNO(vec)
modelNO(vec)
vec |
Time series vector |
Time series vector that is similar to the original one considering relative frequency
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) modelNO(ts)
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) modelNO(ts)
This function generates a new time serie with exactly the same relative frequency as the original one, and a similar auto-dependence by cutting the original variable in segments and shuffeling these segements.
permutAD(vec, nBloks = 10)
permutAD(vec, nBloks = 10)
vec |
Time series vector |
nBloks |
positive integer indicating the number of segements/blocks (default 10) |
Time series vector with exactly the same relative frequency and a similar auto-dependence as the original vector
ts=rep(c(1,1,1,1,1,0,0,0),15) permutAD(ts,nBloks=11)
ts=rep(c(1,1,1,1,1,0,0,0),15) permutAD(ts,nBloks=11)
This function generates a new time serie with exactly the same relative frequency as the original one, but with a lower auto-dependence by shuffeling all time points.
permutNO(vec)
permutNO(vec)
vec |
Time series vector |
Time series vector with exactly the same relative frequency as the original vector
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) permutNO(ts)
ts=rep(c(1,1,1,1,1,0,0,0,0,0),15) permutNO(ts)
Visualize the course of the variables over time
## S3 method for class 'conData' plot(x, plottype = "interval", color = NULL, ...)
## S3 method for class 'conData' plot(x, plottype = "interval", color = NULL, ...)
x |
conData object |
plottype |
Character specified as 'interval', 'line', or 'both' |
color |
Character string of colornames for all variables (default='black') |
... |
Parameters to be transfered to the plot function |
Plot visualizing the course of the variables over time
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c(rep(c(0,0,0,1,1),20), rep(c(0,1,1,1,1),20)), ifelse(rnorm(200,0,1)<0.95,1,0), c( ifelse(rnorm(100,0,1)<0.7,1,0), ifelse(rnorm(100,0,1)<0.7,0,1) ), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') PersData <- conData(ExampleData) fancy.col=c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') plot(PersData,plottype='line',color=fancy.col) data(SymptomData) Sdata <- conData(SymptomData) fancy.col=c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') plot(Sdata, plottype='interval',color=fancy.col)
ExampleData <- cbind(rep(c(0,1),100), rep(c(0,0,0,0,0,1,1,1,1,1),20), c(rep(c(0,0,0,1,1),20), rep(c(0,1,1,1,1),20)), ifelse(rnorm(200,0,1)<0.95,1,0), c( ifelse(rnorm(100,0,1)<0.7,1,0), ifelse(rnorm(100,0,1)<0.7,0,1) ), ifelse(rnorm(200,0,1)<(-0.98),1,0)) colnames(ExampleData) <- c('Var 1','Var 2','Var 3', 'Var 4','Var 5','Var 6') PersData <- conData(ExampleData) fancy.col=c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') plot(PersData,plottype='line',color=fancy.col) data(SymptomData) Sdata <- conData(SymptomData) fancy.col=c('purple','slateblue', 'royalblue', 'cyan4', 'green3', 'olivedrab3', 'orange', 'orangered') plot(Sdata, plottype='interval',color=fancy.col)
Draw contingency profiles
## S3 method for class 'conProf' plot(x, ...)
## S3 method for class 'conProf' plot(x, ...)
x |
Object of a conProf class |
... |
Parameters to be transfered to the plot function |
Contingency profile matrix
IntData <- cbind(rep(rep(c(0,0,1,0,1,0,1,0,0,0),each=5),times=5), rep(rep(c(1,0,0,0), each=10), times=25)) colnames(IntData) <- c('Var1','Var2') CP <- conProf(IntData,maxlag=10,conFun=funClassJacc) plot(CP)
IntData <- cbind(rep(rep(c(0,0,1,0,1,0,1,0,0,0),each=5),times=5), rep(rep(c(1,0,0,0), each=10), times=25)) colnames(IntData) <- c('Var1','Var2') CP <- conProf(IntData,maxlag=10,conFun=funClassJacc) plot(CP)
Draws a Network figure
qgraph.conNEcT(x, signOnly = TRUE, ...)
qgraph.conNEcT(x, signOnly = TRUE, ...)
x |
A conNEcT-object |
signOnly |
Logic indicating whether significant links should be depicted (TRUE; default) or not (FALSE) |
... |
Parameter settings for qgraph |
A network plot
ADOangry=rep(c(1,1,1,1,1,0,0,0,0,0),100) MAangry=rep(c(0,0,1,1,1,1,0,0,0,0),100) MAsad=rep(c(0,0,1,1,1,1,0,0,0,0),100) netdata <- cbind(ADOangry,MAangry,MAsad) netnet <- conNEcT(netdata,lag=1,conFun=funKappa, test=TRUE,nBlox=5) qgraph.conNEcT(netnet,signOnly=FALSE)
ADOangry=rep(c(1,1,1,1,1,0,0,0,0,0),100) MAangry=rep(c(0,0,1,1,1,1,0,0,0,0),100) MAsad=rep(c(0,0,1,1,1,1,0,0,0,0),100) netdata <- cbind(ADOangry,MAangry,MAsad) netnet <- conNEcT(netdata,lag=1,conFun=funKappa, test=TRUE,nBlox=5) qgraph.conNEcT(netnet,signOnly=FALSE)
In this depression symptoms data, a patient reported for each week on the presence and absence of eight depression symptoms. The dataset contains the reports of the eight variables for 145 subsequent weeks.
SymptomData
SymptomData
A data frame with 145 rows and 8 variables:
core depression symptoms including depressed mood and/or diminished interest
lack of energy
eating problems and weight loss or gain
sleeping problems including hyposomnia or hypersomnia
psychomotor problems
feelings of guilt
cognitive problems
preoccupation with death
Bettina Hosenfeld & Peter de Jonge [email protected]
Hosenfeld, B., Bos, E. H., Wardenaar, K. J., Conradi, H. J., van der Maas, H. L. J., Visser, I., & de Jonge, P. (2015). Major depressive disorder as a nonlinear dynamic system: Bimodality in the frequency distribution of depressive symptoms over time. BMC Psychiatry, 15(1), 222. https://doi.org/10.1186/s12888-015-0596-5
Bodner, N., Bringmann, L., Tuerlinckx, F., De Jonge, P., & Ceulemans, E. (in press). ConNEcT: A novel network approach for investigating the co-occurrence of binary psychopathological symptoms over time. Psychometrika. https://doi.org/10.1007/s11336-021-09765-2