generate_networks: Return a JSON array of network data of a fitting model

Description Usage Arguments Value Examples

Description

This function uses repeated calls to var_main to find a fitting model for the data provided and then calls convert_to_graph to return a JSON representation of best valid model found.

Usage

1
2
3
4
5
generate_networks(data, timestamp, always_include = NULL, pairs = NULL,
  positive_variables = NULL, negative_variables = NULL,
  pick_best_of = NULL, incident_to_best_of = NULL, labels = list(),
  measurements_per_day = 3, max_network_size = 6, include_model = FALSE,
  second_significances = c(0.05, 0.01, 0.005))

Arguments

data

a data frame. Each row is a measurement. Each column is an endogenous variable.

timestamp

the date of the first measurement in the format 'yyyy-mm-dd'. If multiple measurements are taken per day, the first measurement (row) in the data frame should correspond to the first measurement on that day.

always_include

a vector of variable names that should always be included in the network if possible. Can also be NULL, in which case no variables are included by default.

pairs

a vector of variable names in the form c('pair1a','pair1b','pair2a','pair2b','pair3a',...). In other words: it is a vector of even length in which each two subsequent positions are seen as a pair. The pairs are treated such that only one pair or one variable of the pairs is included in the networks.

positive_variables

a vector of names of variables that measure a positive affect (e.g., happiness). Variable names not occurring in the positive_variables or negative_variables list are considered neutral.

negative_variables

a vector of names of variables that measure a negative affect (e.g., sadness). Variable names not occurring in the positive_variables or negative_variables list are considered neutral.

pick_best_of

a vector of variable names of which one should always be included in the network. Can also be NULL (the default value), in which case no variable is always included (unless specified by always_include).

incident_to_best_of

if pick_best_of is not NULL, a choice is made between the networks generated at each iteration based on which has the most incoming edges that originate from nodes listed in the vector of variable names incident_to_best_of.

labels

a list where keys are variable names and values are labels.

measurements_per_day

an integer in [1,16] denoting the number of measurements per day. Defaults to 3.

max_network_size

an integer in [2,6] denoting the number of nodes to include in the networks initially. Defaults to 6.

include_model

determines whether the imputed data set and coefficients of the best model should be returned in the network JSON. Defaults to FALSE.

second_significances

is the vector of significance levels to be used after the first attempt.

Value

This function returns a string representing a json array of two networks and an array of the top links.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Not run: 
GN_COLUMNS <- c('ontspanning', 'opgewektheid', 'hier_en_nu', 'concentratie',
                'beweging', 'iets_betekenen', 'humor', 'buiten_zijn',
                'eigenwaarde', 'levenslust', 'onrust', 'somberheid',
                'lichamelijk_ongemak', 'tekortschieten', 'piekeren', 'eenzaamheid',
                'uw_eigen_factor')
d<-load_file("../data/input/DataDndN_nonimputed_voorAndo.sav",log_level=3)
d<-d$raw_data[,GN_COLUMNS]
timestamp <- '2014-03-01'
cat(generate_networks(data = d,
                  timestamp = timestamp,
                  always_include = 'uw_eigen_factor',
                  pairs = c('opgewektheid','onrust',
                            'somberheid','ontspanning',
                            'somberheid','onrust'),
                  positive_variables = c('opgewektheid','ontspanning','hier_en_nu',
                                         'concentratie', 'beweging','iets_betekenen',
                                         'humor', 'buiten_zijn','eigenwaarde', 'levenslust'),
                  negative_variables = c('onrust','somberheid','lichamelijk_ongemak',
                                         'tekortschieten','piekeren','eenzaamheid'),
                  labels = list(ontspanning = "Ontspanning",
                                opgewektheid = "Opgewektheid",
                                hier_en_nu = "In het hier en nu leven",
                                concentratie = "Concentratie",
                                beweging = "Beweging",
                                iets_betekenen = "Iets betekenen",
                                humor = "Humor",
                                buiten_zijn = "Buiten zijn",
                                eigenwaarde = "Eigenwaarde",
                                levenslust = "Levenslust",
                                onrust = "Onrust",
                                somberheid = "Somberheid",
                                lichamelijk_ongemak = "Lichamelijk ongemak",
                                tekortschieten = "Tekortschieten",
                                piekeren = "Piekeren",
                                eenzaamheid = "Eenzaamheid",
                                uw_eigen_factor = "Mijn eigen factor"),
                  measurements_per_day = 3,
                  max_network_size = 6))

## End(Not run)

roqua/autovar documentation built on May 27, 2019, 10:41 p.m.