Skip to content

Commit

Permalink
rename the package (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermebodin authored Feb 4, 2020
1 parent 0008ada commit 7bb02f8
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "GAS"
name = "ScoreDrivenModels"
uuid = "4a87933e-d659-11e9-0e65-7f40dedd4a3a"
authors = ["guilhermebodin <[email protected]>, raphaelsaavedra <[email protected]>"]
version = "0.1.0"
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# GAS.jl
# ScoreDrivenModels.jl

| **Build Status** | **Coverage** | **Documentation** |
|:-----------------:|:-----------------:|:-----------------:|
| [![Build Status][build-img]][build-url] | [![Codecov branch][codecov-img]][codecov-url] |[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://lampspuc.github.io/GAS.jl/latest/)
| [![Build Status][build-img]][build-url] | [![Codecov branch][codecov-img]][codecov-url] |[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://lampspuc.github.io/ScoreDrivenModels.jl/latest/)

[build-img]: https://travis-ci.org/LAMPSPUC/GAS.jl.svg?branch=master
[build-url]: https://travis-ci.org/LAMPSPUC/GAS.jl
[build-img]: https://travis-ci.org/LAMPSPUC/ScoreDrivenModels.jl.svg?branch=master
[build-url]: https://travis-ci.org/LAMPSPUC/ScoreDrivenModels.jl

[codecov-img]: https://codecov.io/gh/LAMPSPUC/GAS.jl/coverage.svg?branch=master
[codecov-url]: https://codecov.io/gh/LAMPSPUC/GAS.jl?branch=master
[codecov-img]: https://codecov.io/gh/LAMPSPUC/ScoreDrivenModels.jl/coverage.svg?branch=master
[codecov-url]: https://codecov.io/gh/LAMPSPUC/ScoreDrivenModels.jl?branch=master

GAS.jl is a Julia package for modeling, forecasting, and simulating time series with generalized autoregressive score models (GAS), also known as score-driven models. Implementations are based on the paper [Generalized Autoregressive Models with Applications](http://dx.doi.org/10.1002/jae.1279) by D. Creal, S. J. Koopman, and A. Lucas.
ScoreDrivenModels.jl is a Julia package for modeling, forecasting, and simulating time series with generalized autoregressive score models (ScoreDrivenModels), also known as score-driven models. Implementations are based on the paper [Generalized Autoregressive Models with Applications](http://dx.doi.org/10.1002/jae.1279) by D. Creal, S. J. Koopman, and A. Lucas.
20 changes: 10 additions & 10 deletions bench/benchmark_estimate.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GAS, Distributions, BenchmarkTools, Random, Test
using ScoreDrivenModels, Distributions, BenchmarkTools, Random, Test

include("test/utils.jl")

Expand All @@ -7,7 +7,7 @@ scaling = 0.0
A = [0.2 0; 0 0.2]
B = [0.2 0; 0 0.2]
simulation = simulate_GAS_1_1(Beta, scaling, ω, A, B, 1)
gas = GAS.Model(1, 1, Beta, scaling)
gas = ScoreDrivenModels.Model(1, 1, Beta, scaling)
gas.ω = ω
gas.A[1] = A
gas.B[1] = B
Expand All @@ -34,8 +34,8 @@ p = 1
q = 1
num_seeds = 3
@benchmark begin
gas = GAS.Model($p, $q, $Beta, $scaling)
opt_method = GAS.LBFGS(gas, $num_seeds)
gas = ScoreDrivenModels.Model($p, $q, $Beta, $scaling)
opt_method = ScoreDrivenModels.LBFGS(gas, $num_seeds)
fit!(gas, $simulation; verbose = $verbose, opt_method = opt_method)
end
# BenchmarkTools.Trial:
Expand All @@ -60,8 +60,8 @@ p = 1
q = 1
num_seeds = 3
@benchmark begin
gas = GAS.Model($p, $q, $LogNormal, $scaling)
opt_method = GAS.LBFGS(gas, $num_seeds)
gas = ScoreDrivenModels.Model($p, $q, $LogNormal, $scaling)
opt_method = ScoreDrivenModels.LBFGS(gas, $num_seeds)
fit!(gas, $simulation; verbose = $verbose, opt_method = opt_method)
end
# BenchmarkTools.Trial:
Expand All @@ -79,8 +79,8 @@ end

scaling = 0.5
@benchmark begin
gas = GAS.Model($p, $q, $LogNormal, $scaling)
opt_method = GAS.LBFGS(gas, $num_seeds)
gas = ScoreDrivenModels.Model($p, $q, $LogNormal, $scaling)
opt_method = ScoreDrivenModels.LBFGS(gas, $num_seeds)
fit!(gas, $simulation; verbose = $verbose, opt_method = opt_method)
end
# BenchmarkTools.Trial:
Expand All @@ -97,8 +97,8 @@ end

scaling = 1.0
@benchmark begin
gas = GAS.Model($p, $q, $LogNormal, $scaling)
opt_method = GAS.LBFGS(gas, $num_seeds)
gas = ScoreDrivenModels.Model($p, $q, $LogNormal, $scaling)
opt_method = ScoreDrivenModels.LBFGS(gas, $num_seeds)
fit!(gas, $simulation; verbose = $verbose, opt_method = opt_method)
end
# BenchmarkTools.Trial:
Expand Down
8 changes: 4 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Documenter, GAS
using Documenter, ScoreDrivenModels

makedocs(
modules = [GAS],
modules = [ScoreDrivenModels],
doctest = false,
clean = true,
format = Documenter.HTML(mathengine = Documenter.MathJax()),
sitename = "GAS.jl",
sitename = "ScoreDrivenModels.jl",
authors = "Guilherme Bodin and Raphael Saavedra",
pages = [
"Home" => "index.md",
Expand All @@ -15,5 +15,5 @@ makedocs(
)

deploydocs(
repo = "github.com/LAMPSPUC/GAS.jl.git",
repo = "github.com/LAMPSPUC/ScoreDrivenModels.jl.git",
)
6 changes: 3 additions & 3 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Water inflow

Let's model some monthly water inflow data from the Northeast of Brazil using a Lognormal GAS model. Since inflow is a highly seasonal phenomenon, we will utilize lags 1 and 12. The former aims to characterize the short-term evolution of the series, while the latter characterizes the seasonality. The full code is in the examples folder.
Let's model some monthly water inflow data from the Northeast of Brazil using a Lognormal ScoreDrivenModels model. Since inflow is a highly seasonal phenomenon, we will utilize lags 1 and 12. The former aims to characterize the short-term evolution of the series, while the latter characterizes the seasonality. The full code is in the examples folder.

```julia
# Convert data to vector
y = Vector{Float64}(vec(inflow'))

# Specify GAS model: here we use lag 1 for trend characterization and
# Specify ScoreDrivenModels model: here we use lag 1 for trend characterization and
# lag 12 for seasonality characterization
gas = GAS.Model([1, 12], [1, 12], LogNormal, 0.0)
gas = ScoreDrivenModels.Model([1, 12], [1, 12], LogNormal, 0.0)

# Estimate the model via MLE
fit!(gas, y)
Expand Down
8 changes: 4 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# GAS.jl Documentation
# ScoreDrivenModels.jl Documentation

GAS.jl is a Julia package for modeling, forecasting and simulating time series with or generalized autoregressive score models (GAS) models, also known as dynamic conditional score models (DCS). Implementations are based on the paper [Generalized Autoregressive Models with Applications](http://dx.doi.org/10.1002/jae.1279) by D. Creal, S. J. Koopman and A. Lucas.
ScoreDrivenModels.jl is a Julia package for modeling, forecasting and simulating time series with or generalized autoregressive score models (ScoreDrivenModels) models, also known as dynamic conditional score models (DCS). Implementations are based on the paper [Generalized Autoregressive Models with Applications](http://dx.doi.org/10.1002/jae.1279) by D. Creal, S. J. Koopman and A. Lucas.

## Installation

This package is not yet registered so you can `Pkg.add` it as follows:
```julia
pkg> add https://github.com/LAMPSPUC/GAS.jl.git
pkg> add https://github.com/LAMPSPUC/ScoreDrivenModels.jl.git
```

## Contributing

Contributions to this package are more than welcome, if you find a bug or have any suggestions for the documentation please post it on the [github issue tracker](https://github.com/LAMPSPUC/GAS.jl/issues).
Contributions to this package are more than welcome, if you find a bug or have any suggestions for the documentation please post it on the [github issue tracker](https://github.com/LAMPSPUC/ScoreDrivenModels.jl/issues).

When contributing please note that the package follows the [JuMP style guide](https://www.juliaopt.org/JuMP.jl/stable/style/).
16 changes: 8 additions & 8 deletions docs/src/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Links

Links are reparametrizations utilized to ensure certain parameter is within its original domain, i.e. in a distribution one would like to ensure that the time varying parameter ``f \in \mathbb{R}^+``. The way to do this is to model ``\tilde{f} = \ln{f}``. More generally one can stablish that ``\tilde{f} = h(f)``. We refer to this procedure as **linking**. When the parameter is linked the GAS recursion happens in the domain of ``\tilde{f}`` and then one can recover the orginal parameter by ``f = \left(h\right)^-1(\tilde f)``. We refer to this procedure as **unlinking**. The new GAS recursion becomes.
Links are reparametrizations utilized to ensure certain parameter is within its original domain, i.e. in a distribution one would like to ensure that the time varying parameter ``f \in \mathbb{R}^+``. The way to do this is to model ``\tilde{f} = \ln{f}``. More generally one can stablish that ``\tilde{f} = h(f)``. We refer to this procedure as **linking**. When the parameter is linked the ScoreDrivenModels recursion happens in the domain of ``\tilde{f}`` and then one can recover the orginal parameter by ``f = \left(h\right)^-1(\tilde f)``. We refer to this procedure as **unlinking**. The new ScoreDrivenModels recursion becomes.

```math
\begin{equation*}\left\{\begin{array}{ccl}
Expand All @@ -17,24 +17,24 @@ Links are reparametrizations utilized to ensure certain parameter is within its
\end{equation*}
```

Notice that the change in parametrization changes the dynamics of the model. The GAS(1,1) for a Normal distribution with inverse scaling ``d = 1`` is equivalent to the GARCH(1, 1) model, but only on the original parameter, if you work with a different parametrization the model is no longer equivalent.
Notice that the change in parametrization changes the dynamics of the model. The ScoreDrivenModels(1,1) for a Normal distribution with inverse scaling ``d = 1`` is equivalent to the GARCH(1, 1) model, but only on the original parameter, if you work with a different parametrization the model is no longer equivalent.


### Types of links

The abstract type `Link` subsumes any type of link that can be expressed.

```@docs
GAS.IdentityLink
GAS.LogLink
GAS.LogitLink
ScoreDrivenModels.IdentityLink
ScoreDrivenModels.LogLink
ScoreDrivenModels.LogitLink
```

### Link functions

```@docs
GAS.link
GAS.unlink
GAS.jacobian_link
ScoreDrivenModels.link
ScoreDrivenModels.unlink
ScoreDrivenModels.jacobian_link
```

16 changes: 8 additions & 8 deletions examples/garch.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using GAS, Statistics, DelimitedFiles
using ScoreDrivenModels, Statistics, DelimitedFiles

# The GARCH(1, 1) is equivaent to a GAS.Model(1, 1) Normal model with inverse scaling. The models are only equivalent under
# The GARCH(1, 1) is equivaent to a ScoreDrivenModels.Model(1, 1) Normal model with inverse scaling. The models are only equivalent under
# no reparametrizations, here this means that the you should fit the model overwriting the default link!, unlink! and
# jacobian_link! methods for the Normal distribution to use only the IdentityLink.

# Overwrite link interface to work with Identity links.
function GAS.link!(param_tilde::Matrix{T}, ::Type{Normal}, param::Matrix{T}, t::Int) where T
function ScoreDrivenModels.link!(param_tilde::Matrix{T}, ::Type{Normal}, param::Matrix{T}, t::Int) where T
param_tilde[t, 1] = link(IdentityLink, param[t, 1])
param_tilde[t, 2] = link(IdentityLink, param[t, 2])
return
end
function GAS.unlink!(param::Matrix{T}, ::Type{Normal}, param_tilde::Matrix{T}, t::Int) where T
function ScoreDrivenModels.unlink!(param::Matrix{T}, ::Type{Normal}, param_tilde::Matrix{T}, t::Int) where T
param[t, 1] = unlink(IdentityLink, param_tilde[t, 1])
param[t, 2] = unlink(IdentityLink, param_tilde[t, 2])
return
end
function GAS.jacobian_link!(aux::AuxiliaryLinAlg{T}, ::Type{Normal}, param::Matrix{T}, t::Int) where T
function ScoreDrivenModels.jacobian_link!(aux::AuxiliaryLinAlg{T}, ::Type{Normal}, param::Matrix{T}, t::Int) where T
aux.jac[1] = jacobian_link(IdentityLink, param[t, 1])
aux.jac[2] = jacobian_link(IdentityLink, param[t, 2])
return
Expand All @@ -30,7 +30,7 @@ initial_params = [mean(y) var(y)]
# There are 2 possibilities to estimate the model.
# The first one is to understand that in the GARCH estimation process usually one
# defines that the parameters ω, α_0, α_1 and β_1 are constrained. The problem is
# that the equivalent GAS model relies that
# that the equivalent ScoreDrivenModels model relies that
# ω_1 = ω
# ω_2 = α_0
# A_1 = α_1
Expand All @@ -42,8 +42,8 @@ initial_params = [mean(y) var(y)]
ub = [1.0; 1.0; 0.5; 1.0]
lb = [-1.0; 0.0; 0.0; 0.5]

# Define a GAS model where only \sigma^2 is varying over time
gas = GAS.Model(1, 1, Normal, 1.0, time_varying_params = [2])
# Define a ScoreDrivenModels model where only \sigma^2 is varying over time
gas = ScoreDrivenModels.Model(1, 1, Normal, 1.0, time_varying_params = [2])

# Give an initial_point in the interior of the bounds.
initial_point = [0.0; 0.5; 0.25; 0.75]
Expand Down
8 changes: 4 additions & 4 deletions examples/inflow_lognormal.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GAS, Plots
using ScoreDrivenModels, Plots

# Some data on monthly inflow from Northeastern Brazil
inflow = [
Expand Down Expand Up @@ -49,8 +49,8 @@ y = Vector{Float64}(vec(inflow'))
y_train = y[1:400]
y_test = y[401:end]

# Specify GAS model: here we use lag 1 for trend characterization and lag 12 for seasonality characterization
gas = GAS.Model([1, 2, 11, 12], [1, 2, 11, 12], LogNormal, 0.0; time_varying_params = [1])
# Specify ScoreDrivenModels model: here we use lag 1 for trend characterization and lag 12 for seasonality characterization
gas = ScoreDrivenModels.Model([1, 2, 11, 12], [1, 2, 11, 12], LogNormal, 0.0; time_varying_params = [1])

# Define initial_params with
initial_params = dynamic_initial_params(y_train, gas)
Expand All @@ -66,7 +66,7 @@ plot(y_train, label = "In-sample inflow")
plot!(y_fitted, label = "in-sample estimates")

# Forecasts with 95% confidence interval
forec = GAS.forecast(y_train, gas, 80; initial_params = initial_params, ci = [0.95])
forec = ScoreDrivenModels.forecast(y_train, gas, 80; initial_params = initial_params, ci = [0.95])

plot(y_test, label = "Out-of-sample inflow")
plot!(forec, label = "Forecast", color = "Steel Blue")
2 changes: 1 addition & 1 deletion src/GAS.jl → src/ScoreDrivenModels.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module GAS
module ScoreDrivenModels

using Distributions, Optim, SpecialFunctions
using LinearAlgebra, Printf
Expand Down
4 changes: 2 additions & 2 deletions src/gas/initial_params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function dynamic_initial_params(obs::Vector{T}, gas::Model{D, T}) where {D, T}
idx = collect(i:biggest_lag:len)
# Fit MLE in the observations
dist = fit_mle(D, obs[idx])
# Adequate to the GAS standard
# Adequate to the ScoreDrivenModels standard
# In Distributions Normal is \mu and \sigma
# In GAS Normal is \mu and \sigma^2
# In ScoreDrivenModels Normal is \mu and \sigma^2
sdm_dist = update_dist(D, permutedims([params(dist)...]), 1)

initial_params[i, :] = [params(sdm_dist)...]
Expand Down
4 changes: 2 additions & 2 deletions src/initial_params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function dynamic_initial_params(obs::Vector{T}, gas::Model{D, T}) where {D, T}
idx = collect(i:biggest_lag:len)
# Fit MLE in the observations
dist = fit_mle(D, obs[idx])
# Adequate to the GAS standard
# Adequate to the ScoreDrivenModels standard
# In Distributions Normal is \mu and \sigma
# In GAS Normal is \mu and \sigma^2
# In ScoreDrivenModels Normal is \mu and \sigma^2
sdm_dist = update_dist(D, permutedims([params(dist)...]), 1)

initial_params[i, :] = [params(sdm_dist)...]
Expand Down
2 changes: 1 addition & 1 deletion src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function number_of_lags(gas::Model)
end

"""
The unknows parameters of a GAS model
The unknows parameters of a ScoreDrivenModels model
Only for internal use
Every unknonws must define
Expand Down
4 changes: 2 additions & 2 deletions src/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export simulate, forecast
"""
simulate(serie::Vector{T}, gas::Model{D, T}, N::Int, S::Int, kwargs...) where {D, T}
Generate scenarios for the future of a time series by updating the GAS recursion `N` times and taking
Generate scenarios for the future of a time series by updating the ScoreDrivenModels recursion `N` times and taking
a sample of the distribution until generate `S` scenarios.
"""
function simulate(serie::Vector{T}, gas::Model{D, T}, N::Int, S::Int;
Expand All @@ -28,7 +28,7 @@ end
"""
forecast(serie::Vector{T}, gas::Model{D, T}, N::Int; kwargs...) where {D, T}
Forecast future values of a time series by updating the GAS recursion `N` times and
Forecast future values of a time series by updating the ScoreDrivenModels recursion `N` times and
taking the mean of the distribution at each time. You can pass the desired confidence interval
as a `Vector{T}`. The forecast will be the first column and the confidence intervals are the remaining
columns.
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using GAS, Distributions, LinearAlgebra
using ScoreDrivenModels, Distributions, LinearAlgebra

using Test, Random, HypothesisTests, DelimitedFiles

include("utils.jl")
include("test_links.jl")
include("test_distributions.jl")

# GAS
# ScoreDrivenModels
include("test_recursion.jl")
include("test_initial_params.jl")
include("test_diagnostics.jl")
Expand Down
4 changes: 2 additions & 2 deletions test/test_distributions.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@testset "Score" begin
for dist in GAS.DISTS
for dist in ScoreDrivenModels.DISTS
@testset "$dist" begin
test_score_mean(dist)
end
end
end

@testset "Log-likelihood" begin
for dist in GAS.DISTS
for dist in ScoreDrivenModels.DISTS
@testset "$dist" begin
test_loglik(dist)
end
Expand Down
Loading

2 comments on commit 7bb02f8

@guilhermebodin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8844

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 7bb02f871dcec9980fd30ae404668f48cec332f4
git push origin v0.1.0

Please sign in to comment.