rkMeta_to_blSpecs {gseries} | R Documentation |
Convert reconciliation metadata
Description
(version française: https://StatCan.github.io/gensol-gseries/fr/reference/rkMeta_to_blSpecs.html)
Convert a tsraking()
metadata data frame to a tsbalancing()
problem specs data frame.
Usage
rkMeta_to_blSpecs(
metadata_df,
alterability_df = NULL,
alterSeries = 1,
alterTotal1 = 0,
alterTotal2 = 0,
alterability_df_only = FALSE
)
Arguments
metadata_df |
(mandatory) Data frame (object of class "data.frame") that describes the cross-sectional aggregation constraints
(additivity rules) for the raking problem. Two character variables must be included in the metadata data frame:
|
alterability_df |
(optional) Data frame (object of class "data.frame"), or Default value is |
alterSeries |
(optional) Nonnegative real number specifying the default alterability coefficient for the component series values. It
will apply to component series for which alterability coefficients have not already been specified in the
alterability coefficients data frame (argument Default value is |
alterTotal1 |
(optional) Nonnegative real number specifying the default alterability coefficient for the 1st dimension
cross-sectional control totals. It will apply to cross-sectional control totals for which alterability
coefficients have not already been specified in the alterability coefficients data frame (argument
Default value is |
alterTotal2 |
(optional) Nonnegative real number specifying the default alterability coefficient for the 2nd dimension
cross-sectional control totals. It will apply to cross-sectional control totals for which alterability
coefficients have not already been specified in the alterability coefficients data frame (argument
Default value is |
alterability_df_only |
(optional) Logical argument specifying whether or not only the set of alterability ceofficients found in the alterability
file (argument Default value is |
Details
The preceding description of argument alterability_df
comes from tsraking()
. This function
(rkMeta_to_blSpecs()
) slightly changes the specification of alterability coefficients with argument
alterability_df
by allowing either
a single observation, specifying the set of alterability coefficients to use for all periods,
or one or several observations with an additional column named
timeVal
allowing the specification of both period-specific alterability coefficients (timeVal
is notNA
) and generic coefficients to use for all other periods (timeVal
isNA
). Values for columntimeVal
correspond to the time values of a "ts" object as returned bystats::time()
, conceptually corresponding toyear + (period - 1) / frequency
.
Another difference with tsraking()
is that missing (NA
) values are allowed in the alterability coefficients
data frame (argument alterability_df
) and result in using the generic coefficients (observations for which
timeVal
is NA
) or the default coefficients (arguments alterSeries
, alterTotal1
and alterTotal2
).
Note that apart from discarding alterability coefficients for series not listed in the tsraking()
metadata
data frame (argument metadata_df
), this function does not validate the values specified in the alterability
coefficients data frame (argument alterability_df
) nor the ones specified with column alterAnnual
in the
tsraking()
metadata data frame (argument metadata_df
). The function transfers them as is in the
returned tsbalancing()
problem specs data frame.
Value
A tsbalancing()
problem specs data frame (argument problem_specs_df
).
See Also
Examples
# `tsraking()` metadata for a 2-dimensional raking problem (2 x 2 table)
my_metadata <- data.frame(series = c("A1", "A2", "B1", "B2"),
total1 = c("totA", "totA", "totB", "totB"),
total2 = c("tot1", "tot2", "tot1", "tot2"))
my_metadata
# Convert to `tsbalancing()` specifications
# Include the default `tsraking()` alterability coefficients
rkMeta_to_blSpecs(my_metadata)
# Almost binding 1st marginal totals (small alter. coef for columns `totA` and `totB`)
tail(rkMeta_to_blSpecs(my_metadata, alterTotal1 = 1e-6))
# Do not include alterability coefficients (aggregation constraints only)
rkMeta_to_blSpecs(my_metadata, alterability_df_only = TRUE)
# With an alterability coefficients file (argument `alterability_df`)
my_alter = data.frame(B2 = 0.5)
tail(rkMeta_to_blSpecs(my_metadata, alterability_df = my_alter))
# Only include the alterability coefficients from `alterability_df`
# (i.e., for column `B2` only)
tail(rkMeta_to_blSpecs(my_metadata, alterability_df = my_alter,
alterability_df_only = TRUE))