@envisim/estimate

0.1.1 • Public • Published

npm package

@envisim/estimate

A TypeScript library that provides functionality for estimating various parameters.

This package provides various statistical estimators, often used in conjunction with sampling designs from @envisim/sampling.

Installation

npm install @envisim/estimate

Usage

The Horvitz-Thompson (HT) estimator is used to estimate the population total of a variable when units are sampled with unequal inclusion probabilities.

The formula is:

\hat{Y}_{HT} = \sum_{i \in S} \frac{y_i}{\pi_i} ,

where $S$ is the set of sampled units, $y_i$ is the value of the variable of interest for unit $i$, and $\pi_i$ is the inclusion probability of unit $i$.

import { horvitzThompson } from "@envisim/estimate";

// Example data from a sample (S)
const y = [10, 15, 8, 12]; // y_i values for the sampled units
const p = [0.2, 0.3, 0.1, 0.25]; // pi_i values for the sampled units

// Calculate the Horvitz-Thompson estimate of the population total
// Expected output: (10/0.2) + (15/0.3) + (8/0.1) + (12/0.25) = 50 + 50 + 80 + 48 = 228
horvitzThompson(y, p);

Package Sidebar

Install

npm i @envisim/estimate

Homepage

envisim.se

Weekly Downloads

77

Version

0.1.1

License

AGPL-3.0-only

Unpacked Size

56 kB

Total Files

13

Last publish

Collaborators

  • wpmg