Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Estimating population parameters with a simple survey design #60

@michaelwalshe

Description

@michaelwalshe

Hi,

I can't seem to find a way to estimate the correct population parameters with a survey that has just a finite population correction. Although it calculates the mean correctly it leads to an incorrect SE (using the API dataset from the R survey package, attached here: apisrs.csv). I believe the issue (from looking at the results in R) is that it should treat the data as having n_psus = fpc? Thank you for any help you can provide!

from samplics import TaylorEstimator
from samplics.utils.types import PopParam

apisrs = pd.read_csv("data/apisrs.csv")

estimator = TaylorEstimator(PopParam.mean)

estimator.estimate(
    y=apisrs["growth"],
    samp_weight=apisrs["pw"],
    fpc=float(apisrs["fpc"][0]),
)

print(estimator)
SAMPLICS - Estimation of Mean

Number of strata: 1
Number of psus: 200
Degree of freedom: 199

 MEAN         SE         LCI        UCI       CV
 31.9 167.248257 -297.906295 361.706295 5.242892

Compare this to R:

library(survey)

data("api")

srs_design <- svydesign(id = ~1, fpc = ~fpc, weights = ~pw, data = apisrs)

svymean(~growth, srs_design)
       mean     SE
growth 31.9 2.0905

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions