How to understand the weights from a survey design object in R? I often use the survey package to deal with the complex survey data in R. I know using the function weights() can extract the weights from the survey design object. I want to understand the process behind this function. Does it consider the design of this complex survey?
For example, I use the nhanes dataset.
nhanes <- svydesign(id = ~SDMVPSU, weights = ~WTMEC2YR, 
                    strata = ~ SDMVSTRA, data = nhanes_full, 
                    nest = TRUE)
wt <- weights(nhanes)

Is wt calculated from WTMEC2YR and SDMVSTRA?

TL;DR: No it just returns the individual weights.
The rationale for weights is to make sample observations representative of the population. Weights are usually individual or person-weights (aka p-weights) that care for the distribution in the population (e.g. age, sex). PSU-IDs denote primary sampling units, usually households, where observations are expected to be more similar within these PSUs than between. Finally, PSUs might be classified in strata of specific characteristics, e.g. specific region, migration. Functions like R's svydesign (or similarly Stata's svyset) bring all this information together in a survey.design object which can be used for regression in svyglm(..., design=<survey.design>).
The survey:::weights.survey.design method, however, calculates the inverse of the probability of being included in the sample, previously calculated by svydesign,
$$ w_i = \frac{1}{P_i}$$
so in the end, it just returns the original weights specified in the svydesign(., weights=) argument. Thus, information of PSU, and strata will not be used.
library(survey)
data('NHANESraw', package='NHANES')
nhanes <- svydesign(id=~SDMVPSU, weights=~WTMEC2YR, strata=~SDMVSTRA,
                    data=NHANESraw, nest=TRUE)


all.equal(unname(weights(nhanes)), NHANESraw$WTMEC2YR)
# [1] TRUE


Data available:
data('NHANESraw', package='NHANES')

