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] "[0,826)" "[826,1.1e+03]"
#> ..$ param_alpha: num [1:2] 0.949 0.78
#> ..$ param_beta : num [1:2] 5.055 0.116
#> ..$ logPost : num [1:2] -353 -271
#> ..$ 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] "[0,826)" "[0,826)" "[0,826)" "[0,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] "[0,826)" "[826,1.1e+03]"
#> ..$ param_alpha: num [1:2] 0.983 0.764
#> ..$ param_beta : num [1:2] 0.9202 0.0841
#> ..$ logPost : num [1:2] -830 -272
#> ..$ logLik : num [1:2] -826 -270
#> $ 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] "[0,826)" "[0,826)" "[0,826)" "[0,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] "[0,826)" "[826,1.1e+03]"
#> ..$ param_alpha: num [1:2] 0.0605 0.5417
#> ..$ param_beta : num [1:2] 0.101 0.106
#> ..$ logPost : num [1:2] -5.35 -77.25
#> ..$ logLik : num [1:2] -1.72 -75.33
#> $ 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] "[0,826)" "[0,826)" "[0,826)" "[0,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] "[0,547)" "[547,822)" "[822,972)" "[972,1.1e+03]"
#> ..$ param_alpha: num [1:4] 0.362 0.657 0.738 0.758
#> ..$ param_beta : num [1:4] 0.3922 0.0883 0.073 0.0749
#> ..$ logPost : num [1:4] -60.1 -197.9 -150.2 -125.8
#> ..$ logLik : num [1:4] -57.4 -196.1 -148.4 -124
#> $ 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] "[0,547)" "[0,547)" "[0,547)" "[0,547)" ...
#> $ model_name : chr "nhpp"
#> - attr(*, "class")= chr [1:2] "nhpp" "mod_cpt"