cusum_single_median_df

cusum_single_median_df(x, target = NULL)

Arguments

x

a numeric vector from which to calculate the cumulative sum statistics

target

value to compare each element of x to. If not provided, the median value of x will be calculated and used as a target value

Value

a dataframe with the original values, target, the variance, the cumulative sum of the variance, and the cumulative sum centered on the target value. This centering is achieved by adding the target value to the cumulative sum.

Examples


test_vec <- c(0.175, 0.152, 0.15, 0.207, 0.136, 0.212, 0.166)
cusum_single_median_df(test_vec, target = 0.16)
#>       x target     si cusumx cusum_target
#> 1 0.175   0.16  0.015  0.015        0.175
#> 2 0.152   0.16 -0.008  0.007        0.167
#> 3 0.150   0.16 -0.010 -0.003        0.157
#> 4 0.207   0.16  0.047  0.044        0.204
#> 5 0.136   0.16 -0.024  0.020        0.180
#> 6 0.212   0.16  0.052  0.072        0.232
#> 7 0.166   0.16  0.006  0.078        0.238
cusum_single_median_df(test_vec)
#>       x target     si cusumx cusum_target
#> 1 0.175  0.166  0.009  0.009        0.175
#> 2 0.152  0.166 -0.014 -0.005        0.161
#> 3 0.150  0.166 -0.016 -0.021        0.145
#> 4 0.207  0.166  0.041  0.020        0.186
#> 5 0.136  0.166 -0.030 -0.010        0.156
#> 6 0.212  0.166  0.046  0.036        0.202
#> 7 0.166  0.166  0.000  0.036        0.202