Methods
Method new()
Create a new ExpertFunction Class
Arguments
distribution
(character)
The distribution name specified by the user.
params
(list)
The parameters for the given distribution.
Could be preset by users or postset by running ExpertFunction$params_init(observations)
penalty_params
(list)
The penalty parameters used to determine the penalty applied on likelihood, will be further used in (initialize_penalty) methods
Calculate the penalty value of the Expert Distribution
Method initialize_penalty()
Prerequisite: self$params and self$penalty_params need to be set. Otherwise will return the default penalty value.
Usage
ExpertFunction$initialize_penalty()
Arguments
default
(logical)
Use default penalty parameters if default is TRUE, else use user defined penalty parameters. Default set to be TRUE.
Method initialize_params()
Estimate all the parameters for this expert function based on observation
Usage
ExpertFunction$initialize_params(y)
Arguments
y
(numeric)
The observations from the preset expert distribution
Method default_penalty()
Set default hyper parameters
Set the parameters for the expert function
Usage
ExpertFunction$default_penalty()
Method set_params()
Usage
ExpertFunction$set_params(expert_params)
Arguments
expert_params
(logical)
The parameters for the given distribution.
Get the parameters for the expert function
Method get_params()
Usage
ExpertFunction$get_params()
Arguments
params
(logical)
The parameters for the given distribution.
Set the penalty parameters
If there are no expert_penalty_params given, use default penalty parameters.
Method set_penalty_params()
Usage
ExpertFunction$set_penalty_params(expert_penalty_params)
Arguments
expert_penalty_params
(logical)
The parameters for the given distribution. Could be preset by users or postset by running ExpertFunction$initialize_params(observations)
Method get_penalty_params()
Get the penalty parameters
Usage
ExpertFunction$get_penalty_params()
Method get_penalty()
Get the penalty value, penalty value cannot be set. It can only been initialized.
Usage
ExpertFunction$get_penalty()
Method get_mean()
Get mean of this expert function
Usage
ExpertFunction$get_mean()
Method get_variance()
Get variance of this expert function
Usage
ExpertFunction$get_variance()
Method get_cdf()
Get the cdf of this expert function given RV
Usage
ExpertFunction$get_cdf(q)
Arguments
q
The value of random variable
Method get_logcdf()
Get the logcdf of this expert function given RV
Usage
ExpertFunction$get_logcdf(q)
Arguments
q
The value of random variable
Method get_pdf()
Get the pdf of this expert function given RV
Usage
ExpertFunction$get_pdf(x)
Arguments
x
The value of random variable
Method get_logpdf()
Get the logpdf of this expert function given RV
Usage
ExpertFunction$get_logpdf(x)
Arguments
x
The value of random variable
Method get_quantile()
Get the quantile of this expert function given probability
Usage
ExpertFunction$get_quantile(p)
Method get_lev()
Get the Limited Expected Value of the expert function.
Usage
ExpertFunction$get_lev(u)
Method get_excess()
Get the Excess of the function.
Usage
ExpertFunction$get_excess(u)
Method exposurize()
Exposurize the parameters, return a copy of the object with the updated parameters
Note this function will not change the parameters of the original object
Usage
ExpertFunction$exposurize(exposure = 1)
Arguments
exposure
(numeric)
The exposure applied to the parameters, default set to be 1
Simulate value based on distribution parameters
Usage
ExpertFunction$simulate(n = 1)
Arguments
n
(numeric)
The number of simulated values you want
Calculate the exact log likelihood of the Expert Distribution
Method ll_exact()
Usage
ExpertFunction$ll_exact(y)
Arguments
y
(numeric)
The observations from the preset expert distribution
Calculate the non-exact log likelihood of the Expert Distribution
Method ll_not_exact()
Usage
ExpertFunction$ll_not_exact(tl, yl, yu, tu)
Arguments
tl
(numeric)
A vector of length N: lower bounds of truncation.
yl
(numeric)
A vector of length N: lower bounds of censoring.
yu
(numeric)
A vector of length N: upper bounds of censoring.
tu
(numeric)
A vector of length N: upper bounds of truncation.
Method EM_notexact()
Perform the EM optimization with non-exact observations
Usage
ExpertFunction$EM_notexact(
expert_old,
tl,
yl,
yu,
tu,
exposure,
z_e_obs,
z_e_lat,
k_e,
penalty,
pen_params
)
Arguments
expert_old
Old expert function
tl
(numeric)
A vector of length N: lower bounds of truncation.
yl
(numeric)
A vector of length N: lower bounds of censoring.
yu
(numeric)
A vector of length N: upper bounds of censoring.
tu
(numeric)
A vector of length N: upper bounds of truncation.
exposure
A vector of length N: exposures for observations
z_e_obs
Calculated from E-step
z_e_lat
Calculated from E-step
k_e
Calculated from E-step
penalty
T/F: whether penalty is imposed
pen_params
A vector of penalty parameters
Method EM_exact()
Perform the EM optimization with exact observations
Usage
ExpertFunction$EM_exact(expert_old, ye, exposure, z_e_obs, penalty, pen_params)
Arguments
expert_old
Old expert function
ye
A vector of length N: exact observations
exposure
A vector of length N: exposures for observations
z_e_obs
Calculated from E-step
penalty
T/F: whether penalty is imposed
pen_params
A vector of penalty parameters
Method clone()
The objects of this class are cloneable with this method.
Usage
ExpertFunction$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
# p = ExpertFunction$new("poisson")
# p$continuous
# p$distribution
# Estimate the start parameters and get them
# p$initialize_params(c(1,12,2,3,4,6,7,7))
# p$get_params()
# Initialize the penalty using default penalty parameters and get them
# p$initialize_penalty()
# p$get_penalty()
# Without setiing parameters, the object will use preset parameters
# p$get_penalty_params()
# Exposurize function, this will not change the parameters of the ExpertFunction
# p$exposurize(2)
# Calculate the loglikelihood by two methods
# p$ll_exact(5)
# p$ll_not_exact(1,1,2,2)