首页 > 解决方案 > 在 SPSS 中规范化和绘制时间序列数据

问题描述

我有一个长格式的数据集,如下所示:

Year ID Mean_Income 
2008 1  15042
2009 1  15205
2010 1  15800
2011 1  16443
2008 1  17324
2009 1  17844
2010 2  18011
2011 2  18099
2008 3  16333
2009 3  16554
2010 3  16831
2011 3  16900
.
.
.
2008 150  14998
2009 150  15200
2010 150  15411
2011 150  15500

我想对数据进行标准化,以便在第一年(2008 年),每个 ID 的收入值都是 100,因此此后每年的值都会随着收入的实际增长而增加。像这样的东西:

Year ID Mean_Income Normalized_inc
2008 1  15042       100
2009 1  15205       101
2010 1  15800       104 
2011 1  16443       108

我希望我说得够清楚。我已经尝试将值转换为 Z 分数,但这并不能完全解决我的问题 - 我想从一个共同的起始水平看到一段时间内的趋势。

标签: time-seriesspss

解决方案


您可以为每个 ID 添加一个具有 2008 值的新变量,然后通过将每个后续值除以第一个值来使用它进行标准化:

if year=2008 Mean_Income_2008=Mean_Income.
aggregate /out=* mode=addvariables overwrite=yes 
     /break=ID /Mean_Income_2008=max(Mean_Income_2008).

*now you have the 2008 value in each line, 
 the following is one possibility of using it for normalization.

compute Normalized_inc=Mean_Income/Mean_Income_2008*100.

推荐阅读