epiverse-trace / epiverse-trace/quickfit
Formula based and survival model fitting
- Dominant language
- R
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Sure. `survival::survreg()` actually computes [two loglikelihoods](https://www.rdocumentation.org/packages/survival/versions/3.5-5/topics/survreg.object), one for the baseline and one for the full models. So, in this case, we get four loglikelihoods for two models.
```
library(survival)
# Define fitting function
fit_survreg <- function(data, dist, ...) {
survival::survreg(
data = data,
dist = dist,
formula = Surv(futime, fustat) ~ ecog.ps + rx, # taken from ?survival::survreg
scale = 1
)
}
# Apply multi_fitdist
multi_fitdist(
data = survival::ovarian,
models = c(dist = "lognormal", dist = "weibull"),
func = fit_survreg
)
# Results
models loglik.1 loglik.2 aic bic
1 weibull -96.24333 -97.19804 196.4867 199.0029
2 weibull -96.24333 -97.19804 198.3961 200.9123
3 lognormal -97.74229 -98.03220 199.4846 202.0008
4 lognormal -97.74229 -98.03220 200.0644 202.5806
Created on 2023-05-19 with [reprex v2.0.2](https://reprex.tidyverse.org/)
```
_Originally posted by @jamesmbaazam in https://github.com/epiverse-trace/quickfit/pull/6#discussion_r1199000779_
Contributor guide
Research direction
Reproduce the reported case with survival::ovarian, fit_survreg, survival::survreg(), and multi_fitdist using the two distributions shown. First inspect how multi_fitdist reads the two loglikelihood values and builds the results table; clarify the expected handling of formula-based survival fits and duplicate model rows before determining what tests should define done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100