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
--- | |
title: "ARIMA Modeling in R" | |
output: html_document | |
--- | |
Let's start off by loading relevant R libraries! | |
```{r include = FALSE} | |
library(tseries) | |
library(zoo) | |
library(forecast) |
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
# Code for the merge subroutine | |
def merge(a,b): | |
""" Function to merge two arrays """ | |
c = [] | |
while len(a) != 0 and len(b) != 0: | |
if a[0] < b[0]: | |
c.append(a[0]) | |
a.remove(a[0]) | |
else: |
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
library(xlsx) | |
library(forecast) | |
library(tseries) | |
library(strucchange) | |
## load the data from a CSV or Excel file. This example is done with an Excel sheet. | |
prod_df <- read.xlsx(file = 'agricultural_productivity.xls', sheetIndex = 'Sheet1', rowIndex = 8:65, colIndex = 2, header = FALSE) | |
colnames(prod_df) <- c('Rice') | |
## store rice data as time series objects | |
rice <- ts(prod_df$Rice, start=c(1951, 1), end=c(2008, 1), frequency=1) |
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
remove_missing_levels <- function(fit, test_data) { | |
library(magrittr) | |
# https://stackoverflow.com/a/39495480/4185785 | |
# drop empty factor levels in test data | |
test_data %>% | |
droplevels() %>% | |
as.data.frame() -> test_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
rm(list = ls()) | |
# Load relevant libraries ----------------------------------------------------- | |
library(stringr) | |
library(data.table) | |
# ============================================================================= | |
# COVID 19-India API: A volunteer-driven, crowdsourced database | |
# for COVID-19 stats & patient tracing in India | |
# ============================================================================= |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# prints recursive count of lines of python source code from current directory | |
# includes an ignore_list. also prints total sloc | |
import os | |
cur_path = os.getcwd() | |
ignore_set = set(["__init__.py", "count_sourcelines.py"]) | |
loclist = [] | |
for pydir, _, pyfiles in os.walk(cur_path): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
library(data.table) | |
train <- fread('train.csv'); test <- fread('test.csv') | |
# consolidate the 2 data sets after creating a variable indicating train / test | |
train$flag <- 0; test$flag <- 1 | |
dat <- rbind(train,test) | |
# change outcome, var_b and var_e into factor var | |
dat$outcome <- factor(dat$outcome) |
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
# assuming you have a 'ts' object in R | |
# 1. install package 'strucchange' | |
# 2. Then write down this code: | |
library(strucchange) | |
# store the breakdates | |
bp_ts <- breakpoints(ts ~ 1) |