Skip to content

Commit

Permalink
exporting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Lalovic committed Mar 27, 2024
1 parent d0c1239 commit e545665
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(convert_params)
export(estimate_mu_sd)
export(estimate_parameters)
export(get_prop_table)
export(get_random_cp)
export(get_responses)
export(pad_levels)
export(percentify)
export(simulate_responses)
4 changes: 4 additions & 0 deletions R/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var_skew_normal <- function(alpha) {

#' Pad missing levels with zeros
#'
#' @export
#' @param pk proportions or probabilities across possible responses
#' @param K number of response categories
#' @return table of proportions across all possible responses
Expand All @@ -30,6 +31,7 @@ pad_levels <- function(pk, K) {

#' Get a table of proportions across each possible response
#'
#' @export
#' @param data a vector or array of responses
#' @param K number of response categories
#' @return table of proportions
Expand All @@ -47,6 +49,7 @@ get_prop_table <- function(data, K) {

#' Get random centered parameters `c(mu, sd, gamma1)` for testing
#'
#' @export
#' @return random centered parameters
get_random_cp <- function() {
mu <- stats::rnorm(1, 0, 1)
Expand All @@ -58,6 +61,7 @@ get_random_cp <- function() {

#' Return percentage for a given number
#'
#' @export
#' @param x number
#' @param digits number of digits
percentify <- function(x, digits=0) {
Expand Down
1 change: 1 addition & 0 deletions R/simulation_of_responses.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ delta_skew_normal <- function(alpha) {
#' Converts from centered parameters to direct parameters appearing in
#' the skew-normal density.
#'
#' @export
#' @param cp centered parameters c(mu, sd, gamma1)
#' @return direct parameters c(xi, omega, alpha)
#' @seealso [sn::cp2dp]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library(testthat)
library(responsesR)
library("testthat")
library("responsesR")
context("Testing optimal discretization")

test_that("discretization of N(0,1) with 5 categories gives expected result", {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library(testthat)
library("testthat")
library("responsesR")
context("Testing estimation of parameters")

set.seed(12345)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library(testthat)
library("testthat")
library("responsesR")
context("Testing get responses")

set.seed(12345)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
library(testthat)
library("testthat")
library("responsesR")
context("Testing univariate skew-normal functions")
source("helper_functions.R")
source("simulation_of_responses.R")

# parameter conversion test
test_that("convert_params gives the same results as sn::cp2dp", {
Expand Down

0 comments on commit e545665

Please sign in to comment.