R Under development (unstable) (2023-08-31 r85038 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("lpcde") > > set.seed(42) > n=1000 > x_data = matrix(rnorm(1*n, mean=0, sd=1), ncol=1) > y_data = matrix(rnorm(n, mean=0, sd=1)) > y_grid = stats::quantile(y_data, seq(from=0.1, to=0.9, by=0.1)) > > #bw estimation > model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw_type = "imse-rot") > summary(model1) Call: lpbwcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method imse-rot ================================== Index y_grid B.W. Eff.n ================================== 1 -1.2512 1.1036 313 2 -0.8452 1.1036 425 3 -0.5287 1.1036 487 4 -0.2550 1.1036 529 5 -0.0106 1.1036 534 ---------------------------------- 6 0.2397 1.1036 507 7 0.5039 1.1036 483 8 0.8026 1.1036 429 9 1.2896 1.1036 283 ================================== > > # density estimation > model2 = lpcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw=model1$BW[,2]) > summary(model2) Call: lpcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method ============================================================================= Point Std. Robust B.C. Index Grid B.W. Eff.n Est. Error [ 95% C.I. ] ============================================================================= 1 -1.2512 1.1036 314 0.1836 0.0046 0.1664 , 0.2087 2 -0.8452 1.1036 428 0.2796 0.0032 0.2757 , 0.3093 3 -0.5287 1.1036 494 0.3421 0.0028 0.3507 , 0.3791 4 -0.2550 1.1036 533 0.3672 0.0024 0.3725 , 0.3989 5 -0.0106 1.1036 546 0.3717 0.0021 0.3718 , 0.3964 ----------------------------------------------------------------------------- 6 0.2397 1.1036 517 0.3613 0.0022 0.3618 , 0.3872 7 0.5039 1.1036 490 0.3267 0.0022 0.3355 , 0.3609 8 0.8026 1.1036 436 0.2738 0.0025 0.2956 , 0.3257 9 1.2896 1.1036 288 0.1790 0.0048 0.1566 , 0.1980 ============================================================================= > > #bw estimation > model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw_type = "mse-rot") > summary(model1) Call: lpbwcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method mse-rot ================================== Index y_grid B.W. Eff.n ================================== 1 -1.2512 1.4927 527 2 -0.8452 1.6655 729 3 -0.5287 1.2025 545 4 -0.2550 1.0869 519 5 -0.0106 1.0589 511 ---------------------------------- 6 0.2397 1.0863 493 7 0.5039 1.1944 540 8 0.8026 1.5764 686 9 1.2896 1.4099 462 ================================== > > # density estimation > model2 = lpcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw=model1$BW[,2]) > summary(model2) Call: lpcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method ============================================================================= Point Std. Robust B.C. Index Grid B.W. Eff.n Est. Error [ 95% C.I. ] ============================================================================= 1 -1.2512 1.4927 526 0.1908 0.0025 0.1746 , 0.1944 2 -0.8452 1.6655 729 0.2706 0.0016 0.3017 , 0.3141 3 -0.5287 1.2025 544 0.3383 0.0024 0.3555 , 0.3789 4 -0.2550 1.0869 524 0.3678 0.0025 0.3719 , 0.3994 5 -0.0106 1.0589 510 0.3733 0.0024 0.3689 , 0.3969 ----------------------------------------------------------------------------- 6 0.2397 1.0863 502 0.3622 0.0023 0.3595 , 0.3864 7 0.5039 1.1944 544 0.3233 0.0018 0.3400 , 0.3605 8 0.8026 1.5764 685 0.2713 0.0010 0.2824 , 0.2927 9 1.2896 1.4099 462 0.1824 0.0021 0.1838 , 0.2027 ============================================================================= > > set.seed(42) > n=1000 > x_data = matrix(rnorm(2*n, mean=0, sd=1), ncol=2) > y_data = matrix(rnorm(n, mean=0, sd=1)) > y_grid = stats::quantile(y_data, seq(from=0.1, to=0.9, by=0.1)) > > #bw estimation > model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=matrix(c(0, 0), ncol=2), bw_type="imse-rot") > summary(model1) Call: lpbwcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method imse-rot ================================== Index y_grid B.W. Eff.n ================================== 1 -1.3242 0.8134 100 2 -0.8334 0.8134 149 3 -0.5201 0.8134 185 4 -0.2590 0.8134 201 5 0.0114 0.8134 206 ---------------------------------- 6 0.2612 0.8134 203 7 0.5211 0.8134 185 8 0.8037 0.8134 162 9 1.3115 0.8134 105 ================================== > > # density estimation > model2 = lpcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=matrix(c(0, 0), ncol=2), bw=model1$BW[,2]) > summary(model2) Call: lpcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method ============================================================================= Point Std. Robust B.C. Index Grid B.W. Eff.n Est. Error [ 95% C.I. ] ============================================================================= 1 -1.3242 0.8134 101 0.1859 0.0266 0.0323 , 0.4269 2 -0.8334 0.8134 151 0.2974 0.0223 0.2147 , 0.5554 3 -0.5201 0.8134 185 0.3473 0.0175 0.3099 , 0.5733 4 -0.2590 0.8134 202 0.3793 0.0168 0.2657 , 0.5366 5 0.0114 0.8134 208 0.3890 0.0160 0.2403 , 0.4780 ----------------------------------------------------------------------------- 6 0.2612 0.8134 202 0.3673 0.0144 0.2986 , 0.5332 7 0.5211 0.8134 184 0.3267 0.0150 0.2047 , 0.4127 8 0.8037 0.8134 162 0.2614 0.0165 0.0557 , 0.3137 9 1.3115 0.8134 104 0.1732 0.0325 -0.0277 , 0.3050 ============================================================================= > > #bw estimation > model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=matrix(c(0, 0), ncol=2), bw_type="mse-rot") > summary(model1) Call: lpbwcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method mse-rot ================================== Index y_grid B.W. Eff.n ================================== 1 -1.3242 0.4494 21 2 -0.8334 0.4401 36 3 -0.5201 0.4804 43 4 -0.2590 0.5872 85 5 0.0114 1.5126 656 ---------------------------------- 6 0.2612 0.5813 80 7 0.5211 0.4788 44 8 0.8037 0.4415 27 9 1.3115 0.4489 19 ================================== > > # density estimation > model2 = lpcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=matrix(c(0, 0), ncol=2), bw=model1$BW[,2]) > summary(model2) Call: lpcde Sample size 1000 Polynomial order for Y point estimation (p=) 2 Polynomial order for X point estimation (q=) 1 Density function estimated (mu=) 1 Order of derivative estimated for covariates (nu=) 0 Kernel function epanechnikov Bandwidth method ============================================================================= Point Std. Robust B.C. Index Grid B.W. Eff.n Est. Error [ 95% C.I. ] ============================================================================= 1 -1.3242 0.4494 21 0.1945 0.6270 -2.1640 , 2.5330 2 -0.8334 0.4401 36 0.4714 0.7144 -6.9962 , 6.2796 3 -0.5201 0.4804 46 0.7639 0.3040 -2.3695 , 7.1679 4 -0.2590 0.5872 81 0.4473 0.1126 -0.3643 , 1.4825 5 0.0114 1.5126 653 0.3572 0.0014 0.4037 , 0.4213 ----------------------------------------------------------------------------- 6 0.2612 0.5813 78 0.3736 0.0987 -0.4594 , 1.2483 7 0.5211 0.4788 44 0.2269 0.1221 -1.2955 , 0.9603 8 0.8037 0.4415 26 0.0575 0.2640 -0.6319 , 0.7393 9 1.3115 0.4489 20 0.0000 0.0000 0.0000 , 0.0000 ============================================================================= > > proc.time() user system elapsed 171.89 3.42 175.29