https://github.com/cran/MuMIn
Tip revision: 4b49b56bb9ac3e480120119fbc1e69bba4f82259 authored by Kamil BartoĊ on 18 October 2013, 17:09:54 UTC
version 1.9.11
version 1.9.11
Tip revision: 4b49b56
Weights.R
# Calculate Akaike weights
`Weights` <-
function(x) UseMethod("Weights")
`Weights.model.selection` <-
function(x) x[, "weight"] / sum(x[, "weight"])
`Weights.averaging` <-
function(x) x$summary$Weight
`Weights.data.frame` <-
function(x) {
if(ncol(x) == 2L && colnames(x)[1L] == "df" && is.numeric(x[, 2L]))
return(Weights.default(x[, 2L]))
if(ncol(x) == 1L && is.numeric(x[, 1L]))
return(Weights.default(x[, 1L]))
return(NA)
}
`Weights.default` <-
function(x) {
delta <- x - min(x)
weight <- exp(-delta / 2) / sum(exp(-delta / 2))
return (weight)
}