首页 > 解决方案 > 为什么我的时间序列中没有正确的变量?

问题描述

我正在尝试根据 csv 数据文件中的连续数字在 R 中进行一些预测。但是,在读取文件、删除文本列并使用 timeseries 函数后,我没有从行中获取值,也不知道它从哪里获取值。

在此处输入图像描述

我试图检查环境中的数据集,似乎对 115 个变量进行了 1 次观察,点击它会将我带到正确的数据,在那里我每月观察我正在研究的内容,但点击下一个蓝色小圆圈名称下拉列表,其中所有 115 个变量都被描述为具有 45 到 60 个级别的因子。在创建时间序列时,我尝试对它们进行矢量化,但这不起作用。

library(TTR)
library(forecast)

# then read in the dataset
tourism <- read.csv2("tourism.csv")

# extract relevant rows, vectorize them, and create a timeseries for each    of the 3 groups

total <- tourism[3,]
total <- total[-1:-2]
total <- as.numeric(total)

foreig_tot <- tourism[4,]
foreig_tot <- foreig_tot[-1:-2]
foreig_tot <- as.numeric(foreig_tot)

norwegian <- tourism[5,]
norwegian <- norwegian[-1:-2]
norwegian <- as.numeric(norwegian)

total_ts <- ts(total, frequency = 12, start = c(2010,1))
foreig_tot_ts <- ts(foreig_tot, frequency = 12, start = c(2010,1))
norwegian_ts <- ts(norwegian, frequency = 12, start = c(2010,1))

创建时间序列时,我应该得到大约 95 000 到 150 000 的值,但我得到的值在 20 到 50 之间。

标签: rcsvtime-series

解决方案


推荐阅读