get_opt_weights {COINr} | R Documentation |
Weight optimisation
Description
This function provides optimised weights to agree with a pre-specified vector of "target importances".
Usage
get_opt_weights(
coin,
itarg = NULL,
dset,
Level,
cortype = "pearson",
optype = "balance",
toler = NULL,
maxiter = NULL,
weights_to = NULL,
out2 = "list"
)
Arguments
coin |
coin object |
itarg |
a vector of (relative) target importances. For example, |
dset |
Name of the aggregated data set found in |
Level |
The aggregation level to apply the weight adjustment to. This can only be one level. |
cortype |
The type of correlation to use - can be either |
optype |
The optimisation type. Either |
toler |
Tolerance for convergence. Defaults to 0.1 (decrease for more accuracy, increase if convergence problems). |
maxiter |
Maximum number of iterations. Default 500. |
weights_to |
Name to write the optimised weight set to, if |
out2 |
Where to output the results. If |
Details
This is a linear version of the weight optimisation proposed in this paper: doi:10.1016/j.ecolind.2017.03.056. Weights are optimised to agree with a pre-specified vector of "importances". The optimised weights are returned back to the coin.
See vignette("weights")
for more details on the usage of this function and an explanation of the underlying
method. Note that this function calculates correlations without considering statistical significance.
This function replaces the now-defunct weightOpt()
from COINr < v1.0.
Value
If out2 = "coin"
returns an updated coin object with a new set of weights in .$Meta$Weights
, plus
details of the optimisation in .$Analysis
.
Else if out2 = "list"
the same outputs (new weights plus details of optimisation) are wrapped in a list.
Examples
# build example coin
coin <- build_example_coin(quietly = TRUE)
# check correlations between level 3 and index
get_corr(coin, dset = "Aggregated", Levels = c(3, 4))
# optimise weights at level 3
l_opt <- get_opt_weights(coin, itarg = "equal", dset = "Aggregated",
Level = 3, weights_to = "OptLev3", out2 = "list")
# view results
tail(l_opt$WeightsOpt)
l_opt$CorrResultsNorm