statable Statistics for study and research

Shift and smooth: previous value, next value, change, moving average

In brief

The data assistant "Shift and smooth" (Edit data) creates new columns from a number column: the value of the previous or next measurement (previous value, next value, delay k), the change from the previous measurement (also in percent) and the moving average. This corresponds to the functions LAG, LEAD, DIFF, MA and PMA of the SPSS command CREATE. The calculation is per person in long format (one row per measurement), the time column sets the order; the rows of the data stay as they are. The value of another person never enters.

Trap: gaps in time

SPSS knows only the order of the cases. If a measurement is missing, the "previous value" is the measurement before, not the one a time unit before. Example person B with the times 1, 2, 4, 5 and the values 5, 6, 8, 9: previous value by order ., 5, 6, 8; only at distance 1 instead ., 5, ., 8. Statable calculates by order (default) and then shows, clearly visible above the result, for how many people time points are missing. The choice "only if the distance is exactly k time units" otherwise leaves the cell empty. The same holds for the change.

Moving average

More rules

Sources

IBM SPSS Statistics Knowledge Center, version 23: CREATE (functions LAG, LEAD, DIFF, MA, PMA).

Related

Open in Statable