arse_ts {arse}R Documentation

Calculates the area of resilience to stress event below a baseline with subtraction of area of growth and scaling for end state growth or non-resilience.

Description

This function takes a series of 'x,y' coordinates and a specified 'y' baseline value. For a given set of x-coordinates over time and repeated measures of a 'y' variable, this function calculates the area of resilience to a stress event (arse) that is formed below the specified baseline value of 'y' using an implementation of the shoelace formula (Gauss's area formula) for the area of irregular polygons. The function also calculates the area of growth (aog) that is formed above the specified baseline in the same manner as arse. The function then subtracts the arse from aog to get a new variable, arse_t. With arse_t calculated, it is scaled in reference to the end state value by (a) if arse_t is greater than or equal to zero, multiplying the arse_t value by the division of baseline value over the end state value (i.e., last measured value of 'y') or arse value * (baseline value/end state value) or (b) if arse_t is less than zero, multiplying the arse_t value by the division of end state value over the baseline value (i.e., last measured value of 'y') or arse value * (end state value/baseline value). Smaller arse_s values are indicative of better resilience on the measured variable.

Usage

arse_ts(data, xcoord, ycoord, ybase = NA, yend = NA, yinvert = FALSE,
  saveout = FALSE)

Arguments

data

A dataframe with x- and y-coordinates in wide format.

xcoord

A specified selection of the x-coordinate values within the dataframe. The first x-coordinate value should correspond to the baseline input of 'y'.

ycoord

A specified selection of the y-coordinate values within the dataframe. The first y-coordinate value should correspond to the baseline value of 'y'. The second y-coordinate value should be the first measure of 'y' after the intrusion of a stress event. The last value of 'y' should correspond to the last measurement of 'y' over the measured timeframe.

ybase

A specified selection of the baseline of the 'y' measured variable. Users are advised to place baseline as the first instance of the y-coordinate values. Function defaults to use the first y-coordinate value in the series.

yend

A specified selection of the end state of the 'y' measured variable. Users are advised to place end state as the last instance of the y-coordinate values. Function defaults to use the last y-coordinate value in the series.

yinvert

Specifies whether resilience occurs above or below the baseline depending on the meaning of high and low 'y' values. When parameter 'yinvert' is set to 'FALSE' (the default), it is assumed that higher numbers are indicative of positive (i.e., desired) 'y' values (e.g., exam grade). When 'yinvert' is set to 'TRUE', it is assumed that lower numbers are indicative of positive (i.e., desired) 'y' values (e.g., blood pressure).

saveout

When the parameter 'saveout' is set to 'FALSE' (the default), a vector of calculated arse_ts values are given for each case. When 'saveout' is set to 'TRUE', a dataframe of the original inputted dataset is returned with a new column of calculated arse_ts values.

Value

When the parameter 'saveout' is set to 'FALSE', a vector of calculated arse_ts values are given for each case. When 'saveout' is set to 'TRUE', a dataframe of the original inputted dataset is returned with a new column of calculated arse_ts values.

Examples

xc <- t(c(1,2,3,4,5,6,7,8,9,10))
yc <- t(c(75,75,77,79,80,81,77,76,77,77))
dataset1 <- data.frame(xc, yc)
arse_ts(data = dataset1, xcoord = dataset1[,1:10], ycoord = dataset1[,11:20], saveout = TRUE)

[Package arse version 1.0.0 Index]