Description Usage Arguments Details Value See Also Examples
View source: R/flatten_ml_fit_problem.R
This function transforms a multi-level fitting problem to a representation more suitable for applying the algorithms: A matrix with one row per controlled attribute and one column per household, a weight vector with one weight per household, and a control vector.
1 2 3 4 5 6 7 | flatten_ml_fit_problem(
ml_problem,
model_matrix_type = c("combined", "separate"),
verbose = FALSE
)
as_flat_ml_fit_problem(x, model_matrix_type = c("combined", "separate"), ...)
|
ml_problem |
A fitting problem created by
|
model_matrix_type |
Which model matrix building strategy to use? See details. |
verbose |
If |
x |
An object |
... |
Further parameters passed to the algorithm |
The standard way to build a model matrix (model_matrix = "combined"
)
is to include intercepts and avoid repeating redundant attributes.
A simpler model matrix specification, available via model_matrix = "separate"
,
is suggested by Ye et al. (2009) and required for the ml_fit_ipu()
implementation:
Here, simply one column per target value is used, which
results in a larger model matrix if more than one control is given.
An object of classes flat_ml_fit_problem
,
essentially a named list.
1 2 3 4 5 6 7 | path <- toy_example("Tiny")
flat_problem <- flatten_ml_fit_problem(ml_problem = readRDS(path))
flat_problem
fit <- ml_fit_dss(flat_problem)
fit$flat_weights
fit$weights
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.