var_mean_indep {probstats4econ}R Documentation

Variance helper functions

Description

These functions help calculate the variance matrix of different kinds of samples. var_mean_indep creates an asymptotic covariance matrix for the sample means of a list of independent samples. var_prop_indep creates an asymptotic covariance matrix for the sample proportions of a list of independent samples. var_mean_onesample creates an asymptotic covariance matrix for the sample means of several variables from the same sample.

Usage

var_mean_indep(x_vectors)

var_mean_onesample(df, vars = names(df))

var_prop_indep(pi_hat, nobs)

Arguments

x_vectors

A list of vectors, representing the different independent samples.

df

A data.frame object

vars

A character vector of variable names in df.

pi_hat

A vector of sample proportions.

nobs

The sample size.

Value

A matrix, representing the asymptotic covariance matrix of the sample means.

Examples

# list of independent samples
x_vectors <- list(
  rnorm(1000, mean = 1, sd = 2),
  rnorm(10, mean = 4, sd = 0.5),
  rnorm(1000000, mean = 0, sd = 1)
)
var_mean_indep(x_vectors)

# sample proportions
pi_hat <- c(0.1, 0.6, 0.3)
nobs <- 1000
var_prop_indep(pi_hat, nobs)

# covariance of educ and age in cps dataset
var_mean_onesample(cps, c("educ", "age"))


[Package probstats4econ version 0.2.0 Index]