Skip to contents

The `hpjkd()` function enables to implement the HPJ bias-corrected kernel density estimation 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

hpjkd(
  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::hpjkd(data = data)
#> $mean

#> 
#> $acov

#> 
#> $acor

#> 
#> $mean_func
#> function (x) 
#> {
#>     hpjkdest1(x = x, X = mean_est, X1 = mean_est1, X2 = mean_est2, 
#>         h = mean_bw)
#> }
#> <bytecode: 0x56308f3737b0>
#> <environment: 0x56308f36ca80>
#> 
#> $acov_func
#> function (x) 
#> {
#>     hpjkdest1(x = x, X = acov_est, X1 = acov_est1, X2 = acov_est2, 
#>         h = acov_bw)
#> }
#> <bytecode: 0x56308f373c48>
#> <environment: 0x56308f36ca80>
#> 
#> $acor_func
#> function (x) 
#> {
#>     hpjkdest1(x = x, X = acor_est, X1 = acor_est1, X2 = acor_est2, 
#>         h = acor_bw)
#> }
#> <bytecode: 0x56308f3740e0>
#> <environment: 0x56308f36ca80>
#> 
#> $bandwidth
#>            mean  autocovariance autocorrelation 
#>      0.35188660      0.04743256      0.06049790 
#> 
#> $quantity
#>                 mean autocovariance autocorrelation
#>   [1,]  0.3074430002     0.97750186     0.256812830
#>   [2,]  0.0533456348     0.64948428     0.197807877
#>   [3,]  0.8062331195     0.43211441     0.109427020
#>   [4,] -0.2544504667     0.23903232     0.170289222
#>   [5,]  0.5726174458     0.34382515     0.167531146
#>   [6,]  0.1090859528     0.11164407     0.684638750
#>   [7,] -0.1590057164     0.21049250     0.192979873
#>   [8,] -0.1723369166     0.32103255     0.235990239
#>   [9,]  1.0206140144     0.82995122    -0.032513916
#>  [10,]  1.1287166572     0.55885619     0.058836432
#>  [11,] -0.3565712928     0.20398919     0.183340677
#>  [12,] -0.8496453169     0.21923184     0.369147414
#>  [13,]  0.6313125247     0.27799606     0.278850546
#>  [14,]  0.7318918262     0.49126598     0.346986093
#>  [15,]  0.5247057164     0.51146202     0.186092194
#>  [16,]  0.0766111862     0.79880417     0.198060088
#>  [17,]  0.8367618777     0.27894740     0.305444564
#>  [18,] -1.2729165422     0.25117192     0.479592621
#>  [19,]  0.7235416340     0.25696211    -0.021087277
#>  [20,]  1.5474340173     0.44782890     0.238335908
#>  [21,]  0.6242044552     0.14531453     0.191674073
#>  [22,] -0.8130640186     0.25848885     0.374118271
#>  [23,] -0.0544813302     0.88713606     0.274205745
#>  [24,] -0.5842921275     0.51433724     0.386834659
#>  [25,]  2.2589804135     0.13377908     0.337327210
#>  [26,]  0.1201514918     0.43242092     0.138134324
#>  [27,]  1.4014437370     0.33003379     0.234633627
#>  [28,] -0.3943390047     0.26499135     0.387877875
#>  [29,]  0.9990498039     0.37160035     0.143137354
#>  [30,] -0.8745499432     0.19759903     0.157904216
#>  [31,]  1.1937654320     0.27232469     0.205532067
#>  [32,] -0.1666321669     0.54389213     0.265946692
#>  [33,]  1.7352777366     0.12367655     0.587098679
#>  [34,] -0.7627231636     0.55931370    -0.024485190
#>  [35,]  0.9554650018     0.55823287     0.302344094
#>  [36,]  0.7607335285     0.25422784    -0.125360768
#>  [37,] -0.4261756766     0.31238769    -0.060419772
#>  [38,] -0.9113866406     0.20246498     0.063793672
#>  [39,] -0.8533753611     0.55367292    -0.180109251
#>  [40,] -0.5871820169     0.22515031     0.424763286
#>  [41,] -1.4217002805     0.26762822     0.523403470
#>  [42,]  0.4937276008     0.10606949     0.304905220
#>  [43,] -2.2356116683     0.29602908     0.241607934
#>  [44,] -1.5103604193     0.13644817     0.384555617
#>  [45,]  1.4228928129     0.32327485     0.182015647
#>  [46,] -0.0690924250     0.19296885     0.500164888
#>  [47,]  0.4899857571     0.14207281     0.225713183
#>  [48,] -1.3190968135     0.08307067     0.486067045
#>  [49,] -0.5783468796     0.12471992     0.713105666
#>  [50,]  0.1579815451     0.34666748     0.403297705
#>  [51,]  0.0949679624     0.13077395     0.628496032
#>  [52,] -0.6849158758     0.17589074     0.266295313
#>  [53,] -1.4034105318     0.04851174     0.688531654
#>  [54,] -1.0581470533     0.83159753    -0.099013269
#>  [55,] -1.0143078195     0.34028589     0.293594734
#>  [56,] -0.2385326079     0.96198859     0.005302933
#>  [57,]  0.3809045310     0.36731436     0.363421418
#>  [58,] -0.6261248748     0.26468570     0.295774940
#>  [59,] -0.3956367251     0.25300413    -0.015733914
#>  [60,] -1.0190775017     0.17786404     0.356947961
#>  [61,] -0.8423295418     0.21899738     0.342450852
#>  [62,] -0.3832679832     0.75863490     0.037839256
#>  [63,]  0.1616352851     0.10102832     0.614274281
#>  [64,]  0.2457788108     0.04786332     0.503365932
#>  [65,]  0.6099898300     0.68269813     0.553543068
#>  [66,] -0.2707039348     0.18161552     0.356903022
#>  [67,]  1.5199220599     0.35554010    -0.030497117
#>  [68,]  2.1182417714     0.72425879    -0.077461590
#>  [69,]  1.4209234354     0.33365112    -0.027915224
#>  [70,]  0.4699223550     0.51805365     0.001515935
#>  [71,] -0.3847144149     0.46182735     0.116003098
#>  [72,] -1.5779338372     0.18464730     0.149526493
#>  [73,] -0.0608929739     0.31352556     0.288447007
#>  [74,]  2.3425146068     0.36950962     0.268643994
#>  [75,] -0.1683907866     0.30460644     0.413881080
#>  [76,]  0.6546313793     0.31077314     0.630557309
#>  [77,] -0.3356454401     0.91529476     0.412793828
#>  [78,] -1.3515438505     0.43695961     0.226573695
#>  [79,] -0.5686966271     0.24439968     0.468145416
#>  [80,] -0.8143773533     0.52906697     0.515473977
#>  [81,] -1.0721629958     0.33101014    -0.102026726
#>  [82,]  0.7617833801     0.44697090     0.412568060
#>  [83,]  1.2854277237     0.82616008     0.125949977
#>  [84,] -0.5833040909     0.37462439     0.303648365
#>  [85,]  0.9519333452     0.61976712    -0.013614180
#>  [86,]  1.0230910413     0.30775463     0.383101827
#>  [87,] -0.2314836138     0.62851073     0.159782275
#>  [88,]  0.1091454068     0.16532997     0.091322647
#>  [89,]  0.7708907810     0.72494876     0.296841574
#>  [90,] -3.2397869757     0.17896226     0.483195884
#>  [91,] -1.0777860285     0.31357195     0.173441707
#>  [92,]  0.0032962878     0.25196709     0.338475793
#>  [93,] -1.2352561452     1.34743319     0.246509769
#>  [94,]  1.0230518403     0.23208515     0.141193833
#>  [95,]  0.0228901911     0.23938822     0.453751889
#>  [96,]  2.2746140598     0.02218516     0.319877457
#>  [97,]  0.0007465796     0.86253459     0.134164914
#>  [98,] -2.4765824942     0.56126008     0.228844798
#>  [99,] -0.3496930256     0.44241083     0.272661417
#> [100,] -0.2086390842     0.34465269     0.126177958
#> [101,] -1.8968082355     0.19456150     0.255718630
#> [102,] -0.9689367428     0.17235529     0.329006638
#> [103,]  1.3600019963     0.56653348    -0.005882379
#> [104,] -0.2335016462     0.18999215     0.215456138
#> [105,] -1.5933167684     0.13010242     0.382686535
#> [106,]  0.6514731807     0.75709772     0.104800586
#> [107,]  1.1883574392     0.20886816     0.444465045
#> [108,] -0.7236442884     0.12176633     0.057846640
#> [109,]  1.3580330228     0.31178516     0.147221211
#> [110,] -0.7340553889     0.57011302    -0.029563632
#> [111,] -1.5340491092     0.18529721     0.404481474
#> [112,]  0.0414520879     0.42031549     0.554360089
#> [113,]  0.6721410485     0.10777906     0.405834248
#> [114,] -0.4924442510     0.58080604     0.205342273
#> [115,]  0.8253774331     0.32731241    -0.116528047
#> [116,]  0.3038208534     0.24044449     0.345339645
#> [117,] -2.5841277856     0.44765956    -0.024181327
#> [118,]  1.2541806678     0.14319031     0.481659593
#> [119,] -0.6696377475     0.18234321     0.366472428
#> [120,]  0.0910105339     0.31719738     0.066098724
#> [121,] -1.6115097379     0.82985497     0.252225753
#> [122,] -0.0626028180     0.06304446     0.623891112
#> [123,]  0.0675283541     0.27821123     0.484391117
#> [124,]  1.0942086072     0.40434205    -0.101680188
#> [125,]  1.0670132430     0.86913550     0.045274085
#> [126,] -1.1340497503     0.41307306    -0.082224055
#> [127,] -1.4892791611     0.08134587     0.526841204
#> [128,] -0.9116419086     0.23511736     0.325749228
#> [129,] -1.1159224502     0.18767489     0.596084411
#> [130,]  0.8173862656     0.13164140     0.618889908
#> [131,] -0.6760369612     0.27673266     0.610239554
#> [132,] -0.7907120352     0.18409086     0.438514881
#> [133,]  0.2600868794     0.27297684     0.488269520
#> [134,] -0.3918177335     0.28634598    -0.028700559
#> [135,]  1.7621996309     0.29551151     0.314839965
#> [136,] -0.0464052570     0.28518395     0.108297790
#> [137,]  0.8553671262     0.51942701     0.333244661
#> [138,] -0.2088993077     0.74123576     0.279392077
#> [139,] -1.2677771070     0.72957389     0.249609170
#> [140,]  0.5699595004     0.04815978     0.910716624
#> [141,] -0.5857138672     0.08232698     0.739426337
#> [142,] -0.3146485840     0.54732052     0.207168354
#> [143,]  0.7546034734     0.24867814     0.210642775
#> [144,]  0.9454199026     0.54838272     0.335397079
#> [145,]  0.3725431177     0.24258071     0.122150571
#> [146,] -0.8994443872     0.23962023     0.334705689
#> [147,]  0.3558364713     0.84964575     0.213343341
#> [148,]  0.8363468166     0.35329062     0.208132658
#> [149,] -0.4424057789     0.62073884     0.348501924
#> [150,] -0.2843623850     0.36244642     0.348453494
#> [151,]  1.2092459634     1.17097892     0.194361852
#> [152,]  0.8163174205     1.02424835     0.232595515
#> [153,]  0.3456844324     0.31359497     0.192249405
#> [154,]  0.3194779686     0.14808596     0.590613677
#> [155,] -0.5920358504     0.56765724     0.336853334
#> [156,]  0.0170691743     0.31302983     0.160617295
#> [157,] -0.4804170348     0.61343753     0.331092083
#> [158,]  0.2247752948     0.44226199    -0.139639548
#> [159,]  1.6723405544     0.38788904     0.225591450
#> [160,]  0.3600933726     0.33624462     0.011288588
#> [161,]  0.4665956136     0.33866252     0.263920948
#> [162,] -3.2753340580     0.25435424     0.338794998
#> [163,] -1.2398015585     0.12237455     0.461309362
#> [164,] -1.4761326669     0.18848718     0.357601915
#> [165,]  1.3111756350     0.48117411     0.093786573
#> [166,] -0.5558518942     0.29000167    -0.070058923
#> [167,]  1.4864924647     0.12720438     0.767042304
#> [168,] -1.4344456849     0.56960809    -0.075607071
#> [169,] -0.2501331846     0.25977317     0.126827234
#> [170,] -0.1645885484     0.11908856     0.060638232
#> [171,] -0.5172998970     0.51917008     0.187929319
#> [172,]  0.5892643425     0.04611229     0.356507523
#> [173,]  2.1455280330     0.13092608     0.310709877
#> [174,]  1.8884518503     0.53155930     0.191089043
#> [175,]  1.1182814986     0.21314889     0.365838452
#> [176,]  0.2787110870     0.07096616     0.541197387
#> [177,] -1.0994094125     0.19758996     0.293010200
#> [178,] -1.6313025034     0.08207880     0.536321581
#> [179,] -0.8211320706     0.12006529     0.360944531
#> [180,]  0.3479986954     0.49269177     0.041198550
#> [181,]  1.2523727591     0.16625460     0.584692171
#> [182,] -0.0766080730     0.48084560     0.307598205
#> [183,] -0.6409676389     0.30001661    -0.081752457
#> [184,]  0.8133809699     0.13886050     0.252955287
#> [185,] -0.3075225394     0.36247371     0.248151145
#> [186,] -1.7217618264     0.40656999     0.029773820
#> [187,] -0.1789421848     0.07731931     0.286458332
#> [188,]  0.2841819644     0.18642158     0.234928397
#> [189,] -1.1695022218     0.31215621     0.424490535
#> [190,] -0.0011826699     0.07255745     0.418520301
#> [191,] -0.6302887201     0.31304594     0.169546976
#> [192,] -0.0870174920     0.35080835     0.035830213
#> [193,] -0.4048445711     0.50512641     0.215103359
#> [194,] -0.1610451573     0.24471463     0.147630260
#> [195,] -0.6452196089     0.22972255     0.290358390
#> [196,]  0.5169971349     0.33814087     0.140534804
#> [197,] -0.3306613880     0.19145458     0.254305261
#> [198,] -0.0622626963     0.69155112    -0.023119092
#> [199,] -0.6379391675     0.43544766     0.368319239
#> [200,] -1.0826486103     0.26287194    -0.023258321
#> [201,] -0.2487217066     0.65755045     0.231184488
#> [202,]  0.5473222592     0.26831797     0.009596384
#> [203,]  0.7453116967     0.26703108     0.195692836
#> [204,] -0.6253387909     0.32950045     0.101371303
#> [205,] -1.0362005303     0.46868943     0.138681967
#> [206,]  0.6586150970     0.43958655     0.007655410
#> [207,]  0.7959228303     0.31717276     0.395350525
#> [208,]  1.6434007427     0.34568117     0.234346213
#> [209,]  0.6255751170     0.22353730     0.615253319
#> [210,]  0.6114187019     0.20742222     0.682818866
#> [211,] -0.1024883447     0.15051580     0.507568294
#> [212,]  1.4394331161     0.42526427     0.284570423
#> [213,]  1.1983758816     0.19020393     0.249146389
#> [214,] -0.1907465985     0.37084544    -0.038231563
#> [215,] -0.5032262955     0.62278066     0.342649491
#> [216,] -2.6969293770     0.26819563     0.146549016
#> [217,]  1.8104527144     0.25326080     0.287366879
#> [218,]  1.6703918451     1.03763451    -0.046424653
#> [219,] -0.5702798377     0.19638354     0.228140361
#> [220,]  0.7779889997     0.24451157     0.166219988
#> [221,]  1.3872003987     0.37973270     0.191751886
#> [222,]  0.8163835201     0.07603432     0.478449234
#> [223,] -0.9409657612     0.28266323     0.221742959
#> [224,] -0.0647316373     0.35754916     0.207768268
#> [225,] -0.3505672863     0.18107349     0.286350934
#> [226,] -0.9354311963     0.41741584     0.366676999
#> [227,]  1.2663397065     0.18454552     0.103445869
#> [228,] -1.4728959950     0.45136835     0.034659565
#> [229,] -0.1801408012     0.23160709     0.441447571
#> [230,]  0.1561403120     0.10001402     0.492544837
#> [231,]  1.3561554940     0.64854054     0.088979188
#> [232,] -0.1764641222     0.39092961     0.285989330
#> [233,] -1.3605403690     0.17682347     0.021211462
#> [234,]  1.4200502799     0.23271904     0.047900876
#> [235,]  0.8529917375     0.06672689     0.172468141
#> [236,] -0.3737216094     0.51910587     0.058935371
#> [237,]  0.0322176021     0.32036291     0.600102579
#> [238,] -0.0759001932     0.37143125     0.454102923
#> [239,] -0.4693656011     0.21684451     0.568063088
#> [240,] -1.7176553681     0.49078902     0.051194871
#> [241,] -0.5210840328     0.27985630     0.287454046
#> [242,] -1.4540286990     0.65181122     0.041204715
#> [243,] -0.9518901570     0.35332707    -0.252113779
#> [244,]  0.3569849994     0.20744435     0.380248194
#> [245,]  1.1134897186     0.32405837     0.144827222
#> [246,]  0.0799940396     0.25693325    -0.148352593
#> [247,]  0.7423700333     0.24404960     0.444629195
#> [248,] -1.1829665778     1.34049084     0.225709632
#> [249,]  1.4683414572     0.23164106     0.247968788
#> [250,]  0.2943667451     0.26895035     0.252040813
#> [251,]  1.6066436774     0.40404506     0.074752698
#> [252,]  0.4640094952     0.21848066     0.338679376
#> [253,] -0.9436282976     0.11050544     0.432172883
#> [254,]  0.3768179691     0.25122746     0.105231476
#> [255,] -0.5346680753     0.31603772     0.388428847
#> [256,]  0.5527331093     0.29329480     0.181857242
#> [257,]  0.2793564390     0.28720013     0.097920445
#> [258,]  0.4120738935     0.52794713     0.113084864
#> [259,]  0.7478514896     0.67179003     0.220681833
#> [260,] -1.5520459357     0.44378777     0.050302754
#> [261,]  1.4427099670     0.24356039     0.587817160
#> [262,]  0.4025201636     0.21519814     0.227411173
#> [263,]  0.6401497607     0.24727673    -0.021334418
#> [264,] -0.5308023865     0.19428075     0.217303063
#> [265,] -0.1661862686     0.58337837     0.032218116
#> [266,]  0.0220617441     0.21248678     0.192051393
#> [267,]  1.0256908664     0.14892459     0.016270408
#> [268,]  0.2875451671     0.48897923     0.316612604
#> [269,]  1.1153589073     0.57102157     0.320260635
#> [270,] -0.3622868688     0.12106230     0.204965269
#> [271,]  0.1118680379     0.46380837     0.425392068
#> [272,] -0.7545479162     0.12726370     0.424971085
#> [273,] -1.3103518276     0.10494566     0.435273886
#> [274,] -1.3044668247     0.36962298     0.242979893
#> [275,]  0.6313667840     0.17060501     0.429813231
#> [276,]  1.0401643422     0.26234818    -0.003654278
#> [277,] -1.4897359332     0.14989346     0.517534735
#> [278,] -1.0305133185     0.25957672     0.362381942
#> [279,]  1.4534044724     0.25626305     0.234494461
#> [280,]  1.1580736568     0.11442053     0.532737535
#> [281,]  2.1061476590     0.28743647     0.005890792
#> [282,]  1.4441677793     0.22550449    -0.044609475
#> [283,]  0.2011323695     1.01410315     0.482675015
#> [284,] -0.0953409751     0.38786520     0.272705532
#> [285,] -0.4845106827     0.28325990     0.542507347
#> [286,] -1.8464074295     0.33581636     0.152589330
#> [287,]  0.3804989713     0.36887163    -0.084099771
#> [288,]  0.7965794476     0.18084318     0.466311682
#> [289,] -0.3198128999     0.35439947     0.264553639
#> [290,] -0.2728269390     0.14486137     0.272987109
#> [291,]  0.4606518702     0.18340787     0.474522983
#> [292,]  0.1114497671     0.17660220     0.456113001
#> [293,]  0.1038869676     0.16616631     0.251193194
#> [294,]  0.9383405931     0.42851143     0.351798243
#> [295,] -0.9087168995     0.18303602     0.365228080
#> [296,] -0.4071856786     0.62730445    -0.013712092
#> [297,]  0.0605160440     0.23391917     0.409237029
#> [298,]  1.2322791531     0.25568885     0.111185892
#> [299,]  0.3106853729     0.79729670     0.302857039
#> [300,]  0.3141422211     0.41195950     0.206144215
#> 
#> $acov_order
#> [1] 0
#> 
#> $acor_order
#> [1] 1
#> 
#> $N
#> [1] 300
#> 
#> $S
#> [1] 50
#>