February 9, 2026 11:39 pm

The Standard Error (SE) is a statistical measure that estimates the variability or precision of a sample statistic (such as the mean, regression coefficients, or proportions) relative to the true population parameter. It quantifies how much a sample statistic is expected to fluctuate due to random sampling variation.

Formula (for the mean):

Where:

  • σ = population standard deviation (use sample SD s if σ is unknown).
  • n = sample size.

SE vs. Standard Deviation (SD):

  • SD: Measures variability in raw data.
  • SE: Measures variability of a sample statistic (e.g., mean).

Key Types

  1. Standard Error of the Mean (SEM) – Measures how far the sample mean (average) is likely to be from the true population mean.
  2. Standard Error of Regression Coefficients – Indicates the precision of slope and intercept estimates in regression models.
  3. Standard Error of Proportions – Used for categorical data to measure variability in sample proportions.

1. Standard Error of the Mean (SEM)

The SEM tells us how well the sample mean approximates the population mean.

Formula:

where:

  • σ = population standard deviation
  • s = sample standard deviation
  • n = sample size

Interpretation:

  • smaller SEM means the sample mean is a more precise estimate of the population mean.
  • larger SEM indicates more uncertainty due to small sample size or high variability.

2. Standard Error of Regression Coefficients (SE of Slope/Intercept)

In regression (Y=a+bX+ϵ), the SE of the slope (b) and intercept (a) measures their reliability.

Formula (for slope b):

where:

  • Yi = actual value
  • Y^i= predicted value
  • n= sample size
  • Xˉ = mean of X

Use in Hypothesis Testing:

  • The t-statistic for testing if a slope is significant is
  • small SE means higher confidence in the coefficient estimate.

3. Standard Error of Proportions

For a sample proportion (p^), the SE measures how much it varies from the true population proportion (p).

Formula:

Example:

If 60% of a sample (n=100) prefers Brand A, the SE is: SE=0.6 × 0.4100=0.0024≈0.049 (4.9%)

Implementation in Python:

without Libraries:

import math

def mean(data):
    return sum(data) / len(data)

def standard_deviation(data):
    m = mean(data)
    variance = sum((x - m) ** 2 for x in data) / (len(data) - 1)
    return math.sqrt(variance)

def standard_error(data):
    sd = standard_deviation(data)
    n = len(data)
    return sd / math.sqrt(n)

# Example usage:
data = [10, 12, 13, 12, 11, 14, 13]
print("Standard Error:", standard_error(data))

Library version:

from scipy import stats

data = [10, 12, 13, 12, 11, 14, 13]
sem = stats.sem(data)
print("Standard Error:", sem)

What is Robust Standard Error:

Robust standard errors (also called heteroskedasticity-consistent standard errors) are used in regression analysis to provide reliable estimates even when the model’s assumptions (like constant variance of errors, i.e., homoskedasticity) are violated.

Key Features:

  1. Purpose:
    • Corrects for heteroskedasticity (uneven variance in residuals).
    • Provides valid inference (confidence intervals, hypothesis tests) when traditional OLS standard errors are biased.
  2. When to Use:
    • Data exhibits non-constant variance (e.g., residuals fan out as predictions increase).
    • Outliers or heavy-tailed distributions are present.
    • Applied in linear regressiongeneralized linear models (GLM), and panel data.
  3. Types of Robust SEs:
    • HC0: Basic White (1980) estimator (original robust SE).
    • HC1: Adjusts for degrees of freedom (default in many software packages).
    • HC2: Better for small samples.
    • HC3: More conservative, performs well with outliers (recommended by many).

Python Implementation for Robust Standard Error:

import statsmodels.api as sm
import numpy as np

# Example data
X = np.array([1, 2, 3, 4, 5])
y = np.array([1, 2, 1.3, 3.75, 2.25])

# Add constant term for intercept
X = sm.add_constant(X)

# Fit OLS regression
model = sm.OLS(y, X).fit()

# Get robust (HC1) standard errors
robust_se = model.get_robustcov_results(cov_type='HC1')

# Print robust standard errors
print("Robust standard errors:", robust_se.bse)
print(robust_se.summary())

Hope you found this post helpful 🙂

Discover more from SolutionShala

Subscribe now to keep reading and get access to the full archive.

Continue reading