This file contains hidden or 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
/* 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 { |
This file contains hidden or 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
/* 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 | |
} |
This file contains hidden or 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(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/") # 任意のフォルダに書き換える |
This file contains hidden or 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(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 |
This file contains hidden or 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(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 |
This file contains hidden or 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
/* 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 | |
} |
This file contains hidden or 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(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 | |
This file contains hidden or 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
/* ----------------------------------------------------------------------------- | |
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 |
This file contains hidden or 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(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) |
This file contains hidden or 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
# !/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 |
OlderNewer