Learn R Programming

refitME (version 1.3.1)

wt.var: Function that calculates a weighted variance

Description

This function that calculates a weighted variance for a given vector.

Usage

wt.var(x, w)

Value

wt.var returns a single value from analysis requested.

Arguments

x

: a vector of numerical data.

w

: a vector of equal length to x representing the weights.

Examples

Run this code
# Define simple data
x = 1:25 # Set of numbers.
wt = runif(25) # Some arbitrary weights.

# Display variances (unweighted and then weighted).
var(x)
wt.var(x, wt)

Run the code above in your browser using DataLab