Learn R Programming

rifreg (version 1.1.0)

check_weights: 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)

Value

positive numeric vector of length(dep_var)

containing the checked weights. If weights = NULL, all weights are set to 1.

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.

Examples

Run this code

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)

Run the code above in your browser using DataLab