Open fabian-s opened 4 years ago
.. not sure how to pull this through the delta method, though.
Could be obtained via the package gratia
, developed by @gavinsimpson.
Example:
library(survival)
library(pammtools)
#>
#> Attaching package: 'pammtools'
#> The following object is masked from 'package:stats':
#>
#> filter
library(gratia)
as_ped(Surv(time, status) ~ temperature + voltage, data = capacitor) |>
pamm(formula = ped_status ~ s(tend, bs="ad", k = 20)+temperature+voltage) |>
derivatives(interval = "simultaneous")
#> # A tibble: 200 x 8
#> smooth var data derivative se crit lower upper
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 s(tend) tend 216 0.0823 0.0324 3.20 -0.0213 0.186
#> 2 s(tend) tend 220. 0.0774 0.0281 3.20 -0.0125 0.167
#> 3 s(tend) tend 225. 0.0724 0.0247 3.20 -0.00657 0.151
#> 4 s(tend) tend 229. 0.0672 0.0220 3.20 -0.00325 0.138
#> 5 s(tend) tend 234. 0.0618 0.0200 3.20 -0.00213 0.126
#> 6 s(tend) tend 238. 0.0562 0.0184 3.20 -0.00265 0.115
#> 7 s(tend) tend 243. 0.0505 0.0171 3.20 -0.00422 0.105
#> 8 s(tend) tend 247. 0.0445 0.0159 3.20 -0.00623 0.0953
#> 9 s(tend) tend 252. 0.0384 0.0146 3.20 -0.00825 0.0852
#> 10 s(tend) tend 256. 0.0322 0.0132 3.20 -0.0100 0.0744
#> # ... with 190 more rows
@StaffanBetner That would be for the derivative of the specified smooth though, not the smooth itself or a derived quantity like the hazard ratio etc.
I'm in the process of exposing the simulation-based approach to simultaneous intervals for smooths (it's there via confint()
methods but it needs a tidy version like the output from derivatives()
, and more general exposure if possible so users could apply it to other quantities than just smooths.
... instead of the pointwise intervals we do now.
Would probably make more sense for at least some of the functional estimates we return like hazard (ratios), survival functions etc.
Implementation could be based on code here: https://www.fromthebottomoftheheap.net/2016/12/15/simultaneous-interval-revisited/