# EBEs output for graphing

**URL:** <https://discourse.pumas.ai/t/ebes-output-for-graphing/241>\
**Category:** Diagnostics\
**Created:** [February 23, 2020, 3:04pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241 "2020-02-23T15:04:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![shli6161](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/shli6161/32/177_2.png) [@shli6161](https://discourse.pumas.ai/u/shli6161)\
**Post date:** [February 23, 2020, 3:04pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/1 "2020-02-23T15:04:36Z")

</div>

Hello.

I am using empirical\_bayes() function for my analysis and I found out all EBEs are merged into one column. Is there a way to output EBEs using empirical\_bayes() in a manner that can be used for graphing and further analyses? Right now, I have a report due so that needs this plot. Is there a way to work it around? Thank you very much~

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [February 26, 2020, 3:10am UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/2 "2020-02-26T03:10:52Z")

</div>

thanks for reporting. There is a fix for this now which will be incorporated into the next release.

---

<div class="post-metadata">

**Author:** ![Anitha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anitha](https://discourse.pumas.ai/u/Anitha)\
**Post date:** [March 17, 2020, 5:18pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/3 "2020-03-17T17:18:11Z")

</div>

Hi Vijay,

I have a similar situation for my empirical\_bayes() function estimates. The data output is without column names (given below) is there a way around?

```auto
 :[0.003893017273809057, -0.0064450897057206896, -0.4832060380064258, -0.3182802749018907, -0.17328388537013614, 0.17692167320092497, -0.20657537748229318, 0.32688207001643593, 0.4408790170505515]
[0.0008039381680160061, 0.40692768174742994, -0.19052280418943815, -0.04766732218965573, 0.10899599268605104, -0.3042683918275428, -0.5320424018883979, 0.2769142699890851, 0.10287926660637328]
[-0.014222914360039892, -0.27825300175500967, 0.04650368905751066, 0.8223221110594434, -0.31471916195993854, -1.2005493073109694, -0.22623475195467443, -0.45139917214592845, -0.2074268722919592]
[0.008481939173097272, 0.2762267839609055, -0.17863133686883892, 0.020495341487036505, 0.027784765856280043, 0.36723239532160984, 0.8875372032632546, -0.18080334531270237, 0.8300731535547978]
[-0.019878243446784752, -0.4278111141523505, -1.0981370176624246, -1.1236560559804318, -0.6193907449016971, -0.19477408627077147, -0.7401290587533766, -0.4889376223961829, -0.07041045991056755]
[-0.003934857213489369, 0.24029421466658812, -0.5412611188854506, -0.7707892208716053, -0.2590068820661076, 0.33418668577238064, -0.4426825915767087, -0.46762064956943, 0.24663286486711308]
[-0.006213644293878277, -0.013908895159926663, -0.3622288107930953, 0.6266078495825546, -0.08367759402400056, -0.22683410345394112, -0.8381489423562987, -0.07684526559008711, -0.25530083570432544]
[-0.0019136687866613488, 0.05357869650828251, 0.18441980399155375, -0.1561105937869351, -0.05530150093480558, -0.5063107925444591, 0.45389260468026843, -0.02945563919613748, -0.12409815646964925]
[0.0033425568928669167, 0.132210340132933, -0.07537987414314398, -0.1470835903369388, 0.3243703957172484, -0.6390644043747173, 0.1847624460997283, 0.1188097927575027, 0.33825544128555646]
[0.006468301009316608, -0.07925703541188905, 0.43524516406166164, -0.2305205983467, 0.339387126527767, 0.3422595543117683, 0.32610516447211424, 0.26715353606482384, 0.39524399026831086]
[-0.0051132021911700215, -0.0762589223935508, -0.5450177725933981, -0.6310463719672519, -0.18205505097899422, -0.19719332949817878, -0.08775852121495444, -0.10764745026932888, -0.18516444694437953]
[-0.00820305073664453, -0.21126339328082763, -0.6527823574564875, -0.7328272311186826, -0.5163621544792658, 0.3689179439961686, -0.5170075347440016, 0.11472442421520221, -0.08696497844668538]
[0.00199495451503551, 0.18077340791812443, -0.24383160661799305, -0.16766064757794794, 0.14959320750796687, 0.2345061891298344, 0.014465620620134598, -0.05478403161328483, 0.07652797553617802]
[-0.018921945618245145, -0.11775921114414262, -0.655403338769185, -0.9591892416239679, -0.30053712316489545, -0.1859074744409664, -1.175865312628053, -0.6501855029649246, -0.6661733951878989]
[0.009455542070219657, 0.266818080489206, -0.5412087708318123, -0.06868055985260811, 0.121830412571343, 1.0735100578753805, 0.38787904545357543, 1.0459134326535127, 0.03324610090726631]

```

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [March 17, 2020, 6:43pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/4 "2020-03-17T18:43:54Z")

</div>

What version of Pumas are you on? You can do

```auto
] st

```

---

<div class="post-metadata">

**Author:** ![Anitha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anitha](https://discourse.pumas.ai/u/Anitha)\
**Post date:** [March 17, 2020, 7:00pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/5 "2020-03-17T19:00:02Z")

</div>

Vijay, I am using Pumas v0.10.0.

---

<div class="post-metadata">

**Author:** ![pkofod](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/pkofod/32/59_2.png) [@pkofod](https://discourse.pumas.ai/u/pkofod)\
**Post date:** [March 17, 2020, 7:56pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/6 "2020-03-17T19:56:00Z")

</div>

It’s not clear to me that this is wrong, but it would be great with more context. When are you getting these vectors? Did you try using `inspect` which is the higher level function?

---

<div class="post-metadata">

**Author:** ![Anitha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anitha](https://discourse.pumas.ai/u/Anitha)\
**Post date:** [March 17, 2020, 8:25pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/7 "2020-03-17T20:25:46Z")

</div>

With inspect here is the output in REPL:

```auto
Fitting was successful: true
Likehood approximations used for
 * Predictions: Pumas.FOCEI()
 * Weighted residuals: Pumas.FOCEI()
 * Empirical bayes: Pumas.FOCEI()

Below are the empirical Bayes estimates. The output does not come with column names? I have 9 omegas in my model and here I have 9 etas per row. Is there a way I can specify each column with the name to the corresponding omega. 

julia> empirical_bayes(result_two_cmtaddprop_pg):

64-element Array{NamedTuple{(:η,),Tuple{Array{Float64,1}}},1}:
 (η = [0.003893017273809057, -0.0064450897057206896, -0.4832060380064258, -0.3182802749018907, -0.17328388537013614, 0.17692167320092497, -0.20657537748229318, 0.32688207001643593, 0.4408790170505515],)
 (η = [0.0008039381680160061, 0.40692768174742994, -0.19052280418943815, -0.04766732218965573, 0.10899599268605104, -0.3042683918275428, -0.5320424018883979, 0.2769142699890851, 0.10287926660637328],)
 (η = [-0.014222914360039892, -0.27825300175500967, 0.04650368905751066, 0.8223221110594434, -0.31471916195993854, -1.2005493073109694, -0.22623475195467443, -0.45139917214592845, -0.2074268722919592],)
 (η = [0.008481939173097272, 0.2762267839609055, -0.17863133686883892, 0.020495341487036505, 0.027784765856280043, 0.36723239532160984, 0.8875372032632546, -0.18080334531270237, 0.8300731535547978],)
 ⋮

```

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)\
**Post date:** [March 17, 2020, 8:44pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/8 "2020-03-17T20:44:00Z")

</div>

You can construct a dataframe from the inspect output with `DataFrame(inspect(result))`. That dataframe will contain columns for each of the random effect variables. One small inconvenience is that the value of the EBE will be repeated in the dataframe for each of time index within a subject. Hence, you can do something like

```auto
by(DataFrame(inspect(result)), :id, first)

```

to just get the first row for each subject.

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [March 17, 2020, 10:42pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/9 "2020-03-17T22:42:40Z")

</div>

@Anitha as Andreas suggested you can get the EBE’s using the `DataFrame` construct on the `inspect` feature

```auto
julia> ebes = DataFrame(inspect(pkres);include_covariates=false)
Calculating: predictions, weighted residuals, empirical bayes. Done.
1210×13 DataFrame. Omitted printing of 3 columns
│ Row │ id │ time │ evid │ dv │ dv_pred │ dv_ipred │ pred_approx │ dv_wres │ dv_iwres │ wres_approx │
│ │ String │ Float64 │ Int64 │ Float64 │ Float64 │ Float64 │ String │ Float64 │ Float64 │ Pumas.FOCEI │
├──────┼────────┼─────────┼───────┼─────────┼─────────┼──────────┼─────────────┼───────────┼───────────┼─────────────┤
│ 1 │ 1 │ 0.0 │ 0 │ 1429.5 │ 1307.04 │ 1805.21 │ Pumas.FOCEI │ 0.19554 │ -1.0314 │ FOCEI() │
│ 2 │ 1 │ 1.0 │ 0 │ 1444.87 │ 1290.6 │ 1734.4 │ Pumas.FOCEI │ 0.179012 │ -0.827269 │ FOCEI() │
│ 3 │ 1 │ 2.0 │ 0 │ 1513.53 │ 1273.44 │ 1666.37 │ Pumas.FOCEI │ 0.366663 │ -0.454535 │ FOCEI() │
│ 4 │ 1 │ 3.0 │ 0 │ 1732.73 │ 1255.64 │ 1601.01 │ Pumas.FOCEI │ 0.980394 │ 0.407719 │ FOCEI() │
│ 5 │ 1 │ 4.0 │ 0 │ 1717.83 │ 1237.28 │ 1538.21 │ Pumas.FOCEI │ 0.891291 │ 0.578708 │ FOCEI() │
⋮
│ 1205 │ 10 │ 115.0 │ 0 │ 533.524 │ 412.679 │ 422.046 │ Pumas.FOCEI │ 1.27836 │ 1.30898 │ FOCEI() │
│ 1206 │ 10 │ 116.0 │ 0 │ 405.293 │ 383.228 │ 396.876 │ Pumas.FOCEI │ 0.0572661 │ 0.105098 │ FOCEI() │
│ 1207 │ 10 │ 117.0 │ 0 │ 432.941 │ 355.821 │ 373.207 │ Pumas.FOCEI │ 0.732809 │ 0.793193 │ FOCEI() │
│ 1208 │ 10 │ 118.0 │ 0 │ 345.416 │ 330.32 │ 350.949 │ Pumas.FOCEI │ -0.14893 │ -0.078139 │ FOCEI() │
│ 1209 │ 10 │ 119.0 │ 0 │ 283.573 │ 306.596 │ 330.019 │ Pumas.FOCEI │ -0.753072 │ -0.697452 │ FOCEI() │
│ 1210 │ 10 │ 120.0 │ 0 │ 266.422 │ 284.526 │ 310.338 │ Pumas.FOCEI │ -0.728372 │ -0.701284 │ FOCEI() │

julia> names(ebes)
13-element Array{Symbol,1}:
 :id         
 :time       
 :evid       
 :dv         
 :dv_pred    
 :dv_ipred   
 :pred_approx
 :dv_wres    
 :dv_iwres   
 :wres_approx
 :η_1        
 :η_2        
 :ebes_approx

```

Notice the names of the random effects in the column names.

To show what Andreas suggested, you will get

```auto
julia> by(ebes, :id, first)
10×13 DataFrame. Omitted printing of 3 columns
│ Row │ id │ time │ evid │ dv │ dv_pred │ dv_ipred │ pred_approx │ dv_wres │ dv_iwres │ wres_approx │
│ │ String │ Float64 │ Int64 │ Float64 │ Float64 │ Float64 │ String │ Float64 │ Float64 │ Pumas.FOCEI │
├─────┼────────┼─────────┼───────┼─────────┼─────────┼──────────┼─────────────┼───────────┼───────────┼─────────────┤
│ 1 │ 1 │ 0.0 │ 0 │ 1429.5 │ 1307.04 │ 1805.21 │ Pumas.FOCEI │ 0.19554 │ -1.0314 │ FOCEI() │
│ 2 │ 2 │ 0.0 │ 0 │ 2416.01 │ 1194.58 │ 2119.11 │ Pumas.FOCEI │ 1.6614 │ 0.694318 │ FOCEI() │
│ 3 │ 3 │ 0.0 │ 0 │ 1758.89 │ 1617.36 │ 1880.99 │ Pumas.FOCEI │ 0.216884 │ -0.321674 │ FOCEI() │
│ 4 │ 4 │ 0.0 │ 0 │ 1358.8 │ 1348.31 │ 1447.04 │ Pumas.FOCEI │ 0.0208924 │ -0.302217 │ FOCEI() │
│ 5 │ 5 │ 0.0 │ 0 │ 2555.35 │ 1575.0 │ 2465.69 │ Pumas.FOCEI │ 1.14604 │ 0.1802 │ FOCEI() │
│ 6 │ 6 │ 0.0 │ 0 │ 943.624 │ 1320.41 │ 1149.22 │ Pumas.FOCEI │ -0.945041 │ -0.886571 │ FOCEI() │
│ 7 │ 7 │ 0.0 │ 0 │ 1229.74 │ 1363.81 │ 1070.52 │ Pumas.FOCEI │ -0.360989 │ 0.737079 │ FOCEI() │
│ 8 │ 8 │ 0.0 │ 0 │ 845.896 │ 1448.94 │ 1232.36 │ Pumas.FOCEI │ -1.41048 │ -1.55409 │ FOCEI() │
│ 9 │ 9 │ 0.0 │ 0 │ 1084.21 │ 1227.76 │ 892.116 │ Pumas.FOCEI │ -0.46381 │ 1.06705 │ FOCEI() │
│ 10 │ 10 │ 0.0 │ 0 │ 1179.46 │ 1357.36 │ 1047.86 │ Pumas.FOCEI │ -0.489355 │ 0.622375 │ FOCEI() │

```

Can you try it out on your version and check if you are getting these and let us know?

Vijay

---

<div class="post-metadata">

**Author:** ![Anitha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anitha](https://discourse.pumas.ai/u/Anitha)\
**Post date:** [March 18, 2020, 11:00am UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/10 "2020-03-18T11:00:44Z")

</div>

Thanks Vijay, and Andreas.  
I did the DataFrame for infer function and now i can see the etas in columns numbered.

| Î·\_1 | Î·\_2 | Î·\_3 | Î·\_4 | Î·\_5 | Î·\_6 | Î·\_7 | Î·\_8 | Î·\_9 | ebes\_approx |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0.003893017 | -0.00644509 | -0.483206038 | -0.318280275 | -0.173283885 | 0.176921673 | -0.206575377 | 0.32688207 | 0.440879017 | Pumas.FOCEI |
| 0.003893017 | -0.00644509 | -0.483206038 | -0.318280275 | -0.173283885 | 0.176921673 | -0.206575377 | 0.32688207 | 0.440879017 | Pumas.FOCEI |

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [March 18, 2020, 11:33am UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/11 "2020-03-18T11:33:55Z")

</div>

I am assuming you meant to say DataFrame for the `inspect` function?

---

<div class="post-metadata">

**Author:** ![Anitha](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@Anitha](https://discourse.pumas.ai/u/Anitha)\
**Post date:** [March 18, 2020, 12:05pm UTC](https://discourse.pumas.ai/t/ebes-output-for-graphing/241/12 "2020-03-18T12:05:47Z")

</div>

Sorry, yes it was for the inspect function.
