time-series - 在 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 分数,但这并不能完全解决我的问题 - 我想从一个共同的起始水平看到一段时间内的趋势。
解决方案
您可以为每个 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.
推荐阅读
- import - 将数据层应用程序导入 Azure SQL 服务器的问题
- java - Webview 不适用于 Android 8.0 (OREO) 上的 Scorm
- swift - Unable to initialise UIImage in TableCellView
- angular - ng 测试返回“0 个测试完成”
- javascript - javascript - 从用户输入转换多个代码并将转换后的字符显示为字符串
- c++ - 如何使用 boost log 防止内存增长?
- javascript - Serverless-webpack 部署脚本在 Webpack 4.8 中“挂起”,而在 3.12 中运行正常。
- javascript - 使用带有 nodejs 的 tesseract 获取无效回调
- java - 如何使用 JPA EclipseLink 启用 Unicode 编码?
- git - 我需要“Git”来安装 Apache Spark