Package 'ssrhom'

Title: Hierarchical ordinal models for analyzing single subject designs
Description: Hierarchical ordinal models for analyzing single subject designs using Bayesian models fit with Stan.
Authors: James Uanhoro [aut, cre]
Maintainer: James Uanhoro <[email protected]>
License: GPL (>= 3)
Version: 0.0.3.9002
Built: 2024-11-17 05:41:20 UTC
Source: https://github.com/jamesuanhoro/ssrhom

Help Index


The 'ssrhom' package.

Description

The 'ssrhom' package.

References

Stan Development Team (NA). RStan: the R interface to Stan. R package version 2.32.6. https://mc-stan.org


Report an effect of interest

Description

Report an effect of interest

Usage

ssrhom_get_effect(res_obj, stat = "nap", interval = 0.95, return_draws = FALSE)

Arguments

res_obj

Object returned by main function

stat

One of "mean", "median", "mean-diff", "median-diff", "lrr", "lor", "nap", "tau", "pem", "smd-c", or "smd-p". lrr or log rate ratio is only computed when the outcome variable is non-negative or has a minimum greater than 0. lor or log odds ratio is only computed when the outcome variable falls entirely in the 0-1 interval, inclusive of both 0 and 1.

interval

Some quantile interval between 0 and 1

return_draws

If TRUE, do not summarize the posterior samples. If FALSE, summarize the posterior samples.

Value

Returns dataset.


Function to list out effects computed by package.

Description

Function to list out effects computed by package.

Usage

ssrhom_list_stats(table = TRUE)

Arguments

table

If TRUE, report statistics in a table describing each statistic. If FALSE, simply return statistics as a list.


Analyze AB design

Description

Analyze AB design

Usage

ssrhom_model_ab(
  data,
  grouping = NA_character_,
  condition = NA_character_,
  time = NA_character_,
  outcome = NA_character_,
  case = NA_character_,
  increase = TRUE,
  warmup = 750,
  sampling = 750,
  refresh = max((warmup + sampling)%/%10, 1),
  adapt_delta = 0.9,
  max_treedepth = 10,
  chains = 3,
  cores = min(chains, max(parallel::detectCores() - 2, 1)),
  seed = sample.int(.Machine$integer.max, 1),
  show_messages = TRUE
)

Arguments

data

A dataset, ideally a data.frame.

grouping

The name of the grouping variable in the dataset.

condition

The level of the grouping variable that identifies the treatment condition.

time

The name of the time variable. This must be a series of positive whole numbers signifiying the time the outcome was measured.

outcome

The name of the outcome variable.

case

The name of the variable that identifies different cases in the dataset.

increase

TRUE (Default) if increase in outcome is desirable. Set FALSE if increase in outcome is undesirable.

warmup

Number of iterations used to warmup the sampler, per chain.

sampling

Number of iterations retained for inference, per chain.

refresh

(Positive whole number) How often to print the status of the sampler.

adapt_delta

Number in (0,1). Increase to resolve divergent transitions.

max_treedepth

(Positive whole number) Increase to resolve problems with maximum tree depth.

chains

Number of chains to use.

cores

Number of cores to use.

seed

Random seed.

show_messages

(Logical) If TRUE, show messages from Stan sampler, if FALSE, hide messages.

Value

Object containing analysis results.

Examples

## Not run: 
tasky_model <- ssrhom_model_ab(
  data = tasky,
  grouping = "phase", condition = "B",
  time = "time", outcome = "count", case = "person"
)
ssrhom_get_effect(tasky_model, stat = "nap")

## End(Not run)

Dataset from Tasky et al. (2008)

Description

Dataset from Tasky et al. (2008)

Usage

tasky

Format

tasky

A data frame with 70 rows and 5 colums:

person

The case label

phase

Intervention phase where "B" is treatment

count

The count of on-task intervals out of 6

proportion

The count as a proportion

time

Session number

Source

Tasky et al. (2008). Using Choice to Increase On-Task Behavior in Individuals with Traumatic Brain Injury. Journal of Applied Behavior Analysis, 41(2), 261–265. https://doi.org/10.1901/jaba.2008.41-261