FJRubio67 / HazReg.jl

Parametric hazard-based regression models (Julia package)
MIT License
5 stars 2 forks source link

Large codebase simplification #7

Closed lrnv closed 5 months ago

lrnv commented 5 months ago

Hey !

Here again is the massive simplification of your codebase. I could go a bit further down by adding types for the different types of models (AFT, PH, etc...) but i was lazy and left one or two conditions hanging around....

Also, I did modify slightly your interface (look at the diff on the docs/ folder to see exactly waht changed in your interface): but it simplifies a lot the code, and actually gives you more generality by allowing application to any other baseline dist from Distributions.jl.

Last but not least, I did not check that the results of your quarto documents were the same. To verify correctness of what I did, you should check carefully (e.g. by comparing by yhand the results to what is stored on the link you gave me last time). If there are issues, you could ping me to solve them if you want i'll gladly help.

A next round of modifications could easily give you 2x less code and 10-100x more performance, but for the moment this was the lowest-haging fruit :)

Tell me what you think


Edit: One more thing is that I did not proof-read the docstrings.

lrnv commented 5 months ago

Voila, should be good to merge to see the online docs and be able to compare them with old quarto reports

FJRubio67 commented 5 months ago

I have approved the merge. I tried to run the quarto file HazReg.qmd, but GHMLE no longer works. Could you provide a reproducible example with the proposed interface/syntax?

https://fjrubio.quarto.pub/hazreg/

We need to be able to at least fit a model ...

# PGWGH
OPTPGWGH = GHMLE(init = fill(0.0, 3 + size(des_t)[2] + size(des)[2]), times = times,
            status = status, hstr = "GH", dist = "PGW", 
            des = des, des_t = des_t, method = "NM", maxit = 1000)

# PGWAFT
OPTPGWAFT = GHMLE(init = fill(0.0, 3 + size(des)[2]), times = times, 
                  status = status, hstr = "AFT", dist = "PGW", 
                  des = des, des_t = nothing, method = "NM", maxit = 1000)

# PGWPH
OPTPGWPH = GHMLE(init = fill(0.0, 3 +size(des)[2]), times = times, 
                 status = status, hstr = "PH", dist = "PGW", 
                 des = des, des_t = nothing, method = "NM", maxit = 1000)

# PGWAH
OPTPGWAH = GHMLE(init = fill(0.0, 3 + size(des_t)[2] ), times = times, 
                 status = status, hstr = "AH", dist = "PGW", 
                 des_t = des_t, des = nothing, method = "NM", maxit = 1000)

# LLGH
OPTLLGH = GHMLE(init = fill(0.0, 2 + size(des_t)[2] + size(des)[2]), times = times,
                status = status, hstr = "GH", dist = "LogLogistic", 
                des = des, des_t = des_t, method = "NM", maxit = 1000)

# LLAFT
OPTLLAFT = GHMLE(init = fill(0.0, 2 + size(des)[2]), times = times, 
                  status = status, hstr = "AFT", dist = "LogLogistic", 
                  des = des, des_t = nothing, method = "NM", maxit = 1000)

# LLPH
OPTLLPH = GHMLE(init = fill(0.0, 2 + size(des)[2]), times = times, 
                status = status, hstr = "PH", dist = "LogLogistic", 
                des = des, des_t = nothing, method = "NM", maxit = 1000)

# LLAH
OPTLLAH = GHMLE(init = fill(0.0, 2 + size(des_t)[2]), times = times, 
                status = status, hstr = "AH", dist = "LogLogistic", 
                des = nothing, des_t = des_t, method = "NM", maxit = 1000)

# EWGH
OPTEWGH = GHMLE(init = fill(0.0, 3 + size(des_t)[2] + size(des)[2]), times = times, 
                status = status, hstr = "GH", dist = "EW", 
                des = des, des_t = des_t, method = "NM", maxit = 1000)

# GGGH
OPTGGGH = GHMLE(init = fill(0.0, 3 + size(des_t)[2] + size(des)[2]), times = times,                  status = status, hstr = "GH", dist = "GenGamma",
                des = des, des_t = des_t, method = "NM", maxit = 1000)

# LNGH
OPTLNGH = GHMLE(init = fill(0.0, 2 + size(des_t)[2] + size(des)[2]), times = times, 
                status = status, hstr = "GH", dist = "LogNormal", 
                des = des, des_t = des_t, method = "NM", maxit = 1000)

# GGH
OPTGGH = GHMLE(init = fill(0.0, 2 + size(des_t)[2] + size(des)[2]), times = times, 
               status = status, hstr = "GH", dist = "Gamma", 
               des = des, des_t = des_t, method = "N", maxit = 1000)
lrnv commented 5 months ago

Did you look at the docs/ folder to see the new syntax ? You can also look at the online documentation that just got compiled and which is working correctly.

Hum... I see that it did not got pushed online, which is weird...