API References

Main Functions in the npDoseResponse Package

npDoseResponse.npDoseResponse.DerivEffect(Y, X, t_eval=None, h_bar=None, kernT_bar='gaussian', h=None, b=None, C_h=7, C_b=3, print_bw=True, degree=2, deriv_ord=1, kernT='epanechnikov', kernS='epanechnikov', parallel=False, processes=20)[source]

Estimating the derivative of the dose-response curve via Nadaraya-Watson conditional CDF estimator.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • t_eval ((m,)-array) – The coordinates of the m evaluation points. (Default: t_eval=None. Then, t_eval=X[:,0], which consists of the observed treatment variables.)

  • h_bar (float) – The bandwidth parameters for the Nadaraya-Watson conditional CDF estimator. (Default: h_bar=None. Then, the Silverman’s rule of thumb is applied. See Chen et al.(2016) for details.)

  • kernT_bar (str) – The name of the kernel function for Nadaraya-Watson conditional CDF estimator. (Default: “gaussian”.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • parallel (boolean) – The indicator of whether the function should be parallel executed by multi-processing. (Default: parallel=False.)

  • processes (int) – The number of processes for parallel execution. (Default: processes=20.)

Returns:

theta_C – The estimated derivative of the dose-response curve evaluated at points “t_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.DerivEffectBoot(Y, X, t_eval=None, boot_num=500, alpha=0.95, h_bar=None, kernT_bar='gaussian', h=None, b=None, C_h=7, C_b=3, print_bw=True, degree=2, deriv_ord=1, kernT='epanechnikov', kernS='epanechnikov', parallel=False, processes=20)[source]

Conduct inference on the derivative of the dose-response curve via Nadaraya-Watson conditional CDF estimator and nonparametric bootstrap.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • t_eval ((m,)-array) – The coordinates of the m evaluation points. (Default: t_eval=None. Then, t_eval=X[:,0], which consists of the observed treatment variables.)

  • boot_num (int) – The number of bootstrapping times. (Default: bootstrap_num=500.)

  • alpha (float) – The confidence level of both the uniform confidence band and pointwise confidence interval. (Default: alpha=0.95.)

  • h_bar (float) – The bandwidth parameters for the Nadaraya-Watson conditional CDF estimator. (Default: h_bar=None. Then, the Silverman’s rule of thumb is applied. See Chen et al.(2016) for details.)

  • kernT_bar (str) – The name of the kernel function for Nadaraya-Watson conditional CDF estimator. (Default: “gaussian”.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • parallel (boolean) – The indicator of whether the function should be parallel executed by multi-processing. (Default: parallel=False.)

  • processes (int) – The number of processes for parallel execution. (Default: processes=20.)

Returns:

  • theta_C ((m,)-array) – The estimated derivative of the dose-response curve evaluated at points “t_eval”.

  • theta_C_boot ((m,)-array) – The estimated derivatives of the dose-response curve on bootstrap samples evaluated at points “t_eval”.

  • theta_alpha (float) – The width of the uniform confidence band.

  • theta_alpha_var ((m,)-array) – The widths of the pointwise confidence bands at evaluation points “t_eval”.

npDoseResponse.npDoseResponse.IntegEst(Y, X, t_eval=None, h_bar=None, kernT_bar='gaussian', h=None, b=None, C_h=7, C_b=3, print_bw=True, degree=2, deriv_ord=1, kernT='epanechnikov', kernS='epanechnikov', parallel=False, processes=20)[source]

Estimating the dose-response curve via our integral estimator with linear interpolation approximation.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • t_eval ((m,)-array) – The coordinates of the m evaluation points. (Default: t_eval=None. Then, t_eval=X[:,0].)

  • h_bar (float) – The bandwidth parameters for the Nadaraya-Watson conditional CDF estimator. (Default: h_bar=None. Then, the Silverman’s rule of thumb is applied. See Chen et al.(2016) for details.)

  • kernT_bar (str) – The name of the kernel function for Nadaraya-Watson conditional CDF estimator. (Default: “gaussian”.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • parallel (boolean) – The indicator of whether the function should be parallel executed by multi-processing. (Default: parallel=False.)

  • processes (int) – The number of processes for parallel execution. (Default: processes=20.)

Returns:

m_est – The estimated dose-response curve evaluated at points “t_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.IntegEstBoot(Y, X, t_eval=None, boot_num=500, alpha=0.95, h_bar=None, kernT_bar='gaussian', h=None, b=None, C_h=7, C_b=3, print_bw=True, degree=2, deriv_ord=1, kernT='epanechnikov', kernS='epanechnikov', parallel=False, processes=20)[source]

Conduct inference on the dose-response curve via our integral estimator and nonparametric bootstrap.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • t_eval ((m,)-array) – The coordinates of the m evaluation points. (Default: t_eval=None. Then, t_eval=X[:,0].)

  • boot_num (int) – The number of bootstrapping times. (Default: bootstrap_num=500.)

  • alpha (float) – The confidence level of both the uniform confidence band and pointwise confidence interval. (Default: alpha=0.95.)

  • h_bar (float) – The bandwidth parameters for the Nadaraya-Watson conditional CDF estimator. (Default: h_bar=None. Then, the Silverman’s rule of thumb is applied. See Chen et al.(2016) for details.)

  • kernT_bar (str) – The name of the kernel function for Nadaraya-Watson conditional CDF estimator. (Default: “gaussian”.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • parallel (boolean) – The indicator of whether the function should be parallel executed by multi-processing. (Default: parallel=False.)

  • processes (int) – The number of processes for parallel execution. (Default: processes=20.)

Returns:

  • m_est ((m,)-array) – The estimated dose-response curve evaluated at points “t_eval”.

  • m_est_boot ((boot_num, m)-array) – The estimated dose-response curves (or their derivatives) on the bootstrap samples evaluated at points “t_eval”.

  • m_alpha (float) – The width of the uniform confidence band.

  • m_alpha_var ((m,)-array) – The widths of the pointwise confidence bands at evaluation points “t_eval”.

npDoseResponse.npDoseResponse.LocalPolyReg(Y, X, x_eval=None, degree=2, deriv_ord=1, h=None, b=None, C_h=7, C_b=3, print_bw=True, kernT='epanechnikov', kernS='epanechnikov', h_lst=numpy.linspace, b_lst=numpy.linspace)[source]

(Partial) Local polynomial regression for estimating the conditional mean outcome function and its partial derivatives. We use higher order local monomials for the treatment variable and first-order local monomials for the confounding variables.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • x_eval ((m,d+1)-array) – The coordinates of the m evaluation points. (Default: x_eval=None. Then, x_eval=X.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • h_lst ((k1,)-array and (k2,)-array) – Candidate searching values of h,b for LOOCV.

  • b_lst ((k1,)-array and (k2,)-array) – Candidate searching values of h,b for LOOCV.

Returns:

Y_est – The estimated conditional mean outcome function or its partial derivatives evaluated at points “x_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.LocalPolyReg1D(Y, X, h=None, x_eval=None, degree=2, deriv_ord=0, kernel='epanechnikov')[source]

Local polynomial regression in one dimension.

Parameters:
  • Y ((m,)-array) – The y coordinates of m data points.

  • X ((m,)-array) – The x coordinates of m data points.

  • h (float) – The bandwidth parameter. (Default: h=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used.)

  • x_eval ((k,)-array) – Vector of evaluation points. (Default: x_eval=None. Then, x_eval=X.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of derivatives of the regression function that are estimated. (Default: deriv_ord=0. Then, it is the usual local polynomial regression.)

Returns:

Y_est – The estimated function or its derivatives by local polynomial regression evaluated at points “x_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.LocalPolyRegMain(Y, X, x_eval=None, degree=2, deriv_ord=1, h=None, b=None, kernT='epanechnikov', kernS='epanechnikov')[source]

Main function for computing the local polynomial regression.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • x_eval ((m,d+1)-array) – The coordinates of the m evaluation points. (Default: x_eval=None. Then, x_eval=X.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables.

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables.

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

Returns:

Y_est – The estimated conditional mean outcome function or its partial derivatives evaluated at points “x_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.LocalPolyReg_Fs(x_eval, Y, X, degree=2, deriv_ord=1, h=None, b=None, C_h=7, C_b=3, print_bw=True, kernT='epanechnikov', kernS='epanechnikov', h_lst=numpy.linspace, b_lst=numpy.linspace)[source]

(Partial) Local polynomial regression for estimating the conditional mean outcome function and its partial derivatives. We use higher order local monomials for the treatment variable and first-order local monomials for the confounding variables. (This function is for multi-process execution only.)

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • x_eval ((m,d+1)-array) – The coordinates of the m evaluation points. (Default: x_eval=None. Then, x_eval=X.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • h_lst ((k1,)-array and (k2,)-array) – Candidate searching values of h,b for LOOCV.

  • b_lst ((k1,)-array and (k2,)-array) – Candidate searching values of h,b for LOOCV.

Returns:

Y_est – The estimated conditional mean outcome function or its partial derivatives evaluated at points “x_eval”.

Return type:

(m,)-array

npDoseResponse.npDoseResponse.RegAdjust(Y, X, t_eval=None, h=None, b=None, C_h=7, C_b=3, print_bw=True, degree=2, deriv_ord=0, kernT='epanechnikov', kernS='epanechnikov', parallel=False, processes=20)[source]

Estimating the dose-response curve via simple integral estimator with linear interpolation approximation.

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • t_eval ((m,)-array) – The coordinates of the m evaluation points. (Default: t_eval=None. Then, t_eval=X[:,0].)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables. (Default: h=None, b=None. Then, the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999) is used with additional scaling factors C_h and C_b, respectively.)

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative of the conditional mean outcome function. (Default: deriv_ord=0. Then, it estimates the conditional mean outcome function itself.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • parallel (boolean) – The indicator of whether the function should be parallel executed by multi-processing. (Default: parallel=False.)

  • processes (int) – The number of processes for parallel execution. (Default: processes=20.)

Returns:

m_est – The estimated dose-response curve (or its derivative) evaluated at points “t_eval”.

Return type:

(m,)-array

Implementations of Common Kernel Functions

npDoseResponse.rbf.KernelRetrieval(name)[source]

Retrieving the kernel function, its second moment, and its variance based on the name.

Parameters:

name (str) – The name of the kernel function.

Returns:

  • kern_func (python function) – The kernel function.

  • sigmaK_sq (float) – The second moment of the kernel function.

  • K_sq (float) – The variance of the kernel function.

npDoseResponse.rbf.bigaussian(t)[source]

Bigaussian kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.biweight(t)[source]

Biweight/quartic kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.cosine(t)[source]

Cosine kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.epanechnikov(t)[source]

Epanechnikov kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.gaussian(t)[source]

Gaussian kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.logistic(t)[source]

Logistic kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.rectangular(t)[source]

Rectangular/uniform kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.sigmoid(t)[source]

Sigmoid kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.silverman(t)[source]

Silverman kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.triangular(t)[source]

Triangular kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.tricube(t)[source]

Tricube kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

npDoseResponse.rbf.triweight(t)[source]

Triweight kernel function.

Parameters:

t (float or (n,)-array) – The query points.

Returns:

res – The kernel values evaluated at the query points.

Return type:

float or (n,)-array

Utility Functions

npDoseResponse.utils.HatMatrix(X, degree=2, deriv_ord=1, h=None, b=None, print_bw=True, kernT='epanechnikov', kernS='epanechnikov')[source]

Compute the hat matrix of the local polynomial regression when it is viewed as a linear smoother.

Parameters:
  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • degree (int) – Degree of local polynomials. (Default: degree=2.)

  • deriv_ord (int) – The order of the estimated derivative the conditional mean outcome function. (Default: deriv_ord=1. Then, it estimates the partial derivative of the conditional mean outcome function with respect to the treatment variable.)

  • h (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables.

  • b (float) – The bandwidth parameters for the treatment/exposure variable and confounding variables.

  • print_bw (boolean) – The indicator of whether the current bandwidth parameters should be printed to the console. (Default: print_bw=True.)

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

Returns:

hat_mat – The hat matrix.

Return type:

(n,n)-array

npDoseResponse.utils.RoTBWLocalPoly(Y, X, kernT='epanechnikov', kernS='epanechnikov', C_h=7, C_b=3)[source]

Compute the rule-of-thumb bandwidth selector in Eq.(A1) of Yang and Tschernig (1999).

Parameters:
  • Y ((n,)-array) – The outcomes of n observations.

  • X ((n,d+1)-array) – The first column of X is the treatment/exposure variable, while the other d columns are confounding variables of n observations.

  • kernT (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • kernS (str) – The names of kernel functions for the treatment/exposure variable and confounding variables. (Default: “epanechnikov”.)

  • C_h (float) – The scaling factors for the rule-of-thumb bandwidth parameters. (Default: C_h=7, C_b=3.)

  • C_b (float) – The scaling factors for the rule-of-thumb bandwidth parameters. (Default: C_h=7, C_b=3.)

Returns:

  • h (float) – The rule-of-thumb bandwidth parameter for the treatment/exposure variable.

  • b ((d,)-array) – The rule-of-thumb bandwidth vector for the confounding variables.