Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Gedevan-Aleksizde's full-sized avatar
⚔️

S-Katagiri Gedevan-Aleksizde

⚔️
View GitHub Profile
/* VARMA (1,1) */
data {
int<lower=1> T ; // num observations
int<lower=1> N ; // num series
vector[N] y[T] ; // observed outputs
int<lower=0> T_forecast ; // forecasting span
}
parameters {
/* VARMA (p,q) */
data {
int<lower=1> T ; // num observations
int<lower=1> N ; // num series
int<lower=0> p ; // AR(p)
int<lower=0> q ; // MA(q)
vector[N] y[T] ; // observed outputs
int<lower=0> T_forecast ; // forecasting span
}
library(tidyr) # ver. 0.3.1.
library(dplyr) # ver. 0.4.3
library(rstan) # ver. 2.9.0
library(forecast) # ver. 6.2
# 並列化させる設定
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
setwd("~/Documents/blog/20160212_StanVARMA/") # 任意のフォルダに書き換える
library(tidyr) # ver. 0.3.1.
library(dplyr) # ver. 0.4.3
library(rstan) # ver. 2.9.0
library(forecast) # ver. 6.2
# 並列化させる設定
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
N <- 2 # num series
library(tidyr) # ver. 0.3.1.
library(dplyr) # ver. 0.4.3
library(rstan) # ver. 2.9.0
library(forecast) # ver. 6.2
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
# VARMA(1,1) N=2
N <- 2 # num series
Time <- 400 # span
/* VARMA (p,q) */
data {
int<lower=1> T ; // num observations
int<lower=1> N ; // num series
int<lower=0> p ; // AR(p)
int<lower=0> q ; // MA(q)
vector[N] y[T] ; // observed outputs
int<lower=0> T_forecast ; // forecasting span
}
library(tidyr) # ver. 0.3.1.
library(dplyr) # ver. 0.4.3
library(rstan) # ver. 2.9.0
library(forecast) # ver. 6.2
library(zoo) # ver. 1.7-11
library(gdata) # ver. 2.13.3
library(loo) # ver. 0.1.6
/* -----------------------------------------------------------------------------
Estimate latent variable hierarchical Bayes RFM model
stan ver. 2.9
CREATED BY: 09/APR/2015, ill-identified
------------------------------------------------------------------------------- */
data {
int<lower=1> N ; // num of customers
library(dplyr)
library(tidyr)
library(ggplot2)
library(rstan)
library(loo)
# working directory
work.dir <- "HOGEHOGE/20160406_RFM"
df <- read.csv(paste(work.dir, "rfm.csv",sep="/"), stringsAsFactors = F)
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# coding: utf-8
# In[1]:
get_ipython().magic('matplotlib inline'
import pystan # ver. 2.9.0.0
import numpy as np # ver.1.11.0
import pandas as pd # ver. 0.18.0 # xlrd, mumxpr module needed