Skip to content

Fix IDs with NAs + new attrition function#76

Merged
bernardo-sieira merged 4 commits intomasterfrom
fix_panel_again
Mar 23, 2026
Merged

Fix IDs with NAs + new attrition function#76
bernardo-sieira merged 4 commits intomasterfrom
fix_panel_again

Conversation

@lauratregadas
Copy link
Member

Not yet working. Problem diagnosis: pasting as.hexmode() for panel and id pastes NA ids, resulting in 300k/2.8M identifiers being 6NA for panel 6. Instead, they should be just NA. I already tried a vectorized validity check approach, but it did not work: I ran the panel again with this new code and I still have the same 6NA ids.

@bernardo-sieira please help!! First check whether the code we currently have makes sense (let me knwo what your AIs suggest), then solve it and test is please.

I also included a new attrition calculation function I believe makes more sense than cria_df_de_atrito. It returns three different percentage_found rates: the unconditional one corresponds to the one we previously had - what % of ids appearing in 1 appear in 2, what % appearing in 1 appears in 3, etc. The conditional ones correspond to what % of ids appearing in 1 appear in 2 (this one coincides with unconditional), what % os ids appearing in 1 AND 2 appear in 3, what % of ids appearing in 1 AND 2 AND 3 appear in 4, etc. For the conditional attrition we have two denominator options: the number of ids found in wave/entrevista 1 OR the number of ids found in the previous wave/entrevista. Notive the former is mehcnically decreasing whereas the latter can be whatever

Basically: dat$id_rs <- ifelse(
      is.na(dat$id_rs),
      NA_character_,
      paste0(as.hexmode(dat$V1014), as.hexmode(dat$id_rs))
    ) using ifelse we are able to set all of the cases where we would have a combination with NA in the id_rs to NA directly
@bernardo-sieira bernardo-sieira marked this pull request as ready for review March 23, 2026 16:56
@bernardo-sieira bernardo-sieira merged commit b4d6f2f into master Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants