-
Notifications
You must be signed in to change notification settings - Fork 33
/
.Rhistory
512 lines (512 loc) · 19.9 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
history
rm()
ls
ls()
rm(ls())
?rm
rm(list = ls())
# Load and attach the contextual package.
library(contextual)
# Define for how long the simulation will run.
horizon <- 400
# Define how many times to repeat the simulation.
simulations <- 10000
# Define the probability that each ad will be clicked.
click_probabilities <- c(0.8, 0.4, 0.2)
# Initialize a ContextualBernoulliBandit
bandit <- ContextualBernoulliBandit$new(weights = click_probabilities)
# Initialize an EpsilonGreedyPolicy with a 40% exploiration rate.
eg_policy <- EpsilonGreedyPolicy$new(epsilon = 0.4)
# Initialize an EpsilonFirstPolicy with a 100 step exploration period.
ef_policy <- EpsilonFirstPolicy$new(first = 100)
# Initialize two Agents, binding each policy to a bandit.
ef_agent <- Agent$new(ef_policy, bandit)
eg_agent <- Agent$new(eg_policy, bandit)
# Assign both agents to a list.
agents <- list(ef_agent, eg_agent)
# Initialize Simulator with agent list, horizon, and nr of simulations.
simulator <- Simulator$new(agents, horizon, simulations, do_parallel = TRUE)
# Now run the simulator.
history <- simulator$run()
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
# Initialize an EpsilonFirstPolicy with a 100 step exploration period.
ef_policy <- EpsilonFirstPolicy$new(time_steps = 100)
# Initialize two Agents, binding each policy to a bandit.
ef_agent <- Agent$new(ef_policy, bandit)
eg_agent <- Agent$new(eg_policy, bandit)
# Assign both agents to a list.
agents <- list(ef_agent, eg_agent)
# Initialize Simulator with agent list, horizon, and nr of simulations.
simulator <- Simulator$new(agents, horizon, simulations, do_parallel = TRUE)
# Now run the simulator.
history <- simulator$run()
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
?plot
history
summary(history)
library(broom)
tidy(history)
history
test_R6
library(R6)
test_R6
test_R6()
# Finally, plot the average reward per time step t
plot.default(history, type = "average", regret = FALSE, lwd = 2)
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2)
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2, position = "lowerleft")
history
history$agents
class(history)
typeof(history)
legend(legend = FALSE)
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2, position = "lowerleft")
legend(legend = FALSE)
### COntextual bandits
# +-----+----+-----------> ads: k = 3
# | | |
click_probs <- matrix(c( 0.2, 0.3, 0.1, # --> d1: old (p=.5)
0.6, 0.1, 0.1 ), # --> d2: young (p=.5)
# features: d = 2
nrow = 2, ncol = 3, byrow = TRUE)
# Initialize a ContextualBernoulliBandit with contextual weights
context_bandit <- ContextualBernoulliBandit$new(weights = click_probs)
# Initialize LinUCBDisjointPolicy
lucb_policy <- LinUCBDisjointPolicy$new(0.6)
# Initialize three Agents, binding each policy to a bandit.
ef_agent <- Agent$new(ef_policy, context_bandit)
eg_agent <- Agent$new(eg_policy, context_bandit)
lucb_agent <- Agent$new(lucb_policy, context_bandit)
# Assign all agents to a list.
agents <- list(ef_agent, eg_agent, lucb_agent)
# Initialize Simulator with agent list, horizon, and nr of simulations.
simulator <- Simulator$new(agents, horizon, simulations, do_parallel = FALSE)
# Now run the simulator.
history <- simulator$run()
# And plot the cumulative reward rate again.
plot(history, type = "cumulative", regret = FALSE, rate = TRUE)
plot(history, type = "average", regret = FALSE, rate = TRUE)
library(contextual)
?plot
contextual::Plot
?PLot
?Plot
library(contextual)
policy <- EpsilonGreedyPolicy$new(epsilon = 0.1)
bandit <- BasicBernoulliBandit$new(weights = c(0.6, 0.1, 0.1))
agent <- Agent$new(policy, bandit)
simulator <- Simulator$new(agents = agent,
horizon = 100,
simulations = 1000)
history <- simulator$run()
Plot(history, type = "cumulative", regret = TRUE, disp = "ci",
traces_max = 100, traces_alpha = 0.1, traces = TRUE,
legend_position = "topleft")
plot(history, type = "cumulative", regret = TRUE, disp = "ci",
traces_max = 100, traces_alpha = 0.1, traces = TRUE,
legend_position = "topleft")
# Load and attach the contextual package.
library(contextual)
# Define for how long the simulation will run.
horizon <- 400
# Define how many times to repeat the simulation.
simulations <- 10000
# Define the probability that each ad will be clicked.
click_probabilities <- c(0.8, 0.4, 0.2)
# Initialize a ContextualBernoulliBandit
bandit <- ContextualBernoulliBandit$new(weights = click_probabilities)
# Initialize an EpsilonGreedyPolicy with a 40% exploiration rate.
eg_policy <- EpsilonGreedyPolicy$new(epsilon = 0.4)
set.seed(1)
# Define for how long the simulation will run.
horizon <- 400
# Define how many times to repeat the simulation.
simulations <- 10000
# Define the probability that each ad will be clicked.
click_probabilities <- c(0.8, 0.4, 0.2)
# Initialize a ContextualBernoulliBandit
bandit <- ContextualBernoulliBandit$new(weights = click_probabilities)
# Initialize an EpsilonGreedyPolicy with a 40% exploiration rate.
eg_policy <- EpsilonGreedyPolicy$new(epsilon = 0.4)
# Initialize an EpsilonFirstPolicy with a 100 step exploration period.
ef_policy <- EpsilonFirstPolicy$new(time_steps = 100)
# Initialize two Agents, binding each policy to a bandit.
ef_agent <- Agent$new(ef_policy, bandit)
eg_agent <- Agent$new(eg_policy, bandit)
# Assign both agents to a list.
agents <- list(ef_agent, eg_agent)
# Initialize Simulator with agent list, horizon, and nr of simulations.
simulator <- Simulator$new(agents, horizon, simulations, do_parallel = TRUE)
# Now run the simulator.
history <- simulator$run()
saveRDS("history_simulations_onlineadvertising.rds")
saveRDS(history,"history_simulations_onlineadvertising.rds")
library(here)
here()
paste(here(), "work")
filePath <- paste(here(), "/scripts/contextual/")
saveRDS(history, paste0(filePath,"history_simulations_onlineadvertising.rds"))
here()
filePath <- paste0(here(), "/scripts/contextual/")
saveRDS(history, paste0(filePath,"history_simulations_onlineadvertising.rds"))
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2,
legend_position = "lowerleft")
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
### COntextual bandits
# +-----+----+-----------> ads: k = 3
# | | |
click_probs <- matrix(c( 0.2, 0.3, 0.1, # --> d1: old (p=.5)
0.6, 0.1, 0.1 ), # --> d2: young (p=.5)
# features: d = 2
nrow = 2, ncol = 3, byrow = TRUE)
# Initialize a ContextualBernoulliBandit with contextual weights
context_bandit <- ContextualBernoulliBandit$new(weights = click_probs)
# Initialize LinUCBDisjointPolicy
lucb_policy <- LinUCBDisjointPolicy$new(0.6)
# Initialize three Agents, binding each policy to a bandit.
ef_agent <- Agent$new(ef_policy, context_bandit)
eg_agent <- Agent$new(eg_policy, context_bandit)
lucb_agent <- Agent$new(lucb_policy, context_bandit)
# Assign all agents to a list.
agents <- list(ef_agent, eg_agent, lucb_agent)
# Initialize Simulator with agent list, horizon, and nr of simulations.
simulator <- Simulator$new(agents, horizon, simulations, do_parallel = FALSE)
# Now run the simulator.
history_lucb <- simulator$run()
saveRDS(history1, paste0(filePath,"history_lucb_simulations_onlineadvertising.rds"))
# And plot the cumulative reward rate again.
plot(history, type = "cumulative", regret = FALSE, rate = TRUE)
plot(history, type = "average", regret = FALSE, rate = TRUE)
saveRDS(history_lucb, paste0(filePath,"history_lucb_simulations_onlineadvertising.rds"))
# And plot the cumulative reward rate again.
plot(history_lucb, type = "cumulative", regret = FALSE, rate = TRUE)
plot(history_lucb, type = "average", regret = FALSE, rate = TRUE)
plot(history_lucb, type = "average", regret = FALSE, rate = TRUE, legend_position ="bottomright)
plot(history_lucb, type = "average", regret = FALSE, rate = TRUE, legend_position ="bottomright")
# And plot the cumulative reward rate again.
plot(history_lucb, type = "cumulative", regret = FALSE, rate = TRUE, legend_position ="bottomright")
plot(history_lucb, type = "average", regret = FALSE, rate = TRUE, legend_position ="bottomright")
history <- loadRDS(paste0(filePath,"history_simulations_onlineadvertising.rds"))
history <- readRDS(paste0(filePath,"history_simulations_onlineadvertising.rds"))
# Finally, plot the average reward per time step t
plot(history, type = "average", regret = FALSE, lwd = 2,
legend_position = "lowerleft")
# And the cumulative reward rate, which equals the Click Through Rate)
plot(history, type = "cumulative", regret = FALSE, rate = TRUE, lwd = 2)
### COntextual bandits
# +-----+----+-----------> ads: k = 3
# | | |
click_probs <- matrix(c( 0.2, 0.3, 0.1, # --> d1: old (p=.5)
0.6, 0.1, 0.1 ), # --> d2: young (p=.5)
# features: d = 2
nrow = 2, ncol = 3, byrow = TRUE)
history_lucb <-readRDS(paste0(filePath,"history_lucb_simulations_onlineadvertising.rds"))
# And plot the cumulative reward rate again.
plot(history_lucb, type = "cumulative", regret = FALSE, rate = TRUE, legend_position ="bottomright")
plot(history_lucb, type = "average", regret = FALSE, rate = TRUE, legend_position ="bottomright")
install.packages("bsts")
library(bsts)
vignette(bsts)
install.packages("BART")
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)
pkgbuild::has_build_tools(debug = TRUE)
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars"))
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",
if( grepl("^darwin", R.version$os)) "CXX14FLAGS += -arch x86_64 -ftemplate-depth-256" else
if (.Platform$OS.type == "windows") "CXX11FLAGS=-O3 -march=corei7 -mtune=corei7" else
"CXX14FLAGS += -fPIC",
file = M, sep = "\n", append = TRUE)
library(rstan)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
// saved as 8schools.stan
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // standard error of effect estimates
}
parameters {
real mu; // population treatment effect
real<lower=0> tau; // standard deviation in treatment effects
vector[J] eta; // unscaled deviation from mu by school
}
transformed parameters {
vector[J] theta = mu + tau * eta; // school treatment effects
}
model {
target += normal_lpdf(eta | 0, 1); // prior log-density
target += normal_lpdf(y | theta, sigma); // log-likelihood
}
getwd()
setwd("~/Desktop")
schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
schools_dat
fit <- stan(file = '8schools.stan', data = schools_dat)
set.seed(10)
fit <- stan(file = '8schools.stan', data = schools_dat)
print(fit)
plot(fit)
pairs(fit, pars = c("mu", "tau", "lp__"))
la <- extract(fit, permuted = TRUE) # return a list of arrays
mu <- la$mu
### return an array of three dimensions: iterations, chains, parameters
a <- extract(fit, permuted = FALSE)
### use S3 functions on stanfit objects
a2 <- as.array(fit)
m <- as.matrix(fit)
d <- as.data.frame(fit)
y <- as.matrix(read.table('https://raw.github.com/wiki/stan-dev/rstan/rats.txt', header = TRUE))
x <- c(8, 15, 22, 29, 36)
xbar <- mean(x)
N <- nrow(y)
T <- ncol(y)
rats_fit <- stan('https://raw.githubusercontent.com/stan-dev/example-models/master/bugs_examples/vol1/rats/rats.stan')
# https://nth-iteration-labs.github.io/contextual/articles/mabs.html
library(contextual)
library(here)
set.seed(1)
prob_per_arm <- c(0.9, 0.1, 0.1)
horizon <- 100
simulations <- 1000
bandit <- BasicBernoulliBandit$new(prob_per_arm)
agents <- list(Agent$new(OraclePolicy$new(), bandit),
Agent$new(EpsilonGreedyPolicy$new(0.1), bandit),
Agent$new(ThompsonSamplingPolicy$new(1.0, 1.0), bandit),
Agent$new(Exp3Policy$new(0.1), bandit),
Agent$new(GittinsBrezziLaiPolicy$new(), bandit),
Agent$new(UCB1Policy$new(), bandit),
Agent$new(UCB2Policy$new(0.1), bandit))
simulation <- Simulator$new(agents, horizon, simulations)
history <- simulation$run()
saveRDS(history, paste0(filePath,"history_mabs.rds"))
history <- readRDS(paste0(filePath,"history_mabs.rds"))
plot(history, type = "cumulative")
plot(history, type = "cumulative")
plot(history, type = "cumulative")
?contextual::plot
?contextual::Plot
# https://nth-iteration-labs.github.io/contextual/articles/eckles_kaptein.html
library(contextual)
library(here)
# Replication of THOMPSON SAMPLING WITH THE ONLINE BOOTSTRAP By Dean Eckles and Maurits Kaptein
# This evaluations takes time - up to a few hours when run single core.
# Running the script in parallel (for example, on 8 cores)
# shortens the evaluation time substantially.
# https://arxiv.org/abs/1410.4009
# Fig 2. Empirical regret for Thompson sampling and BTS in a K-armed binomial bandit problem.
bandit <- BasicBernoulliBandit$new(weights = c(0.5, rep(0.4,9)))
agents <- list(Agent$new(BootstrapTSPolicy$new(1000), bandit, "BTS 1000"),
Agent$new(ThompsonSamplingPolicy$new(), bandit, "TS"))
simulator <- Simulator$new(agents = agents,
do_parallel = TRUE,
save_interval = 50,
set_seed = 999,
horizon = 1e+05,
simulations = 1000)
history <- simulator$run()
saveRDS(history, paste0(filePath,"history_ts_bootstrap.rds"))
history <- readRDS(paste0(filePath,"history_ts_bootstrap.rds"))
plot(history, log = "x")
filePath <- paste0(here(), "/scripts/contextual/")
saveRDS(history, paste0(filePath,"history_ts_bootstrap.rds"))
here()
filePath <- paste0(here(), "r/scripts/contextual/")
saveRDS(history, paste0(filePath,"history_ts_bootstrap.rds"))
filePath <- paste0(here(), "/r/scripts/contextual/")
saveRDS(history, paste0(filePath,"history_ts_bootstrap.rds"))
library(contextual)
?LinUCBDisjointOptimizedPolicy
library(data.table)
library(contextual)
library(data.table)
# Import personalization data-set
# Info: https://d1ie9wlkzugsxr.cloudfront.net/data_irecsys_CARSKit/Movie_DePaulMovie/README.txt
url <- "http://d1ie9wlkzugsxr.cloudfront.net/data_irecsys_CARSKit/Movie_DePaulMovie/ratings.csv"
data <- fread(url, stringsAsFactors=TRUE)
# Convert data
data <- contextual::one_hot(data, cols = c("Time","Location","Companion"), sparsifyNAs = TRUE)
data[, itemid := as.numeric(itemid)]
data[, rating := ifelse(rating <= 3, 0, 1)]
# Set simulation parameters.
simulations <- 10 # here, "simulations" represents the number of boostrap samples
horizon <- nrow(data)
# Initiate Replay bandit with 10 arms and 100 context dimensions
log_S <- data
formula <- formula("rating ~ itemid | Time_Weekday + Time_Weekend + Location_Cinema + Location_Home +
Companion_Alone + Companion_Family + Companion_Partner")
bandit <- OfflineBootstrappedReplayBandit$new(formula = formula, data = data)
# Define agents.
agents <-
list(Agent$new(RandomPolicy$new(), bandit, "Random"),
Agent$new(EpsilonGreedyPolicy$new(0.03), bandit, "EGreedy 0.05"),
Agent$new(ThompsonSamplingPolicy$new(), bandit, "ThompsonSampling"),
Agent$new(LinUCBDisjointOptimizedPolicy$new(0.37), bandit, "LinUCB 0.37"))
# Initialize the simulation.
simulation <-
Simulator$new(
agents = agents,
simulations = simulations,
horizon = horizon
)
# Run the simulation.
# Takes about 5 minutes: bootstrapbandit loops for arms x horizon x simulations (times nr of agents).
sim <- simulation$run()
# plot the results
plot(sim, type = "cumulative", regret = FALSE, rate = TRUE,
legend_position = "topleft", ylim=c(0.48,0.87))
?sample
contextual::sample
sample(100, 5)
?UCB2Policy
install.packages(bayestestR)
install.packages("bayestestR")
install.packages(recipes)
install.packages("recipes")
getwd
setwd("~/Documents/BayesianElasticNet")
library(here)
my_stan_model <- stan_model(file = "../normal_elastic_net.stan")
library(tidyverse)
library(recipes)
library(rstan)
library(bayestestR)
library(here)
my_stan_model <- stan_model(file = "../normal_elastic_net.stan")
set.seed(200350623)
df <- tibble(
y = rnorm(100),
x1 = rnorm(100, 5, 3),
x2 = rnorm(100, 10, 3)
)
my_recipe <- recipe(y ~., data = df) %>%
step_center(all_predictors()) %>%
step_scale(all_predictors())
params <- recipes::prep(my_recipe, df)
train <- juice(params)
data_list <- list(
x = as.matrix(train[, !names(train) %in% c("y")]),
y = as.numeric(train$y),
lambda_one = 3,
lambda_two = 0.01,
N = nrow(train),
K = 2)
samples <- sampling(
my_stan_model,
data = data_list,
iter = 11000,
refresh = 11000,
control = list(adapt_delta = 0.9999999)
)
all_samples <- extract(samples)
here()
my_stan_model <- stan_model(file = "./stan/normal_elastic_net.stan")
set.seed(200350623)
df <- tibble(
y = rnorm(100),
x1 = rnorm(100, 5, 3),
x2 = rnorm(100, 10, 3)
)
my_recipe <- recipe(y ~., data = df) %>%
step_center(all_predictors()) %>%
step_scale(all_predictors())
params <- recipes::prep(my_recipe, df)
train <- juice(params)
data_list <- list(
x = as.matrix(train[, !names(train) %in% c("y")]),
y = as.numeric(train$y),
lambda_one = 3,
lambda_two = 0.01,
N = nrow(train),
K = 2)
samples <- sampling(
my_stan_model,
data = data_list,
iter = 11000,
refresh = 11000,
control = list(adapt_delta = 0.9999999)
)
all_samples <- extract(samples)
all_samples
library(reticulate)
?reticulate
install.packages(c("devtools", "roxygen2", "testthat", "knitr"))
library(devtools)
has_devel()
install.packages("mbsts")
library(mbsts)
data(exdata)
#Two target series
Y<-as.matrix(exdata[,1:2])
#Sixteen candidate predictors
X.star<-as.matrix(exdata[,3:18])
#split dataset into training set and test set
n=dim(Y)[1]
ntrain=n-5
Ytrain<-Y[1:ntrain,]
Xtrain<-X.star[1:ntrain,]
Ytest<-Y[(ntrain+1):n,]
Xtest<-X.star[(ntrain+1):n,]
#Specify time series components
STmodel<-tsc.setting(Ytrain,mu=c(1,1),rho=c(0.6,1),S=c(4,0),
vrho=c(0,0.5),lambda=c(0,pi/10))
#prior parameters setting
#gama
ki<- c(8,dim(Xtrain)[2])
pii<- matrix(rep(0.5,dim(Xtrain)[2]),nrow=dim(Xtrain)[2])
#beta
b<-matrix(0,dim(Xtrain)[2])
kapp<-0.01
#v0 and V0 for obs Sigma
R2<-0.8
v0<-5
#State component Sigma
v<-0.01
ss<-0.01
#train a mbsts model
mbsts.model<-mbsts(Ytrain,Xtrain,STmodel,ki,pii,b,kapp,R2,v0,v,ss,mc=15,burn=5)
mbsts.model
exdata
glimpse
library(tidyverse)
glimpse(exdata)
?mbsts
library(tseries)
library(zoo)
library(fpp2)
install.packages("fpp2")
setwd("~/Documents/mds/574/trial")
library(devtools)
library(tidyverse)
library(fs)
create_package("~/Documents/mds/524/basketballr")
create_package("~/Documents/mds/524/rsketball")
use_github()
use_github()