ExpertFunction | R Documentation |
This is the base class for Expert Functions. Users are expected to interact with ExpertFunction
to perform all the computations.
distribution
(character
)
The distribution name specified by the user.
continuous
(logical
)
Given distribution is continuous or not, default set to be TRUE
.
new()
Create a new ExpertFunction Class
ExpertFunction$new(distribution, params = list(), penalty_params = list())
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
initialize_penalty()
Prerequisite: self$params and self$penalty_params need to be set. Otherwise will return the default penalty value.
ExpertFunction$initialize_penalty()
default
(logical
)
Use default penalty parameters if default is TRUE, else use user defined penalty parameters. Default set to be TRUE.
initialize_params()
Estimate all the parameters for this expert function based on observation
ExpertFunction$initialize_params(y)
y
(numeric
)
The observations from the preset expert distribution
default_penalty()
Set default hyper parameters
Set the parameters for the expert function
ExpertFunction$default_penalty()
set_params()
ExpertFunction$set_params(expert_params)
expert_params
(logical
)
The parameters for the given distribution.
Get the parameters for the expert function
get_params()
ExpertFunction$get_params()
params
(logical
)
The parameters for the given distribution.
Set the penalty parameters
If there are no expert_penalty_params given, use default penalty parameters.
set_penalty_params()
ExpertFunction$set_penalty_params(expert_penalty_params)
expert_penalty_params
(logical
)
The parameters for the given distribution. Could be preset by users or postset by running ExpertFunction$initialize_params(observations)
get_penalty_params()
Get the penalty parameters
ExpertFunction$get_penalty_params()
get_penalty()
Get the penalty value, penalty value cannot be set. It can only been initialized.
ExpertFunction$get_penalty()
get_mean()
Get mean of this expert function
ExpertFunction$get_mean()
get_variance()
Get variance of this expert function
ExpertFunction$get_variance()
get_cdf()
Get the cdf of this expert function given RV
ExpertFunction$get_cdf(q)
q
The value of random variable
get_logcdf()
Get the logcdf of this expert function given RV
ExpertFunction$get_logcdf(q)
q
The value of random variable
get_pdf()
Get the pdf of this expert function given RV
ExpertFunction$get_pdf(x)
x
The value of random variable
get_logpdf()
Get the logpdf of this expert function given RV
ExpertFunction$get_logpdf(x)
x
The value of random variable
get_quantile()
Get the quantile of this expert function given probability
ExpertFunction$get_quantile(p)
p
The probability
get_lev()
Get the Limited Expected Value of the expert function.
ExpertFunction$get_lev(u)
u
(numeric
)
get_excess()
Get the Excess of the function.
ExpertFunction$get_excess(u)
u
(numeric
)
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
ExpertFunction$exposurize(exposure = 1)
exposure
(numeric
)
The exposure applied to the parameters, default set to be 1
simulate()
Simulate value based on distribution parameters
ExpertFunction$simulate(n = 1)
n
(numeric
)
The number of simulated values you want
Calculate the exact log likelihood of the Expert Distribution
ll_exact()
ExpertFunction$ll_exact(y)
y
(numeric
)
The observations from the preset expert distribution
Calculate the non-exact log likelihood of the Expert Distribution
ll_not_exact()
ExpertFunction$ll_not_exact(tl, yl, yu, tu)
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.
EM_notexact()
Perform the EM optimization with non-exact observations
ExpertFunction$EM_notexact( expert_old, tl, yl, yu, tu, exposure, z_e_obs, z_e_lat, k_e, penalty, pen_params )
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
EM_exact()
Perform the EM optimization with exact observations
ExpertFunction$EM_exact(expert_old, ye, exposure, z_e_obs, penalty, pen_params)
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
clone()
The objects of this class are cloneable with this method.
ExpertFunction$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.