Lab 1: Feedback and Discussion

Nicky Wakim

2026-04-15

Mistake on my end

  • I forgot to update the lab qmd for your work! So sorry!
  • The TAs were lenient on the grading for this, but in the future make sure to complete the tasks from the instruction page!

Notes from me and the TAs

  • Using ANY_HARDSHIP or MULT_HARDSHIPS
    • If you look at the User Guide, this involves information from food security
    • We need to adapt the variable to exclude food security: use case_when() to construct it
    • Other option: use a different variable!!
  • Using “Survey Questions”: please avoid using these
    • Be very careful of this!
  • Activity 2.9: List any categorical variables that have less than 100 observations in a group
    • Not the number of observations for an entire variable, but check each level/group of the variable!
  • Do not use multiple variables that capture the same information: multicollinearity issues
    • Example: PPINCIMP and FPL50_100
  • Do NOT use variables that are measuring missing data unless you are interested in how missingness is related to the outcome
    • Example: FAMSIZE_MISS, NUM_CHILD_HH_MISS
  • Make sure your image shows in your html
    • You need to have right file path!
    • How’s the Rproj going?

More notes: things that will lose points in Lab 2

  • Purposefuly model selection
    • Dataset should have your outcome and 10 other variables
    • You should have a clear research question
  • LASSO
    • You should have a dataset with a lot of variables (~51)
    • Start taking a look at the variables and think critically about potential multicollinearity issues
      • AND
  • Make sure your categorical variables are factors
    • Remake Table 1 in Lab 2 with the appropriate variable types

LASSO: Updated variable selection

  • There are a few more variables to remove
wbns2 = wbns %>% select(-starts_with("Q")) %>%  # remove survey questions
  select(-starts_with("V_")) %>%                # remove different versions of variables
  select(-ends_with("IMP")) %>%                 # remove imputed variables 
  select(-PPREG4, -NUM_SIBLING, -NUM_PARGUARD) %>%
  drop_na()
  • This left me with a dataset with 51 variables and 6,658 observations

Purposeful Model Selection: A note on the “Survey Questions”

  • I said not to use the variables under this, but you can if you found one to be very interesting
  • You just need to be extra cautious using these because they are not as nicely packaged/processed
  • And some of them go into other variables!!
    • Like UNMETCARE_Y already includes the survey questions about health care
  • Some of the variable have A LOT of missing data

For everyone

  • If you had issues with removing the “(0)” and “(1)” from variable names WHILE preserving the factor class of the variables, here’s some code that might help
wbns3 <- wbns2 %>%
  mutate(across(where(is.factor), ~ {
    levels(.) <- gsub("^\\(\\d+\\)\\s*", "", levels(.)) 
    .
  }))

Get into groups of 2-4

  • No more than 4!
  • Introduce yourself if you do not know each other
  • Share you html documents with each other (email, airdrop, etc.)

Introduce your project type

  • Are you doing LASSO or purposeful model selection?
  • Share your research question with each other!
  • Share your other variables
  • Is everyone using the appropriate variables?
  • Did anyone see any potential issues with how many individuals are in each category of a variable?

 

  • If time, did anyone want to use ANY_HARDSHIP or MULT_HARDSHIPS? How would you construct these variables?

Double check code and saved data

  • Did everyone in the group successfully save the dataset?
  • Can you open it right now?
  • How many observations do you have after you dropped your NAs?

Compiled introductions

  • What major points did you include in your introduction?
  • Would you change anything after discussing with your group?