Skip to content

Commit

Permalink
Fix tests for GLM v1.9 (#47)
Browse files Browse the repository at this point in the history
* warning for wrong type for

* print test_args

* qrpred not exported by GLM v1.9.0

format

undo format

qrpred not fully defined in GLM v1.9

qrpred is not defined in GLM v1.9

* GHA: do not duplicate jobs

* add julia-format action

add julia-format action

format docs files

gha naming

* docs add CategoricalArrays dep

* refactor and improve treating edge cases

* correct function entries in docs

* refactorize input validation for fit method

* fix doctest

* use format-check from MixedModels.jl

* add typos github action

* run typos

* follow .JuliaFormatter.toml

* run format

correct type

correct type

correct type

* do not show QR pivoted warning when installing the package

* fix docs

fix docs

* fix some docs
  • Loading branch information
getzze authored Sep 25, 2024
1 parent cea156e commit 9796dad
Show file tree
Hide file tree
Showing 21 changed files with 440 additions and 200 deletions.
74 changes: 65 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,71 @@
name: CI

on:
- push
- pull_request
push:
branches:
- 'main'
- 'release-'
tags: '*'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"


jobs:
format-check:
# note: keep in sync with `format/run.jl`
name: Style check (Julia ${{ matrix.julia-version }} - ${{ github.event_name }})
# Run on push's or non-draft PRs
if: (github.event_name == 'push') || (github.event.pull_request.draft == false)
runs-on: ubuntu-latest
strategy:
matrix:
julia-version: [1.6]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
- uses: actions/checkout@v4
- name: Instantiate `format` environment and format
run: |
julia --project=format -e 'using Pkg; Pkg.instantiate()'
julia --project=format 'format/run.jl'
- uses: reviewdog/action-suggester@v1
if: github.event_name == 'pull_request'
with:
tool_name: JuliaFormatter
fail_on_error: true

typos-check:
name: Spell Check with Typos
# Run on PRs
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@master
with:
config: ./_typos.toml
write_changes: true
- uses: reviewdog/action-suggester@v1
with:
tool_name: Typos
fail_on_error: true

test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
julia-version:
- '1.6'
- '1' # latest stable 1.x release
- 'nightly'
Expand All @@ -18,10 +74,10 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
version: ${{ matrix.julia-version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
Expand All @@ -43,8 +99,8 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- name: Install dependencies
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/format-check.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ This package implements:

## Installation

```julia
```
julia>] add RobustModels
```

To install the last development version:

```julia
```
julia>] add RobustModels#main
```

Expand Down
10 changes: 10 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://github.com/crate-ci/typos#false-positives
[default]

[default.extend-identifiers]
missings = "missings"
Missings = "Missings"
Artic = "Artic"

[default.extend-words]
qest = "qest"
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
RobustModels = "d6ea1423-9682-4bbd-952f-b1577cbf8c98"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
24 changes: 14 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using Documenter
using GLM, StatsBase, SparseArrays, LinearAlgebra
using GLM, StatsBase, StatsAPI, SparseArrays, LinearAlgebra
using RobustModels

DocMeta.setdocmeta!(
RobustModels, :DocTestSetup, :(using RobustModels, StatsBase, GLM); recursive=true
RobustModels,
:DocTestSetup,
:(using RobustModels, StatsBase, GLM, StatsAPI);
recursive=true,
)

prettyurls = get(ENV, "CI", "false") == "true"

makedocs(;
modules=[RobustModels, GLM, StatsBase],
modules=[RobustModels, GLM, StatsBase, StatsAPI],
sitename="RobustModels",
authors="Bertrand Lacoste <[email protected]>",
repo="https://github.com/getzze/RobustModels.jl/blob/{commit}{path}#{line}",
Expand All @@ -18,17 +21,18 @@ makedocs(;
canonical="https://getzze.github.io/RobustModels.jl",
assets=["assets/favicon.ico"],
),
#! format: off
pages=[
"Home" => "index.md",
"manual.md",
"examples.md",
"Home" => "index.md",
"manual.md",
"examples.md",
"api.md",
],
#! format: on
## Uncomment the line below to re-generate doctest outputs
# doctest = :fix,
warnonly=[:missing_docs],
debug=false,
)

deploydocs(;
devbranch="main",
repo="github.com/getzze/RobustModels.jl",
)
deploydocs(; devbranch="main", repo="github.com/getzze/RobustModels.jl")
63 changes: 40 additions & 23 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ AbstractEstimator
AbstractQuantileEstimator
LossFunction
RobustLinearModel
RobustModels.RobustLinResp
GLM.LinPred
RobustModels.DensePredCG
RobustModels.SparsePredCG
GLM.DensePredChol
GLM.SparsePredChol
GLM.DensePredQR
RobustModels.RidgePred
RobustModels.RobustLinResp
RobustModels.AbstractRegularizedPred
QuantileRegression
```

## Constructors for models

```@docs
fit(::Type{M}, ::Union{AbstractMatrix{T},SparseMatrixCSC{T}}, ::AbstractVector{T}, ::AbstractEstimator) where {T<:AbstractFloat, M<:RobustLinearModel}
fit(::Type{M}, ::Union{AbstractMatrix{T},SparseMatrixCSC{T}}, ::AbstractVector{T}) where {T<:AbstractFloat, M<:QuantileRegression}
fit(::Type{M}, ::Union{AbstractMatrix{T}}, ::AbstractVector{T}, ::AbstractMEstimator) where {T<:AbstractFloat, M<:RobustLinearModel}
fit(::Type{M}, ::Union{AbstractMatrix{T}}, ::AbstractVector{T}) where {T<:AbstractFloat, M<:QuantileRegression}
```

```@docs
Expand All @@ -33,34 +36,45 @@ refit!

## Model methods
```@docs
StatsBase.coef
StatsBase.coeftable
StatsBase.confint
StatsModels.coef
StatsAPI.coeftable
StatsAPI.coefnames
StatsModels.responsename
StatsAPI.confint
StatsBase.deviance
StatsBase.nulldeviance
StatsBase.dof
StatsBase.dof_residual
nobs(::StatisticalModel)
StatsBase.isfitted
StatsBase.islinear
StatsBase.loglikelihood
StatsBase.nullloglikelihood
StatsBase.stderror
StatsAPI.dof
StatsAPI.dof_residual
StatsBase.nobs
wobs
StatsAPI.isfitted
StatsAPI.islinear
StatsAPI.loglikelihood
StatsAPI.nullloglikelihood
StatsAPI.stderror
StatsBase.vcov
StatsBase.weights
workingweights
StatsBase.fitted
StatsAPI.fitted
StatsBase.predict
StatsBase.leverage
StatsBase.modelmatrix
StatsModels.leverage
leverage_weights
StatsAPI.modelmatrix
projectionmatrix
GLM.dispersion(::RobustLinearModel, ::Bool)
StatsBase.response
StatsBase.residuals
dispersion(::RobustLinearModel, ::Bool)
StatsAPI.response
StatsAPI.residuals
StatsModels.hasintercept
hasformula
formula
scale
tauscale
RobustModels.location_variance
Estimator
GLM.linpred!
RobustModels.pirls!
RobustModels.pirls_Sestimate!
RobustModels.pirls_τestimate!
```

## Estimators
Expand All @@ -78,18 +92,23 @@ RobustModels.QuantileEstimator

## Loss functions
```@docs
BoundedLossFunction
L2Loss
L1Loss
HuberLoss
L1L2Loss
FairLoss
LogcoshLoss
ArctanLoss
CatoniWideLoss
CatoniNarrowLoss
CauchyLoss
GemanLoss
WelschLoss
TukeyLoss
YohaiZamarLoss
HardThresholdLoss
HampelLoss
```

## Estimator and Loss functions methods
Expand All @@ -98,7 +117,7 @@ RobustModels.rho
RobustModels.psi
RobustModels.psider
RobustModels.weight
RobustModels.values
RobustModels.estimator_values
RobustModels.estimator_norm
RobustModels.estimator_bound
tuning_constant
Expand All @@ -121,5 +140,3 @@ RobustModels.update_weight!
RobustModels.tau_scale_estimate
RobustModels.quantile_weight
```


7 changes: 3 additions & 4 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ X 2.02857 0.200679 10.11 0.0005 1.4714 2.58575
─────────────────────────────────────────────────────────────────────────
julia> round.(stderror(ols), digits=5)
2-element Array{Float64,1}:
2-element Vector{Float64}:
0.78153
0.20068
julia> round.(predict(ols), digits=5)
6-element Array{Float64,1}:
6-element Vector{Float64}:
2.09524
4.12381
6.15238
Expand All @@ -61,7 +61,7 @@ julia> data[5, :Y] = 1; data
4 │ 4 8
5 │ 5 1
6 │ 6 13
julia> rob = rlm(@formula(Y ~ X), data, MMEstimator{TukeyLoss}(); σ0=:mad)
Robust regression with MM-Estimator(TukeyLoss(1.5476), TukeyLoss(4.685))
Expand All @@ -76,4 +76,3 @@ X 2.18005 0.14112 15.45 0.0001 1.78824 2.57186
─────────────────────────────────────────────────────────────────────────
```

Loading

0 comments on commit 9796dad

Please sign in to comment.