shift_dist: Shift the scale of a habitual intake distribution

View source: R/shift_dists.R

shift_distR Documentation

Shift the scale of a habitual intake distribution

Description

This function shifts the scale of a habitual intake distribution and provides the new parameters used to describe the shifted distribution. The shift in scale is defined by either a shift in the mean or median of of the habitual intake distribution.

Usage

shift_dist(
  shape = NULL,
  rate = NULL,
  meanlog = NULL,
  sdlog = NULL,
  by = NULL,
  to = NULL,
  type = "mean",
  plot = F
)

Arguments

shape

Shape parameter for gamma distribution

rate

Rate parameter for gamma distribution

meanlog

Mean parameter for gamma distribution

sdlog

Standard deviation parameter for gamma distribution

by

Amount to shift the current mean/median by

to

New mean/median to shift the current mean/median to

type

Measure of scale to shift ("mean" or "median"); mean is default

plot

Boolean (TRUE/FALSE) indicating whether to plot the current/shifted distributions

Value

A list with the parameters for the shifted distribution

Examples

# Shift gamma distribution by an amount (2 and -3)
shift_dist(shape=9.7, rate=1.25, by=2, plot=T)
shift_dist(shape=9.7, rate=1.25, by=-3, plot=T)

# Shift gamma distribution to a new mean (10 or 4)
shift_dist(shape=9.7, rate=1.25, to=10, plot=T)
shift_dist(shape=9.7, rate=1.25, to=4, plot=T)

# Shift log-normal distribution by an amount (10 and -5)
shift_dist(meanlog=3, sdlog=0.5, by=10, plot=T)
shift_dist(meanlog=3, sdlog=0.5, by=-5, plot=T)

# Shift log-normal distribution to a new mean (35 and 15)
shift_dist(meanlog=3, sdlog=0.5, to=35, plot=T)
shift_dist(meanlog=3, sdlog=0.5, to=15, plot=T)

cfree14/nutriR documentation built on Oct. 31, 2024, 6:27 p.m.