
I need to use this formula to calculate the upper limit and lower limit for the below vector. Please help..
> a <- c(2150, 2261, 2018, 2217, 2074, 1986, 1662, 2324, 1591, 1700, 1809, 1824, 2026, 2169, 2072, 1463, 1484, 841, 851, 3742, 889, 905, 1203, 967, 1776, 1075, 1031)
> a
[1] 2150 2261 2018 2217 2074 1986 1662 2324 1591 1700 1809 1824 2026 2169 2072
[16] 1463 1484 841 851 3742 889 905 1203 967 1776 1075 1031
This is just a simple R formula:
The tricky part is |X_i – X_(i-1)| and so we use a few built-in R functions:
diffgives X_i – X_(i-1)absgives the absolute valuethe first part of the formula is the mean and the +/- is just split up.