A period change compares the current observation with an earlier point in the same series.

Program

Play the script to change the lookback distance and see the difference.

period_change.R
periods_back <- 
values <- c(100, 108, 111, 120)
current <- values[length(values)]
previous <- values[length(values) - periods_back]
change <- current - previous
label <- paste("change", change, sep = ":")
cat(label, "\n", sep = "")
periods_back <- 
values <- c(100, 108, 111, 120)
current <- values[length(values)]
previous <- values[length(values) - periods_back]
change <- current - previous
label <- paste("change", change, sep = ":")
cat(label, "\n", sep = "")
periods_back <- 
values <- c(100, 108, 111, 120)
current <- values[length(values)]
previous <- values[length(values) - periods_back]
change <- current - previous
label <- paste("change", change, sep = ":")
cat(label, "\n", sep = "")
current The current value is the last observation in the ordered vector.
lookback `periods_back` selects how far back to compare.
difference `current - previous` is the absolute period change.