sample_size: Sample size calculations.

View source: R/utils.R

sample_sizeR Documentation

Sample size calculations.

Description

The unweighed sample size is the number of non-missing elements in x. The weighted sample size is the sum of the weights for the complete cases in x and w. The effective sample size is (sum(w)^2) / sum(w^2).

Usage

sample_size(x, w, type = "u")

Arguments

x

A vector.

w

A vector of weights.

type

One of "u" for unweighted, "w" for weighted, "e" effective, or "all" for all three.

Value

Either a single numeric value, or a named vector if type = "all".

Examples

x <- 1:3
w <- c(0.75, 1.00, 1.25)

sample_size(x, w, type = "u")
sample_size(x, w, type = "w")
sample_size(x, w, type = "e")
sample_size(x, w, type = "all")


ttrodrigz/iterake documentation built on March 27, 2024, 12:48 a.m.