Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "GAM"
name = "GeneralizedAdditiveModels"
uuid = "cc454e9f-ce0f-441e-b193-468e31ddef4b"
authors = ["Trent Henderson <trent.henderson1@outlook.com>"]
version = "0.1.0"
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GAM.jl
# GeneralizedAdditiveModels.jl
Fit, evaluate, and visualise generalised additive models (GAMs) in native Julia

## Motivation
Expand All @@ -7,7 +7,7 @@ Fit, evaluate, and visualise generalised additive models (GAMs) in native Julia

## Usage

The basic interface to `GAM.jl` is the `gam` function, which is as easy as:
The basic interface to `GeneralizedAdditiveModels.jl` is the `gam` function, which is as easy as:

```{julia}
mod = gam("Volume ~ s(Girth, k=10, degree=3) + s(Height, k=10, degree=3)", df)
Expand All @@ -28,12 +28,14 @@ Note that currently, the following families are supported:
* `Normal`
* `Poisson`
* `Gamma`
* `Bernoulli`

And the following link functions:

* `Identity`
* `Log`
* `Logit`

## Development notes

`GAM.jl` is very much in active development. Please check back for updates and new features or feel free to contribute yourself! The project to-date has been a collaboration between [Trent Henderson](https://github.com/hendersontrent) and [Mason Yahr](https://github.com/yahrMason).
`GeneralizedAdditiveModels.jl` is very much in active development. Please check back for updates and new features or feel free to contribute yourself! The project to-date has been a collaboration between [Trent Henderson](https://github.com/hendersontrent) and [Mason Yahr](https://github.com/yahrMason).
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GAM = "cc454e9f-ce0f-441e-b193-468e31ddef4b"
GeneralizedAdditiveModels = "cc454e9f-ce0f-441e-b193-468e31ddef4b"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
8 changes: 4 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ using Documenter

# Make sure the package loads when building from docs/
push!(LOAD_PATH, joinpath(@__DIR__, "..", "src"))
using GAM
using GeneralizedAdditiveModels

# Doctesting
DocMeta.setdocmeta!(GAM, :DocTestSetup, :(using GAM); recursive=true)

makedocs(
sitename = "GAM.jl",
modules = [GAM],
sitename = "GeneralizedAdditiveModels.jl",
modules = [GeneralizedAdditiveModels],
pages = [
"Home" => "index.md",
"API Reference" => "api_reference.md",
Expand All @@ -22,4 +22,4 @@ makedocs(
)

# for later
# deploydocs(repo = "github.com/hendersontrent/GAM.jl.git", devbranch = "main")
# deploydocs(repo = "github.com/hendersontrent/GeneralizedAdditiveModels.jl.git", devbranch = "main")
4 changes: 2 additions & 2 deletions docs/src/api_reference.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# API Reference

```@autodocs
Modules = [GAM]
Modules = [GeneralizedAdditiveModels]
Recursive = true
Public = true
Private = false
Order = [:module, :type, :function, :macro, :constant]
```
```
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To install the package, clone it directly from the repository:

```julia
using Pkg
Pkg.add(url="https://github.com/hendersontrent/GAM.jl")
Pkg.add(url="https://github.com/hendersontrent/GeneralizedAdditiveModels.jl")
```

---
Expand All @@ -44,7 +44,7 @@ Fitting a GAM in GeneralizedAdditiveModels.jl is quick and easy. The syntax of t

```julia
using RDatasets
using GAM
using GeneralizedAdditiveModels

df = dataset("datasets", "trees");

Expand All @@ -55,7 +55,7 @@ mod = gam("Volume ~ s(Girth, k=10, degree=3) + s(Height, k=10, degree=3)", df)

**GeneralizedAdditiveModels.jl** is under active development, and contributions are very welcome!

- If you’ve found a bug or want to propose a feature, please [open an issue](https://github.com/hendersontrent/GAM.jl/issues).
- If you’ve found a bug or want to propose a feature, please [open an issue](https://github.com/hendersontrent/GeneralizedAdditiveModels.jl/issues).
- If your idea gets positive feedback, feel free to submit a pull request.
- If you’re unsure where to start, you can also browse the open issues and pick one that interests you.

Expand Down
2 changes: 1 addition & 1 deletion src/GAM.jl → src/GeneralizedAdditiveModels.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module GAM
module GeneralizedAdditiveModels

using Distributions, GLM, Optim, BSplines, LinearAlgebra, DataFrames, Plots, Optim

Expand Down
2 changes: 1 addition & 1 deletion src/alpha.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Calculate alpha.

Usage:
```julia-repl
alpha((y, mu, Dist, Link)
alpha(y, mu, Dist, Link)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch!

```
Arguments:
- `y` : `Vector` containing the response variable.
Expand Down
22 changes: 11 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using GAM
using GeneralizedAdditiveModels
using Test
using RDatasets, DataFrames, Plots
using Distributions, Random, Statistics, LinearAlgebra

#-------------------- Run tests -----------------

@testset "GAM.jl Test Suite" begin
@testset "GeneralizedAdditiveModels.jl" begin

# ===========================
# Core Gaussian GAM Tests
Expand Down Expand Up @@ -44,7 +44,7 @@ using Distributions, Random, Statistics, LinearAlgebra

# Test partial predictions for each smooth
for i in 1:length(mod.x)
partial = GAM.PredictPartial(mod, i)
partial = GeneralizedAdditiveModels.PredictPartial(mod, i)
@test length(partial) == length(mod.x[i])
@test !any(isnan.(partial))
@test !any(isinf.(partial))
Expand Down Expand Up @@ -202,7 +202,7 @@ using Distributions, Random, Statistics, LinearAlgebra

# Linear term should have minimal degrees of freedom
# (This assumes Height is the second term)
partial_height = GAM.PredictPartial(mod, 2)
partial_height = GeneralizedAdditiveModels.PredictPartial(mod, 2)
@test length(unique(diff(partial_height[sortperm(df.Height)]))) < 5 # Should be nearly constant slope
end

Expand All @@ -229,12 +229,12 @@ using Distributions, Random, Statistics, LinearAlgebra
@test all(0 .<= mod.Fitted .<= 1)

# Check that linear effect is captured
partial_linear = GAM.PredictPartial(mod, 1)
partial_linear = GeneralizedAdditiveModels.PredictPartial(mod, 1)
linear_coef = cov(partial_linear, x_linear) / var(x_linear)
@test abs(linear_coef - beta_linear) < 0.5 # Should be close to true value

# Check that smooth captures nonlinearity
partial_smooth = GAM.PredictPartial(mod, 2)
partial_smooth = GeneralizedAdditiveModels.PredictPartial(mod, 2)
smooth_sorted = partial_smooth[sortperm(x_smooth)]

# Should have multiple turning points (capturing the sine wave)
Expand Down Expand Up @@ -295,16 +295,16 @@ using Distributions, Random, Statistics, LinearAlgebra
x = randn(100)

@testset "Uniform basis" begin
basis = GAM.BuildUniformBasis(x, 10, 3)
basis = GeneralizedAdditiveModels.BuildUniformBasis(x, 10, 3)
@test length(basis.breakpoints) == 10
@test basis.order == 3
@test minimum(basis.breakpoints) ≈ minimum(x)
@test maximum(basis.breakpoints) ≈ maximum(x)
end

@testset "Basis matrix properties" begin
basis = GAM.BuildUniformBasis(x, 8, 3)
X = GAM.BuildBasisMatrix(basis, x)
basis = GeneralizedAdditiveModels.BuildUniformBasis(x, 8, 3)
X = GeneralizedAdditiveModels.BuildBasisMatrix(basis, x)

@test size(X, 1) == length(x)
@test size(X, 2) == length(basis)
Expand All @@ -313,8 +313,8 @@ using Distributions, Random, Statistics, LinearAlgebra
end

@testset "Penalty matrix" begin
basis = GAM.BuildUniformBasis(x, 10, 3)
D = GAM.BuildDifferenceMatrix(basis)
basis = GeneralizedAdditiveModels.BuildUniformBasis(x, 10, 3)
D = GeneralizedAdditiveModels.BuildDifferenceMatrix(basis)

@test size(D, 2) == length(basis)
@test size(D, 1) == length(basis) - 2 # Second differences
Expand Down