Quick way of impute WTFINL?

Dear team of IPUMS,
dear members of the forum,

In order to create a longitudinal weight for linking adjacent months, I need a final weight for imputed data (non-responses or refusals).
As a first draft, I am using ipfraking, taking the population totals weighted by WTFINL as a control and raking a monthly data set of an unweighted sample of imputed and original data. I am using an altered .do-file from the IPUMS for the creation of a longitudinal weight link

The months I’ve done this for have a difference of total(WTFINL, CPS final weight) - total(FINAL_RAKED, recreated final weight) of zero, which gives me some confidence.

However, I would appreciate your thoughts on this approach.

Below you find my Stata code.

Kind regards,

Hannes

*#delimit
version 15
clear
set more off
set matsize 2000

cd "Z:\Daten\CPS\imputation_final_weights\"
local logdate = string( d(`c(current_date)'), "%dN.D.Y" )
log using logs\generate_weights_for_linked_cps_data_`logdate'.log, t replace

local startyr = 1996
local startmo = 1
if "`0'" != "" {
  if "`2'" != "" {
    local startyr = `1'
    local startmo = `2'
  }
  else {
    di as error "No month specified"
  }
}
di as text `"Starting from `startyr'-`startmo'."'

forval yr = `startyr'/2021 {
  forval mo = `startmo'/3 {
    use "Z:\Daten\CPS\imputation_final_weights\monthly\ipums_cps_`yr'_`mo'.dta", clear
    svyset [pw=wtfinl]
    disp "...combining categories of age, sex, race, hispan, state from which we will generate population totals"
	  include "G:\final weight recalc\create_grouped_vars.doi"
    foreach x in has_group ras_group gas_group {
		    disp "...summing counts for raking groups based on individuals"
		    svy: total _one, over(`x', nolabel)
			  matrix rake_`x' = e(b)
			  matrix rowname rake_`x' = `x'
			  matrix list rake_`x'
			}

    disp "...generate overall population count."
    svyset [pw=_one]
    *svy: total _one if imputed_mish != 1
    svy: total _one
    gen double pre_ipfraking_total=`e(N_pop)'

    disp "...perform raking using groups defined in create_grouped_vars.doi"
    local threeway rake_ras_group rake_has_group rake_gas_group
    ipfraking [pw=_one], ctotal(`threeway') gen(rakeweight_threeway)  nograph

    disp "...generate original population count with final weights of CPS."
    svyset [pw=rakeweight_threeway]
    svy: total _one
    gen double post_ipfraking_total=`e(N_pop)'

    /*check pre-raked weight sum and post-raked weight sum*/
    format pre_ipfraking_total %15.0f
    format post_ipfraking_total %15.0f

    gen final_raked=rakeweight_threeway

    gen diff=round(final_raked)-round(wtfinl)
    tab diff
    disp "...saving the raked file"

    rename mish mis_`yr'_`mo'
    rename wtfinl wtfinl_`yr'_`mo'

    save generated/raked_`yr'_`mo'.dta, replace
  } //end mo
} //end yr

This topic, and detailed code review in general, are beyond the purview of IPUMS User Support, so the help I can give is limited, but I’ll share my thoughts since you asked :slight_smile:

Your overall approach seems reasonable to me. I assume you’re trying to do this to avoid dropping people who have some data, but not a complete set of longitudinal observations, for example if an individual has data for only 7 of 8 rounds. The one thing that I’ll mention is that I don’t think using an unweighted sample as your starting point is the right way to do the raking. The sampling weights contain important information about the probability of selection into the sample, which will be lost if you start with an unweighted sample. You might consider assigning weights to imputed cases as a first step (for example, assigning the average of an individual’s sampling weights for samples in which they are not missing), and using that as a starting point for the raking process.

1 Like

Hi, Matthew,

thank you for your input. This is something I did not consider.

I do not want a code review, I merely wanted to share my approach with this community, since this forum is the first place I turn to when looking for answers to questions related to IPUMS. And now I got a crucial suggestion from you - something that other users can read up here.

Thank you very much, Matthew, for all the effort and patience you are putting into this forum here.

No problem! You’re always welcome to post code, I just wanted to set expectations in terms of the type of support you can expect from IPUMS staff. Of course other forum participants can post replies, too.