Skip to content

Commit 6f6bdb9

Browse files
authored
Merge pull request #2 from bsiepe/devel
Update to version 0.2.0
2 parents dde86c4 + 01acd34 commit 6f6bdb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1553
-591
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
6+
# local testing files
7+
tempfiles/

CRAN-SUBMISSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Version: 0.1.0
2-
Date: 2024-02-20 15:36:22 UTC
3-
SHA: 40df86c9c02e76044b2499df231d4ddc43ce4940
2+
Date: 2024-02-27 07:01:18 UTC
3+
SHA: 15721ee1ca7a92c51b130bafde6eb79d19e235da

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: tsnet
22
Type: Package
33
Title: Fitting, Comparing, and Visualizing Networks Based on Time Series Data
4-
Version: 0.1.0
4+
Version: 0.2.0
55
Authors@R:
66
c(person("Björn S.", "Siepe",
77
email = "bjoernsiepe@gmail.com",
@@ -22,13 +22,14 @@ Encoding: UTF-8
2222
LazyData: true
2323
URL: https://github.com/bsiepe/tsnet
2424
BugReports: https://github.com/bsiepe/tsnet/issues
25-
RoxygenNote: 7.3.1
25+
RoxygenNote: 7.3.2
2626
Imports:
2727
cowplot,
2828
dplyr,
2929
ggdist,
3030
ggokabeito,
3131
ggplot2,
32+
loo,
3233
methods,
3334
posterior,
3435
Rcpp (>= 0.12.0),

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ importFrom(ggdist,stat_slab)
2626
importFrom(ggdist,theme_ggdist)
2727
importFrom(ggokabeito,palette_okabe_ito)
2828
importFrom(ggokabeito,scale_fill_okabe_ito)
29+
importFrom(loo,loo)
30+
importFrom(loo,loo_model_weights)
31+
importFrom(loo,pareto_k_values)
32+
importFrom(loo,psis)
33+
importFrom(loo,relative_eff)
34+
importFrom(loo,weights.importance_sampling)
2935
importFrom(posterior,as_draws_matrix)
3036
importFrom(rlang,.data)
3137
importFrom(rstan,extract)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# tsnet 0.2.0
2+
* Fixed documentation issues (e.g., wrong display of LaTex equations)
3+
14
# tsnet 0.1.0
25

36
* Initial CRAN submission.

R/centrality.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
#' a network, while density describes the networks' overall connectedness.
66
#' Specifically, it computes the in-strength, out-strength, contemporaneous
77
#' strength, temporal network density, and contemporaneous network density. The
8-
#' result can then be visualized using [plot_centrality()].
8+
#' result can then be visualized using \code{\link{plot_centrality}}.
99
#'
1010
#' @param fitobj Fitted model object for a Bayesian GVAR model. This can be
11-
#' `tsnet_fit` object (obtained from [stan_gvar()]), a BGGM object (obtained
12-
#' from [BGGM::var_estimate()]), or extracted posterior samples (obtained from
13-
#' [stan_fit_convert()).
11+
#' `tsnet_fit` object (obtained from \code{\link{stan_gvar}},
12+
#' a BGGM object (obtained from \code{\link[BGGM]{var_estimate}} in \code{BGGM}),
13+
#' or extracted posterior samples (obtained from \code{\link{stan_fit_convert}}).
1414
#' @param burnin An integer specifying the number of initial samples to discard
15-
#' as burn-in. Default is 0.
15+
#' as burn-in. Default is \code{0}.
1616
#' @param remove_ar A logical value specifying whether to remove the
17-
#' autoregressive effects for centrality calculation. Default is TRUE. This is
18-
#' only relevant for the calculation of temporal centrality/density measures.
17+
#' autoregressive effects for centrality calculation. Default is \code{TRUE}.
18+
#' This is only relevant for the calculation of temporal centrality/density
19+
#' measures.
1920
#'
2021
#' @return A list containing the following centrality measures:
2122
#' \itemize{
@@ -106,11 +107,11 @@ get_centrality <- function(fitobj,
106107
#' centrality measures.
107108
#'
108109
#' @param obj An object containing the centrality measures obtained from
109-
#' [get_centrality()].
110+
#' \code{\link{get_centrality}}.
110111
#' @param plot_type A character string specifying the type of plot. Accepts
111-
#' "tiefighter" or "density". Default is "tiefighter".
112+
#' "tiefighter" or "density". Default is \code{"tiefighter"}.
112113
#' @param cis A numeric value specifying the credible interval. Must be between
113-
#' 0 and 1 (exclusive). Default is 0.95.
114+
#' 0 and 1 (exclusive). Default is \code{0.95}.
114115
#'
115116
#' @return A ggplot object visualizing the centrality measures. For a
116117
#' "tiefighter" plot, each point represents the mean centrality measure for a

R/check_eigen.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#'
33
#' This function checks the eigenvalues of the Beta matrix (containing the
44
#' temporal coefficients) to assure that the model is stationary. It uses the
5-
#' same check as the `graphicalVAR` package. The function calculates the
5+
#' same check as the \code{graphicalVAR} package. The function calculates the
66
#' eigenvalues of the Beta matrix and checks if the sum of the squares of the
77
#' real and imaginary parts of the eigenvalues is less than 1. If it is, the VAR
88
#' model is considered stable.
99
#'
1010
#' @param fitobj A fitted Bayesian GVAR object. This can be a tsnet_fit object
11-
#' (obtained from [stan_gvar()]), a BGGM object (obtained from
12-
#' [BGGM::var_estimate()]), or extracted posterior samples (obtained from
13-
#' [stan_fit_convert()).
11+
#' (obtained from \code{\link{stan_gvar}}, a \code{BGGM} object (obtained from
12+
#' \code{\link[BGGM]{var_estimate}}), or extracted posterior samples
13+
#' (obtained from \code{\link{stan_fit_convert}}.
1414
#' @param verbose Logical. If TRUE, a verbal summary of the results is printed.
15-
#' Default is TRUE.
15+
#' Default is \code{TRUE}.
1616
#' @examples
1717
#' data(fit_data)
1818
#' fitobj <- fit_data[[1]]

R/compare_gvar.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@
1010
#' <doi:10.31234/osf.io/uwfjc>.
1111
#'
1212
#' @param fit_a Fitted model object for Model A. This can be a tsnet_fit object
13-
#' (obtained from [stan_gvar()]), a BGGM object (obtained from
14-
#' [BGGM::var_estimate()]), or extracted posterior samples (obtained from
15-
#' [stan_fit_convert()).
13+
#' (obtained from \code{\link{stan_gvar}}, a \code{BGGM} object (obtained from
14+
#' \code{\link[BGGM]{var_estimate}}, or extracted posterior samples (obtained from
15+
#' \code{\link{stan_fit_convert}}).
1616
#' @param fit_b Fitted model object for Model B. This can be a tsnet_fit object
17-
#' (obtained from [stan_gvar()]), a BGGM object (obtained from
18-
#' [BGGM::var_estimate()]), or extracted posterior samples (obtained from
19-
#' [stan_fit_convert()).
20-
#' @param cutoff The percentage level of the test (default: 5\%) as integer.
21-
#' @param dec_rule The decision rule to be used. Currently supports default "or"
17+
#' (obtained from \code{\link{stan_gvar}}, a \code{BGGM} object (obtained from
18+
#' \code{\link[BGGM]{var_estimate}}, or extracted posterior samples (obtained from
19+
#' \code{\link{stan_fit_convert}}).
20+
#' @param cutoff The percentage level of the test (default: \code{5}) as integer.
21+
#' @param dec_rule The decision rule to be used. Currently supports default \code{"or"}
2222
#' (comparing against two reference distributions) and "comb" (combining the
2323
#' reference distributions). The use of "or" is recommended, as "comb" is less
2424
#' stable.
2525
#' @param n_draws The number of draws to use for reference distributions
26-
#' (default: 1000).
26+
#' (default: \code{1000}).
2727
#' @param comp The distance metric to use. Should be one of "frob" (Frobenius
2828
#' norm), "maxdiff" (maximum difference), or "l1" (L1 norm) (default:
29-
#' "frob"). The use of the Frobenius norm is recommended.
29+
#' \code{"frob"}). The use of the Frobenius norm is recommended.
3030
#' @param return_all Logical indicating whether to return all distributions
31-
#' (default: FALSE). Has to be set to TRUE for plotting the results.
31+
#' (default: \code{FALSE}). Has to be set to TRUE for plotting the results.
3232
#' @param sampling_method Draw sequential pairs of samples from the posterior,
3333
#' with certain distance between them ("sequential") or randomly from two
3434
#' halves of the posterior ("random"). The "random" method is preferred to
3535
#' account for potential autocorrelation between subsequent samples. Default:
36-
#' "random".
36+
#' \code{"random"}.
3737
#' @param indices A list of "beta" and "pcor" indices specifying which elements
38-
#' of the matrices to consider when calculating distances. If NULL (default),
38+
#' of the matrices to consider when calculating distances. If \code{NULL} (default),
3939
#' all elements of both matrices are considered. If provided, only the
4040
#' elements at these indices are considered. If only one of the matrices
4141
#' should have indices, the other one should be NULL. This can be useful if
4242
#' you want to calculate distances based on a subset of the elements in the
4343
#' matrices.
44-
#' @param burnin The number of burn-in iterations to discard (default: 0).
45-
#' @return A list (of class "compare_gvar") containing the results of the
44+
#' @param burnin The number of burn-in iterations to discard (default: \code{0}).
45+
#' @return A list (of class \code{compare_gvar}) containing the results of the
4646
#' comparison. The list includes:
4747
#'
4848
#' \item{sig_beta}{Binary decision on whether there is a significant difference between the temporal networks of A and B}

R/data.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#' Simulated Time Series Dataset
22
#'
33
#' This dataset contains a simulated time series dataset for two individuals
4-
#' generated using the `graphicalVAR` package. The dataset is useful for testing
4+
#' generated using the \code{graphicalVAR} package. The dataset is useful for testing
55
#' and demonstrating the functionality of the package.
66
#'
77
#' @format ## `ts_data` A data frame with 500 rows and 7 columns.
88
#' \describe{
99
#' \item{id}{A character string identifier for the individual. There are two unique ids, representing two individuals.}
1010
#' \item{V1-V6}{These columns represent six different variables in the time series data.}
1111
#' }
12-
#' @source Simulated using the [graphicalVAR::graphicalVARsim()] function.
12+
#' @source Simulated using the \code{\link[graphicalVAR]{graphicalVARsim}} function in the \code{graphicalVAR} package.
1313
#'
1414
#' @usage data(ts_data)
1515
#'
@@ -28,19 +28,19 @@
2828
#' Example Posterior Samples
2929
#'
3030
#' This dataset contains posterior samples of beta coefficients and partial correlations for two individuals.
31-
#' It was generated by fitting a GVAR model using [stan_gvar()] with three variables from the [ts_data] dataset.
31+
#' It was generated by fitting a GVAR model using \code{\link{stan_gvar}} with three variables from the \code{\link{ts_data}} dataset.
3232
#'
3333
#' @format ## `fit_data`
3434
#' A list with two elements, each containing posterior samples for one individual.
3535
#'
3636
#' @usage data(fit_data)
3737
#'
38-
#' @source The data is generated using the [stan_gvar()] function on subsets
39-
#' of the [ts_data] time series data.
38+
#' @source The data is generated using the \code{\link{stan_gvar}} function on subsets
39+
#' of the \code{\link{ts_data}} time series data.
4040
#'
4141
#' @details
4242
#' The list contains two elements, each containing posterior samples for one individual.
43-
#' The samples were extracted using the [stan_fit_convert()] function.
43+
#' The samples were extracted using the \code{\link{stan_fit_convert}} function.
4444
#' For each individual, the list elements contain the posterior means of the beta coefficients
4545
#' ("beta_mu") and the posterior means of the partial correlations ("pcor_mu").
4646
#' The "fit" element contains all 1000 posterior samples of the beta coefficients and partial correlations.

0 commit comments

Comments
 (0)