Fit a non-homogeneous Poisson process model to the exceedances of a time series.
fit_nhpp.Rd
Fit a non-homogeneous Poisson process model to the exceedances of a time series.
Value
An nhpp
object, which inherits from mod_cpt.
Details
Any time series can be modeled as a non-homogeneous Poisson process of the
locations of the exceedances of a threshold in the series.
This function uses the BMDL criteria to determine the best fit
parameters for each
region defined by the changepoint set tau
.
See also
Other model-fitting:
fit_lmshift()
,
fit_meanshift()
,
fit_meanvar()
,
model_args()
,
model_name()
,
new_fun_cpt()
,
whomademe()
Examples
# Fit an NHPP model using the mean as a threshold
fit_nhpp(DataCPSim, tau = 826)
#> List of 6
#> $ data : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#> $ tau : num 826
#> $ region_params: tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
#> ..$ region : chr [1:2] "[1,826)" "[826,1.1e+03)"
#> ..$ param_alpha: num [1:2] 0.945 0.778
#> ..$ param_beta : num [1:2] 4.953 0.113
#> ..$ logPost : num [1:2] -352 -272
#> ..$ logLik : num [1:2] -337 -270
#> $ model_params : Named num 63.2
#> ..- attr(*, "names")= chr "threshold"
#> $ fitted_values: Named num [1:1096] 43.2 43.2 43.2 43.2 43.2 ...
#> ..- attr(*, "names")= chr [1:1096] "[1,826)" "[1,826)" "[1,826)" "[1,826)" ...
#> $ model_name : chr "nhpp"
#> - attr(*, "class")= chr [1:2] "nhpp" "mod_cpt"
# Fit an NHPP model using other thresholds
fit_nhpp(DataCPSim, tau = 826, threshold = 20)
#> List of 6
#> $ data : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#> $ tau : num 826
#> $ region_params: tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
#> ..$ region : chr [1:2] "[1,826)" "[826,1.1e+03)"
#> ..$ param_alpha: num [1:2] 0.975 0.761
#> ..$ param_beta : num [1:2] 0.867 0.081
#> ..$ logPost : num [1:2] -828 -273
#> ..$ logLik : num [1:2] -825 -271
#> $ model_params : Named num 20
#> ..- attr(*, "names")= chr "threshold"
#> $ fitted_values: Named num [1:1096] 43.2 43.2 43.2 43.2 43.2 ...
#> ..- attr(*, "names")= chr [1:1096] "[1,826)" "[1,826)" "[1,826)" "[1,826)" ...
#> $ model_name : chr "nhpp"
#> - attr(*, "class")= chr [1:2] "nhpp" "mod_cpt"
fit_nhpp(DataCPSim, tau = 826, threshold = 200)
#> List of 6
#> $ data : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#> $ tau : num 826
#> $ region_params: tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
#> ..$ region : chr [1:2] "[1,826)" "[826,1.1e+03)"
#> ..$ param_alpha: num [1:2] 0.0664 0.5413
#> ..$ param_beta : num [1:2] 0.0814 0.106
#> ..$ logPost : num [1:2] -4.19 -77.32
#> ..$ logLik : num [1:2] -0.664 -75.402
#> $ model_params : Named num 200
#> ..- attr(*, "names")= chr "threshold"
#> $ fitted_values: Named num [1:1096] 43.2 43.2 43.2 43.2 43.2 ...
#> ..- attr(*, "names")= chr [1:1096] "[1,826)" "[1,826)" "[1,826)" "[1,826)" ...
#> $ model_name : chr "nhpp"
#> - attr(*, "class")= chr [1:2] "nhpp" "mod_cpt"
# Fit an NHPP model using changepoints determined by PELT
fit_nhpp(DataCPSim, tau = changepoints(segment(DataCPSim, method = "pelt")))
#> List of 6
#> $ data : Time-Series [1:1096] from 1 to 1096: 35.5 29 35.6 33 29.5 ...
#> $ tau : int [1:3] 547 822 972
#> $ region_params: tibble [4 × 5] (S3: tbl_df/tbl/data.frame)
#> ..$ region : chr [1:4] "[1,547)" "[547,822)" "[822,972)" "[972,1.1e+03)"
#> ..$ param_alpha: num [1:4] 0.34 0.657 0.738 0.756
#> ..$ param_beta : num [1:4] 0.2306 0.0883 0.073 0.0736
#> ..$ logPost : num [1:4] -58.6 -197.9 -150.2 -126.8
#> ..$ logLik : num [1:4] -56.2 -196.1 -148.4 -125
#> $ model_params : Named num 63.2
#> ..- attr(*, "names")= chr "threshold"
#> $ fitted_values: Named num [1:1096] 35.3 35.3 35.3 35.3 35.3 ...
#> ..- attr(*, "names")= chr [1:1096] "[1,547)" "[1,547)" "[1,547)" "[1,547)" ...
#> $ model_name : chr "nhpp"
#> - attr(*, "class")= chr [1:2] "nhpp" "mod_cpt"