check_weights: Check weights

View source: R/check_weights.R

check_weightsR Documentation

Check weights

Description

Helper function to check a weights vector. Makes sure the weights are positive numeric values (not all zeros) and of the same length as the dependent variable dep_var. Replaces all NAs with 0 and sets all weights to 1 if weights is set to NULL.

Usage

check_weights(dep_var, weights)

Arguments

dep_var

dependent variable of distributional function. Can be any discrete or continuous vector of length 1 or more.

weights

positive numeric vector of length(dep_var) containing the weights or NULL.

Value

positive numeric vector of length(dep_var) containing the checked weights. If weights = NULL, all weights are set to 1.

Examples


dep_var <- c(1, 3, 9, 16, 3, 7, 4, 9)
weights <- c(2, 1, 3, 4, 4, 1, 6, 3)
check_weights(dep_var, weights)


rifreg documentation built on June 21, 2025, 5:08 p.m.