View source: R/micro2intData.r
| micro2intData | R Documentation |
Aggregates microdata from a data frame into interval-valued data using various criteria and latent distribution settings.
micro2intData(
microdata,
agrby,
agrcrt = "minmax",
LatentParam = NULL,
LatentCase = c("U_id_symmetric", "U_id", "General"),
LatentDist = c("Unif", "Triang", "TNorm", "InvTri", "Beta", "KDE", "Degenerated"),
TriangParam = 0,
BetaParam.a = 1,
BetaParam.b = 1,
estimate.DistParam = FALSE,
removeDegenerate = FALSE
)
microdata |
A data frame containing the microdata. All columns should be numeric. |
agrby |
A factor used to specify the grouping of the microdata for aggregation. |
agrcrt |
A string or numeric vector of length 2 specifying the aggregation criterion. The default is |
LatentParam |
(Optional) A list with the parameters of the latent variables.
Expects a list with a single number if
|
LatentCase |
A string specifying which of the three scenarios applies to the latent variables:
Defaults to |
LatentDist |
A string or vector of strings specifying the distribution(s) of the latent variables. If the variables are identically distributed it can be one of ( |
TriangParam |
Mode of the triangular distribution. If the latent variables are identically distributed, it is only necessary to provide a number, if not a vector is needed.
The default is |
BetaParam.a |
Parameter alpha of the Beta distribution. If the latent variables are identically distributed, it is only necessary to provide a number, if not a vector is needed.
The default is |
BetaParam.b |
Parameter beta of the Beta distribution. If the latent variables are identically distributed, it is only necessary to provide a number, if not a vector is needed.
The default is |
estimate.DistParam |
Logical parameter indicating if estimation of the parameters of the latent distributions should be performed in the case of triangular or Beta distributions.
Can only be set to TRUE if |
removeDegenerate |
Logical parameter indicating if observations with at least one degenerate interval should be removed. The default is |
This function processes a data frame of microdata and aggregates it into interval-valued data according to the specified grouping factor and aggregation criteria. It can handle different latent distribution cases and parameter settings.
If some rows contain invalid (non-finite or missing) values, those rows are removed before aggregation. Degenerate intervals (i.e., intervals whose lower and upper bounds are equal) can be removed by setting removeDegenerate to TRUE.
An intData object containing the aggregated interval-valued data. If removeDegenerate is TRUE, observations with degenerate intervals are removed, and NULL is returned if all observations are removed.
Adapted from package MAINT.Data (https://cran.r-project.org/package=MAINT.Data).
data(creditcard)
CreditCard_microdata <- creditcard$microdata
# Define grouping variable for microdata aggregation
credit_agrby <- factor(paste(CreditCard_microdata$Name, CreditCard_microdata$Month, sep = "_"))
# Create intData object by aggregating microdata using the default minmax criterion
# and using KDE for estimation of the latent distribution in the general case
credit_agr <- micro2intData(CreditCard_microdata[,3:7],
agrby = credit_agrby,
LatentCase = "General")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.