sCurve: S-Curve Transform

View source: R/sCurve.R

sCurveR Documentation

S-Curve Transform

Description

Functions for transforming and back-transforming data using an s-shaped curve.

Usage

sCurve(x, location = 0, scale = 1, shape = 1)

IsCurve(x, location = 0, scale = 1, shape = 1)

Arguments

x

a numeric vector to be transformed by sCurve or back-transformed by IsCurve. Missing values are allowed and result in corresponding missing values in the output.

location

the transition point in the s-curve transform.

scale

the scaling factor for the data, the slope at the transition point in the s-curve transform. Must be greater than 0.

shape

a value that determines how quickly the curve approaches the limits of -1 or 1. Must be greater than 0.

Details

The basic equation for the s-curve is z/(1 + abs(z)^shape)^(1/shape), where z is scale*(x-location).

The function sCurve computes the forward transform and the function IsCurve computes the inverse [sCurve] transform, or back-transform.

Value

A numeric vector of the transformed or back-transformed values in x.

Note

The sCurve function is related to the hyperbolic function in that both can represent mixing models for flow in stream water chemistry. The sCurve function is more flexible when there are distinct upper and lower limits to the concentration. The hyperbolic function is more flexible for open-ended concentrations for either high or low flows. Also, sCurve would typically use log-transformed values for flow.

See Also

hyperbolic

Examples

## Not run: 
# Basic changes to the s-curve
curve(sCurve(x), -5,5, ylim=c(-1,1))
# Shift to left
curve(sCurve(x, location=1), -5,5, add=TRUE, col="red")
# increase slope
curve(sCurve(x, scale=2), -5,5, add=TRUE, col="cyan")
# increase rate
curve(sCurve(x, shape=2), -5,5, add=TRUE, col="purple")

## End(Not run)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.