Last active
December 11, 2021 23:07
-
-
Save thistleknot/eeaf1631f736e20806c37107f344d50e to your computer and use it in GitHub Desktop.
undifference seasonally (and non seasonally) differenced data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw <- read.csv("https://raw.githubusercontent.com/thistleknot/Python-Stock/master/data/combined_set.csv",row.names=1,header=TRUE) | |
nv_diff_sets <- function(var_of_int,dataset,f_casts) | |
{ | |
s_=sndif_[which(colnames(raw)==var_of_int)] | |
d_=ndif_[which(colnames(raw)==var_of_int)] | |
startRow = which(rownames(raw)==rownames(dataset[1:d_,,drop=FALSE])) | |
data_ <- c(na.omit(c(dataset[,var_of_int], f_casts))) | |
if(s_==0) | |
{ | |
inv_d <- diffinv(data_,differences=d_,xi=raw[startRow,var_of_int]) | |
}else | |
{ | |
inv_d <- diffinv(diffinv(data_,differences = d_, xi=raw[startRow,var_of_int]), differences = s_,xi=raw[startRow:(startRow+season-1),var_of_int]) | |
} | |
return(inv_d) | |
} | |
nv_diff_sets(var_of_int,dataframe,c()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment