Last chance! 50% off unlimited learning
Sale ends in
Calculate, extract or set normalized model likelihoods (‘Akaike weights’).
Weights(x)
Weights(x) <- value
For the extractor, a numeric vector of normalized likelihoods.
a numeric vector of any information criterion (such as
AIC, AICAIC
. There are also methods for extracting ‘Akaike weights’ from
"model.selection"
or "averaging"
objects.
numeric, the new weights for the "averaging"
object or
NULL
to reset the weights based on the original IC used.
The assigned value
need not sum to one, but if they are all zero, the
result will be invalid (NaN
).
Kamil Bartoń
‘Akaike weights’,
where
The replacement version of Weights
can assign new weights to an
"averaging"
object, affecting coefficient values and the order of
component models. Upon assignment, the weights are normalised to sum to one.
sw
, weighted.mean
armWeights
,
bootWeights
, BGWeights
, cos2Weights
,
jackknifeWeights
and stackingWeights
can be used to
produce various kinds of model weights.
Not to be confused with weights
, which extracts fitting weights
from model objects.
fm1 <- glm(Prop ~ dose, data = Beetle, family = binomial)
fm2 <- update(fm1, . ~ . + I(dose^2))
fm3 <- update(fm1, . ~ log(dose))
fm4 <- update(fm3, . ~ . + I(log(dose)^2))
round(Weights(AICc(fm1, fm2, fm3, fm4)), 3)
am <- model.avg(fm1, fm2, fm3, fm4, rank = AICc)
coef(am)
# Assign equal weights to all models:
Weights(am) <- rep(1, 4) # assigned weights are rescaled to sum to 1
Weights(am)
coef(am)
# Assign dummy weights:
wts <- c(2,1,4,3)
Weights(am) <- wts
coef(am)
# Component models are now sorted according to the new weights.
# The same weights assigned again produce incorrect results!
Weights(am) <- wts
coef(am) # wrong!
#
Weights(am) <- NULL # reset to original model weights
Weights(am) <- wts
coef(am) # correct
Run the code above in your browser using DataLab