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.
auto_penalize(data, likelihood, big_segment_penalty = 10,
small_segment_penalty = 10)
dataset to be segmented by the segment()
function
function to be maximized using the segment()
function.
It's used to find out the scale of the values in the segment function
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
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
the likelihood function with the guessed penalty function applied
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.
# NOT RUN {
penalized_likelihood <- auto_penalize(berlin, multivariate)
# }
Run the code above in your browser using DataLab