*! version 1.0.0

Title

genindweights -- Generate individual weights for standardization

Syntax

genindweights newvar [if] [in]
[, options]

agegroup(varname) name of age group variable

by(varlist) calculate weights separately by varlist

obsproportion(newvar) save observed proportions

refconditional(expression) reference weights defined by conditioning on data

refexternal(string) reference weights defined externally

refframe(framename) reference weights stored in frame

refproportion(framename) save reference proportion

saverefframe(newframename) save reference weights to new frame

stignore do not do survival data checks

nosummary do not display summary table

Description

genindweights calculate individual weights that are needed for standardization
to a reference population. It will commonly be used for age standardization of
(relative) survival (Rutherford et al. 2020), but can also be used more generally.
Individuals are upweighted or downweighted relative to a reference population.

The reference population can be defined in three different ways.

(1) Using the refexternal() option for known external weights, such as the international cancer survival standard (ICSS) weights.

(2) Using the refframe() option for weights stored in a frame.

(3) Using the refconditional() option for weights calculated on a subset of the data.

Options

agegroup(varname) specifies name of the variable that defines age groups.
This option is compulsory when using refexternal(),
but cannot be used when using refframe() or refconditional().

by(varlist) will calculate relative weights separately for each of the groups
defined by varlist.

obsproportion(newvarname) save the observed proportions in a new variable.

refconditional([exp], strata(varlist) defines the reference subpopulation based on expression exp.
For example, it is sometimes useful to age standardize to the most recent
calendar period when investigating time trends.
The strata() option is compulsory and gives the variables that defines the groups
to standardize over.

refexternal(external_weights) gives the name of the external weights used for age
standardization.

For the traditional ICSS five age groups (Corazziari {et al.} 2004) the weights, and correspnding options, are defined as follows:

| ICSS1_5 ICSS2_5 ICSS3_5
-------+

15-44 | 0.07 0.28 0.6
45-54 | 0.12 0.17 0.1
55-64 | 0.23 0.21 0.1
65-74 | 0.29 0.20 0.1
75+ | 0.29 0.14 0.1

Note that often the youngest group is defined for ages 18-44.

For the adapted ICSS five age group weights used in the NORDCAN survival studies (Lundberg et al. 2020),
the weights, and corresponding options, are defined as follows:

| ICSS1_5N ICSS2_5N
-------+

18-49 | 0.11906 0.36283
50-59 | 0.16735 0.18611
60-69 | 0.27593 0.22098
70-79 | 0.28897 0.16262
80+ | 0.14869 0.06746

Note that it is the responsibility of the user to define age groups appropriately.

refframe(framename, strata(varlist) refwtname(varname)) gives the name of the frame where external weights are stored.
The strata() option is compulsory and gives the variables that defines the groups
to standardize over. These variables must exist in both the active frame and the
frame containing the weights.
The refwtname() option gives the name of the variable containing the reference weights.
By default, this variable is named refp.

refproportion(newvarname) save the reference proportions in a new variable.

saverefframe(newframename), [replace refwtname(varname)) gives the name of a new frame to save the
external weights. This is useful when using the refconditional() option,
so that the weights can be applied to a different dataset.
The default name of the reference proportions is refp, but this can
be changed with the refwtname() option.

nosummary do not display summary table of weights.

stignore do not do survival analysis checks. Although genindweights was
originally developed for use with survival data, it is also potentially useful in other contexts,
so this option will omit any checks that data has been stset and _st=1.

Examples

The examples here show the use of individual weights for standardization of non-parametric estimates
of relative survival using stpp. However, these weights are useful in many contexts.
For example, when using regression standardization using standsurv.

You can run the code below without losing your data as each example is run
using preserve and restore.

Example 1

The refexternal() option uses some standard external reference weights.
In the example below the ICCS1 weights in 5 year age groups is used.
You need to define the age groups using the same definitions as used for ICSS1,
but note that this is the responsibility of the user.
The use of the by(sex) option in genindweights calculates the
reference weights separately in males and females.
This is necessary as the following stpp command calculates estimates
stratified by sex.

. use https://pclambert.net/data/colon.dta , clear

. stset surv_mm,f(status=1,2) id(id) scale(12)

// Form ICSS age groups

. recode age (min/44=1) (45/54=2) (55/64=3) (65/74=4) (75/max=5), gen(ICSSagegrp)

. genindweights wt1, by(sex) agegroup(ICSSagegrp) refexternal(ICSS1_5)

. stpp R_pp using "https://pclambert.net/data/popmort.dta", ///

agediag(age) datediag(dx) ///

pmother(sex) list(1 5 ) ///

by(sex) ///

indweights(wt1)

(click to run)

Example 2

This example illustrates the use of the refframe() option.
It will give identical estimates to Example 1, but the weights
are provided in a frame.

. use https://pclambert.net/data/colon.dta , clear

. stset surv_mm,f(status=1,2) id(id) scale(12)

// Form ICSS age groups

. recode age (min/44=1) (45/54=2) (55/64=3) (65/74=4) (75/max=5), gen(ICSSagegrp)

. frame create ageweights

. frame ageweights {

input ICSSagegrp wt

1 0.07

2 0.12

3 0.23

4 0.29

5 0.29

end

. }

// These are ICSS1 weights so will give same estimate as above

// strata gives the strata in the reference frame

. genindweights wt2, by(sex) ///

refframe(ageweights, strata(ICSSagegrp) wtname(wt))

. stpp R_pp using "https://pclambert.net/data/popmort.dta", ///

agediag(age) datediag(dx)text ///

pmother(sex) list(1 5)text ///

by(sex)text ///

indweights(wt2)

(click to run)

Example 3

This example illustrates the use of the refconditional() option.
The analysis age standardizes to the age distribution of males,
using 10 approximately equal sized age groups.
Note that the the reference probabilities are stratified by
the strata() suboption of refconditional() and the
observed probabilities are stratified by the by() option.
The individual weights are the ratio of reference/observed probabilities.

. use https://pclambert.net/data/colon.dta , clear

. stset surv_mm,f(status=1,2) id(id) scale(12)

. egen agegrp10 = cut(age), group(10)

. genindweights wt3, by(sex) refconditional(sex==1, strata(agegrp10))

. stpp R_pp using "https://pclambert.net/data/popmort.dta", ///

agediag(age) datediag(dx) ///

pmother(sex) list(1 5 ) ///

by(sex) ///

indweights(wt3)

(click to run)

Example 4

This example is similar to above, but shows use of the
obsproportion(), refproportion() and saverefframe() options.
The obsproportion() and refproportion() options
saves in new variables the observerved and reference proportions respectively.
The saverefframe() option saves the reference proportions in a new
frame. This can later be used in a new dataset using the refframe() option.

. use https://pclambert.net/data/colon.dta , clear

. stset surv_mm,f(status=1,2) id(id) scale(12)

. egen agegrp10 = cut(age), group(10)

. genindweights wt3, by(sex) refconditional(sex==1, strata(agegrp10)) ///

obsproportion(obsp) refproportion(refp) ///

saverefframe(age10ref)

. summ obsp refp

. frame age10ref: list, noobs abbrev(13)

(click to run)

Author

Paul C. Lambert

Cancer Registry of Norway

National Institute of Public Health

Oslo, Norway

and

Department of Medical Epidemiology and Biostatistics

Karolinska Institutet

Stockholm, Sweden

pclt@kreftregisteret.no

References

I. Corazziari, M. Quinn, R. Capocaccia.
Standard cancer patient population for age standardising survival ratios.
European Journal of Cancer 2004;40:2307-16.

F.E. Lundberg, T.M-L. Andersson, M. Lambe, G. Engholm, L. Steinrud Mørch, T.B. Johannesen, A. Virtanen,
D. Pettersson, E.J. Ólafsdóttir, H. Birgisson, A.L.V. Johansson, P.C Lambert.
Trends in cancer survival in the Nordic countries 1990-2016:the NORDCAN survival studies.
Acta Oncologica 2020;59:1266–1274

M. Pohar Perme, J. Stare, J. Estève. On estimation in relative survival.
Biometrics 2012;68:113-120

M.J. Rutherford, P.W. Dickman, E. Coviello, P.C. Lambert. Estimation of age-standardized net survival, even when age-specific data are sparse.
Cancer Epidemiology 2020;67:101745.