Title: | Network Applications to Facial Communication Data |
---|---|
Description: | Functions to analyze and visualize communication data, based on network theory and resampling methods. Farine, D. R. (2017) <doi:10.1111/2041-210X.12772>; Carsey, T., & Harden, J. (2014) <doi:10.4135/9781483319605>. Primarily targeted at datasets of facial expressions coded with the Facial Action Coding System. Ekman, P., Friesen, W. V., & Hager, J. C. (2002). "Facial action coding system - investigator's guide" <https://www.paulekman.com/facial-action-coding-system/>. |
Authors: | Alex Mielke [aut], Bridget M. Waller [aut], Claire Perez [aut], Alan V. Rincon [aut, cre], Julie Duboscq [aut], Jerome Micheletta [aut] |
Maintainer: | Alan V. Rincon <[email protected]> |
License: | Apache License (>= 2.0) |
Version: | 0.5.0 |
Built: | 2025-02-21 05:17:58 UTC |
Source: | https://github.com/netfacs/netfacs |
Add inactive (missing) single units
add_inactive_single_units(d, single.units)
add_inactive_single_units(d, single.units)
d |
A dataframe, result of |
single.units |
A character vector of single AUs |
Calculate combination size
calculate_combination_size(x)
calculate_combination_size(x)
x |
A character vector of AU combinations, sep by _ |
A vector
For all dyadic combinations that appear in the test dataset, this function returns the probability of A occurring (P(A)), the probability of B occurring (P(B)), the probability of A and B occurring simultaneously (P(AandB)) and, the probability of A given B (P(A|B)).
conditional_probabilities(netfacs.data)
conditional_probabilities(netfacs.data)
netfacs.data |
An object of class |
A summary tibble
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 50, combination.size = 2 ) conditional_probabilities(angry.face)
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 50, combination.size = 2 ) conditional_probabilities(angry.face)
Define truth for AUs active in different contexts
define_contexts(aus, n_active_aus, contexts = NULL, au_fidelity = 1)
define_contexts(aus, n_active_aus, contexts = NULL, au_fidelity = 1)
aus |
A character vector of AUs |
n_active_aus |
A numeric vector, the same length as contexts, indicating the number of AUs active per context. |
contexts |
A character vector of contexts |
au_fidelity |
A number between 1 and 0.5, indicating the probability that an AU is active in a context. |
A matrix of probabilities with contexts in rows and AUs in columns
Joint probability distribution of AUs
define_joint_prob(aus, n_jp = 2, min_jp = 0.5)
define_joint_prob(aus, n_jp = 2, min_jp = 0.5)
aus |
A character vector of AUs |
n_jp |
Number of joint probabilities >0 |
min_jp |
Minimum joint probability. Must be between 0 and 1 |
The function takes all single elements in a netfacs object, and plots the distribution of probabilities under the null hypothesis, marking where the observed probability falls
distribution.plot(netfacs.data)
distribution.plot(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a ggplot showing for each element the distribution of expected probabilities (blue) and the observed probability (black line)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) # show distribution of AU4 distribution.plot(netfacs.data = angry.face)$"4"
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) # show distribution of AU4 distribution.plot(netfacs.data = angry.face)$"4"
The function takes all single elements in a netfacs object, and plots the observed value and the expected value based on all randomisations
element.plot(netfacs.data)
element.plot(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a ggplot showing for each element the observed probability and expected probability
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) # plot all element.plot(netfacs.data = angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) # plot all element.plot(netfacs.data = angry.face)
This function is defunct Please see specificity_increase
instead
element.specificity(netfacs.data)
element.specificity(netfacs.data)
netfacs.data |
object resulting from |
Data from the Extended Cohn-Kanade database, FACS data and emotions for posed images
data(emotions_set)
data(emotions_set)
An object of class.
Lucey P, Cohn JF, Kanade T, Saragih J, Ambadar Z, Matthews I (2010) The extended Cohn-Kanade dataset (CK+): A complete dataset for action unit and emotion-specified expression. In: 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition - Workshops, CVPRW 2010. pp 94-101
Compares the observed and expected information content of the dataset.
entropy_overall(x)
entropy_overall(x)
x |
An object of class |
Function returns a summary tibble
containing the observed entropy, expected entropy and entropy ratio
(observed / expected) of the dataset. Observed entropy is calculated using
Shannon's information entropy formula . Expected entropy is based on randomization (shuffling the observed
elements while maintaining the number of elements per row) and represents
the maximum entropy that a dataset with the same properties as this one can
reach. Ratios closer to 0 are more ordered; ratios closer to 1 are more
random.
Shannon, C. E. (1948). A Mathematical Theory of Communication.
Bell System Technical Journal.
https://doi.org/10.1002/j.1538-7305.1948.tb01338.x
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) entropy_overall(angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) entropy_overall(angry.face)
This function is deprecated. Please see entropy_overall
instead
entropy.overall(x, netfacs.data)
entropy.overall(x, netfacs.data)
x |
An object of class |
netfacs.data |
deprecated. Please use x instead. |
lenght(vector), nrow(matrix), nrow(dataframe)
equal_observations(x, ...)
equal_observations(x, ...)
x |
Object to compare number of observations |
... |
Additional objects to compare number of observations |
Logical
The function takes all combination size in a netfacs object, and plots the distribution of ratios between the observed value and all randomisations
event_size_plot(netfacs.data) event.size.plot(netfacs.data)
event_size_plot(netfacs.data) event.size.plot(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a ggplot showing for each combination size the observed and expected probabilities of occurrance
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) event_size_plot(angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) event_size_plot(angry.face)
Extract active elements from matrix
get_active_elements(m)
get_active_elements(m)
m |
A binary matrix where 1 indicates an element was active. colnames(m) must contain the element names |
A list of vectors
netfacs
objectExtract used data from a netfacs
object
get_data(x, condition = "all")
get_data(x, condition = "all")
x |
extract data from the test condition of a |
condition |
one of "all" (default), "test" or "null". |
netfacs
objectChecks if argument is a netfacs
object
is.netfacs(x)
is.netfacs(x)
x |
An R object |
netfacs_multiple
objectChecks if argument is a netfacs_multiple
object
is.netfacs_multiple(x)
is.netfacs_multiple(x)
x |
An R object |
netfacs_specificity
objectChecks if argument is a netfacs_specificity
object
is.netfacs_specificity(x)
is.netfacs_specificity(x)
x |
An R object |
Data from the German, English, and French Versions of The Communist Manifesto, to have large datasets to test different functions in this package for now
data(letternet)
data(letternet)
An object of class.
Marx & Engels, 'The Communist Manifesto'
Takes the results of the nefacs object for combinations of 2 elements and
turns them into a network object (class igraph
and
tbl_graph
) that can be used for further plotting and analyses
multiple_netfacs_network( netfacs.list, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL ) multiple.netfacs.network( netfacs.list, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL )
multiple_netfacs_network( netfacs.list, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL ) multiple.netfacs.network( netfacs.list, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL )
netfacs.list |
list of multiple objects resulting from
|
link |
determines how nodes/elements are connected. 'unweighted' gives a 1 to significant connections and 0 to all others; 'weighted' gives the difference between observed and expected probability of co-occurrence; 'raw' just uses the observed probability of co-occurrence; 'SRI' uses the simple ratio index/affinity (probability of co-occurrence/ (probabilities of each element and the combination)) |
significance |
numeric value, determining the p-value below which combinations are considered to be dissimilar enough from the null distribution |
min.count |
numeric value, suggesting how many times a combination should at least occur to be displayed |
min.prob |
numeric value, suggesting the probability at which a combination should at least occur to be displayed |
ignore.element |
vector of elements that will not be considered for the network, e.g. because they are too common or too rare or their interpretation is not relevant here |
Function returns a network object where the nodes are the elements, edges represent their co-occurrence, and the vertex and edge attributes contain all additional information from the netfacs object
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, # only for example combination.size = 2 ) emo.nets <- multiple_netfacs_network(emo.faces)
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, # only for example combination.size = 2 ) emo.nets <- multiple_netfacs_network(emo.faces)
The function takes multiple network objects and plots them next to each other
while keeping the element positions etc constant. Uses ggraph
function
multiple_network_plot(netfacs.graphs, sig.level = 0.01, sig.nodes.only = FALSE) multiple.network.plot(netfacs.graphs, sig.level = 0.01, sig.nodes.only = FALSE)
multiple_network_plot(netfacs.graphs, sig.level = 0.01, sig.nodes.only = FALSE) multiple.network.plot(netfacs.graphs, sig.level = 0.01, sig.nodes.only = FALSE)
netfacs.graphs |
List of network objects resulting from
|
sig.level |
Numeric between 0 and 1. P value used to determine whether nodes are significant. Default = 0.01. |
sig.nodes.only |
Logical. Should only nodes that were significant in _at least_ one of the networks be included in the plots? Default = FALSE. |
Function returns a ggraph
plot showing connections
between nodes in the different networks. Elements that are significantly
more likely to occur than expected are large, non-significant elements are
small, and absent elements are absent.
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, duration = NULL, ran.trials = 10, # only for example control = NULL, random.level = NULL, combination.size = 2 ) emo.nets <- multiple_netfacs_network(emo.faces, min.count = 5) multiple_network_plot(emo.nets)
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, duration = NULL, ran.trials = 10, # only for example control = NULL, random.level = NULL, combination.size = 2 ) emo.nets <- multiple_netfacs_network(emo.faces, min.count = 5) multiple_network_plot(emo.nets)
netfacs
function across multiple
levels of the condition and puts them in a listThis function is deprecated. Please see netfacs_multiple
instead
multiple.netfacs( data, condition = NULL, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = NULL, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
multiple.netfacs( data, condition = NULL, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = NULL, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
data |
A binary matrix with one column per element, and one row per event, consisting of 1 (element was active during that event) and 0 (element was not active). |
condition |
character vector of same length as 'data' that contains information on the condition each event belongs to, so probabilities can be compared across conditions |
duration |
A numeric vector that contains information on the duration of each event; if NULL, all events are assumed to have equal duration. |
ran.trials |
Number of randomisations that will be performed to find the null distribution. |
control |
A list of vectors that are used as control variables. During bootstraps, the ratio of events in each level will be adapted. So, for example, if in the test distribution, there are three angry participants for each happy participant, the null distribution will maintain that ratio. |
random.level |
A character vector of the level on which the randomization should take place. If NULL, the randomization takes place on the event level (i.e., every row can either be selected or not); if a vector is provided, the randomization takes place on the levels of that vector rather than individual events. |
combination.size |
A positive integer, indicating the maximum combination size of element combinations. Higher numbers will increase computation time. Default is 2. |
tail |
Either 'upper.tail' (proportion of null probabilities that are larger than observed probabilities), or 'lower.tail' (proportion of null probabilities that are smaller than observed probabilities); default is 'upper.tail'. |
use_parallel |
Logical, indicating whether randomization or bootstrap
should be parallelized (default is |
n_cores |
Numeric, indicating the number cores to be used for parallelization. Default is 2. |
Function returns for each level of the condition a list equivalent to the results of the netfacs function; can be used to create multiple networks and graphs at the same time
Calculates the pointwise mutual information of units with each other
mutual.information(netfacs.data)
mutual.information(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a dataframe that includes all combinations, their occurrence counts and probabilities, and the pointwise mutual information (standardised between -1 and 1). 1 means seeing one necessitates seeing the other, -1 means one precludes the other
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = NULL, test.condition = NULL, ran.trials = 100, combination.size = 4 ) mutual.information(angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = NULL, test.condition = NULL, ran.trials = 100, combination.size = 4 ) mutual.information(angry.face)
The function takes all elements and dyadic combinations of elements in a netfacs object, goes through all combinations these elements are in, and compares the specificity (strength with which the combination identifies the test condition) of all combinations with the element and the same combinations without the element, to test how much specificity the element adds when added to a signal. Only works for netfacs objects based on comparison between conditions.
mutual.information.condition(netfacs.data)
mutual.information.condition(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a list with two data frames that include all elements and first-order combinations that occur at all, the number of combinations that each element/combination is part of, and how much adding this element to a combination adds on average to its specificity, and how often it occurs
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", null.condition = NULL, ran.trials = 100, combination.size = 4 ) head(mutual.information.condition(angry.face), 20)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", null.condition = NULL, ran.trials = 100, combination.size = 4 ) head(mutual.information.condition(angry.face), 20)
The netfacs
function underlies most other functions in this
package.
It takes the data set and reports the observed and expected
probabilities that elements and combinations of elements occur in this data
set, and whether this differs from a null condition.
netfacs( data, condition = NULL, test.condition = NULL, null.condition = NULL, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = 2, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
netfacs( data, condition = NULL, test.condition = NULL, null.condition = NULL, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = 2, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
data |
A binary matrix with one column per element, and one row per event, consisting of 1 (element was active during that event) and 0 (element was not active). |
condition |
A character vector the same length as 'data' that contains information on the condition each event belongs to, so probabilities can be compared across conditions; if NULL, all events will be tested against a random null condition based on permutations. |
test.condition |
A string, indicating the level of 'condition' that is supposed to be tested. |
null.condition |
A string, indicating the level of 'condition' that is used to create the null distribution of values; if NULL, all levels that are not the test condition will be used. |
duration |
A numeric vector that contains information on the duration of each event; if NULL, all events are assumed to have equal duration. |
ran.trials |
Number of randomisations that will be performed to find the null distribution. |
control |
A list of vectors that are used as control variables. During bootstraps, the ratio of events in each level will be adapted. So, for example, if in the test distribution, there are three angry participants for each happy participant, the null distribution will maintain that ratio. |
random.level |
A character vector of the level on which the randomization should take place. If NULL, the randomization takes place on the event level (i.e., every row can either be selected or not); if a vector is provided, the randomization takes place on the levels of that vector rather than individual events. |
combination.size |
A positive integer, indicating the maximum combination size of element combinations. Higher numbers will increase computation time. Default is 2. |
tail |
Either 'upper.tail' (proportion of null probabilities that are larger than observed probabilities), or 'lower.tail' (proportion of null probabilities that are smaller than observed probabilities); default is 'upper.tail'. |
use_parallel |
Logical, indicating whether randomization or bootstrap
should be parallelized (default is |
n_cores |
Numeric, indicating the number cores to be used for parallelization. Default is 2. |
If the 'condition' and 'test.condition' arguments are specified, the null distribution of probability values are based on bootstraps of the null condition. If the 'condition' argument is not specified, the null distribution is based on random permutations of the data.
For a general overview on how to use the netfacs function and package see
vignette("netfacs_tutorial")
.
An object of class netfacs
, which contains the probabilities
of observing element combinations in the data, along with other useful
information. The resulting object is the basis for most other functions in
this package.
Alex Mielke, Alan V. Rincon
Mielke, A., Waller, B. M., Perez, C., Rincon, A. V., Duboscq, J.,
& Micheletta, J. (2021). NetFACS: Using network science to understand
facial communication systems. Behavior Research Methods.
https://doi.org/10.3758/s13428-021-01692-5
netfacs_multiple
, netfacs_extract
,
conditional_probabilities
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", null.condition = NULL, duration = NULL, ran.trials = 100, control = NULL, random.level = NULL, combination.size = 5, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 ) head(angry.face$result, 20) angry.face$event.size.information
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", null.condition = NULL, duration = NULL, ran.trials = 100, control = NULL, random.level = NULL, combination.size = 5, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 ) head(angry.face$result, 20) angry.face$event.size.information
Calculate expected probability from single bootstrap
netfacs_bootstrap( subject, subject.weight, null.subjects, null.elements, test.combinations, max.combination.size, max.event.size )
netfacs_bootstrap( subject, subject.weight, null.subjects, null.elements, test.combinations, max.combination.size, max.event.size )
subject |
A character vector of unique subjects present in the data |
subject.weight |
A numeric vector of weights to be used when sampling subjects |
null.subjects |
A denoting the subject of null.elements |
null.elements |
A list of active elements in the null condition |
test.combinations |
A vector denoting AU combinations that are present in the test data |
max.combination.size |
A positive integer indicating the maximum AU combination size considered in the bootstrap |
max.event.size |
A positive integer indicating the maximum event size to be considered |
A list of bootstrapped probabilities for combinations and event sizes
Extract results from a netfacs
object.
netfacs_extract( netfacs.data, combination.size = NULL, significance = 1, min.count = 0, min.prob = 0 ) netfacs.extract( netfacs.data, combination.size = NULL, significance = 1, min.count = 0, min.prob = 0 )
netfacs_extract( netfacs.data, combination.size = NULL, significance = 1, min.count = 0, min.prob = 0 ) netfacs.extract( netfacs.data, combination.size = NULL, significance = 1, min.count = 0, min.prob = 0 )
netfacs.data |
An object of class |
combination.size |
Numeric, denoting the combination size(s) that should
be extracted. If |
significance |
Numeric value between 0 and 1, determining the p-value below which combinations are considered to be dissimilar enough from the null distribution. |
min.count |
Numeric, denoting the minimum number of times an element combination occurred. |
min.prob |
Numeric value between 0 and 1, denoting the minimum probability an element combination occurred to be displayed. |
Function returns a tibble
data.frame
that contains the results of the netfacs
object. By default,
returns all results for all observed combinations, but can optionally
pre-filter results.
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) netfacs_extract(angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) netfacs_extract(angry.face)
netfacs
function across multiple levels of the
condition and puts them in a listTake dataset and report observed and expected likelihood that elements and combinations of elements occur in this dataset, and whether this differs from a null condition. Expected values are based on bootstraps of null distribution, so the values represent distribution of element co-occurrence under null condition. The resulting object is the basis for most other functions in this package.
netfacs_multiple( data, condition, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = 2, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
netfacs_multiple( data, condition, duration = NULL, ran.trials = 1000, control = NULL, random.level = NULL, combination.size = 2, tail = "upper.tail", use_parallel = TRUE, n_cores = 2 )
data |
A binary matrix with one column per element, and one row per event, consisting of 1 (element was active during that event) and 0 (element was not active). |
condition |
character vector of same length as 'data' that contains information on the condition each event belongs to, so probabilities can be compared across conditions |
duration |
A numeric vector that contains information on the duration of each event; if NULL, all events are assumed to have equal duration. |
ran.trials |
Number of randomisations that will be performed to find the null distribution. |
control |
A list of vectors that are used as control variables. During bootstraps, the ratio of events in each level will be adapted. So, for example, if in the test distribution, there are three angry participants for each happy participant, the null distribution will maintain that ratio. |
random.level |
A character vector of the level on which the randomization should take place. If NULL, the randomization takes place on the event level (i.e., every row can either be selected or not); if a vector is provided, the randomization takes place on the levels of that vector rather than individual events. |
combination.size |
A positive integer, indicating the maximum combination size of element combinations. Higher numbers will increase computation time. Default is 2. |
tail |
Either 'upper.tail' (proportion of null probabilities that are larger than observed probabilities), or 'lower.tail' (proportion of null probabilities that are smaller than observed probabilities); default is 'upper.tail'. |
use_parallel |
Logical, indicating whether randomization or bootstrap
should be parallelized (default is |
n_cores |
Numeric, indicating the number cores to be used for parallelization. Default is 2. |
An object of class netfacs_multiple
, which contains the
probabilities of observing element combinations in one condition vs. all
other conditions, along with other useful information. The resulting object
is the basis for most other functions in this package.
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, # only for example combination.size = 2 ) netfacs_extract(emo.faces)
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, # only for example combination.size = 2 ) netfacs_extract(emo.faces)
Takes the results of the nefacs object for combinations of 2 elements and turns them into a network object (igraph) that can be used for further plotting and analyses
netfacs_network( netfacs.data, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL ) netfacs.network( netfacs.data, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL )
netfacs_network( netfacs.data, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL ) netfacs.network( netfacs.data, link = "unweighted", significance = 0.01, min.count = 1, min.prob = 0, ignore.element = NULL )
netfacs.data |
object resulting from |
link |
determines how nodes/elements are connected. 'unweighted' gives a 1 to significant connections and 0 to all others; 'weighted' gives the difference between observed and expected probability of co-occurrence; 'raw' just uses the observed probability of co-occurrence |
significance |
numeric value, determining the p-value below which combinations are considered to be dissimilar enough from the null distribution |
min.count |
numeric value, suggesting how many times a combination should at least occur to be displayed |
min.prob |
numeric value, suggesting the probability at which a combination should at least occur to be displayed |
ignore.element |
vector of elements that will not be considered for the network, e.g. because they are too common or too rare or their interpretation is not relevant here |
Function returns a network object where the nodes are the elements, edges represent their co-occurrence, and the vertex and edge attributes contain all additional information from the netfacs object
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 )
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 )
Calculate probabilities from single randomization
netfacs_randomize(m, test.combinations, max.combination.size, max.event.size)
netfacs_randomize(m, test.combinations, max.combination.size, max.event.size)
m |
A numeric matrix |
test.combinations |
A vector of AU combinations observed in test data |
max.combination.size |
A positive integer |
max.event.size |
A Positive integer |
A list of randomized probabilities for combinations and event sizes
For all dyadic combinations that ever appear, this function calculates how reciprocal the conditional probabilities (i.e. probability of A given B, and B given A) of the two elements are. Combinations that are highly reciprocal indicate that the two elements always occur together and might represent a fixed combination, while low reciprocity might indicate that one element is an extension of the other. Values approaching -1 indicate that one element is strongly dependent on the other, but this is not reciprocated; values around 0 indicate that neither is conditional on the other; and values approaching 1 indicate that both values are conditional on each other. If P[A|B] is the larger conditional probability, the reciprocity is calculated as reciprocity = ((P[B|A]/P[A|B]) - (P[A|B] - P[B|A])) * P[A|B].
netfacs.reciprocity(netfacs.data)
netfacs.reciprocity(netfacs.data)
netfacs.data |
object resulting from netfacs() function |
Function returns a data frame with each combination, the reciprocity of conditional occurrence from -1 (one element entirely depends on the other, but not vice versa) to 1 (both elements always occur together)
The directions and conditional probabilities of both elements are also returned
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) netfacs.reciprocity(angry.face)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) netfacs.reciprocity(angry.face)
This is a convenience function to create and visualize a network of
conditional probabilities for all dyadic element combinations of a
netfacs
object. Conditional probabilities are calculated using
the conditional_probabilities
function.
network_conditional( netfacs.data, min.prob = 0, min.count = 0, ignore.element = NULL, plot.bubbles = TRUE )
network_conditional( netfacs.data, min.prob = 0, min.count = 0, ignore.element = NULL, plot.bubbles = TRUE )
netfacs.data |
object resulting from |
min.prob |
minimum conditional probability that should be shown in the graph |
min.count |
minimum number of times that a combination should occur before being included in the graph |
ignore.element |
string vector, can be used to exclude certain elements when creating the plots |
plot.bubbles |
if TRUE (default), then the nodes in the network plots will be surrounded by bubbles; if FALSE, the edges connect the names directly |
Function returns named list that includes a
tbl_graph
network and a
ggraph
plot.
netfacs
, conditional_probabilities
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) conditional.probs <- conditional_probabilities(angry.face) network_conditional( netfacs.data = conditional.probs, min.prob = 0.01, min.count = 3, ignore.element = "25", plot.bubbles = FALSE )
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 100, combination.size = 2 ) conditional.probs <- conditional_probabilities(angry.face) network_conditional( netfacs.data = conditional.probs, min.prob = 0.01, min.count = 3, ignore.element = "25", plot.bubbles = FALSE )
Plots the network created using the netfacs_network
function;
for networks with clear clusterin of elements, clusters can get different
colours
network_plot( netfacs.graph, title = "network", clusters = FALSE, plot.bubbles = FALSE, hide.unconnected = TRUE ) network.plot( netfacs.graph, title = "network", clusters = FALSE, plot.bubbles = FALSE, hide.unconnected = TRUE )
network_plot( netfacs.graph, title = "network", clusters = FALSE, plot.bubbles = FALSE, hide.unconnected = TRUE ) network.plot( netfacs.graph, title = "network", clusters = FALSE, plot.bubbles = FALSE, hide.unconnected = TRUE )
netfacs.graph |
igraph network object resulting from
|
title |
string of the graph's main title |
clusters |
if |
plot.bubbles |
if TRUE, then the nodes in the network plots will be surrounded by bubbles; if FALSE, the edges connect the names directly |
hide.unconnected |
if TRUE, then the nodes that do not have any significant connections will be hidden in the plot |
Function returns a ggraph
plot of the network,
where the size of nodes indicates how often they occur on their own, and
edges indicate significant co-occurrence between them
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_plot(anger.net, title = "Angry Faces", clusters = FALSE, plot.bubbles = TRUE)
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_plot(anger.net, title = "Angry Faces", clusters = FALSE, plot.bubbles = TRUE)
Calculates node level centrality measures from the network object
network_summary(netfacs.graph) network.summary(netfacs.graph)
network_summary(netfacs.graph) network.summary(netfacs.graph)
netfacs.graph |
igraph network object resulting from netfacs_network function |
Function returns a data frame with the element, its 'strength' (mean probability of co-occurrence), 'eigenvector' centrality (connection to other highly connected elements), 'betweenness' centrality (number of connections running through the element), and a number of other network measures
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_summary(anger.net)
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_summary(anger.net)
Calculates graph level summary measures from the network object
network_summary_graph(netfacs.net) network.summary.graph(netfacs.net)
network_summary_graph(netfacs.net) network.summary.graph(netfacs.net)
netfacs.net |
igraph network object resulting from netfacs_network function |
Function returns a dataframe with the number of elements in the graph, the number of connected edges, mean strength of connections, transitivity (mean number of closed triads), diameter (furthest path between two elements), degree centralization, and mean distance between elements
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_summary_graph(anger.net)
data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) anger.net <- netfacs_network( netfacs.data = angry.face, link = "unweighted", significance = 0.01, min.count = 1 ) network_summary_graph(anger.net)
This function is deprecated. Please see network_conditional
instead
network.conditional( netfacs.data, min.prob = 0, min.count = 0, ignore.element = NULL, plot.bubbles = FALSE )
network.conditional( netfacs.data, min.prob = 0, min.count = 0, ignore.element = NULL, plot.bubbles = FALSE )
netfacs.data |
object resulting from |
min.prob |
minimum conditional probability that should be shown in the graph |
min.count |
minimum number of times that a combination should occur before being included in the graph |
ignore.element |
string vector, can be used to exclude certain elements when creating the plots |
plot.bubbles |
if TRUE (default), then the nodes in the network plots will be surrounded by bubbles; if FALSE, the edges connect the names directly |
Function returns a dataframe that includes all dyadic combinations and their observed and conditional probabilities
The function takes multiple netfacs objects and plots how different elements connect the conditions, based on the conditional probabilities that the element occurs in the condition and that the condition is seen when the element is present
overlap_network( x, min.prob = 0, min.count = 5, significance = 0.01, specificity = 0.1, ignore.element = NULL, clusters = FALSE, plot.bubbles = TRUE )
overlap_network( x, min.prob = 0, min.count = 5, significance = 0.01, specificity = 0.1, ignore.element = NULL, clusters = FALSE, plot.bubbles = TRUE )
x |
list of objects resulting from |
min.prob |
minimum conditional probability that should be shown in the graph |
min.count |
minimum number of times that a combination should occur before being included in the graph |
significance |
sets the level of significance that combinations have to pass before added to the network |
specificity |
for the 'reduced' graph, select only elements that surpass this context specificity value |
ignore.element |
string vector, can be used to exclude certain elements when creating the plots |
clusters |
boolean; if TRUE, the cluster_fast_greedy algorithm is used to detect underlying community structure, based on the occurrence probability network |
plot.bubbles |
if TRUE, then the nodes in the network plots will be surrounded by bubbles; if FALSE, the edges connect the names directly |
Function returns a ggraph
plot where each
condition is connected to those elements that occur significantly in this
condition, and each element is connected to each condition under which it
occurs significantly more than expected. Creates four graphs: context
specificity, occurrence in that context, a combined graph, and a 'reduced'
graph where edges are only included if they pass the 'specificity' value
set by the user
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, combination.size = 2 ) # calculate element specificity spec <- specificity(emo.faces) overlap <- overlap_network(spec, min.prob = 0.01, min.count = 3, significance = 0.01, specificity = 0.5, ignore.element = "25", clusters = TRUE, plot.bubbles = TRUE)
data(emotions_set) emo.faces <- netfacs_multiple( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, ran.trials = 10, combination.size = 2 ) # calculate element specificity spec <- specificity(emo.faces) overlap <- overlap_network(spec, min.prob = 0.01, min.count = 3, significance = 0.01, specificity = 0.5, ignore.element = "25", clusters = TRUE, plot.bubbles = TRUE)
This function is deprecated. Please see overlap_network
instead
overlap.network( netfacs.list, min.prob = 0, min.count = 5, significance = 0.01, specificity = 0.1, ignore.element = NULL, clusters = FALSE, plot.bubbles = FALSE )
overlap.network( netfacs.list, min.prob = 0, min.count = 5, significance = 0.01, specificity = 0.1, ignore.element = NULL, clusters = FALSE, plot.bubbles = FALSE )
netfacs.list |
list of objects resulting from |
min.prob |
minimum conditional probability that should be shown in the graph |
min.count |
minimum number of times that a combination should occur before being included in the graph |
significance |
sets the level of significance that combinations have to pass before added to the network |
specificity |
for the 'reduced' graph, select only elements that surpass this context specificity value |
ignore.element |
string vector, can be used to exclude certain elements when creating the plots |
clusters |
boolean; if TRUE, the cluster_fast_greedy algorithm is used to detect underlying community structure, based on the occurrence probability network |
plot.bubbles |
if TRUE, then the nodes in the network plots will be surrounded by bubbles; if FALSE, the edges connect the names directly |
Takes a vector of elements and returns a vector with all possible combinations
possible_combinations(elements, maxlen, sep = "_")
possible_combinations(elements, maxlen, sep = "_")
elements |
A vector of elements |
maxlen |
maximum size of combinations to be considered |
sep |
String. Separator used for showing combinations of elements |
A vector with all element combinations
The netfacs
function requires data to be entered with the element data as a matrix of each element by each event,
with occurrence marked as 1 and non-occurrence marked as 0.
This is often not the case, so this function transforms data in other routine formats to have the right look.
Specifically, users can define whether they want to enter 'photos', which indicates that all elements in an event are simply strung together in a vector; or they define 'video', in which case it is assumed that each element has a start and an end point in a specified video
prepare.netfacs( elements, type = c("video", "photo"), video.id = NULL, start.time = NULL, duration = NULL, separator = ",", frame.duration = NULL )
prepare.netfacs( elements, type = c("video", "photo"), video.id = NULL, start.time = NULL, duration = NULL, separator = ",", frame.duration = NULL )
elements |
vector with either one element per index (for videos) or all elements that occurred in the whole event (for photos) |
type |
either 'video' or 'photo'. If 'photo', the function separates the string and returns a matrix of the correct dimensions. If 'video', the function creates a matrix using the highest common factor of all 'durations' and for each of those 'frames' assigns whether each element was present or absent |
video.id |
name of the video, so all cases are treated together. For photos, can be entered so that photos can be matched to IDs after |
start.time |
for videos, time when the element is first active |
duration |
for videos, how long is the element active for |
separator |
for photos, how are elements separated in the list |
frame.duration |
for videos, how long is a 'frame' supposed to last? If NULL, frame duration is the shortest 'duration' of any element specified |
The assumption for this function is that for photos, elements are stored like this:
'AU1/AU2/AU3/AU4'
'AU1/AU3/AU4'
'AU1/AU2'
For videos, the assumption is that they are stored in a data frame like this:
element = AU1, video.id = 1, start.time = 0.5, duration = 2sec
Function returns a list with element.matrix (the matrix of elements and when they occurred) and video.info (the supporting information, e.g. video names, durations, frames etc)
# for a photo au.photos <- c( "AU1/AU5/AU9", "AU1/AU2", "AU1/AU2/AU10", "AU1/AU2", "AU5/AU17/AU18", "AU6/AU12" ) au.names <- c("photo1", "photo2", "photo3", "photo4", "photo5", "photo6") au.prepared <- prepare.netfacs( elements = au.photos, type = "photo", video.id = au.names, separator = "/" ) au.prepared$element.matrix au.prepared$video.info # for a video aus <- c( "AU1", "AU5", "AU9", "AU1", "AU2", "AU1", "AU2", "AU10", "AU1", "AU2", "AU5", "AU17", "AU18", "AU6", "AU12" ) video.names <- c( rep("video1", 3), rep("video2", 2), rep("video3", 3), rep("video4", 2), rep("video5", 3), rep("video6", 2) ) start.times <- c( 0.1, 0.2, 0.3, 0.1, 0.3, 0.1, 0.4, 0.4, 0.1, 0.2, 0.1, 0.5, 0.6, 0.1, 0.2 ) durations <- rep(0.3, times = length(start.times)) frame.dur <- 0.05 au.prepared <- prepare.netfacs( elements = aus, type = "video", video.id = video.names, start.time = start.times, duration = durations, frame.duration = frame.dur ) head(au.prepared$element.matrix) head(au.prepared$video.info)
# for a photo au.photos <- c( "AU1/AU5/AU9", "AU1/AU2", "AU1/AU2/AU10", "AU1/AU2", "AU5/AU17/AU18", "AU6/AU12" ) au.names <- c("photo1", "photo2", "photo3", "photo4", "photo5", "photo6") au.prepared <- prepare.netfacs( elements = au.photos, type = "photo", video.id = au.names, separator = "/" ) au.prepared$element.matrix au.prepared$video.info # for a video aus <- c( "AU1", "AU5", "AU9", "AU1", "AU2", "AU1", "AU2", "AU10", "AU1", "AU2", "AU5", "AU17", "AU18", "AU6", "AU12" ) video.names <- c( rep("video1", 3), rep("video2", 2), rep("video3", 3), rep("video4", 2), rep("video5", 3), rep("video6", 2) ) start.times <- c( 0.1, 0.2, 0.3, 0.1, 0.3, 0.1, 0.4, 0.4, 0.1, 0.2, 0.1, 0.5, 0.6, 0.1, 0.2 ) durations <- rep(0.3, times = length(start.times)) frame.dur <- 0.05 au.prepared <- prepare.netfacs( elements = aus, type = "video", video.id = video.names, start.time = start.times, duration = durations, frame.duration = frame.dur ) head(au.prepared$element.matrix) head(au.prepared$video.info)
netfacs
Print method for objects of class netfacs
## S3 method for class 'netfacs' print(x, ...)
## S3 method for class 'netfacs' print(x, ...)
x |
An object of class |
... |
Additional arguments that would be passed to or from other methods |
netfacs_multiple
Print method for objects of class netfacs_multiple
## S3 method for class 'netfacs_multiple' print(x, ...)
## S3 method for class 'netfacs_multiple' print(x, ...)
x |
An object of class |
... |
Additional arguments that would be passed to or from other methods |
Calculate probabilities of single elements and combinations occurring
probability_of_combination(elements, maxlen, sep = "_")
probability_of_combination(elements, maxlen, sep = "_")
elements |
A vector with all elements observed together at an event. Or
a list of vectors or a binary matrix with elements as |
maxlen |
maximum size of combinations to be considered |
sep |
String. Separator used for showing combinations of elements |
Function returns a dataframe with observed probabilities for each combination in the dataset
Count number of event sizes
probability_of_event_size(elements, max.event.size)
probability_of_event_size(elements, max.event.size)
elements |
A list of vectors containing active elements or a binary matrix with events in rows |
max.event.size |
A positive integer |
A named vector, including probabilities for event sizes that were not observed in the data
Simulate FACS data
sim_facs(m, n_obs = 10, jp = NULL)
sim_facs(m, n_obs = 10, jp = NULL)
m |
A matrix with condition as |
n_obs |
Number of observations per condition to simulate |
jp |
An optional list of matrices, the same length as |
elements <- as.character(1:10) conditions <- letters[1:2] # randomly generate probability of elements probabilities <- sapply(elements, function(x) { p <- runif(length(conditions)) setNames(round(p, 1), nm = conditions) }) sim_facs(probabilities)
elements <- as.character(1:10) conditions <- letters[1:2] # randomly generate probability of elements probabilities <- sapply(elements, function(x) { p <- runif(length(conditions)) setNames(round(p, 1), nm = conditions) }) sim_facs(probabilities)
Calculate specificity of element combinations to a given condition
specificity( x, condition, test.condition = NULL, null.condition = NULL, combination.size = NULL, upsample = TRUE )
specificity( x, condition, test.condition = NULL, null.condition = NULL, combination.size = NULL, upsample = TRUE )
x |
A binary matrix, with AUs as |
condition |
A character condition vector |
test.condition |
A string, denoting the test condition. If |
null.condition |
A string, denoting the null condition. If |
combination.size |
A positive integer, indicating the maximum
combination size of element combinations. If |
upsample |
Logical. Should minority condition(s) be
|
Specificity values are biased when the number of observations per
condition is highly imbalanced. When upsample
= TRUE
(recommended), the condition(s) with fewer observations are randomly
upsample
d to match the number of observations in the most
common condition prior to the specificity calculation. This procedure
minimizes the bias in the specificity results.
A data frame
specificity( x = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger" )
specificity( x = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger" )
The function takes all elements and dyadic combinations of elements in a netfacs object, goes through all combinations these elements are in, and compares the specificity (strength with which the combination identifies the test condition) of all combinations with the element and the same combinations without the element, to test how much specificity the element adds when added to a signal. Only works for netfacs objects based on comparison between conditions.
specificity_increase(x)
specificity_increase(x)
x |
object resulting from |
Function returns a list with two data frames that include all elements and first-order combinations that occur at all, the number of combinations that each element/combination is part of, and how much adding this element to a combination adds on average to its specificity, and how often it occurs
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) spec <- specificity(angry.face) specificity_increase(spec)
### how do angry facial expressions differ from non-angry ones? data(emotions_set) angry.face <- netfacs( data = emotions_set[[1]], condition = emotions_set[[2]]$emotion, test.condition = "anger", ran.trials = 10, combination.size = 2 ) spec <- specificity(angry.face) specificity_increase(spec)
Summarise combination results from bootstrap
summarise_combination( combination, combination.size, observed.prob, boot.prob, tail, test.count )
summarise_combination( combination, combination.size, observed.prob, boot.prob, tail, test.count )
combination |
A vector of AU combinations |
combination.size |
A vector denoting the number of active AUs in combination |
observed.prob |
A vector with probability of combination in test data |
boot.prob |
A matrix with boot probabilities of a given combination in columns |
tail |
upper.tail or lower.tail, |
test.count |
Number of times a combination occurs in test dataset |
A dataframe
Summarise event size probabilities
summarise_event_size(observed.prob, boot.prob)
summarise_event_size(observed.prob, boot.prob)
observed.prob |
A named vector with probabilities of event sizes. |
boot.prob |
A matrix with boot probabilities of a given event size. Combination size in rows, trials in columns. |
A dataframe
Randomly up-sample the minority condition(s) to have the same number of observations as the majority condition. Random samples are added to the existing observations of the minority conditions
upsample(x, condition, .name = "condition")
upsample(x, condition, .name = "condition")
x |
A data.frame or something coercible to one |
condition |
A character vector the same length as 'x' denoting which condition each observation belongs to |
.name |
A string used to name the condition column |
A tibble
d <- data.frame( condition = c(rep("a", times = 7), rep("b", times = 3)), x = sample(0:1, size = 10, replace = TRUE), y = sample(0:1, size = 10, replace = TRUE) ) upsample(x = d, condition = d$condition)
d <- data.frame( condition = c(rep("a", times = 7), rep("b", times = 3)), x = sample(0:1, size = 10, replace = TRUE), y = sample(0:1, size = 10, replace = TRUE) ) upsample(x = d, condition = d$condition)
Check that condition arguments are formatted correctly
validate_condition(data, condition, test.condition, null.condition)
validate_condition(data, condition, test.condition, null.condition)
data |
data passed by the user |
condition |
condition passed by the user |
test.condition |
condition passed by the user |
null.condition |
condition passed by the user |
Check that 'data' argument is formatted correctly
validate_data(data)
validate_data(data)
data |
data passed by the user |
data as a matrix