condir: Examples

Condir

Below we provide two basic examples that use the R package condir. The first example regards data coming from a single group, and the second example data coming from two groups. More details about the package condir are described in the paper by: Krypotos, A. M., Klugkist, I., & Engelhard, I. M. (2017). Bayesian hypothesis testing for human threat conditioning research: An introduction and the condir R package. European Journal of Psychotraumatology, 8.

Installation

You can install condir via cran using the following command:

install.packages("condir")

For loading condir, use the line below. Please note that for using condir you have to load it at every new R session.

library(condir)

One group example

Here we show a single group example. Specifically, we first simulate data from a normal distribution for two stimuli, the cs1 and the cs2.

set.seed(1000)
cs1 <- rnorm(50, 5, 5)
cs2 <- rnorm(50, 4.5, 5)

These data correspond to the conditioned responses during the presentation of each stimulus (i.e., the cs1 and the cs2). For comparing the two stimuli, we can use the csCompare function in condir as follow.

tmp <- csCompare(cs1, cs2)
tmp

The data can be plotted with the csPlot function.

csPlot(cs1, cs2, ylab = "CRs")

In order to make a basic report of the data, we use the csReport function.

csReport(tmp)

Lastly, the csSensitivity function can be used for a sensitivity analysis, with the csRobustnessPlot function plotting the results.

set.seed(1000)
tmp <- csSensitivity(cs1, cs2)
csRobustnessPlot(cs1, cs2, BF01 = TRUE)

The results are now reported with the csReport function.

csReport(csSensitivityObj = tmp)

Two groups example

The same steps as above are used for the two group example. The only difference is that we now have to define the group allocation by using the group argument -- see the first line below. Apart from that, the code is the same as in the example above. That is why we provide the code for this example in a single chunk of code.

set.seed(1000)
group <- factor(rep(1:2, length(cs1)/2))
tmp <- csCompare(cs1, cs2, group = group)
tmp
csPlot(cs1, cs2, group = group, ylab = "CRs")
csReport(csCompareObj = tmp)
tmp <- csSensitivity(cs1, cs2)
csRobustnessPlot(cs1, cs2, group, BF01 = TRUE)
csReport(csSensitivityObj = tmp)


Try the condir package in your browser

Any scripts or data that you put into this service are public.

condir documentation built on Jan. 13, 2021, 12:25 p.m.