This function performs empirical Bayes estimation on the provided (log) likelihood matrix, incorporating an optional Dirichlet prior penalty.

fash_eb_est(L_matrix, penalty = 1, grid)

Arguments

L_matrix

A numeric matrix representing the log-likelihood values. Rows correspond to datasets, and columns correspond to grid points.

penalty

A numeric value representing the lambda value for the Dirichlet prior.

grid

A numeric vector representing the grid of PSD (Predictive Standard Deviation) values.

Value

A list containing:

prior_weight

A data frame with two columns: psd (non-trivial PSD values) and prior_weight (learned prior weights).

posterior_weight

A numeric matrix where rows correspond to datasets, and columns correspond to non-trivial PSD values, representing the posterior weights.

Examples

# Example usage
set.seed(1)
L_matrix <- matrix(rnorm(500), nrow = 100, ncol = 5)
grid <- seq(0, 2, length.out = 5)
result <- fash_eb_est(L_matrix, penalty = 2, grid = grid)
print(result$prior_weight)
#>   psd prior_weight
#> 1 0.0    0.2748459
#> 2 0.5    0.1307114
#> 3 1.0    0.1784805
#> 4 1.5    0.2325166
#> 5 2.0    0.1834456
print(result$posterior_weight)
#>                 0         0.5          1         1.5           2
#>   [1,] 0.09230602 0.044166986 0.16888769 0.357089989 0.337549318
#>   [2,] 0.12072643 0.049838152 0.35319702 0.029824692 0.446413698
#>   [3,] 0.04235192 0.018680905 0.30997752 0.593318137 0.035671520
#>   [4,] 0.70615158 0.079786877 0.06681384 0.082571783 0.064675913
#>   [5,] 0.21170602 0.037633226 0.01006158 0.673566762 0.067032417
#>   [6,] 0.02856040 0.180649344 0.51204882 0.249000050 0.029741386
#>   [7,] 0.31017510 0.185526280 0.24105933 0.175111804 0.088127490
#>   [8,] 0.32805203 0.185267902 0.17494014 0.233882635 0.077857296
#>   [9,] 0.28485858 0.111852161 0.10262494 0.048638433 0.452025888
#>  [10,] 0.12538737 0.435177284 0.18404378 0.198850596 0.056540971
#>  [11,] 0.55353261 0.030740598 0.06725105 0.293214069 0.055261670
#>  [12,] 0.29645383 0.060170649 0.19854423 0.187518544 0.257312746
#>  [13,] 0.09668597 0.358443943 0.07831437 0.096671920 0.369883794
#>  [14,] 0.08599026 0.195394127 0.12992989 0.345814682 0.242871046
#>  [15,] 0.47914761 0.060128154 0.27128910 0.126964352 0.062470791
#>  [16,] 0.12199981 0.040973533 0.37878437 0.314462729 0.143779552
#>  [17,] 0.23570845 0.082729329 0.11424146 0.124906064 0.442414698
#>  [18,] 0.58621006 0.082064853 0.04230144 0.170986201 0.118437445
#>  [19,] 0.48586906 0.166615280 0.26380976 0.049567182 0.034138714
#>  [20,] 0.22912153 0.050390461 0.07856380 0.175460695 0.466463513
#>  [21,] 0.28355743 0.032435743 0.01298101 0.353926693 0.317099122
#>  [22,] 0.24936036 0.207801389 0.07422965 0.431192572 0.037416029
#>  [23,] 0.24808222 0.088358022 0.07961193 0.439944673 0.144003157
#>  [24,] 0.11019687 0.320167666 0.37200995 0.105065336 0.092560178
#>  [25,] 0.36855300 0.085314905 0.04050621 0.271656734 0.233969152
#>  [26,] 0.08971388 0.092038009 0.37396607 0.126677030 0.317605016
#>  [27,] 0.34396213 0.177601771 0.18744098 0.238812272 0.052182853
#>  [28,] 0.10799203 0.215283714 0.06128685 0.471561839 0.143875567
#>  [29,] 0.26273991 0.101945193 0.33521667 0.151113275 0.148984949
#>  [30,] 0.32220006 0.072947643 0.17923104 0.353970246 0.071651009
#>  [31,] 0.72923956 0.094657426 0.04541148 0.114316707 0.016374818
#>  [32,] 0.36383366 0.106417621 0.01456808 0.071033623 0.444147014
#>  [33,] 0.43919615 0.241182005 0.10200908 0.174613464 0.042999304
#>  [34,] 0.15377338 0.016906058 0.18643107 0.537253953 0.105635541
#>  [35,] 0.07591936 0.194429634 0.18406280 0.182217484 0.363370718
#>  [36,] 0.18046632 0.027962660 0.16087521 0.481082977 0.149612834
#>  [37,] 0.11287629 0.058932186 0.19050379 0.365007907 0.272679828
#>  [38,] 0.32259975 0.095988368 0.06786606 0.290869722 0.222676100
#>  [39,] 0.48924182 0.040347034 0.31667548 0.096859376 0.056876292
#>  [40,] 0.42796598 0.089635579 0.12886855 0.099377273 0.254152612
#>  [41,] 0.19103050 0.015790025 0.29664506 0.399133892 0.097400516
#>  [42,] 0.09277980 0.184371934 0.21832120 0.034913872 0.469613196
#>  [43,] 0.43201557 0.019361895 0.17473100 0.232865280 0.141026256
#>  [44,] 0.38662141 0.066289631 0.05976045 0.140335274 0.346993234
#>  [45,] 0.13785578 0.042769482 0.57031983 0.024114792 0.224940116
#>  [46,] 0.47167281 0.214807620 0.08408975 0.197884046 0.031545774
#>  [47,] 0.18145554 0.483173787 0.04746093 0.266453309 0.021456429
#>  [48,] 0.50401265 0.113096925 0.11752684 0.163292076 0.102071517
#>  [49,] 0.20736854 0.030487734 0.12761166 0.438288794 0.196243265
#>  [50,] 0.24239025 0.009259193 0.18094158 0.560969636 0.006439338
#>  [51,] 0.17686207 0.088608918 0.08838967 0.438735373 0.207403970
#>  [52,] 0.13506193 0.116277680 0.24303279 0.414792873 0.090834722
#>  [53,] 0.35975846 0.088502071 0.15492286 0.316406209 0.080410394
#>  [54,] 0.17411775 0.101140829 0.27306218 0.375796382 0.075882860
#>  [55,] 0.42529158 0.010903372 0.13210157 0.415878890 0.015824591
#>  [56,] 0.61966110 0.013878788 0.17473493 0.131335867 0.060389315
#>  [57,] 0.20273202 0.378386604 0.01718917 0.076575757 0.325116453
#>  [58,] 0.13723578 0.099618662 0.44891950 0.282292430 0.031933629
#>  [59,] 0.55240926 0.037222888 0.29517339 0.038799631 0.076394837
#>  [60,] 0.14050483 0.495897002 0.06825821 0.111920481 0.183419475
#>  [61,] 0.79221105 0.052200475 0.12060152 0.004543208 0.030443744
#>  [62,] 0.08950376 0.034870972 0.04095822 0.293029666 0.541637379
#>  [63,] 0.30107316 0.207032982 0.07381428 0.067682111 0.350397468
#>  [64,] 0.18786834 0.210806999 0.27961621 0.100535548 0.221172910
#>  [65,] 0.08282515 0.044591489 0.63137577 0.124391964 0.116815634
#>  [66,] 0.13693920 0.489619390 0.09645423 0.176922873 0.100064307
#>  [67,] 0.05565535 0.124697508 0.14405882 0.564097958 0.111490364
#>  [68,] 0.58625934 0.015494636 0.02677217 0.202129859 0.169343989
#>  [69,] 0.21373651 0.075480339 0.08551798 0.087505273 0.537759894
#>  [70,] 0.74361616 0.049562416 0.02148496 0.018326957 0.167009512
#>  [71,] 0.20729521 0.616090531 0.06458426 0.073896327 0.038133672
#>  [72,] 0.15208247 0.163522869 0.29797735 0.345514450 0.040902862
#>  [73,] 0.47969086 0.195624195 0.07215578 0.096745650 0.155783518
#>  [74,] 0.03317647 0.037172407 0.77539640 0.066676234 0.087578491
#>  [75,] 0.06755931 0.080593623 0.17963372 0.062285453 0.609927898
#>  [76,] 0.27732702 0.095183466 0.41664202 0.173850044 0.036997457
#>  [77,] 0.17460685 0.284362408 0.01790310 0.261761859 0.261365783
#>  [78,] 0.12956946 0.490359076 0.17633435 0.094631191 0.109105920
#>  [79,] 0.19582469 0.241544105 0.03165520 0.130545071 0.400430936
#>  [80,] 0.05925696 0.170050196 0.17407335 0.527267030 0.069352465
#>  [81,] 0.14326645 0.035122173 0.24463665 0.458844979 0.118129750
#>  [82,] 0.16296473 0.237315175 0.08059630 0.479572207 0.039551586
#>  [83,] 0.46296964 0.084460201 0.34796507 0.047900144 0.056704952
#>  [84,] 0.10321579 0.051931201 0.15253987 0.472237249 0.220075890
#>  [85,] 0.14303114 0.063238927 0.02869638 0.212022487 0.553011074
#>  [86,] 0.13227462 0.038472988 0.02262661 0.075804633 0.730821149
#>  [87,] 0.48652526 0.345695193 0.05593998 0.016904491 0.094935076
#>  [88,] 0.18173993 0.054459634 0.41166691 0.294228705 0.057904825
#>  [89,] 0.48619250 0.103871568 0.33648614 0.042282842 0.031166956
#>  [90,] 0.27431956 0.039561901 0.37264383 0.078946921 0.234527787
#>  [91,] 0.12051862 0.082599322 0.09114709 0.659234691 0.046500276
#>  [92,] 0.25495759 0.054164316 0.07208664 0.119297126 0.499494337
#>  [93,] 0.45299686 0.032476461 0.11767381 0.357774366 0.039078504
#>  [94,] 0.39059908 0.211584053 0.03024950 0.222922433 0.144644932
#>  [95,] 0.12289206 0.003572163 0.09665725 0.019049964 0.757828561
#>  [96,] 0.54396067 0.051893174 0.23115932 0.104462561 0.068524275
#>  [97,] 0.03187185 0.229580637 0.15952226 0.475316178 0.103709077
#>  [98,] 0.15971768 0.048793975 0.47822380 0.250744566 0.062519983
#>  [99,] 0.09835062 0.240304621 0.20661451 0.138486674 0.316243569
#> [100,] 0.16769151 0.087464394 0.12876387 0.541044097 0.075036128