Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur-brigatto authored Dec 27, 2023
0 parents commit bb4d101
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
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.
13 changes: 13 additions & 0 deletions Project.toml
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"]
14 changes: 14 additions & 0 deletions README.md
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.
3 changes: 3 additions & 0 deletions docs/Project.toml
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"
25 changes: 25 additions & 0 deletions docs/make.jl
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",
)
14 changes: 14 additions & 0 deletions docs/src/index.md
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]
```
7 changes: 7 additions & 0 deletions src/SeasonalNaive.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module SeasonalNaive

include("forecast.jl")

export forecast

end
11 changes: 11 additions & 0 deletions src/forecast.jl
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
20 changes: 20 additions & 0 deletions test/runtests.jl
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

0 comments on commit bb4d101

Please sign in to comment.