auto_penalize: Penalize a likelihood function with a guessed penalty...

Description Usage Arguments Details Value Examples

View source: R/auto_penalize.R

Description

Given a dataset, a likelihood function and penalty parameters on how to penalize big and small segments, this function makes an educated guess on a penalty function for the likelihood function.

Usage

1
2
auto_penalize(data, likelihood, big_segment_penalty = 10,
  small_segment_penalty = 10)

Arguments

data

dataset to be segmented by the segment() function

likelihood

function to be maximized using the segment() function. It's used to find out the scale of the values in the segment function

big_segment_penalty

penalty factor for big segments. The bigger it is, the bigger the penalty on big segments. Must be greater than or equal to 1. Penalty on big segments is constant when it's equal to 1. Default: 10

small_segment_penalty

penalty factor for small segments. The bigger it is, the bigger the penalty on small segments. Must be greater than or equal to 1. Penalty on small segments is constant when it's equal to 1. Default: 10

Details

This function tries to fit a sum of two exponential functions to values inferred from the dataset and the likelihood function. The model for the penalty function we try to fit is in the form:

C1 exp(s1(x - L/2)) + C2 exp(s2(-x + L/2))

In the equation, C1 and s1 are, respectively, a multiplier constant and an exponential scale modifier for small segments, whereas C2 and s2 are the equivalent ones for big segments. L is the number of columns in the data matrix.

Assuming the penalty function to be as such, the parameters are estimated considering the scale of values yielded by the likelihood function for small and big segments, also taking into account the big_segment_penalty and small_segment_penalty tuning parameters, which can be used to adjust the effect of the penalty function over big and small segments, respectively.

Value

the likelihood function with the guessed penalty function applied

Examples

1
2
3
4
## Not run: 
penalized_likelihood <- auto_penalize(berlin, multivariate)

## End(Not run)

segmentr documentation built on Aug. 29, 2019, 1:03 a.m.