-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bb4d101
Showing
9 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Arthur Brigatto <[email protected]> and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = "SeasonalNaive" | ||
uuid = "4e5a55a7-a1e0-4c7c-8281-8d51e13076a6" | ||
authors = ["Arthur Brigatto <[email protected]> and contributors"] | ||
version = "1.0.0-DEV" | ||
|
||
[compat] | ||
julia = "1" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SeasonalNaive | ||
|
||
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://arthur-brigatto.github.io/SeasonalNaive.jl/stable/) | ||
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://arthur-brigatto.github.io/SeasonalNaive.jl/dev/) | ||
[![Build Status](https://github.com/arthur-brigatto/SeasonalNaive.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/arthur-brigatto/SeasonalNaive.jl/actions/workflows/CI.yml?query=branch%3Amaster) | ||
[![Coverage](https://codecov.io/gh/arthur-brigatto/SeasonalNaive.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/arthur-brigatto/SeasonalNaive.jl) | ||
|
||
A Julia package to forecast time series using the seasonal naïve model. | ||
|
||
Forecasts are done using the following equation: | ||
|
||
$`\hat{y}_{T+k} = y_{T+k-m*(\lfloor \frac{k+1}{m}\rfloor + 1)}`$ | ||
|
||
where $m$ is the seasonal period. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
SeasonalNaive = "4e5a55a7-a1e0-4c7c-8281-8d51e13076a6" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using SeasonalNaive | ||
using Documenter | ||
|
||
DocMeta.setdocmeta!(SeasonalNaive, :DocTestSetup, :(using SeasonalNaive); recursive=true) | ||
|
||
makedocs(; | ||
modules=[SeasonalNaive], | ||
authors="Arthur Brigatto <[email protected]> and contributors", | ||
repo="https://github.com/arthur-brigatto/SeasonalNaive.jl/blob/{commit}{path}#{line}", | ||
sitename="SeasonalNaive.jl", | ||
format=Documenter.HTML(; | ||
prettyurls=get(ENV, "CI", "false") == "true", | ||
canonical="https://arthur-brigatto.github.io/SeasonalNaive.jl", | ||
edit_link="master", | ||
assets=String[], | ||
), | ||
pages=[ | ||
"Home" => "index.md", | ||
], | ||
) | ||
|
||
deploydocs(; | ||
repo="github.com/arthur-brigatto/SeasonalNaive.jl", | ||
devbranch="master", | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```@meta | ||
CurrentModule = SeasonalNaive | ||
``` | ||
|
||
# SeasonalNaive | ||
|
||
Documentation for [SeasonalNaive](https://github.com/arthur-brigatto/SeasonalNaive.jl). | ||
|
||
```@index | ||
``` | ||
|
||
```@autodocs | ||
Modules = [SeasonalNaive] | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module SeasonalNaive | ||
|
||
include("forecast.jl") | ||
|
||
export forecast | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function forecast(past_data::Vector{Float64}, seasonality::Int64, steps_ahead::Int64) | ||
|
||
forecasts = zeros(steps_ahead)::Vector{Float64} | ||
for k in 1:steps_ahead | ||
forecast = past_data[Int(end + k - seasonality*(floor((k - 1)/seasonality)+1))] | ||
forecasts[k] = forecast | ||
end | ||
|
||
return forecasts | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using SeasonalNaive | ||
using Test | ||
|
||
@testset "SeasonalNaive.jl" begin | ||
@testset "forecast season 120" begin | ||
past_data = rand(120) | ||
forecasted = forecast(past_data, 120, 120) | ||
@test past_data == forecasted | ||
end | ||
@testset "forecast season 12" begin | ||
past_data = rand(60) | ||
forecasted = forecast(past_data, 12, 12) | ||
@test past_data[end-11: end] == forecasted | ||
end | ||
@testset "forecast season 13" begin | ||
past_data = rand(60) | ||
forecasted = forecast(past_data, 13, 26) | ||
@test [past_data[end-12: end]; past_data[end-12: end]] == forecasted | ||
end | ||
end |