autoregressive-models

R: How to fit a time series model such as “Y(t) = αX + βY(t-1)”?

戏子无情 提交于 2021-02-08 08:18:15
问题 How do I fit this model in R, step by step? My scope is to make a forecast for t+1. Y(t) = αX(t) + βY(t-1) Y(t) <- years from 1900 to 2000. X <- a score measure from 0 to 100. Y(t-1) <- lagged value of order 1 for Y. Thanks in advance. 回答1: Your model is an AR(1) time series for y with covariate x . We can just use arima0 (no missing value) or arima (missing value allowed) from R base: fit <- arima0(y, order = c(1, 0, 0), xreg = x) Let's consider a small example: set.seed(0) x <- runif(100) #

NARX Neural network prediction?

試著忘記壹切 提交于 2020-01-01 19:42:49
问题 I am trying to solve a time series problem using the NARX Neural Network solution that Matlab provides. I am trying to understand how to predict actual values, but the results I get are almost perfect! The errors are so small that I am not sure if I am actually predicting. I just want to make sure I am doing everything right! Basically I train the network with some samples using the GUI solution. Then I use the following script to test the neural network with new samples: X = num2cell(open2(1

Choosing specific lags in ARIMA or VAR Model

£可爱£侵袭症+ 提交于 2019-12-18 17:28:17
问题 I've seen this issue raised here and here but unfortunately the answers are not satisfactory. Inputting the lags in either the p argument in VAR or the order argument in arima , R will include all the lags at and below that stated value. However, what if you want specific lags only? For example, what if I wanted lags 1, 2, and 4 only in a VAR? Inputting P=4 in VAR will give me lags 1,2,3 and 4, but I would like to exclude the third lag. In the first link, the user provided an answer by

Repeat many times the same code with R and collect the final results

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 17:02:37
问题 i have a problem. I hope that you will understand me. My english is not very good. I need to repeat B times (where B is at least one thousand) a R code that i write and collect the 1000 final results. I report the code: phi=0.5 p=1 n=100 M=1000 serie1=arima.sim(model=list(ar =phi ,order=c(p,0,0)),n = n,innov=rnorm(100,0,1)) stima<-arima(serie1,order=c(p,0,0),include.mean=F) phi.stima=stima$coef res=stima$residual ress=res[2:n] res.c=ress-mean(ress) serie.b=vector("numeric",length=n+M) ps

How to get fitted values from ar() method model in R

倖福魔咒の 提交于 2019-12-11 14:47:01
问题 I want to retrieve the fitted values from an ar() function output model in R . When using Arima() method, I get them using fitted(model.object) function, but I cannot find its equivalent for ar() . 回答1: It does not store a fitted vector but does have the residuals. An example of using the residuals from the ar -object to reconstruct the predictions from the original data: data(WWWusage) arf <- ar(WWWusage) str(arf) #==================== List of 14 $ order : int 3 $ ar : num [1:3] 1.175 -0

Auto.arima is not showing any order

微笑、不失礼 提交于 2019-12-11 14:46:31
问题 I am trying to fit arima model using auto.arima function in R. The result is showing order (0,0,0) even though the data is non-stationary. auto.arima(x,approximation=TRUE) ARIMA(0,0,0) with non-zero mean Can someone advice why such results are coming? Btw i am running this function on only 10 data points. 回答1: 10 data points is a very low number of observations for estimating an ARIMA model. I doubt that you can make any sensible estimation based on this. Moreover, the estimated model may

NARX Neural network prediction?

谁都会走 提交于 2019-12-06 21:09:51
I am trying to solve a time series problem using the NARX Neural Network solution that Matlab provides. I am trying to understand how to predict actual values, but the results I get are almost perfect! The errors are so small that I am not sure if I am actually predicting. I just want to make sure I am doing everything right! Basically I train the network with some samples using the GUI solution. Then I use the following script to test the neural network with new samples: X = num2cell(open2(1:end))'; % input T = num2cell(close2(1:end))'; % this is the output I should get net = removedelay(net)