API

DegreesOfFreedom.calc_df_marsMethod
calc_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.

source
DegreesOfFreedom.df_regtreeMethod
df_regtree(; ps = [1, 5, 10], maxd = 4)

Experiment for degrees of freedom for regression trees with number of features ps and maximum depth maxd.

source
DegreesOfFreedom.df_splinesMethod
df_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
source
DegreesOfFreedom.gen_dataFunction
gen_data(n, p, p1)

Generate simulation data:

  • X of size nxp
  • β of size p, where only the first p1 elements are signal.
  • y of size p: y = Xβ + ε
source
DegreesOfFreedom.gen_data_marsFunction
gen_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).

source
DegreesOfFreedom.iter_ridgeMethod
iter_ridge(X::AbstractMatrix, y::AbstractVector, λ::Real)

Conduct iterative ridge regression for y on X with smoothness penalty parameter λ.

source
DegreesOfFreedom.mars_experiment_mseMethod
mars_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.

source
DegreesOfFreedom.mse_marsMethod
mse_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.

  • N and p: the dimension for the data generating model
source
DegreesOfFreedom.run_experiment_splinesMethod
run_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")
source
DegreesOfFreedom.run_experiment_treeMethod
run_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).

source
DegreesOfFreedom.vary_pFunction
vary_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
source