Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 207118

using lag function to predict the next value in R

$
0
0

I'm trying to use the lag function on my dataset so I can do Neural Network analysis after it but im facing a problem with the output of the lag function

the data-set contains 500 rows and 3 columns the first column is date and it contains the date from October 2011 until October 2013 (500 data). the second column is Wdy and it contain the weakly days the final column is the USD and contains the currency rate.

library(readxl)
data <- read_excel("C:/Users/GTS/Desktop/ML project/ExchangeUSD.xlsx")

 normalize <- function(x) {
 return ((x - min(x)) / (max(x) - min(x)))
  }
 rate<- as.data.frame(lapply(data[3], normalize))  

 time_series  <- ts(rate)
  la <-lag(time_series)

I was expecting to have a table of of 4 columns the first 3 is the input and the 4th column is the predicted column this is a sample of the data

the output looks like this

Time Series:
 Start = 0 
End = 499 
Frequency = 1 
USD.EUR
[1,] 0.79099526
[2,] 0.85260664
[3,] 0.80900474
[4,] 0.78530806
[5,] 0.81184834
[6,] 0.76350711

Viewing all articles
Browse latest Browse all 207118

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>