EBEs output for graphing

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~

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

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?

 :[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]

What version of Pumas are you on? You can do

]  st

Vijay, I am using Pumas v0.10.0.

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?

With inspect here is the output in REPL:

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],)
 โ‹ฎ

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

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

to just get the first row for each subject.

1 Like

@Anitha as Andreas suggested you can get the EBEโ€™s using the DataFrame construct on the inspect feature

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

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

1 Like

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

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

Sorry, yes it was for the inspect function.