Skip to contents

The `nekd()` function enables to implement the naive kernel density estimation without bias correction for the heterogeneous mean, the autocovariance, and the autocorrelation. The method is developed by Okui and Yanagi (2020). For more details, see the package vignette with `vignette("panelhetero")`.

Usage

nekd(
  data,
  acov_order = 0,
  acor_order = 1,
  mean_bw = NULL,
  acov_bw = NULL,
  acor_bw = NULL
)

Arguments

data

A matrix of panel data. Each row corresponds to individual time series.

acov_order

A non-negative integer of the order of autocovariance. Default is 0.

acor_order

A positive integer of the order of autocorrelation. Default is 1.

mean_bw

A scalar of bandwidth used for the estimation of the denisty of mean. Default is NULL, and the plug-in bandwidth is used.

acov_bw

A scalar of bandwidth used for the estimation of the denisty of autocovariance. Default is NULL, and the plug-in bandwidth is used.

acor_bw

A scalar of bandwidth used for the estimation of the denisty of autocorrelation. Default is NULL, and the plug-in bandwidth is used.

Value

A list that contains the following elements:

mean

A plot of the corresponding density

acov

A plot of the corresponding density

acor

A plot of the corresponding density

mean_func

A function that returns the corresponding density

acov_func

A function that returns the corresponding density

acor_func

A function that returns the corresponding density

bandwidth

A Vector of the bandwidths

quantity

A matrix of the estimated heterogeneous quantities

acov_order

The order of autocovariance

acor_order

The order of autocorrelation

N

The number of cross-sectional units

S

The length of time series

References

Okui, R. and Yanagi, T., 2020. Kernel estimation for panel data with heterogeneous dynamics. The Econometrics Journal, 23(1), pp.156-175.

Examples

data <- panelhetero::simulation(N = 300, S = 50)
panelhetero::nekd(data = data)
#> $mean

#> 
#> $acov

#> 
#> $acor

#> 
#> $mean_func
#> function (x) 
#> {
#>     kdest(x = x, X = mean_est, h = mean_bw)
#> }
#> <bytecode: 0x56308f298f60>
#> <environment: 0x56308f299f20>
#> 
#> $acov_func
#> function (x) 
#> {
#>     kdest(x = x, X = acov_est, h = acov_bw)
#> }
#> <bytecode: 0x56308f2992a8>
#> <environment: 0x56308f299f20>
#> 
#> $acor_func
#> function (x) 
#> {
#>     kdest(x = x, X = acor_est, h = acor_bw)
#> }
#> <bytecode: 0x56308f2995f0>
#> <environment: 0x56308f299f20>
#> 
#> $bandwidth
#>            mean  autocovariance autocorrelation 
#>      0.35605017      0.05144543      0.06734172 
#> 
#> $quantity
#>                mean autocovariance autocorrelation
#>   [1,]  0.990865136     0.46650031     0.092054388
#>   [2,]  0.376291248     0.39027353     0.149450786
#>   [3,] -2.265495072     0.78156306     0.137845819
#>   [4,] -1.214334932     0.19671643     0.095093454
#>   [5,] -0.860734550     0.23498650     0.178790257
#>   [6,] -0.098839354     0.41814844     0.106509560
#>   [7,]  0.530735300     0.09367492     0.358387586
#>   [8,] -0.799044965     0.26567879     0.375943912
#>   [9,]  1.463751370     0.22128183     0.098993551
#>  [10,]  1.714683395     0.28682199     0.217475213
#>  [11,]  0.741508474     0.09424717     0.184717651
#>  [12,]  0.234245589     0.43464557     0.371507732
#>  [13,] -0.299229616     0.18114963    -0.054887905
#>  [14,]  1.425237835     0.20843405     0.292385041
#>  [15,]  0.095027885     0.97005224     0.205579562
#>  [16,]  0.045084831     0.45225647     0.226636272
#>  [17,] -0.331770999     0.34070393     0.073689730
#>  [18,] -0.335128821     0.14796517     0.304410151
#>  [19,] -3.623004928     0.14470745     0.367821706
#>  [20,] -1.443884910     0.18565843     0.167416677
#>  [21,] -0.186552374     0.23878736     0.333379952
#>  [22,] -0.484841561     0.41603885     0.057382452
#>  [23,] -0.799471884     0.94740658    -0.020483369
#>  [24,] -1.500378980     0.36769003     0.376054331
#>  [25,] -1.273593657     0.54774818     0.281810987
#>  [26,] -0.508112616     0.52168123     0.485358073
#>  [27,]  0.139240976     0.99615446     0.093395382
#>  [28,]  0.304300352     0.79275026     0.294416856
#>  [29,]  0.170490407     0.17881819     0.350711502
#>  [30,]  0.728237699     0.24572132     0.039212957
#>  [31,] -0.359128298     0.26670551    -0.234862095
#>  [32,]  1.929109531     0.55745838     0.201567046
#>  [33,] -0.691685802     0.23099758     0.018824187
#>  [34,]  1.731708012     0.21998267     0.192598353
#>  [35,] -1.270484237     0.28951376    -0.095068253
#>  [36,]  2.542528226     0.36044730     0.526767163
#>  [37,]  0.085400987     0.32085050     0.340553927
#>  [38,] -0.739524877     0.21864596     0.212991203
#>  [39,] -1.764619178     0.32123688     0.434336607
#>  [40,]  0.347356796     0.67155305     0.072390217
#>  [41,] -0.761036151     0.48782405     0.145268243
#>  [42,]  0.747305558     0.34878800     0.200910033
#>  [43,] -0.647273181     0.57744782     0.301980982
#>  [44,]  0.703830937     0.26086682    -0.293220287
#>  [45,] -0.022000852     0.10652863     0.591871146
#>  [46,] -0.594828114     0.28309554     0.004288754
#>  [47,]  0.348629297     0.76815492     0.335823066
#>  [48,]  0.509892718     0.22067103     0.269814418
#>  [49,]  0.555469424     0.11852734     0.164322838
#>  [50,]  0.074937060     1.21857989     0.027786421
#>  [51,]  1.258158804     0.28063110    -0.010125267
#>  [52,]  0.274083886     0.15148058     0.133082816
#>  [53,]  1.295763235     0.61230450     0.307596437
#>  [54,]  0.135142066     0.30558773     0.055581424
#>  [55,]  0.799987805     0.52045696     0.001943795
#>  [56,] -0.326002706     0.61833670     0.082930004
#>  [57,]  0.606400955     0.21741277     0.800293291
#>  [58,]  0.572244287     0.23036604     0.503077463
#>  [59,] -0.144190477     0.15677092     0.135493933
#>  [60,]  1.419649821     0.37253205     0.082223963
#>  [61,]  1.687823638     0.61033396     0.031429385
#>  [62,]  1.368887503     0.38267733     0.309822636
#>  [63,]  1.365437728     0.48707949     0.505216389
#>  [64,] -0.622977482     0.61899323     0.246025168
#>  [65,]  0.201466435     0.44943659     0.339849335
#>  [66,]  0.206722333     0.70961218     0.034830403
#>  [67,]  0.952403445     0.55936710    -0.029696440
#>  [68,] -1.113056921     1.14807526    -0.070703502
#>  [69,] -0.731362939     0.35785347     0.239196174
#>  [70,]  0.972358953     0.89092513     0.382557925
#>  [71,]  0.451051014     0.10203143     0.503926764
#>  [72,]  0.906563732     0.35121120     0.118335914
#>  [73,]  0.426087010     0.33304882     0.174595121
#>  [74,]  0.038918409     0.05476516     0.555773654
#>  [75,] -0.168339162     0.35170092     0.292831814
#>  [76,]  0.930079819     0.88459982     0.111263269
#>  [77,] -1.714725330     0.32262992     0.347311749
#>  [78,]  1.021365408     1.06748792     0.092866358
#>  [79,] -0.633621989     0.53478226     0.077351518
#>  [80,]  0.956424513     0.46326928     0.178394827
#>  [81,]  1.303815716     0.18870079     0.732318126
#>  [82,] -0.242338731     0.65175705     0.125064375
#>  [83,] -0.361786233     0.43997200    -0.082223054
#>  [84,]  0.785726006     0.09457220     0.650824543
#>  [85,] -0.405949131     0.11874017     0.497962720
#>  [86,] -0.143744394     0.14413974     0.505828510
#>  [87,]  0.178952225     0.14762400     0.503544289
#>  [88,]  1.266215694     0.38964259     0.114753581
#>  [89,] -0.774852505     0.24982826     0.128135873
#>  [90,]  1.686146448     0.35696799     0.349450979
#>  [91,]  0.124082422     0.16694448     0.080480025
#>  [92,]  0.091533781     0.37613874     0.312005158
#>  [93,] -0.798153588     0.71678087     0.188734572
#>  [94,]  2.411869744     0.34879265     0.254034924
#>  [95,]  0.142582110     0.10449712     0.597747879
#>  [96,] -1.760012601     0.26275342     0.097987135
#>  [97,] -0.392098782     0.30129288     0.485724125
#>  [98,]  0.189096936     0.57837913     0.291856153
#>  [99,] -0.709299464     0.13128140     0.313842342
#> [100,]  0.549609570     0.13737823     0.490485941
#> [101,]  0.756475322     0.40374307     0.275372560
#> [102,]  1.044746330     0.41587796     0.432132900
#> [103,]  0.559197051     0.17770043     0.009444480
#> [104,] -1.245580816     0.58680224     0.269286163
#> [105,] -0.155759648     0.24901537     0.247756176
#> [106,] -1.416586395     0.61979892     0.268340847
#> [107,] -2.222005396     0.53395016     0.045544019
#> [108,] -0.461953887     0.52933128     0.143136000
#> [109,]  0.338283210     0.37144542     0.352608123
#> [110,] -1.098539662     0.52632782     0.408594664
#> [111,] -1.040656057     0.32570566    -0.020022409
#> [112,] -2.929185175     0.37031285     0.269799041
#> [113,]  0.277389019     0.26885213     0.551197217
#> [114,]  3.928060927     0.43184513     0.350330849
#> [115,] -0.606471064     0.25590407     0.128784698
#> [116,] -0.233926572     0.39656397     0.080775763
#> [117,]  0.501450338     0.90825829     0.325997004
#> [118,] -1.742224538     0.17995376     0.147100635
#> [119,]  0.308834869     0.91084767     0.025680702
#> [120,] -0.010685738     0.60522653    -0.103204098
#> [121,]  2.957064358     0.14575062     0.150993958
#> [122,] -0.734034258     0.42353339     0.284231891
#> [123,] -0.179751555     0.67200845    -0.093923580
#> [124,] -0.235828123     0.43487145     0.439161130
#> [125,] -0.779957141     0.24278788     0.338781520
#> [126,] -0.544039387     0.25431530     0.285139850
#> [127,]  0.227706855     0.53646981     0.337982283
#> [128,] -1.335663612     0.52493847     0.031829742
#> [129,]  1.503460010     1.31243880     0.063187996
#> [130,] -0.809494489     0.13233910     0.342584942
#> [131,]  2.231864105     0.11466245     0.209050731
#> [132,] -0.750028472     0.12689495     0.558870777
#> [133,]  1.619812216     0.44963946     0.468769341
#> [134,] -0.220386648     0.31838023     0.212234457
#> [135,]  0.134435766     0.87599322     0.173738969
#> [136,] -0.297443557     0.35533287     0.122908909
#> [137,] -0.059628964     0.11764026     0.315275036
#> [138,]  0.261840720     0.23707351    -0.006773256
#> [139,] -1.700510335     0.74085236     0.232502754
#> [140,]  0.200612926     0.23918609     0.077756884
#> [141,] -0.250106204     0.22350392     0.420942043
#> [142,]  1.941823898     0.17637769     0.272197959
#> [143,] -0.768950426     0.28211386     0.081240850
#> [144,] -1.562814292     0.43592216     0.003902645
#> [145,]  2.331259852     0.25231753     0.373089082
#> [146,] -0.367956806     0.15089961     0.482454547
#> [147,] -0.183806819     0.34336385     0.114274995
#> [148,] -1.105878840     0.12959146     0.564069052
#> [149,] -0.613342094     0.25446401     0.524992359
#> [150,] -1.103440439     0.34328580     0.429321372
#> [151,]  0.367633931     0.27989403     0.153086570
#> [152,]  1.816497218     0.07580479     0.263694218
#> [153,] -0.987450976     0.10840049     0.435030033
#> [154,]  0.260139555     0.16948619     0.405083735
#> [155,] -0.418240517     0.18681059    -0.006188901
#> [156,]  1.081324668     0.28202646     0.031808016
#> [157,]  1.592496068     0.84819382     0.055029842
#> [158,]  0.542824550     0.26229212     0.081506128
#> [159,] -0.384011208     0.34202333    -0.077143174
#> [160,] -0.971745508     0.12150283    -0.211959246
#> [161,]  1.176044458     0.23815269     0.161470412
#> [162,]  0.009391157     0.15070797     0.229571363
#> [163,] -0.630388972     0.16522660     0.277881788
#> [164,] -1.405241222     0.78536417     0.180432251
#> [165,] -0.221739365     0.54974553    -0.010487700
#> [166,] -0.828889951     0.21301117     0.121520362
#> [167,]  0.662028254     0.42221741     0.003200604
#> [168,]  0.939414368     0.53568114     0.012345987
#> [169,] -0.811063344     0.11084815     0.432076420
#> [170,]  0.909671340     0.15857954     0.192886993
#> [171,] -0.213806821     1.05222229     0.070145923
#> [172,]  0.721128878     0.27145075     0.005272572
#> [173,] -0.907965889     0.15577822     0.679978751
#> [174,] -2.125283971     0.27623573     0.263834678
#> [175,]  2.362076252     0.27693876     0.360219251
#> [176,]  0.660102255     0.79536009     0.103917675
#> [177,] -0.716417944     0.31295943     0.137085481
#> [178,]  0.235748873     0.13255176     0.793931379
#> [179,] -0.822421563     0.33816654     0.130882886
#> [180,] -1.594959412     0.56715693     0.094318876
#> [181,]  0.016454127     0.17266498     0.530212305
#> [182,] -1.378061676     0.16451993     0.147842984
#> [183,]  0.503541299     0.06722209     0.452628464
#> [184,]  0.725293469     0.26327351     0.114047501
#> [185,] -0.095185541     0.17520178     0.324901168
#> [186,]  0.812860997     0.41870179     0.342952441
#> [187,] -1.466208002     1.08866045     0.209704609
#> [188,]  0.278453402     0.46834889     0.470348695
#> [189,] -0.017587277     0.13807310     0.486003655
#> [190,]  0.842337891     0.40746090     0.270893968
#> [191,]  1.299392287     0.34913523     0.255804876
#> [192,]  0.662813491     0.09561483     0.422409321
#> [193,] -1.142309284     0.39316735     0.019999288
#> [194,] -0.814339430     0.08728260     0.320037825
#> [195,] -0.370915683     0.39378115     0.465565318
#> [196,] -1.095367780     0.31491839    -0.004269562
#> [197,]  0.562547827     0.47417178     0.143652336
#> [198,] -0.384597701     0.13000005     0.597758219
#> [199,]  0.080266773     0.07963358     0.354233142
#> [200,]  0.643318325     0.14234205     0.604508162
#> [201,]  0.196620648     0.05324766     0.637240728
#> [202,] -0.091031126     0.33022296     0.199498448
#> [203,] -1.158445834     0.24097884     0.366053144
#> [204,] -0.258121236     0.74565835     0.449014515
#> [205,]  0.242601898     0.53500186    -0.124713691
#> [206,] -0.024949338     0.19201390     0.488185980
#> [207,]  0.125025726     0.49545292     0.174850007
#> [208,] -0.521730822     0.16256488     0.585659539
#> [209,]  0.692029506     0.41724339     0.303514511
#> [210,]  0.055970761     0.19668131     0.048069878
#> [211,] -0.785607383     0.19517844     0.024398516
#> [212,]  0.562033932     0.15025956     0.084579824
#> [213,]  1.345893692     0.25072339     0.546812652
#> [214,]  0.622400678     0.12261176     0.472157349
#> [215,]  0.011188306     0.65148546     0.277438039
#> [216,]  1.198294444     0.23587042     0.075916362
#> [217,] -1.454814487     0.27815483     0.185268699
#> [218,] -0.246361682     0.21809665     0.218616326
#> [219,]  0.216111821     0.11780306     0.078739791
#> [220,] -0.808316382     0.44454128     0.209348764
#> [221,] -0.131580440     0.41056996    -0.113233692
#> [222,]  0.717702631     0.31547046    -0.175393635
#> [223,] -1.985577634     0.10478331     0.557777159
#> [224,] -0.789773572     0.13234027     0.158575349
#> [225,]  0.404426654     1.11494666    -0.004137798
#> [226,] -1.789787969     0.21881040     0.127007230
#> [227,] -0.231952694     0.76738067    -0.085181791
#> [228,] -0.283397419     0.25849039     0.172271598
#> [229,]  0.936303494     0.53930735     0.245546373
#> [230,] -0.004089354     0.44724154     0.291769553
#> [231,]  0.371538433     0.59649584     0.241454249
#> [232,] -0.650992845     0.24498229    -0.159157941
#> [233,] -0.604831940     0.16680626     0.545788385
#> [234,]  1.474606024     0.14618490     0.538767820
#> [235,]  0.138793871     0.26655847     0.225976696
#> [236,]  0.549908940     0.18517846     0.250973365
#> [237,] -0.814776780     0.32962147     0.525208870
#> [238,] -0.666246081     0.54786216     0.017728020
#> [239,] -0.792465807     0.31558557     0.439148331
#> [240,] -0.719959053     0.33827403     0.104368437
#> [241,] -0.079858576     0.63283279     0.021883965
#> [242,]  1.618115737     0.30466888     0.279080914
#> [243,] -0.430342920     0.62924464    -0.102269176
#> [244,] -0.166424044     0.31042902     0.227398607
#> [245,]  1.268891239     0.25420897     0.143693549
#> [246,] -1.908168129     0.34843099    -0.034915255
#> [247,]  1.294960466     0.11455671     0.521662223
#> [248,]  0.894470405     0.20983056     0.320551915
#> [249,]  0.109289010     0.45920705     0.350899185
#> [250,]  0.674227954     0.51627551     0.224516735
#> [251,] -0.241313486     0.04970841     0.174955468
#> [252,] -0.619759342     0.39605349     0.217859436
#> [253,]  0.935351555     0.52053980     0.206165374
#> [254,]  0.265232881     0.13577118     0.486900904
#> [255,]  0.416089472     0.40944156     0.372140911
#> [256,] -0.952017617     0.75024834     0.212252901
#> [257,]  0.710205724     0.18619194     0.315016368
#> [258,]  1.234438870     0.11523531     0.668603323
#> [259,] -1.899861149     0.50375959     0.453196031
#> [260,]  0.222450841     0.64991661     0.362508974
#> [261,] -0.146099804     0.86122770     0.014230848
#> [262,]  0.257305765     0.40487436    -0.263399112
#> [263,] -0.293327952     0.47218487     0.632699585
#> [264,]  0.605883088     0.11605091     0.381873406
#> [265,]  0.293912862     0.45037670     0.362217040
#> [266,] -1.054949209     0.43634372     0.063604203
#> [267,] -0.976557720     0.24997897     0.391191617
#> [268,] -0.665200922     0.24268497     0.173262071
#> [269,]  1.059268774     0.40245220     0.346011757
#> [270,]  0.941457819     0.49691703    -0.075338205
#> [271,]  0.609777093     0.14227834     0.252883019
#> [272,] -2.284771516     0.69859644     0.092359641
#> [273,] -0.476049047     0.24050606     0.207255641
#> [274,] -1.081990951     0.34290912    -0.006158764
#> [275,] -1.308844291     0.52849947     0.712538362
#> [276,] -0.831740821     0.12343899     0.125638358
#> [277,]  3.031215977     0.43345266     0.482136038
#> [278,]  0.637611821     0.32664977    -0.077384736
#> [279,]  1.383266235     0.76367059     0.090369394
#> [280,]  0.191222202     0.19337347     0.230288886
#> [281,] -1.549881726     0.21442985     0.366328005
#> [282,] -1.260622168     0.19613661     0.341290221
#> [283,]  0.011609159     0.32296179     0.081013654
#> [284,]  1.462568429     0.27748132     0.479751083
#> [285,]  0.037835603     0.36155924     0.244384170
#> [286,] -1.128769934     0.41014938     0.241132690
#> [287,] -0.481452174     0.31553408     0.296133207
#> [288,]  0.650854281     0.53034404     0.150577807
#> [289,] -1.529604532     0.28480893     0.324019785
#> [290,] -0.761174237     0.76025029     0.217950504
#> [291,] -0.297728748     0.19822494     0.190738643
#> [292,]  1.494097702     0.56663843     0.006672565
#> [293,]  1.723505292     0.13431272     0.396356659
#> [294,] -0.623864900     0.16554578     0.458883338
#> [295,]  0.976408464     0.23554535     0.111856661
#> [296,]  0.465911156     0.34958736     0.249603375
#> [297,]  1.832798959     1.04956596     0.233558785
#> [298,]  1.495787224     0.99885893    -0.174694089
#> [299,]  1.902270247     0.23442297     0.130743449
#> [300,] -0.660334790     0.21823472     0.107900870
#> 
#> $acov_order
#> [1] 0
#> 
#> $acor_order
#> [1] 1
#> 
#> $N
#> [1] 300
#> 
#> $S
#> [1] 50
#>