Stan
R Markdown Stan Python R Stata Julia R Stata References Please don’t mind this post. I use this to try out various highlighting styles for my code and formats. \begin{algorithm} \caption{Quicksort} \begin{algorithmic} \PROCEDURE{Quicksort}{$A, p, r$} \IF{$p < r$} \STATE $q = $ \CALL{Partition}{$A, p, r$} \STATE \CALL{Quicksort}{$A, p, q - 1$} \STATE \CALL{Quicksort}{$A, q + 1, r$} \ENDIF \ENDPROCEDURE \PROCEDURE{Partition}{$A, p, r$} \STATE $x = A[r]$ \STATE $i = p - 1$ \FOR{$j = p$ \TO $r - 1$} \IF{$A[j] < x$} \STATE $i = i + 1$ \STATE exchange $A[i]$ with $A[j]$ \ENDIF \STATE exchange $A[i]$ with $A[r]$ \ENDFOR \ENDPROCEDURE \end{algorithmic} \end{algorithm} YPost⁡=β0+β1Group⁡+β2Base⁡+β3Age⁡+β4Z⁡+β5R1⁡+β6R2⁡+ϵY^{\operatorname{Post}} = \beta_{0} + \beta_{1}^{\operatorname{Group}} + \beta_{2}^{\operatorname{Base}} + \beta_{3}^{\operatorname{Age}} + \beta_{4}^{\operatorname{Z}} + \beta_{5}^{\operatorname{R1}} + \beta_{6}^{\operatorname{R2}} + \epsilonYPost=β0​+β1Group​+β2Base​+β3Age​+β4Z​+β5R1​+β6R2​+ϵ \[Y^{\operatorname{Post}} = \beta_{0} + \beta_{1}^{\operatorname{Group}} + \beta_{2}^{\operatorname{Base}} + \beta_{3}^{\operatorname{Age}} + \beta_{4}^{\operatorname{Z}} + \beta_{5}^{\operatorname{R1}} + \beta_{6}^{\operatorname{R2}} + \epsilon\] R Markdown This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com. When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: Stan df1 <- read.csv("/Users/zad/Dropbox/LessLikely/ts.csv") df1$y <- ts(df1$Sales) df1$ds <- as.Date(df1$Time.Increment) splits <- initial_time_split(df1, prop = 0.5) train <- training(splits) test <- testing(splits) interactive <- TRUE # Forecasting with auto.arima library("forecast") md <- auto.arima(train$y) fc <- forecast(md, h = 12) model_fit_arima_no_boost <- arima_reg() %>% set_engine(engine = "auto_arima") %>% fit(y ~ ds, data = training(splits)) # Model 2: arima_boost ---- model_fit_arima_boosted <- arima_boost( min_n = 2, learn_rate = 0.015 ) %>% set_engine(engine = "auto_arima_xgboost") %>% fit(y ~ ds + as.numeric(ds) + factor(month(ds, label = TRUE), ordered = F ), data = training(splits) ) # Model 3: ets ---- model_fit_ets <- exp_smoothing() %>% set_engine(engine = "ets") %>% fit(y ~ ds, data = training(splits)) model_fit_lm <- linear_reg() %>% set_engine("lm") %>% fit(y ~ as.numeric(ds) + factor(month(ds, label = TRUE), ordered = FALSE ), data = training(splits) ) # Model 4: prophet ---- model_fit_prophet <- prophet_reg() %>% set_engine(engine = "prophet") %>% fit(y ~ ds, data = training(splits)) #> Error in sampler$call_sampler(c(args, dotlist)): c++ exception (unknown reason) # Model 6: earth ---- model_spec_mars <- mars(mode = "regression") %>% set_engine("earth") recipe_spec <- recipe(y ~ ds, data = training(splits)) %>% step_date(ds, features = "month", ordinal = FALSE) %>% step_mutate(date_num = as.numeric(ds)) %>% step_normalize(date_num) %>% step_rm(ds) wflw_fit_mars <- workflow() %>% add_recipe(recipe_spec) %>% add_model(model_spec_mars) %>% fit(training(splits)) models_tbl <- modeltime_table( model_fit_arima_no_boost, model_fit_arima_boosted, model_fit_ets, model_fit_prophet, model_fit_lm, wflw_fit_mars ) #> Error in eval_tidy(xs[[j]], mask): object 'model_fit_prophet' not found calibration_tbl <- models_tbl %>% modeltime_calibrate(new_data = testing(splits)) #> Error in modeltime_calibrate(., new_data = testing(splits)): object 'models_tbl' not found calibration_tbl %>% modeltime_forecast( new_data = testing(splits), actual_data = df1 ) %>% plot_modeltime_forecast( .legend_max_width = 25, # For mobile screens .interactive = interactive ) #> Error in modeltime_forecast(., new_data = testing(splits), actual_data = df1): object 'calibration_tbl' not found calibration_tbl %>% modeltime_accuracy() %>% table_modeltime_accuracy( .interactive = FALSE ) #> Error in c(".type", ".calibration_data") %in% names(object): object 'calibration_tbl' not found refit_tbl <- calibration_tbl %>% modeltime_refit(data = df1) #> Error in modeltime_refit(.