Helper functions for RH imputation and survey weighting

amelia2df | Retrieve an imputed dataset (as a data frame) from an amelia... |

attrition_drop | Replace values with NAs if respondent did not participate in... |

bounds_matrix | Make bounds matrix for Amelia |

cap | Set all elements of a vector or matrix above a certain value... |

cut_numeric_leftclosed | Wrapper for 'cut()' with 'labels = FALSE', 'right = FALSE' |

cv | Coefficient of variation |

empty_df | Create a placeholder NA-filled data.frame |

fac2binary | Convert 2-level factor variable to a binary 0/1 variable |

flag_names | Get names of imputation flag variables |

imp_varlist | Create list of information about variables to be imputed |

include_waves | Take baseline variable names and return variable names for... |

indicator12_to_indicator01 | Convert (one or more) 1/2 indicator variables to 1/0... |

lt_eq_gt | Recode variable based on whether it is less than, equal to,... |

margins_for_rake | Sample and population margins for raking |

max_over_min | Ratio of maximum to minimum |

mean_plus_sds | Mean plus k standard deviations |

naive_imputation_step | Naively impute continuous value given a bracket (i.e.,... |

NAs_to_zeros | Convert NAs in imputation flags to zeros |

normalize | Normalize to have mean 1 |

ones | Make a one-column matrix of 1s |

prepare_imp_NAs | Make all values of vars with imputation flag = 1 into NAs |

rescale_weights_to_pop | Rescale weights to sum to population |

RHhelpers | Convenience functions for working with CPRC/RH survey data |

save_weights | Save weights as .rds or .dta file |

simple_impute | Simple imputations |

status | Print status messages |

survey_summary | Print survey summary statistics |

upper_quantile_trimming | Trim high survey weights using quantile as upper bound |

weights_hist | Histogram of weights |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.