Learn R Programming

RCPA3 (version 1.3.1)

wtd.var: Calculates Variance of Variable With Option for Weights

Description

Takes in variable and calculates its variance, works with sampling weights. Makes use of the wtd.var function from the Hmisc package. See wtd.stats documentation for details.

Usage

wtd.var(x, w = NULL, data, digits = 3, ...)

Value

Returns the variance of the variable, a numeric value.

Arguments

x

A variable (must be numeric), should be in dataset$var form unless dataset specified in optional data argument.

w

(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains x (and w) variable.

digits

(Optional) Number of decimal places reported in result (defaults to 3).

...

(Optional) Additional arguments passed to Hmisc::wtd.var function.

Examples

Run this code
   library(RCPA3)
   
   wtd.var(x=nes$ft.socialists, w=nes$wt)
   wtd.var(x=nes$ft.socialists)

Run the code above in your browser using DataLab