# 时间序列模型加法和乘法过程.rar

• zzcdc
了解作者
• R language
开发工具
• 1KB
文件大小
• rar
文件格式
• 0
收藏次数
• 1 积分
下载积分
• 0
下载次数
• 2021-03-31 23:23
上传日期

• 时间序列模型加法和乘法过程.R
5.8KB

# Getting the data points in form of a R vector. snowfall <- c(790, 1170.8, 860.1, 1330.6, 630.4, 911.5, 683.5, 996.6, 783.2, 982, 881.8, 1021) # Convertting it into a time series object. snowfall_timeseries<- ts(snowfall, start = c(2013, 1), frequency = 12) # Printing the timeseries data. print(snowfall_timeseries) # Giving a name to the chart file. png(file = "snowfall.png") # Plotting a graph of the time series. plot(snowfall_timeseries) # Saving the file. dev.off() #Importing library fpp 加法模型图 共五步 install.packages("fpp") install.packages("forecast") install.packages("xts") library(forecast) library(fpp) #Using ausbeer data data(ausbeer) #Creating time series for ausbeer dataset timeserie.beer = tail(head(ausbeer, 17*4+2), 17*4-4) # Giving a name to the chart file. png(file = "time.png") plot(as.ts(timeserie.beer), col="magenta") # Saving the file. dev.off() #Detecting trend 检测加法模型趋势 trend.beer = ma(timeserie.beer, order = 4, centre = T) # Giving a name to the file. png(file = "time.png") plot(as.ts(timeserie.beer), col="red") lines(trend.beer, col="red") plot(as.ts(trend.beer), col="red") # Saving the file. dev.off() #Detrend the time series.加法模型时间序列趋势检验 detrend.beer=timeserie.beer-trend.beer # Giving a name to the file. png(file = "time.png") plot(as.ts(detrend.beer), col="magenta") # Saving the file. dev.off() #Average the seasonality 检测平均季节性 m.beer = t(matrix(data = detrend.beer, nrow = 4)) seasonal.beer = colMeans(m.beer, na.rm = T) # Giving a name to the file. png(file = "time.png") plot(as.ts(rep(seasonal.beer, 16)), col="magenta") # Saving the file. dev.off() # Examining the Remaining Random Noise 检测剩余的白噪声 random.beer = timeserie.beer - trend.beer - seasonal.beer # Giving a name to the file. png(file = "time.png") plot(as.ts(rep(random.beer)), col="magenta") # Saving the file. dev.off() #Reconstruction of original signal 重建原始信号 recomposed.beer=trend.beer+seasonal.beer+random.beer # Giving a name to the file. png(file = "time.png") plot(as.ts(recomposed.beer), col="magenta") # Saving the file. dev.off() #Importing library Ecdat 乘法模型图 install.packages("Ecdat") install.packages("Ecfun") library(Ecfun) library(Ecdat) #Using AirPassengers data data(AirPassengers) #Creating time series for AirPassengers dataset timeserie_air = AirPassengers # Giving a name to the file. png(file = "time.png") plot(as.ts(timeserie_air)) # Saving the file. dev.off() #Detecting trend 乘法模型趋势检测 trend.air = ma(timeserie_air, order = 12, centre = T) # Giving a name to the file. png(file = "time.png") plot(as.ts(timeserie_air), col="blue") lines(trend.air, col="blue") plot(as.ts(trend.air), col="blue") # Saving the file. dev.off() #Detrend of time series 乘法模型时间序列趋势检验 detrend.air=timeserie_air / trend.air # Giving a name to the file. png(file = "time.png") plot(as.ts(detrend.air), col="blue") # Saving the file. dev.off() #Average the seasonality 乘法模型检测季节性 m.air = t(matrix(data = detrend.air, nrow = 12)) seasonal.air = colMeans(m.air, na.rm = T) # Giving a name to the file. png(file = "time.png") plot(as.ts(rep(seasonal.air, 12)), col="blue") # Saving the file. dev.off() # Examining the Remaining Random Noise 检测剩余的白噪声 random.air = timeserie_air / (trend.air * seasonal.air) # Giving a name to the file. png(file = "time.png") plot(as.ts(random.air), col="blue") # Saving the file. dev.off() #Reconstruction of original signal 重建原始信号 recomposed.air = trend.air*seasonal.air*random.air # Giving a name to the file. png(file = "time.png") plot(as.ts(recomposed.air), col="blue") # Saving the file. dev.off() #使用decompose()进行时间序列分解 #Importing libraries 对于加性模型 library(forecast) install.packages("timeSeries") library(timeDate) library(timeSeries) library(fpp) #Using ausbeer data data(ausbeer) #Creating time series timeserie.beer = tail(head(ausbeer, 17*4+2), 17*4-4) #Detect trend trend.beer = ma(timeserie.beer, order = 4, centre = T) #Detrend of time series detrend.beer=timeserie.beer-trend.beer #Average the seasonality m.beer = t(matrix(data = detrend.beer, nrow = 4)) seasonal.beer = colMeans(m.beer, na.rm = T) #Examine the remaining random noise random.beer = timeserie.beer - trend.beer - seasonal.beer #Reconstruct the original signal recomposed.beer = trend.beer+seasonal.beer+random.beer #Decomposed the time series ts.beer = ts(timeserie.beer, frequency = 4) decompose.beer = decompose(ts.beer, "additive") # Giving a name to the file. png(file = "time.png") par(mfrow=c(2, 2)) plot(as.ts(decompose.beer\$seasonal), col="magenta") plot(as.ts(decompose.beer\$trend), col="magenta") plot(as.ts(decompose.beer\$random), col="magenta") plot(decompose.beer, col="magenta") # Saving the file. dev.off() #Importing libraries 对于乘法模型 library(forecast) library(timeSeries) library(fpp) library(Ecdat) #Using Airpassengers data data(AirPassengers) #Creating time series timeseries.air = AirPassengers #Detect trend trend.air = ma(timeseries.air, order = 12, centre = T) #Detrend of time series detrend.air=timeseries.air / trend.air #Average the seasonality m.air = t(matrix(data = detrend.air, nrow = 12)) seasonal.air = colMeans(m.air, na.rm = T) #Examine the remaining random noise random.air = timeseries.air / (trend.air * seasonal.air) #Reconstruct the original signal recomposed.air = trend.air*seasonal.air*random.air #Decomposed the time series ts.air = ts(timeseries.air, frequency = 12) decompose.air = decompose(ts.air, "multiplicative") # Giving a name to the file. png(file = "time.png") par(mfrow=c(2, 2)) plot(as.ts(decompose.air\$seasonal), col="blue") plot(as.ts(decompose.air\$trend), col="blue") plot(as.ts(decompose.air\$random), col="blue") plot(decompose.air, col="blue") # Saving the file. dev.off()

相关推荐
• svm_predic.m.rar
应用支持向量机回归和相空间重构对时间序列进行预测
• LSSVM.rar
lssvm用于时间序列预测的matlab程序
• lssvm_prediction.rar
LSSVM时间序列预测，基于matlab lssvm工具箱！推荐！！！！！
• lssvm.rar
SVM对时间序列的预测，很实用，改变数据可直接使用。
• LSSVM.rar
可以用于时间序列数据下的预测,以及数据模拟。
• LSSVM_1.rar
最小二乘支持向量机、时间序列预测、交叉验证
• svm.zip
采用支持向量机算法对高边坡变形时间序列进行预测
• LSSVMlabv1_8_R2009b_R2011a.zip
lssvm模型时间序列预测，加上粒子群优化算法
• ssi法的修正
随机子空间法的修正之后代码,,,,,%1、噪声添加程序 y向加速度 %读取数据文件 clc;clear [FileName,PathName]=... %第一列为时间序列 TimePointNum=TimePointNum; Baizaosheng=wgn(TimePointNum,MesNodeTotalNum,1);
• matlabcnhelp.rar
matlab中文帮助很难找的，快速下载