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
source("common.R", encoding = "utf-8") | |
# ----- KFAS ------ | |
df$RP <- calc_RP(df$RP095, df$AP, .95) | |
z <- calc_Z(RP = df$RP, p = df$AP) | |
df <- mutate(df, z1=z$z1, z2=z$z2) | |
df <- mutate(df, z1E=z1*end, z2E=z2*end) | |
# specify model | |
model3KFAS <- SSModel(logPI ~ SSMtrend(1, Q=NA) + |
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
source("common.R", encoding = "utf-8") | |
df$RP <- calc_RP(df$RP095, df$AP, .95) | |
z <- calc_Z(RP = df$RP, p = df$AP) | |
df <- mutate(df, z1=z$z1, z2=z$z2) | |
df <- mutate(df, z1E=z1*end, z2E=z2*end) | |
ss <- AddLocalLevel(list(), y = df$logPI) # c | |
ss <- AddAr(ss, lags=2, y = df$logPI) # AR(2) | |
# time-varying regression |
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
require(bsts) # 0.7.1 | |
data(iclaims) # bring the initial.claims data into scope | |
# --- model 1 ---- | |
ss <- AddLocalLinearTrend(list(), initial.claims$iclaimsNSA) | |
ss <- AddSeasonal(ss, initial.claims$iclaimsNSA, nseasons = 52) | |
model1 <- bsts(initial.claims$iclaimsNSA, | |
state.specification = ss, | |
niter = 1000) |
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
require(KFAS) # 1.2.9 | |
require(dplyr) | |
require(tidyr) | |
require(ggplot2) | |
# --- ARIMA(2, 1) with linear trend --- | |
# generate a dataset | |
set.seed(42) | |
t <- 100 | |
y <- arima.sim(n = t, model = list(ar=c(.3, -0.1), ma=.2), sd=.1) + seq(from=1, to=10, length.out = t) |
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
require(KFAS) # 1.2.9 | |
require(dplyr) | |
require(tidyr) | |
require(ggplot2) | |
require(data.table) | |
require(zoo) | |
##### read dataset ##### | |
# https://catalog.data.gov/dataset/allegheny-county-crash-data | |
# data description |
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
require(ggplot2) | |
require(purrr) | |
require(stringr) | |
require(glue) | |
require(qrencoder) | |
require(png) | |
require(gridExtra) | |
# given_name 必須. 名 | |
# family_name 任意. 姓 |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import argparse | |
import random | |
from pathlib import Path | |
from itertools import chain | |
# fname = Path('~/Downloads/vpylm/out_2018-04-01T040258.txt') |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Mar 31 22:57:58 2018 | |
https://www.quora.com/How-can-I-extract-only-text-data-from-HTML-pages | |
https://qiita.com/matsu0228/items/edf7dbba9b0b0246ef8f | |
@author: ks | |
""" | |
import sys, re, datetime |
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
require(tidyverse) | |
require(ggthemes) | |
require(rjson) | |
require(jsonlite) | |
# 参考 | |
# https://www.data.jma.go.jp/gmd/risk/obsdl/index.php | |
# https://www.data.jma.go.jp/gmd/risk/obsdl/top/help3.html#hukajoho | |
# https://twitter.com/mehori/status/1020644999703089152 |