Skip to contents

Extract the (fitting) weights from a “model” object

Usage

# S3 method for model
weights(object, ...)

Arguments

object

A “model” object.

...

Currently not used.

Value

Returns either a vector of weights or NULL.

See also

Examples

# Simulate data
set.seed(314159)
n <- 50
x <- rnorm(n)
w <- runif(n)
y <- x + rnorm(n)/sqrt(w)

# Weighted lm
mymodel <- model(lm(y~x, weights = w))

# Extract weights
weights(mymodel)
#>  [1] 0.616979080 0.448061164 0.339249190 0.765733340 0.902529915 0.170293750
#>  [7] 0.215506481 0.708476310 0.658423500 0.106406077 0.699817682 0.336702210
#> [13] 0.971562987 0.738613351 0.188098839 0.807358315 0.108103753 0.639530915
#> [19] 0.929791097 0.260112991 0.432363673 0.437570636 0.138395336 0.679279183
#> [25] 0.955625676 0.851648425 0.614217912 0.167567696 0.138068559 0.939057660
#> [31] 0.519199798 0.702348737 0.473862721 0.001528634 0.440513609 0.545426817
#> [37] 0.090390960 0.091366257 0.591672173 0.130695508 0.639025257 0.945186972
#> [43] 0.525592272 0.701906522 0.020342527 0.230885630 0.985840238 0.597736365
#> [49] 0.210308769 0.251103677