tau = -1.5)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -0.5)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5)
View(thrips_xmap_maxT)
View(thrips_xmap_maxT)
help(ccm)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, stats_only=FALSE)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, stats_only = TRUE)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, stats_only = False)
help(CCM)
thrips_xmap_maxT <- ccm(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, stats_only = False)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, includeData=True)
thrips_xmap_maxT <- CCM(dataFrame = Thrips, E = 4, Tp = 0.5, columns = "Thrips_imaginis",
target = "maxT_degC", libSizes = "13 73 3", sample = 300, showPlot = TRUE,
tau = -1.5, includeData=TRUE)
View(input_data)
View(thrips_xmap_maxT)
library(rEDM)
help(make_surrogate_data)
make_surrogate_data(B[:,1])
make_surrogate_data(B[,1])
data = make_surrogate_data(block_3sp$x_t)
View(data)
view(make_surrogate_data)
make_surrogate_data
help(SurrogateData)
open(SurrogateData)
library('rEDM')
data(sardine_anchovy_sst)
rm(list = ls())
library('rEDM')
data(sardine_anchovy_sst)
sardine_anchovy_sst['sardine']
lib <- c(1, 50)
pred <- c(51, 75)
smap_output <- s_map(sardine_anchovy_sst['np_sst'], lib, pred, E = 3)
sardine_anchovy_sst['np_sst']
ts <- sardine_anchovy_sst['np_sst']
lib <- c(1, 50)
pred <- c(51, 75)
smap_output <- s_map(ts, lib, pred, E = 3)
sardine_anchovy_sst['np_sst']
unlist(sardine_anchovy_sst['np_sst'])
x <- unlist(sardine_anchovy_sst['np_sst'])
x <- num(sardine_anchovy_sst['np_sst'])
ts <- unlist(sardine_anchovy_sst['np_sst'])
lib <- c(1, 50)
pred <- c(51, 75)
smap_output <- s_map(ts, lib, pred, E = 3)
View(smap_output)
smap_output <- s_map(ts, E = 3)
View(smap_output)
help(s_map)
data(sardine_anchovy_sst)
ts <- unlist(sardine_anchovy_sst['np_sst'])
smap_output <- s_map(ts, E = 3)
ts_ <- make_surrogate_data(ts, method='ebisuzaki')
ts_[:,1]
ts_[,1]
smap_output <- s_map(ts, E = 3)
View(smap_output)
View(smap_output)
optim_embed <- which.max(unlist(simplex_output["rho"]))
theta_optim <- simplex_output$theta[optim_embed]
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,1], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,2], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,3], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
ts_[,1]
smap_output <- s_map(ts_[,4], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,5], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,6], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,7], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,8], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,9], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,10], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
smap_output <- s_map(ts_[,11], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
source('~/Untitled.R')
source('~/Untitled.R')
source('~/Untitled.R')
source('~/Untitled.R')
source('~/Untitled.R')
theta_null <- c()
i=1
while(i<=100) {
smap_output <- s_map(ts_[,11], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null<-c(theta_null,smap_output$theta[optim_embed])
i=i+1
}
theta_null <- c()
i=1
while(i<=100) {
smap_output <- s_map(ts_[,i], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null<-c(theta_null,smap_output$theta[optim_embed])
i=i+1
}
num_surr= 100
ts_ <- make_surrogate_data(ts, method='ebisuzaki', num_surr=num_surr)
num_surr= 100
ts_ <- make_surrogate_data(ts, method='ebisuzaki', num_surr=num_surr)
theta_null <- vector("list", num_surr)
i=1
while(i<=num_surr) {
smap_output <- s_map(ts_[,i], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null[[i]] <- smap_output$theta[optim_embed]
i=i+1
}
View(theta_null)
sum(theta_null >= theta_optim)
theta_optim
data(sardine_anchovy_sst)
ts <- unlist(sardine_anchovy_sst['np_sst'])
smap_output <- s_map(ts, E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
theta_optim
sum(theta_null >= theta_optim)
View(theta_null)
View(theta_null)
num_surr= 1000
ts_ <- make_surrogate_data(ts, method='ebisuzaki', num_surr=num_surr)
theta_null <- vector("list", num_surr)
i=1
while(i<=num_surr) {
smap_output <- s_map(ts_[,i], E = 3)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null[[i]] <- smap_output$theta[optim_embed]
i=i+1
}
sum(theta_null >= theta_optim) / n_surr
sum(theta_null >= theta_optim) / num_surr
library('rEDM')
data(sardine_anchovy_sst)
ts <- unlist(sardine_anchovy_sst['np_sst'])
smap_output <- s_map(ts, E = 2)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
theta_optim
library('rEDM')
data(sardine_anchovy_sst)
ts <- unlist(sardine_anchovy_sst['np_sst'])
smap_output <- s_map(ts, E = 4)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
num_surr= 1000
ts_ <- make_surrogate_data(ts, method='ebisuzaki', num_surr=num_surr)
theta_null <- vector("list", num_surr)
i=1
while(i<=num_surr) {
smap_output <- s_map(ts_[,i], E = 4)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null[[i]] <- smap_output$theta[optim_embed]
i=i+1
}
sum(theta_null >= theta_optim) / num_surr
ts <- unlist(sardine_anchovy_sst['np_sst'])
smap_output <- s_map(ts, E = 5)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_optim <- smap_output$theta[optim_embed]
num_surr= 1000
ts_ <- make_surrogate_data(ts, method='ebisuzaki', num_surr=num_surr)
theta_null <- vector("list", num_surr)
i=1
while(i<=num_surr) {
smap_output <- s_map(ts_[,i], E = 5)
optim_embed <- which.max(unlist(smap_output["rho"]))
theta_null[[i]] <- smap_output$theta[optim_embed]
i=i+1
}
sum(theta_null >= theta_optim) / num_surr
R.version
install.packeages('rEDM')
install.packages('rEDM')
library('rEDM')
require(devtools)
require(devtools)
install_version("rEDM", version = "1.8.0")
library(rEDM)
help(ccm)
help(rEDM)
help('rEDM')
remove.packages(rEDM)
remove.packages('rEDM')
library(rEDM)
library('rEDM')
require(devtools)
install_version("rEDM", version = "1.5.0")
library(rEDM)
help(rEDM)
help('rEDM')
help(ccm)
remove.packages(rEDM)
remove.packages('rEDM')
help(ccm)
sessionInfo()
remove.packages(rEDM)
require(devtools)
install_version("rEDM", version = "0.7.2", repos = "http://cran.us.r-project.org")
library(rEDM)
help("ccm")
# parameters
max_tau = 120
max_E = 3
min_tau = 120
min_E = 3
min_lib_size = 10
max_lib_size = 310
lib_size_step = 20
num_samples = 300
lib_begin = 1
lib_end = 1000
pred_begin = 1
pred_end = 1000
rand_libs = TRUE
prediction_horizon = c(0)
input_filename = "tmp/data.csv"
n_surr = 100
n_surr_samples = 1
surr_type = "ebisuzaki"
surr_test = FALSE
surr_period = 1
replace = TRUE
seed = NULL
# import library
library(rEDM)
# import data
input_data = read.csv(input_filename)
vars <- colnames(input_data)
# determine optimal embedding for series A
ts <- input_data$A
lib <- c(lib_begin, lib_end)
pred <- c(pred_begin, pred_end)
simplex_output = data.frame()
for (tau in min_tau : max_tau) {
for (E in min_E : max_E){
sp_libsize = lib_end - lib_begin
simplex_output <- rbind(simplex_output, ccm(input_data, lib, pred, tau=tau, E=E, random_libs=FALSE,
lib_sizes=sp_libsize, tp=1, lib_column='A', target_column='A'))
}
}
optim_embed = which.max(unlist(simplex_output["rho"])) # for v0.7.3
tau_star_A = simplex_output$tau[optim_embed]
E_star_A = simplex_output$E[optim_embed]
# set min_lib_size = -1 to automatically choose min_lib_size
if (min_lib_size == -1){
min_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
}
# set max_lib_size = -1 to automatically choose max_lib_size
if (max_lib_size == -1){
max_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
if ((replace == FALSE) && rand_libs){
max_lib_size = max_lib_size - 1
}
}
# set lib_size_step = -1 for single step
if (lib_size_step == -1) {
lib_size_step = max_lib_size - min_lib_size
}
### run CCM with with optimal embedding of predictor
A_xmap_B <- data.frame() #NEW
for (tp in prediction_horizon){
ccm_tp <- ccm(input_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = seq(min_lib_size, max_lib_size, by = lib_size_step),
num_samples = num_samples, tp = tp,
stats_only = TRUE, RNGseed = seed)
ccm_tp['tp'] = tp
A_xmap_B <- rbind(A_xmap_B, ccm_tp)
} #NEW
setwd('/Users/alexyuan/Documents/Shou Lab/timeseries_review/lib_construction')
# parameters
max_tau = 120
max_E = 3
min_tau = 120
min_E = 3
min_lib_size = 10
max_lib_size = 310
lib_size_step = 20
num_samples = 300
lib_begin = 1
lib_end = 1000
pred_begin = 1
pred_end = 1000
rand_libs = TRUE
prediction_horizon = c(0)
input_filename = "tmp/data.csv"
n_surr = 100
n_surr_samples = 1
surr_type = "ebisuzaki"
surr_test = FALSE
surr_period = 1
replace = TRUE
seed = NULL
# import library
library(rEDM)
# import data
input_data = read.csv(input_filename)
vars <- colnames(input_data)
# determine optimal embedding for series A
ts <- input_data$A
lib <- c(lib_begin, lib_end)
pred <- c(pred_begin, pred_end)
simplex_output = data.frame()
for (tau in min_tau : max_tau) {
for (E in min_E : max_E){
sp_libsize = lib_end - lib_begin
simplex_output <- rbind(simplex_output, ccm(input_data, lib, pred, tau=tau, E=E, random_libs=FALSE,
lib_sizes=sp_libsize, tp=1, lib_column='A', target_column='A'))
}
}
optim_embed = which.max(unlist(simplex_output["rho"])) # for v0.7.3
tau_star_A = simplex_output$tau[optim_embed]
E_star_A = simplex_output$E[optim_embed]
# set min_lib_size = -1 to automatically choose min_lib_size
if (min_lib_size == -1){
min_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
}
# set max_lib_size = -1 to automatically choose max_lib_size
if (max_lib_size == -1){
max_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
if ((replace == FALSE) && rand_libs){
max_lib_size = max_lib_size - 1
}
}
# set lib_size_step = -1 for single step
if (lib_size_step == -1) {
lib_size_step = max_lib_size - min_lib_size
}
A_xmap_B <- data.frame() #NEW
for (tp in prediction_horizon){
ccm_tp <- ccm(input_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = seq(min_lib_size, max_lib_size, by = lib_size_step),
num_samples = num_samples, tp = tp,
stats_only = TRUE, RNGseed = seed)
ccm_tp['tp'] = tp
A_xmap_B <- rbind(A_xmap_B, ccm_tp)
} #NEW
ccm_tp <- ccm(input_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = seq(min_lib_size, max_lib_size, by = lib_size_step),
num_samples = num_samples, tp = tp,
RNGseed = seed)
View(ccm_tp)
A_xmap_B <- data.frame() #NEW
for (tp in prediction_horizon){
ccm_tp <- ccm(input_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = seq(min_lib_size, max_lib_size, by = lib_size_step),
num_samples = num_samples, tp = tp,
RNGseed = seed)
ccm_tp['tp'] = tp
A_xmap_B <- rbind(A_xmap_B, ccm_tp)
} #NEW
# parameters
max_tau = 120
max_E = 3
min_tau = 120
min_E = 3
min_lib_size = 10
max_lib_size = 310
lib_size_step = 20
num_samples = 300
lib_begin = 1
lib_end = 1000
pred_begin = 1
pred_end = 1000
rand_libs = TRUE
prediction_horizon = c(0)
input_filename = "tmp/data.csv"
n_surr = 100
n_surr_samples = 1
surr_type = "ebisuzaki"
surr_test = FALSE
surr_period = 1
replace = TRUE
seed = NULL
# import library
library(rEDM)
# import data
input_data = read.csv(input_filename)
vars <- colnames(input_data)
# determine optimal embedding for series A
ts <- input_data$A
lib <- c(lib_begin, lib_end)
pred <- c(pred_begin, pred_end)
simplex_output = data.frame()
for (tau in min_tau : max_tau) {
for (E in min_E : max_E){
sp_libsize = lib_end - lib_begin
simplex_output <- rbind(simplex_output, ccm(input_data, lib, pred, tau=tau, E=E, random_libs=FALSE,
lib_sizes=sp_libsize, tp=1, lib_column='A', target_column='A'))
}
}
optim_embed = which.max(unlist(simplex_output["rho"])) # for v0.7.3
tau_star_A = simplex_output$tau[optim_embed]
E_star_A = simplex_output$E[optim_embed]
# set min_lib_size = -1 to automatically choose min_lib_size
if (min_lib_size == -1){
min_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
}
# set max_lib_size = -1 to automatically choose max_lib_size
if (max_lib_size == -1){
max_lib_size = lib_end - lib_begin + 1 - tau_star_A * (E_star_A - 1) # for v0.7.3
if ((replace == FALSE) && rand_libs){
max_lib_size = max_lib_size - 1
}
}
# set lib_size_step = -1 for single step
if (lib_size_step == -1) {
lib_size_step = max_lib_size - min_lib_size
}
### run CCM with with optimal embedding of predictor
A_xmap_B <- data.frame() #NEW
for (tp in prediction_horizon){
ccm_tp <- ccm(input_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = seq(min_lib_size, max_lib_size, by = lib_size_step),
num_samples = num_samples, tp = tp,
RNGseed = seed)
ccm_tp['tp'] = tp
A_xmap_B <- rbind(A_xmap_B, ccm_tp)
} #NEW
write.csv(A_xmap_B,'tmp/AxB1.csv')
### redo with surrogate time series
# execution of surrogate series calculations
if (surr_test){
surr_B = make_surrogate_data(input_data$B, surr_type, n_surr)
surr_AxB = data.frame() # initialize data frame in which to store result
# begin the for loop here...
for (sidx in 1:n_surr){
surr_data = data.frame(input_data$A, surr_B[,sidx])
colnames(surr_data) <- c("A", "B")
# run CCM on surrogate data
A_xmap_B = data.frame() #NEW
for (tp in prediction_horizon){
ccm_tp <- ccm(surr_data, E = E_star_A, tau = tau_star_A,
lib=c(lib_begin, lib_end), pred=c(pred_begin, pred_end),
random_libs = rand_libs, replace = replace, lib_column = "A",
target_column = "B", lib_sizes = max_lib_size,
num_samples=n_surr_samples, tp = tp,
RNGseed = seed)
ccm_tp['tp'] = tp
A_xmap_B <- rbind(A_xmap_B, ccm_tp)
} #NEW
A_xmap_B$rep <- rep(sidx, length(prediction_horizon)) #NEW
# save result in the ledger data structures
surr_AxB <- rbind(surr_AxB, A_xmap_B)
}
write.csv(surr_AxB,'tmp/AxB_surr.csv')
}
View(A_xmap_B)
