Open navigation
OpenOpen workspace

Modelling survey data

Regression on survey data: linear and logistic

Use linear regression when the survey outcome is numeric (spend, a 0–10 score) and logistic regression when it is yes/no (bought, would recommend). In linear regression, B is the change in the outcome per unit of a predictor with the others held fixed; in logistic regression, Exp(B) is the odds ratio per unit. Survey weights belong in the coefficients when you describe a population, but ordinary weighted standard errors are wrong for sampling weights: use a design-based (complex samples) procedure for p-values and confidence intervals.

Published by crosstabs.com · Last updated ·
How results are checkedNamed statistical review pending. Selected automated reference cases are published on the validation page.

Choosing the model

The outcome decides the model. A numeric outcome with roughly symmetric residuals suits linear regression (ordinary least squares). A two-category outcome suits binary logistic regression; three or more unordered categories call for multinomial logistic regression, and ordered categories (low, medium, high) for ordinal regression.

Predictors can be numeric or categorical. Categorical predictors enter as dummy (indicator) variables against a reference category, and each coefficient compares one category with that reference.

What survey weights do, and do not do

There are different kinds of weight. A frequency weight says a row stands for that many identical cases, and ordinary inference with the weighted count as n is correct. A sampling (survey) weight corrects for unequal selection or non-response so estimates describe the population. Applied to a regression, a sampling weight changes the coefficients towards the population relationship, but standard regression software then computes standard errors as if the weights were frequencies or precision weights. Those standard errors are wrong, often too small, and they ignore stratification and clustering.

The defensible practice is to report weighted coefficients, and to get standard errors, tests and intervals from a design-based procedure (Taylor linearisation or replicate weights) that knows the weights, strata and clusters. If the unweighted and weighted coefficients differ a lot, that is itself a finding: the relationship differs between the over- and under-represented groups, and a model with those groups as predictors may be more informative.

The method

Formula

Definition

Linear: y = b₀ + b₁x₁ + … + bkxk + e · Betaj = bj × sxj / sy
Logistic: log[p / (1 − p)] = b₀ + b₁x₁ + … + bkxk · odds ratioj = ebj

where

b_j
change in y (linear) or in the log-odds (logistic) per unit of x_j, other predictors fixed
s
standard deviations (weighted when a weight is used)
p
probability of the event (the outcome coded 1)
Weights
weighted estimates minimise Σ wᵢ eᵢ² (linear) or maximise Σ wᵢ log Lᵢ (logistic, pseudo-likelihood); design-based standard errors need strata, clusters and weights

Worked example

Worked example

Sample data: the synthetic shopper survey that the free latent class tool loads with “Use sample data” (900 generated respondents, not real people, with a survey weight column). Both models use brand loyalty and price sensitivity (each rated 1–5) as predictors and are run with the same procedures as the workspace's Statistics mode.

Linear regression of monthly grocery spend (780 complete respondents, unweighted): spend = 447.24 + 35.33 × loyalty − 26.81 × price sensitivity, R² = 0.182. Each extra point of brand loyalty goes with 35.33 more spend per month (SE 4.25, t = 8.31, 95% CI 26.99 to 43.67), holding price sensitivity fixed; each point of price sensitivity goes with 26.81 less (t = −6.74). The standardised Betas, 0.287 and −0.232, put the two on a common scale. The model explains 18.2% of the variation in spend: real, but most of what drives spend is elsewhere.

Logistic regression of buying organic (781 respondents, 276 who buy organic): Exp(B) for loyalty is 1.44 (95% CI 1.27 to 1.64), so each loyalty point multiplies the odds of buying organic by 1.44; for price sensitivity it is 0.67 (0.59 to 0.75), about a third lower odds per point. Nagelkerke R² is 0.192 and the model classifies 70.0% of respondents correctly at a 0.5 cut-off.

With the survey weight declared as a sampling weight, the coefficients move only slightly (loyalty B 34.04, price sensitivity B −26.10; odds ratios 1.45 and 0.67), because this weight is mild. What changes is what the procedure is willing to report: it gives the weighted point estimates but withholds every standard error, test and interval, because ordinary least-squares and maximum-likelihood inference is not valid under a sampling design. For those, use the Complex Samples procedures with the design declared.

Using it well

When to use it

Use it when

  • Use: Estimating how an outcome changes with one predictor while holding others fixed.
  • Use: Testing whether a block of predictors adds explanatory power beyond controls.
  • Use: Adjusted comparisons between groups (for example, region differences controlling for age).

Not the right tool when

  • Avoid: Ranking many correlated satisfaction drivers by importance: use relative importance (Shapley or relative weights).
  • Avoid: Reading p-values from an ordinary weighted regression on sampling-weighted data: use complex samples procedures.
  • Avoid: Claiming causal effects from cross-sectional survey data; regression adjusts for measured variables only.
  • Avoid: Very rare events or a predictor that perfectly separates the outcome: logistic estimates become unstable.

How to interpret it

Rule of thumb

Report each coefficient with its unit, its confidence interval and the model base. A significant coefficient in a model with a small R² can still be practically minor; an odds ratio is a change in odds, not in probability.

Next step: run the regression in the workspace

In the free workspace, Statistics mode runs linear regression (Enter, stepwise, forward and backward blocks, R² change, B with confidence intervals, Beta, VIF and residual diagnostics) and binary logistic regression (omnibus tests, Nagelkerke R², Hosmer–Lemeshow, classification table and odds ratios with intervals) on your own file, in your browser.

A declared frequency weight gives SPSS-style weighted results. A declared sampling weight gives weighted point estimates only, with tests withheld. For design-based inference, declare the strata, clusters and weight and use Complex Samples GLM or Complex Samples logistic regression.

Questions

Frequently asked questions

Should I use survey weights in a regression?

If you want estimates that describe the population the weights target, yes, for the coefficients. But the ordinary standard errors and p-values from a weighted regression treat the weights as if they were repeated cases or precision weights, which is wrong for sampling weights. Use a design-based (complex samples) procedure that takes the weights, strata and clusters into account for inference.

What is the difference between B and Beta?

B is the change in the outcome per one-unit change in the predictor, in the outcome's units, holding the other predictors fixed. Beta is the same coefficient after standardising every variable, so it is the change in standard deviations of the outcome per standard deviation of the predictor; it is useful for comparing predictors measured on different scales within one model.

How do I interpret an odds ratio from logistic regression?

Exp(B) is the factor by which the odds of the outcome multiply for a one-unit increase in the predictor, holding the others fixed. An odds ratio of 1.44 means 44% higher odds per unit; 0.67 means one third lower odds. Odds ratios are not risk ratios: when the outcome is common, the change in probability is smaller than the change in odds.

When should I use logistic instead of linear regression?

When the outcome is yes/no (bought or not, churned or not, top box or not). Linear regression on a 0/1 outcome can predict probabilities below 0 or above 1 and has non-constant error variance; logistic regression models the log-odds and keeps predictions between 0 and 1.

Can I treat a 1–5 rating as a numeric predictor?

Often, if the categories are roughly evenly spaced and the relationship looks linear; then B is the change per scale point. If the effect is clearly non-linear or the scale has few points, enter it as a categorical predictor with dummy coding instead and compare the fit.

Sources and next steps

References & further reading

  1. [1]DuMouchel, W. H., & Duncan, G. J. (1983). Using sample survey weights in multiple regression analyses of stratified samples. Journal of the American Statistical Association, 78(383), 535–543.
  2. [2]Solon, G., Haider, S. J., & Wooldridge, J. M. (2015). What are we weighting for? Journal of Human Resources, 50(2), 301–316.
  3. [3]Lumley, T. (2010). Complex Surveys: A Guide to Analysis Using R. Wiley.
  4. [4]Hosmer, D. W., Lemeshow, S., & Sturdivant, R. X. (2013). Applied Logistic Regression (3rd ed.). Wiley.

Try it on your own data — free, no signup

Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.

Open the workspace →

← All calculators & guides