AR(1) Time-varying Parameters #307
Answered
by
seananderson
Nathan-Hebert
asked this question in
Q&A
-
Hi, Is there a way to pull out the AR(1) correlation estimated for time_varying_type = 'ar1'? I've found sigma_V in sdreport, but not rho_V. Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
seananderson
Feb 28, 2024
Replies: 1 comment 1 reply
-
See library(sdmTMB)
fit <- sdmTMB(
catch_weight ~ 1,
data = dogfish,
spatial = "off",
time = "year",
spatiotemporal = "off",
time_varying = ~ 1,
time_varying_type = "ar1",
family = tweedie(link = "log")
)
#> Detected irregular time spacing with an AR(1) or random walk process.
#> Consider filling in the missing time slices with `extra_time`.
#> `extra_time = c(2005, 2007, 2009, 2011, 2013, 2015, 2017, 2019, 2020)`
fit$sd_report
#> sdreport(.) result
#> Estimate Std. Error
#> b_j 4.3622661 0.38181529
#> thetaf 1.3042638 0.04396550
#> ln_phi 2.3763279 0.03156677
#> ln_tau_V -0.2012370 0.26920637
#> rho_time_unscaled 0.8839355 0.73973581
#> Maximum gradient component: 2.277666e-05
# see `rho_time_unscaled`
pl <- as.list(fit$sd_report, "Estimate")
pls <- as.list(fit$sd_report, "Std. Error")
.rho <- pl$rho_time_unscaled[1,1]
.se <- pls$rho_time_unscaled[1,1]
bound <- function(x) 2 * plogis(x) - 1
bound(.rho)
#> [1] 0.4152742
bound(.rho + 1.96 * .se)
#> [1] 0.8232787
bound(.rho - 1.96 * .se)
#> [1] -0.2756548 Created on 2024-02-28 with reprex v2.1.0 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Nathan-Hebert
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See
rho_time_unscaled
. Sorry this is a bit obscure to obtain still!