Skip to contents

The `tojkd()` function enables to implement the TOJ 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

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

#> 
#> $acov

#> 
#> $acor

#> 
#> $mean_func
#> function (x) 
#> {
#>     tojkdest2(x = x, X = mean_est, X21 = mean_est21, X22 = mean_est22, 
#>         X31 = mean_est31, X32 = mean_est32, X33 = mean_est33, 
#>         X34 = mean_est34, X35 = mean_est35, X36 = mean_est36, 
#>         X37 = mean_est37, X38 = mean_est38, X39 = mean_est39, 
#>         h = mean_bw)
#> }
#> <bytecode: 0x5630973d06e8>
#> <environment: 0x5630983ad300>
#> 
#> $acov_func
#> function (x) 
#> {
#>     tojkdest2(x = x, X = acov_est, X21 = acov_est21, X22 = acov_est22, 
#>         X31 = acov_est31, X32 = acov_est32, X33 = acov_est33, 
#>         X34 = acov_est34, X35 = acov_est35, X36 = acov_est36, 
#>         X37 = acov_est37, X38 = acov_est38, X39 = acov_est39, 
#>         h = acov_bw)
#> }
#> <bytecode: 0x5630973d1750>
#> <environment: 0x5630983ad300>
#> 
#> $acor_func
#> function (x) 
#> {
#>     tojkdest2(x = x, X = acor_est, X21 = acor_est21, X22 = acor_est22, 
#>         X31 = acor_est31, X32 = acor_est32, X33 = acor_est33, 
#>         X34 = acor_est34, X35 = acor_est35, X36 = acor_est36, 
#>         X37 = acor_est37, X38 = acor_est38, X39 = acor_est39, 
#>         h = acor_bw)
#> }
#> <bytecode: 0x5630973ce678>
#> <environment: 0x5630983ad300>
#> 
#> $bandwidth
#>            mean  autocovariance autocorrelation 
#>      0.35466670      0.04619656      0.07022076 
#> 
#> $quantity
#>               mean autocovariance autocorrelation
#>   [1,]  0.77967245     0.39281602     0.304169077
#>   [2,]  0.31505700     0.49352789     0.125429191
#>   [3,] -0.27732824     0.22615213     0.263426844
#>   [4,]  0.53940856     0.87941379     0.415071001
#>   [5,] -0.65772344     0.55620304    -0.080413971
#>   [6,]  0.67651984     0.61765960     0.367801410
#>   [7,] -1.00039011     0.22114647    -0.008778793
#>   [8,]  0.74444858     0.93979632     0.239165642
#>   [9,]  0.11832446     0.22779751     0.047413292
#>  [10,] -0.15944346     0.20213859     0.571993477
#>  [11,]  0.12059125     0.45724089     0.308292169
#>  [12,]  0.59143307     0.44110810     0.339254667
#>  [13,] -1.45131937     0.53509907     0.174044381
#>  [14,] -0.60664229     0.70067277     0.071584376
#>  [15,]  0.18157139     0.43934298    -0.196019184
#>  [16,] -1.15536104     0.27046576     0.230026000
#>  [17,]  1.77458706     0.28180918     0.196451771
#>  [18,] -0.25175488     0.70005954     0.057172453
#>  [19,] -1.30439121     0.38674725     0.133006940
#>  [20,]  0.49728507     0.41179805     0.295971129
#>  [21,]  1.31736428     0.08879579     0.642774534
#>  [22,]  0.28949646     0.37003698     0.360164002
#>  [23,]  1.24297542     0.23964482     0.361069219
#>  [24,] -0.71498015     0.23310581     0.522525165
#>  [25,] -0.19491272     0.18490762     0.440613678
#>  [26,] -1.24187574     0.24275813     0.413850520
#>  [27,] -0.02867669     0.16210680     0.334868849
#>  [28,]  1.15766856     0.17614707     0.224297105
#>  [29,]  1.49086802     0.35598957     0.306587803
#>  [30,]  0.25163613     0.17262657     0.227672181
#>  [31,]  0.96071338     0.21864608    -0.153854442
#>  [32,] -1.01640151     0.28791452     0.205250402
#>  [33,]  0.31688011     0.31668241     0.132828100
#>  [34,] -0.78575209     0.18187432     0.138837893
#>  [35,] -0.74031309     0.16911505     0.134440028
#>  [36,] -0.06591595     0.36471906     0.275446923
#>  [37,] -1.43676491     0.18648415     0.667856193
#>  [38,]  0.10479563     0.45920700    -0.184056464
#>  [39,]  1.00462512     0.34100639     0.325169854
#>  [40,] -1.05840075     0.38236895     0.439602030
#>  [41,]  0.46987633     0.21250336     0.242585296
#>  [42,]  0.96751224     0.34470290     0.550645135
#>  [43,]  0.14749837     0.10763299     0.717466527
#>  [44,] -0.86869603     0.51415513     0.043809766
#>  [45,] -1.52783933     0.22624839    -0.064210507
#>  [46,] -0.11379511     0.34260649     0.302661174
#>  [47,] -0.97399636     0.41241022     0.042737337
#>  [48,]  0.47481231     0.28647384     0.366870470
#>  [49,] -1.14230420     0.16800304     0.758128492
#>  [50,] -0.99687897     0.20557489     0.301567500
#>  [51,]  0.34132598     0.27785481     0.374029335
#>  [52,]  0.08091590     0.74612911     0.141821557
#>  [53,]  2.25246158     0.42710263    -0.016377051
#>  [54,] -0.22373802     0.27696865     0.210313176
#>  [55,]  0.06698620     0.49579983     0.452224146
#>  [56,]  1.42181148     0.54517760     0.332460922
#>  [57,] -0.30690876     0.26390541     0.307381157
#>  [58,]  1.05487990     0.07787342    -0.021879786
#>  [59,]  0.28745261     0.50535192     0.177694816
#>  [60,] -1.01311351     0.14628079     0.416661466
#>  [61,] -0.32760683     0.24781664     0.275911347
#>  [62,] -0.27601498     0.05791999     0.390153307
#>  [63,]  0.15184675     0.38693668     0.007822189
#>  [64,]  0.24508391     0.34342433     0.424451097
#>  [65,] -1.32707974     0.25955400     0.140445859
#>  [66,] -0.81937256     0.40169026     0.088759514
#>  [67,] -1.12262618     0.16224668     0.296372140
#>  [68,]  1.55118006     0.12964186     0.443448681
#>  [69,]  1.44668793     0.35334846     0.255145595
#>  [70,]  0.03280341     0.27289684     0.513433060
#>  [71,] -1.17097160     0.59434252     0.134897314
#>  [72,] -1.58380152     0.09663832     0.388758973
#>  [73,] -0.32105726     0.29313201     0.126236684
#>  [74,] -1.07824709     0.43064490    -0.245108662
#>  [75,]  1.33758245     0.35964137     0.307612320
#>  [76,]  1.52729523     0.26367705     0.408815705
#>  [77,]  1.60799094     0.74206132     0.144631614
#>  [78,]  1.51343491     0.21790512     0.185774680
#>  [79,] -0.44768618     0.37653850     0.142054402
#>  [80,] -2.33417447     0.29039620     0.134421386
#>  [81,] -0.30940666     0.20468021     0.516662305
#>  [82,]  0.69851221     0.47121763     0.101907324
#>  [83,] -0.72722735     0.39491159    -0.085598413
#>  [84,]  1.00435914     0.22548645    -0.035852726
#>  [85,] -0.52304252     0.28959159     0.118448311
#>  [86,]  2.21674237     0.64915682     0.014155355
#>  [87,]  0.89766877     0.23364429     0.108175166
#>  [88,]  0.13283372     0.46631624     0.129253284
#>  [89,]  0.66779130     0.28120328     0.553435338
#>  [90,]  0.97452032     0.41234797     0.172688294
#>  [91,] -2.15683435     0.58863529     0.056035600
#>  [92,]  0.69381298     0.24115889     0.264257406
#>  [93,] -0.87687271     0.27820595     0.073229411
#>  [94,] -0.42931844     0.29079429     0.249513322
#>  [95,] -0.53508279     0.35469916     0.224989352
#>  [96,]  0.29860785     0.14358559     0.111543778
#>  [97,]  0.54243712     0.36441012     0.191005455
#>  [98,] -2.72887841     0.26858157     0.216732854
#>  [99,]  1.08011783     0.38965040     0.391703027
#> [100,] -0.57746968     0.34767637     0.286586166
#> [101,]  0.08294231     0.09094625    -0.123757070
#> [102,] -1.05236318     0.76907238     0.025225893
#> [103,]  0.68256737     0.67323711     0.178175403
#> [104,] -0.62389562     0.21747720     0.265163886
#> [105,]  0.70127047     0.21851001     0.128230989
#> [106,] -1.37142210     0.22176475     0.440236175
#> [107,]  0.71054647     0.15667375     0.362164251
#> [108,]  1.16942663     0.07788642     0.253527458
#> [109,] -0.10207761     0.20885346     0.229567118
#> [110,] -0.04390427     0.53814083     0.094501111
#> [111,] -0.69267811     0.06948468     0.554963258
#> [112,]  0.98360019     0.19748323     0.394748350
#> [113,] -0.22303418     0.55090029     0.589047317
#> [114,] -1.57043242     0.38500196    -0.238045587
#> [115,]  1.35098816     0.32752078     0.068463271
#> [116,] -0.02539275     0.12115774     0.530584747
#> [117,]  0.21278518     0.10305960     0.567696644
#> [118,] -0.31938025     0.36038404     0.360215292
#> [119,] -1.21927279     0.24868372    -0.005239527
#> [120,] -0.37759096     0.14206383     0.332808821
#> [121,]  1.10402424     0.38337800     0.160917953
#> [122,]  0.19605560     0.11123304     0.570725218
#> [123,]  0.62333755     0.19146314    -0.149548538
#> [124,]  0.50732952     0.18095186     0.157206910
#> [125,] -1.71131494     0.33209516     0.126876363
#> [126,]  0.92197211     0.28200948     0.166423170
#> [127,]  0.77963723     0.68882606     0.035745626
#> [128,]  0.57058495     0.67281613     0.413693436
#> [129,]  1.21090936     0.24594250     0.168834821
#> [130,]  0.04613922     0.09109463     0.695474911
#> [131,]  1.23365956     0.30205255     0.439552665
#> [132,]  0.11897745     0.58760328    -0.177390634
#> [133,] -0.43548429     0.44943960    -0.006073062
#> [134,]  0.60469375     0.31156938    -0.079150561
#> [135,] -1.58919786     0.36777309     0.436894413
#> [136,] -0.30122244     0.30234602    -0.093896289
#> [137,]  0.88387163     0.33016716     0.169376992
#> [138,] -1.22611795     0.95655284    -0.133605353
#> [139,] -0.02912155     0.13676102     0.440147139
#> [140,]  0.76286627     0.19004921     0.397371495
#> [141,]  0.25023016     0.22128326     0.074826072
#> [142,] -1.40262781     0.12142257     0.449915736
#> [143,] -2.62723656     0.27475961     0.292642818
#> [144,]  0.50886253     0.34123051     0.524775422
#> [145,] -2.07058199     0.28782849     0.650883851
#> [146,] -0.75646104     0.17678334     0.894589404
#> [147,]  0.39472855     0.27123932    -0.092011538
#> [148,]  0.29730561     0.16082612     0.203021484
#> [149,] -2.12717753     0.30340655     0.235298439
#> [150,] -0.50307434     0.30115584     0.418692906
#> [151,] -1.35770820     0.82527480    -0.468715190
#> [152,] -1.87822249     0.32160006     0.042565496
#> [153,] -1.38676451     0.21771502     0.524124604
#> [154,]  0.01649640     0.41352389     0.487734671
#> [155,]  0.39872161     0.14166851     0.560506703
#> [156,] -0.88171485     0.23398800     0.359259644
#> [157,] -1.20466649     0.12276906     0.201846191
#> [158,]  0.25589328     0.33173210     0.363345760
#> [159,] -1.68092360     0.31581427     0.060632294
#> [160,] -0.63121693     0.16375381     0.465567623
#> [161,] -0.18428320     0.44438814     0.111545254
#> [162,] -0.32979996     0.36817926     0.133183750
#> [163,]  0.24769434     0.09086193     0.251639559
#> [164,] -1.30386118     0.15139863     0.083583607
#> [165,]  0.46139146     0.27364349     0.721080173
#> [166,]  2.33528841     0.24820841    -0.262788213
#> [167,]  0.28740174     0.22711781     0.290816937
#> [168,] -0.75531577     0.15543242     0.274226070
#> [169,] -1.25496255     0.24507650     0.312140637
#> [170,] -1.54781818     0.24562091     0.415022368
#> [171,] -0.65906233     0.12167925     0.295567199
#> [172,]  0.25230801     0.20246336     0.674416737
#> [173,]  0.12664478     0.27359925     0.419821047
#> [174,]  0.01707104     0.31200314     0.175395320
#> [175,] -2.07134174     0.34990519    -0.040459190
#> [176,] -1.27654308     0.52414904     0.087200131
#> [177,]  0.00945767     0.23118181     0.257631452
#> [178,] -0.45530368     0.08227432     0.774793489
#> [179,]  0.03079507     0.12452300     0.394952888
#> [180,]  0.59047212     0.17073490     0.094422460
#> [181,] -0.56649187     0.21462285     0.314697419
#> [182,]  0.65501424     0.77641534     0.006670576
#> [183,]  1.22071059     0.79294758     0.190583452
#> [184,]  0.26107090     0.29414531     0.237803564
#> [185,]  0.85464379     0.13477271     0.188866637
#> [186,] -0.28688324     0.66928660    -0.049674175
#> [187,] -1.21504293     0.46690342     0.244072081
#> [188,]  0.01291758     0.25820238     0.451295281
#> [189,]  0.43519887     0.23690951     0.471268921
#> [190,]  1.16713930     0.18263649     0.490783723
#> [191,] -0.06417340     0.80968775     0.059980690
#> [192,]  0.24804341     0.60033059     0.299356934
#> [193,]  0.45909426     0.18763022     0.409367246
#> [194,] -0.95612919     0.36923198     0.348217624
#> [195,] -1.52471436     0.14007852     0.082835042
#> [196,]  1.17606183     0.16062507     0.248818035
#> [197,] -0.25978085     0.13377409     0.266974474
#> [198,] -0.29659043     0.65438630     0.341426170
#> [199,] -0.33415865     0.09274085     0.338104496
#> [200,]  0.58829055     0.26878378     0.048395875
#> [201,]  0.67941279     0.39736045     0.144802066
#> [202,] -0.01297179     0.37532905     0.247389270
#> [203,] -0.66804546     0.25998336     0.381936087
#> [204,]  1.14018013     0.19585373     0.258768722
#> [205,] -0.86439445     0.25260827     0.247379176
#> [206,] -0.43784842     0.06253396     0.633469903
#> [207,]  0.15966657     0.39170731     0.184183709
#> [208,] -0.95374086     0.38647945     0.474495866
#> [209,] -0.40726550     0.39226853    -0.040760856
#> [210,]  0.88373138     0.16006684     0.260657280
#> [211,]  0.43008003     0.83866148     0.165657872
#> [212,]  1.49568548     1.10985650     0.352002528
#> [213,]  0.52500849     0.32656953     0.277227428
#> [214,]  0.66538981     1.02318781     0.276363629
#> [215,] -0.22996479     0.43835950     0.309526272
#> [216,]  0.52601463     0.15011111     0.317027471
#> [217,]  1.49587470     0.26613786     0.277571678
#> [218,] -2.24339918     0.81998347    -0.099662859
#> [219,] -1.25176269     0.29673739     0.605531973
#> [220,]  1.27551853     0.17794100     0.373352773
#> [221,] -1.34673182     0.13055983     0.242147795
#> [222,]  0.16300918     0.36248728     0.175541822
#> [223,]  1.38034729     0.46155912     0.184560629
#> [224,]  0.29134132     0.31819805     0.435579100
#> [225,]  1.25897818     0.43555276     0.269076385
#> [226,]  0.75564474     0.24609597    -0.133693260
#> [227,]  0.26307942     0.14672264     0.436541746
#> [228,] -0.07499641     0.51251736    -0.102620690
#> [229,]  1.22438189     0.20933935     0.048041004
#> [230,]  0.70398334     0.31055177     0.046129764
#> [231,]  1.38264932     0.23936916     0.095225048
#> [232,]  0.75108599     0.54185011     0.361410687
#> [233,]  1.34655062     0.32392269     0.203919480
#> [234,]  0.96244395     0.42519588     0.516456775
#> [235,]  2.12693076     0.30232925     0.335663505
#> [236,]  0.37586014     0.08146036     0.356307047
#> [237,] -1.56423838     0.13836547     0.330474257
#> [238,] -0.07609463     0.10229750     0.178222480
#> [239,]  0.06232657     0.89113834    -0.135592038
#> [240,]  0.47230349     0.18122699     0.777611201
#> [241,] -1.67809417     0.45831799     0.139526772
#> [242,]  0.72787766     0.13182932     0.455323906
#> [243,] -1.28440233     0.31916359     0.233913665
#> [244,] -0.04973289     0.34071389     0.298632471
#> [245,]  1.76723682     0.53339458     0.164401597
#> [246,]  2.25082400     0.37319739     0.398980801
#> [247,]  0.87882170     0.52661764     0.320553863
#> [248,]  0.77883048     0.57322313     0.062857761
#> [249,] -0.65321235     0.13068901     0.656904120
#> [250,] -0.33180980     0.61843515     0.357545236
#> [251,] -0.48990989     0.26184615     0.148044458
#> [252,] -1.42209856     0.62696619    -0.017805177
#> [253,] -0.14182456     0.15337389     0.429488380
#> [254,]  1.21696274     0.30366440     0.081050452
#> [255,] -0.60130636     0.16295975     0.448878314
#> [256,] -0.40478163     0.37531565     0.219195320
#> [257,]  0.91325321     0.62883121     0.137741156
#> [258,]  0.56733512     0.60748996     0.119706834
#> [259,]  0.10429441     0.33948978     0.203975737
#> [260,]  0.62023056     0.33170154     0.511812173
#> [261,]  0.53887478     0.24281395     0.291728120
#> [262,] -1.14069446     0.41036929    -0.052302458
#> [263,]  2.05123020     0.18345656     0.123086879
#> [264,]  0.39240460     0.33511909     0.297704610
#> [265,]  0.45869503     0.57139217     0.078250809
#> [266,]  0.74553466     0.17747201     0.445038139
#> [267,]  1.28842853     0.61219226    -0.097788559
#> [268,] -0.85046594     0.25220384     0.345783424
#> [269,] -0.20907466     0.19837674    -0.134380858
#> [270,] -1.87300302     0.98460874     0.270765907
#> [271,]  1.63385189     0.37779883    -0.018263405
#> [272,]  1.61594307     0.22623019     0.307828221
#> [273,] -0.47516312     0.08416657     0.575159143
#> [274,]  1.51894451     0.28813163     0.299394730
#> [275,] -0.60651066     0.39428725     0.511104235
#> [276,] -1.14502390     0.19731393     0.357987365
#> [277,] -0.25807112     0.09466320     0.189493861
#> [278,] -2.73673159     0.79238983     0.455198013
#> [279,]  0.39451831     0.27490163     0.199841302
#> [280,] -0.79756192     0.43248777     0.411490638
#> [281,]  0.37808870     0.29793886     0.433846406
#> [282,]  1.72944908     0.61061613     0.431349149
#> [283,] -0.79396458     0.43432488     0.147714932
#> [284,]  1.49780045     0.12477441     0.520269536
#> [285,]  1.30040224     0.21321929     0.155314893
#> [286,] -0.59941016     0.28245364     0.309497153
#> [287,]  0.31218706     0.53517615     0.178747018
#> [288,]  2.35604343     0.28560436     0.243456405
#> [289,] -1.12169759     0.15090241     0.360703068
#> [290,] -0.24456074     0.33919715     0.148579782
#> [291,] -0.49556018     0.05988239     0.623218309
#> [292,] -1.37655088     0.59433842     0.478220203
#> [293,]  1.35503563     0.17209277     0.229243187
#> [294,] -0.46454427     0.18703372     0.547658606
#> [295,]  1.54653701     0.11380325     0.381301581
#> [296,]  0.77652434     0.58193163     0.149175393
#> [297,] -0.93358387     0.62052288     0.216529925
#> [298,]  0.19787158     0.92092823     0.093712609
#> [299,] -2.03904916     0.18789009     0.273281436
#> [300,]  0.87525786     0.57788956     0.018524472
#> 
#> $acov_order
#> [1] 0
#> 
#> $acor_order
#> [1] 1
#> 
#> $N
#> [1] 300
#> 
#> $S
#> [1] 50
#>