API
DegreesOfFreedom.anim_plot — Methodanim_plot(βs, βlasso)Compare the lasso solution from glmnet and the iterative ridge via an animated plot.
DegreesOfFreedom.calc_df_mars — Methodcalc_df_mars(;n = 100, p = 10, N = 100, nk = 5, d = 1, penalty = d+1, tol = 1e-6, seedx = rand(UInt), seedy = rand(UInt))Calculate the degrees of freedom of MARS, and extract the nominal degrees of freedom used in earth::earth.
DegreesOfFreedom.cvlasso_vs_iter_ridge — Functioncvlasso_vs_iter_ridge(n, p)Compare lasso with LOOCV and iterative ridge.
DegreesOfFreedom.demo_lasso — Functiondemo_lasso(n, p, p1)Demo for Lasso fitted by iterative ridge regressions.
DegreesOfFreedom.demo_lasso_df — Functiondemo_lasso_df(n, p)Demo for degrees of freedom of lasso via the iterative ridge regression.
DegreesOfFreedom.df_regtree — Methoddf_regtree(; ps = [1, 5, 10], maxd = 4)Experiment for degrees of freedom for regression trees with number of features ps and maximum depth maxd.
DegreesOfFreedom.df_splines — Methoddf_splines(; Js = [5, 10, 15], λs = [0.001, 0.01, 0.1], n = 20, nrep = 10, nMC = 100)Calculate the empirical degrees of freedom of four splines:
- cubic splines with number of basis functions Js
- smoothing splines with tuning parameter λs
- sample size n
- number of repetition nrep
- number of Monte Carlo samples nMC
DegreesOfFreedom.gen_data — Functiongen_data(n, p, p1)Generate simulation data:
- Xof size- nxp
- βof size- p, where only the first- p1elements are signal.
- yof size- p:- y = Xβ + ε
DegreesOfFreedom.gen_data_mars — Functiongen_data_mars(N = 100, p = 2)Generate N observations from the tensor-product example with p predictors in Section 9.4.2 of Hastie et al. (2009) (The ESL book).
DegreesOfFreedom.iter_ridge — Methoditer_ridge(X::AbstractMatrix, y::AbstractVector, λ::Real)Conduct iterative ridge regression for y on X with smoothness penalty parameter λ.
DegreesOfFreedom.mars_experiment_df_vs_df — Methodmars_experiment_df_vs_df(; ps = [1, 10, 50], folder = "/tmp", maxnk = 100)Compare the nominal df and actual df for MARS for different number of predictors ps.
DegreesOfFreedom.mars_experiment_mse — Methodmars_experiment_mse(; folder = "/tmp", ps = [2, 10, 20, 30, 40, 50, 60], with_cv = false)Run MARS experiments with default MARS, and MARS with corrected penalty factor, and if with_cv, MARS with corrected penalty factor by 10-fold CV.
DegreesOfFreedom.mse_mars — Methodmse_mars(; d = 1, N = 200, p = 2, penalty = d+1, nk = 50, with_cv = false)Calculate the proportion of MSE decrease of the default MARS and the MARS with corrected df. If with_cv, the corrected df by cross-validation is also considered. 
- Nand- p: the dimension for the data generating model
DegreesOfFreedom.run_experiment_lasso_vs_subset — Methodrun_experiment_lasso_vs_subset()Run the experiment for comparing the degrees of freedom of lasso and best subset, whose results are saved into the figure shown in the paper.
DegreesOfFreedom.run_experiment_splines — Methodrun_experiment_splines()Run the experiment of splines, whose results will be saved into a .sil file (can be later loaded via deserialize) and a .tex file (the table displayed in the paper).
run_experiment_splines(folder = "/home/weiya/Overleaf/paperDoF/res/df")DegreesOfFreedom.run_experiment_tree — Methodrun_experiment_tree()Run the experiment for regression tree, whose results are saved into a .sil file (can be later loaded via deserialize) and a .tex file (the table in the paper).
DegreesOfFreedom.save_plots — Methodsave_plots(ps; output)Save multi-images into a pdf file, if output is unspecified (default), the resulting file is /tmp/all.pdf. See also: https://github.com/szcf-weiya/Xfunc.jl/blob/master/src/plot.jl
DegreesOfFreedom.vary_p — Functionvary_p(d = 1, ps = [2, 10, 20, 30, 40, 50, 60]; with_cv = false, nrep = 10, nMC = 100)Run MARS experiments with different number of predictors ps for degree d. 
- nrep: number of replications
- nMC: number of Monte Carlo samples for calculating df
- with_cv: whether include the comparisons with the cross-validation method