 # Geometric mean in NCA analysis

Hello I would like to calculate geometric mean of AUC, t1/2, Cmax etc.
Is there any way to calculate geometric mean from NCAReport results?
Thank you.

hi @jdw7262 - welcome to the community and thanks for asking the question.

Yes, we can do any sort of summary statistics on the NCAReport after converting it to a datframe (`NCA.to_dataframe`). We are planning to add some convenience functions to allow the standard summaries in a NCA report that are usually generated. But until then, specifically for your case, if you want to compute the geometric mean of something in julia you would have to do something like below:

``````using DataFrames
using Statistics

mynca = DataFrame(cmax = [2,2.3,3,3.1], auc =[10,10.4,11,11.8])
julia> describe(mynca)
2×8 DataFrame
│ Row │ variable │ mean    │ min     │ median  │ max     │ nunique │ nmissing │ eltype   │
│     │ Symbol   │ Float64 │ Float64 │ Float64 │ Float64 │ Nothing │ Nothing  │ DataType │
├─────┼──────────┼─────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┤
│ 1   │ cmax     │ 2.6     │ 2.0     │ 2.65    │ 3.1     │         │          │ Float64  │
│ 2   │ auc      │ 10.8    │ 10.0    │ 10.7    │ 11.8    │         │          │ Float64  │
``````

`describe` is a julia function in the `DataFrames` package that give you many summaries of all columns in your dataset. In addition to that, you can then write any summary function and pass it into the `describe` function. Below, is a small function for geometric mean

``````function geomean(x)
data = log.(x)
gmean = exp(mean(data))
gmean
end
``````

Then, I call the function with only specific outputs as below

``````describe(mynca, :min, :max, :geomean => geomean)

julia> describe(mynca, :min, :max, :geomean => geomean)
2×4 DataFrame
│ Row │ variable │ min     │ max     │ geomean  │
│     │ Symbol   │ Float64 │ Float64 │ Float64  │
├─────┼──────────┼─────────┼─────────┼──────────┤
│ 1   │ cmax     │ 2.0     │ 3.1     │ 0.939018 │
│ 2   │ auc      │ 10.0    │ 11.8    │ 2.3776   │
``````

This is a small example. We intend to add these as convenience functions that have standard NCA summaries in an upcoming release.

Hope this helps.

2 Likes

Thank you so much for your explanation. It is really helpful Have a great day!
Best Regards, Dawoon

Hi I am not sure about my concept, but ‘geomean’ function is already existing in pkg’ StatsBase’, so a function which had the name, ‘geomean’, couldn’t be created when I tried.
So I tried like below and it worked.

function AAA(x)
data = log.(x)
gmean = exp(mean(data))
gmean
end

Thank you.