Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change bkr for qrr to avoid undefined variable error #85

Merged
merged 5 commits into from
Dec 9, 2024
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
28 changes: 28 additions & 0 deletions .devcontainer/DOCKERFILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:24.04
ENV TZ America/New_York
ENV JULIA_VERSION 1.11.1
ENV JULIA_NUM_THREADS 4
ENV QUARTO_VERSION 1.6.37

RUN apt-get update \
&& apt-get install -y wget \
&& apt-get install -y unzip \
&& apt-get install -y git
RUN cd /usr/local/bin \
&& mkdir quarto_dir \
&& cd quarto_dir \
&& wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb \
&& echo "7ec9346bca871f96fa9d8983f4dde1e659e8103075037daf4f547032315282b3 quarto-${QUARTO_VERSION}-linux-amd64.deb" | sha256sum -c - \
&& apt-get install -y ./quarto-${QUARTO_VERSION}-linux-amd64.deb \
&& quarto add --no-prompt kapsner/authors-block
RUN cd /usr/local/bin \
&& mkdir julia_dir \
&& cd julia_dir \
&& wget -q https://julialang-s3.julialang.org/bin/linux/x64/`echo ${JULIA_VERSION} | cut -d. -f 1,2`/julia-${JULIA_VERSION}-linux-x86_64.tar.gz \
&& echo "cca8d13dc4507e4f62a129322293313ee574f300d4df9e7db30b7b41c5f8a8f3 julia-${JULIA_VERSION}-linux-x86_64.tar.gz" | sha256sum -c - \
&& tar fxz julia-${JULIA_VERSION}-linux-x86_64.tar.gz \
&& rm -R julia-${JULIA_VERSION}-linux-x86_64.tar.gz \
&& cd .. \
&& ln -s julia_dir/julia-${JULIA_VERSION}/bin/julia julia
RUN julia -e 'using Pkg; Pkg.add(["Revise"]);'
RUN bash
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"julialang.language-julia",
"quarto.quarto",
"ritwickdey.liveserver"
]
}
}
}
43 changes: 34 additions & 9 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
name: CompatHelper

on:
schedule:
- cron: '00 00 * * *'

- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v2
with:
version: 1.5
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ on:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand All @@ -12,3 +28,5 @@ jobs:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
ssh: ${{ secrets.DOCUMENTER_KEY }}
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.8']
julia-version: ['1.11']
julia-arch: [x64]
os: [ubuntu-22.04]
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
- name: Cache artifacts
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -57,7 +57,7 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v4
with:
files: lcov.info
- uses: julia-actions/julia-docdeploy@v1
Expand Down
29 changes: 23 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,56 @@ uuid = "4d6a76a9-bfbc-5492-8924-cf6ed7875f06"
license = "ISC"
description = "Econometrics in Julia"
maintainer = "José Bayoán Santiago Calderón"
version = "0.2.10"
version = "0.2.11"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
TableOperations = "ab02a1b2-a7df-11e8-156e-fb1833f50b87"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"
WooldridgeDatasets = "b46f53ff-21ea-4df8-83e7-e19d2972755a"

[compat]
CSV = "0.10.15"
CategoricalArrays = "0.10"
Distributions = "0.25"
FillArrays = "0.13"
Documenter = "1.8.0"
FillArrays = "1"
ForwardDiff = "0.10"
JLLWrappers = "1"
MLJBase = "1.7.0"
MLJModelInterface = "1"
Optim = "1"
Parameters = "0.12"
RDatasets = "0.7.7"
StatsAPI = "1"
StatsBase = "0.33"
StatsBase = "0.34"
StatsFuns = "1"
StatsModels = "0.6"
StatsModels = "0.7"
TableOperations = "1"
Tables = "1"
julia = "1.6"
Test = "1.11"
Weave = "0.10.12"
WooldridgeDatasets = "0.1.4"
julia = "1.11"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand All @@ -52,4 +66,7 @@ Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"
WooldridgeDatasets = "b46f53ff-21ea-4df8-83e7-e19d2972755a"

[targets]
test = ["CSV", "Documenter", "MLJBase", "MLJModelInterface", "RDatasets", "StatsAPI", "Test", "Weave", "WooldridgeDatasets"]
test = [
"CSV", "Documenter", "MLJBase", "MLJModelInterface", "RDatasets",
"StatsAPI", "Test", "Weave", "WooldridgeDatasets"
]
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.27"
Documenter = "1.8"
4 changes: 2 additions & 2 deletions src/formula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function decompose(
convert(Vector{Symbol}, filter!(!isnothing, union(termvars(f), [panel, time, wts])))
data = select(data, pns...) |> columntable
if isa(wts, Symbol)
wts = ifelse.(getproperty(data, wts) .≤ 0, missing, getproperty(data, wts))
data = (data..., wts = ifelse.(getproperty(data, wts) .≤ 0, missing, getproperty(data, wts)))
end
categorical_variables =
Tables.schema(data) |> (
Expand Down Expand Up @@ -158,7 +158,7 @@ function decompose(
Z = zeros(0, 0)
end
wts =
isnothing(wts) ? FrequencyWeights(ones(length(y))) : FrequencyWeights(collect(wts))
isnothing(wts) ? FrequencyWeights(ones(length(y))) : FrequencyWeights(collect(getproperty(data, wts)))
if isa(estimator, Type{<:RandomEffectsEstimator})
panel = (
panel,
Expand Down
4 changes: 2 additions & 2 deletions src/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
F = qr(X, ColumnNorm())
qrr = count(x -> abs(x) ≥ √eps(), diag(F.R))
if qrr < size(F, 2)
lin_ind = sort!(F.p[sortperm(F.p)[1:bkr]])
lin_ind = sort!(F.p[sortperm(F.p)[1:qrr]])

Check warning on line 182 in src/solvers.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers.jl#L182

Added line #L182 was not covered by tests
X = convert(Matrix{Float64}, X[:,lin_ind])
F = qr(X, ColumnNorm())
else
Expand Down Expand Up @@ -234,7 +234,7 @@
F = qr(X, ColumnNorm())
qrr = count(x -> abs(x) ≥ √eps(), diag(F.R))
if qrr < size(F, 2)
lin_ind = sort!(F.p[sortperm(F.p)[1:bkr]])
lin_ind = sort!(F.p[sortperm(F.p)[1:qrr]])

Check warning on line 237 in src/solvers.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers.jl#L237

Added line #L237 was not covered by tests
X = convert(Matrix{Float64}, X[:,lin_ind])
else
lin_ind = collect(1:size(F, 2))
Expand Down
42 changes: 23 additions & 19 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@
file,
out_path = joinpath(prefix, "docs", "src"),
doctype = "github"
)
)
end

DocMeta.setdocmeta!(Econometrics,
:DocTestSetup,
:(using Econometrics, Documenter, CSV, RDatasets, StatsBase;
ENV["COLUMNS"] = 120;
ENV["LINES"] = 30;),
recursive = true)
DocMeta.setdocmeta!(
Econometrics,
:DocTestSetup,
:(using Econometrics, Documenter, CSV, RDatasets, StatsBase;
ENV["COLUMNS"] = 120;
ENV["LINES"] = 30;),
recursive = true
)
# doctest(Econometrics, fix = true)
makedocs(sitename = "Econometrics",
format = Documenter.HTML(assets = [joinpath("assets", "custom.css")]),
modules = [Econometrics, StatsAPI],
pages = [
"Introduction" => "index.md",
"Getting Started" => "getting_started.md",
"Estimators" => "estimators.md",
"API" => "api.md",
],
source = joinpath(prefix, "docs", "src"),
build = joinpath(prefix, "docs", "build"),
)
makedocs(
sitename = "Econometrics",
format = Documenter.HTML(assets = [joinpath("assets", "custom.css")]),
modules = [Econometrics, StatsAPI],
pages = [
"Introduction" => "index.md",
"Getting Started" => "getting_started.md",
"Estimators" => "estimators.md",
"API" => "api.md",
],
source = joinpath(prefix, "docs", "src"),
build = joinpath(prefix, "docs", "build"),
checkdocs = :none,
)
@test true
end
11 changes: 11 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@testset "Issues" begin
@testset "Nonpositive Weights" begin
x = randn(100)
y = 2*x + randn(100)
w = randn(100)
data = DataFrame(x = x, y = y, w = w)
# Test that no error is thrown
# https://github.com/JuliaLang/julia/issues/18780#issuecomment-251534863
@test fit(EconometricModel, @formula(y ~ x), data; wts = :w) isa Any
end
end
Loading