Set up environment

#####STEP 0-1: Reset environment #####
rm(list=ls())
knitr::opts_chunk$set(echo = TRUE)
options(repos = structure(c(CRAN = "http://cran.rstudio.com/")))

#####STEP 0-2: Install packages #####
list.of.packages <- c( "grf", "metafor", "splitstackshape", "dplyr", "tidyverse", "foreach", "cowplot",
                       "reshape2", "doParallel", "survival", "readstata13", "ggplot2", "rsample", "DiagrammeR",
                       "e1071", "pscl", "pROC", "caret", "ModelMetrics", "MatchIt", "Hmisc", "scales",
                       "lmtest", "sandwich","haven", "rpms", "randomForest",  "fabricatr", "gridExtra",  # nolint
                       "VIM", "mice", "missForest", "lmtest", "ivreg", "kableExtra")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

lapply(list.of.packages, library, character.only = TRUE)
## Warning: package 'grf' was built under R version 4.3.3
## Warning: package 'metafor' was built under R version 4.3.3
## Warning: package 'metadat' was built under R version 4.3.3
## Warning: package 'numDeriv' was built under R version 4.3.1
## Warning: package 'splitstackshape' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'ggplot2' was built under R version 4.3.3
## Warning: package 'tibble' was built under R version 4.3.3
## Warning: package 'tidyr' was built under R version 4.3.3
## Warning: package 'readr' was built under R version 4.3.3
## Warning: package 'purrr' was built under R version 4.3.3
## Warning: package 'stringr' was built under R version 4.3.3
## Warning: package 'forcats' was built under R version 4.3.3
## Warning: package 'lubridate' was built under R version 4.3.3
## Warning: package 'foreach' was built under R version 4.3.3
## Warning: package 'cowplot' was built under R version 4.3.3
## Warning: package 'reshape2' was built under R version 4.3.3
## Warning: package 'doParallel' was built under R version 4.3.3
## Warning: package 'iterators' was built under R version 4.3.3
## Warning: package 'readstata13' was built under R version 4.3.3
## Warning: package 'rsample' was built under R version 4.3.3
## Warning: package 'DiagrammeR' was built under R version 4.3.3
## Warning: package 'e1071' was built under R version 4.3.3
## Warning: package 'pscl' was built under R version 4.3.3
## Warning: package 'pROC' was built under R version 4.3.3
## Warning: package 'caret' was built under R version 4.3.3
## Warning: package 'ModelMetrics' was built under R version 4.3.3
## Warning: package 'MatchIt' was built under R version 4.3.3
## Warning: package 'Hmisc' was built under R version 4.3.3
## Warning: package 'scales' was built under R version 4.3.3
## Warning: package 'lmtest' was built under R version 4.3.3
## Warning: package 'zoo' was built under R version 4.3.3
## Warning: package 'sandwich' was built under R version 4.3.3
## Warning: package 'haven' was built under R version 4.3.3
## Warning: package 'rpms' was built under R version 4.3.3
## Warning: package 'randomForest' was built under R version 4.3.3
## Warning: package 'fabricatr' was built under R version 4.3.3
## Warning: package 'gridExtra' was built under R version 4.3.3
## Warning: package 'VIM' was built under R version 4.3.3
## Warning: package 'colorspace' was built under R version 4.3.3
## Warning: package 'mice' was built under R version 4.3.3
## Warning in check_dep_version(): ABI version mismatch: 
## lme4 was built with Matrix ABI version 1
## Current Matrix ABI version is 0
## Please re-install lme4 from source or restore original 'Matrix' package
## Warning: package 'missForest' was built under R version 4.3.3
## Warning: package 'ivreg' was built under R version 4.3.3
## Warning: package 'kableExtra' was built under R version 4.3.3
print(paste("Version of grf package:", packageVersion("grf")))

#####STEP 0-3: Basic information #####
Sys.time()
# Get detailed R session and system information
session_info <- sessionInfo()
system_info <- Sys.info()
# Combine the output
list(session_info = session_info, system_info = system_info)

Set non-run-specific parameters

#####STEP 0-4: Set non-run-specific parameters #####
seedset <- 777
numthreadsset <- min(6, parallel::detectCores()) 
if (numthreadsset!= 6) {
  print("the results of grf vary by num.thread (publication paper used num.thread=6)")
} 

cat("number of threads (affects grf results):", numthreadsset,"\n")
## number of threads (affects grf results): 6
# Set printing options
options(digits = 4)

Set run-specific parameters

#####STEP 0-5: Set run-specific parameters #####
published_paper_run <- 0 # ANALYST FORM
if (published_paper_run == 1) {
  print("save output into PP_Full_Analysis/Saved_tables_figures/As_published/ folder")
  warning("Changing this setting to 1 overwrites the input files required for replicating on different platforms.")
} else {
  print("save output into PP_Full_Analysis/Saved_tables_figures/Testing/ folder")
}
## [1] "save output into PP_Full_Analysis/Saved_tables_figures/Testing/ folder"
use_auxiliary_file <- 0 # ANALYST FORM
if (use_auxiliary_file == 1) {
  print("outcome and ranking variable pairs are coming from auxiliary file.")
} else {
  print("please specify outcome and ranking variable pairs in this file")
}
## [1] "please specify outcome and ranking variable pairs in this file"
# Each outcome and ranking var needs to be identified by outcome_cwX_lambda_X, where the first X is the Cw value and the second X is the lambda value. If you don't want either modification, use 0. 
if (use_auxiliary_file == 1) {
  #read in pairs from file into dataframe as specified_pairs
  # cate_outcome_rankvar_pairs <- specified_pairs$cate_pairs
  # clate_outcome_rankvar_pairs <- specified_pairs$clate_pairs
} else {
  cate_outcome_rankvar_pairs <- list( # ANALYST FORM
    list("debt_neg_cw0_lambda_0", "debt_neg_cw0_lambda_0"),
    list("debt_neg_cw0_lambda_0", "ohp_all_ever_inperson_cw0_lambda_0")
  )
  clate_outcome_rankvar_pairs <- list( # ANALYST FORM
    list("debt_neg_cw0_lambda_0", "debt_neg_cw0_lambda_0")
  )
}

# Get first item from each list in cate_outcome_rankvar_pairs
outcomes_list <- sapply(cate_outcome_rankvar_pairs, `[[`, 1)

covariates_list <- c("X.gender_inp", "X.age_inp") # ANALYST FORM *** Important: never include numhh_list in covariates_list.

cw_run_name <- "med" # ANALYST FORM
cw_grid <- 1 # ANALYST FORM

# Define cw_name
cw_name <- paste0("cw_", cw_run_name, "_", cw_grid)

Set file paths

#####STEP 0-6: Set file paths #####
# Set the processed path based on published_paper_run
processedpath <- if (published_paper_run == 1) {
  paste0("PP_Full_Analysis/Intermediate_data/As_published/empirical/", cw_name)
} else {
  paste0("PP_Full_Analysis/Intermediate_data/Testing/empirical/", cw_name)
}

# Set the results_dir based on published_paper_run and cw_name
results_dir <- if (published_paper_run == 1) {
  paste0("PP_Full_Analysis/Saved_tables_figures/As_published/", cw_name)
} else {
  paste0("PP_Full_Analysis/Saved_tables_figures/Testing/", cw_name)
}

# If results directory does not exist, create it
if (!dir.exists(results_dir)) {
  dir.create(results_dir, recursive = TRUE)
}

# Print processed path and results directory
print(paste("Processed path:", processedpath))
## [1] "Processed path: PP_Full_Analysis/Intermediate_data/Testing/empirical/cw_med_1"
print(paste("Results directory:", results_dir))
## [1] "Results directory: PP_Full_Analysis/Saved_tables_figures/Testing/cw_med_1"

Create functions

Create CLATE cdf function

#####STEP 5-1: Create CLATE cdf function #####
create_cumulative_clate_plot <- function(outcome_var, ranking_var, cdf_dataframe, decreasing=FALSE) {
    print("#####Running clate function.#####")

    # Initialize vectors to store results for cumulative analysis
    rnk <- numeric()        # Will store percentile labels
    estimate <- numeric()   # Will store estimates
    lowCI <- numeric()      # Will store lower confidence interval bounds
    highCI <- numeric()     # Will store upper confidence interval bounds
    n_obs <- numeric()      # Will store number of observations
    quantiles_used <- numeric()  # Will store the quantile values used

    # Create cumulative analysis from 20th to 100th percentile
    percentiles <- seq(20, 100, by=10)  # 20,30,40,50,60,70,80,90,100
    ranking_rescale <- cdf_dataframe$clate_rankings_selected * .5 +.1
    ranking_rescale <- 10*round(ranking_rescale,0)

    # Print the table of ranking_rescale
    print(table(ranking_rescale))
    
    for (i in percentiles) {
        
        current_index <- which(percentiles == i)
        
        quantiles_used[current_index] <- ifelse(decreasing, i/100, (100-i)/100)
                
        # Subset data based on direction
        if(decreasing) {
            # For bottom plot (20-100)
            data_subset <- cdf_dataframe[ranking_rescale <= i, ]

            glimpse(data_subset)
            
        } else {
            # For top plot (20-100)
            data_subset <- cdf_dataframe[ranking_rescale > 100-i, ]

            glimpse(data_subset)
        }
                # UNCOMMENT TO DEBUG
          print(quantiles_used[current_index])
                  
        # Check if household size has multiple levels
        numhh_levels <- length(unique(na.omit(data_subset$numhh_list)))
        
        # Create appropriate IV regression formula
        if (numhh_levels > 1) {
            formula_str <- paste("Y ~ clate_W + as.factor(numhh_list) +", paste(covariates_list, collapse = " + "), "|",
                               "Z + as.factor(numhh_list) +", paste(covariates_list, collapse = " + "))
        } else {
            formula_str <- paste("Y ~ clate_W +", paste(covariates_list, collapse = " + "), "|",
                               "Z +", paste(covariates_list, collapse = " + "))
        }
        print(formula_str)

      # Run instrumental variables regression with error handling
      tryCatch({
          model <- ivreg(as.formula(formula_str),
                        weights = weights,
                        data = data_subset)
          print(summary(model))          
          # Extract and store results
          coef_summary <- summary(model)$coefficients
          rnk[current_index] <- paste0(i, "th")
          estimate[current_index] <- coef_summary["clate_W", "Estimate"]
          lowCI[current_index] <- coef_summary["clate_W", "Estimate"] -
                                  1.96 * coef_summary["clate_W", "Std. Error"]
          highCI[current_index] <- coef_summary["clate_W", "Estimate"] +
                                  1.96 * coef_summary["clate_W", "Std. Error"]
          n_obs[current_index] <- nrow(data_subset)

          print("Estimate:",estimate[current_index])
          print("LowCI:",lowCI[current_index])
          print("HighCI:",highCI[current_index])
          print("N:",n_obs[current_index])

      }, error = function(e) {
          rnk[current_index] <- paste0(i, "th")
          estimate[current_index] <- NA
          lowCI[current_index] <- NA
          highCI[current_index] <- NA
          n_obs[current_index] <- nrow(data_subset)
      })
  }
  
  print("Results of cumulative analysis:")
  print(rnk)
  
  # Create plot data frame
  plot_data <- data.frame(
      Percentile = factor(rnk, 
          levels = paste0(seq(20, 100, by=10), "th")),
      Estimate = estimate,
      LowCI = lowCI,
      HighCI = highCI,
      N = n_obs,
      Quantile_Value = quantiles_used,
      Group = if(decreasing) "Bottom" else "Top"
  )

  # Create file name for csv
  df_file_name <- paste0(results_dir, "/","cdf_clate_", outcome_var, "_", ranking_var, ".csv")

  # Save plot dataframe to csv
  write.csv(plot_data, df_file_name, row.names = FALSE)
  
  # Create plot title with direction indication
  direction_text <- if(decreasing) "Bottom Groups (20-100)" else "Top Groups (20-100)"
  title_text <- sprintf("%s\n%s", outcome_var, direction_text)
  
  # Get global min and max values for consistent y-axis scaling
  y_min <- min(c(plot_data$LowCI, plot_data$HighCI), na.rm = TRUE)
  y_max <- max(c(plot_data$LowCI, plot_data$HighCI), na.rm = TRUE)
  
  # Add some padding to the y-axis limits
  y_range <- y_max - y_min
  y_min <- y_min - 0.1 * y_range
  y_max <- y_max + 0.1 * y_range
  
  xaxislabel <- paste0("Percentile Groups ranked by ", ranking_var)
    print(xaxislabel)
  
  # Create ggplot visualization
  p <- ggplot(plot_data, aes(x = Percentile, y = Estimate)) +
      geom_point(position=position_dodge(0.2), size=3) +
      geom_errorbar(aes(ymin = LowCI, ymax = HighCI),
                    width=.2, position=position_dodge(0.2)) +
      geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
      theme_minimal() +
      labs(title = title_text,
            y = "CLATE: Change by Medicaid",
            x = xaxislabel) +
      theme(legend.position = "bottom",
            axis.text.x = element_text(angle = 45, hjust = 1),
            plot.title = element_text(hjust = 0.5)) +
      suppressMessages(coord_cartesian(ylim = c(y_min, y_max)))  # Suppress coordinate system message
  
  # Create file name for png  
  png_file_name <- paste0(results_dir, "/","clate_cdf_", outcome_var, "_", ranking_var, ".png")
  
  # Save png plot to file
  ggsave(png_file_name, plot = p, width = 10, height = 6, dpi = 300)

  # Create file name for pdf
  pdf_file_name <- paste0(results_dir, "/","clate_cdf_", outcome_var, "_", ranking_var, ".pdf")
  
  # Save pdf plot to file
  ggsave(pdf_file_name, plot = p, width = 10, height = 6)
  
  return(list(plot = p, y_limits = c(y_min, y_max)))
}

Create CATE cdf function

#####STEP 5-2: Create CATE cdf function #####
create_cumulative_cate_plot <- function(outcome_var, ranking_var, cdf_dataframe, decreasing=FALSE) {    
  print("#####Running cate function.#####")

    # Initialize vectors to store results for cumulative analysis
    rnk <- numeric()        # Will store percentile labels
    estimate <- numeric()   # Will store estimates
    lowCI <- numeric()      # Will store lower confidence interval bounds
    highCI <- numeric()     # Will store upper confidence interval bounds
    n_obs <- numeric()      # Will store number of observations
    quantiles_used <- numeric()  # Will store the quantile values used
    
    # Create cumulative analysis from 20th to 100th percentile
    percentiles <- seq(20, 100, by=10)  # 20,30,40,50,60,70,80,90,100
    ranking_rescale <- cdf_dataframe$cate_rankings_selected * .5 +.1
    ranking_rescale <- 10*round(ranking_rescale,0)

    # Print the table of ranking_rescale
    print(table(ranking_rescale))
    
    for (i in percentiles) {
        current_index <- which(percentiles == i)
        quantiles_used[current_index] <- ifelse(decreasing, i/100, (100-i)/100)
        
        # Subset data based on direction
        if(decreasing) {
            data_subset <- cdf_dataframe[ranking_rescale <= i, ]
        } else {
            data_subset <- cdf_dataframe[ranking_rescale > 100-i, ]
        }
        
        # Check if household size has multiple levels
        numhh_levels <- length(unique(na.omit(data_subset$numhh_list)))
        
        # Create appropriate regression formula
        if (numhh_levels > 1) {
            formula_str <- sprintf("Y ~ cate_W + as.factor(numhh_list) + %s",
                                 paste(covariates_list, collapse = " + "))
        } else {
            formula_str <- sprintf("Y ~ cate_W + %s",
                                 paste(covariates_list, collapse = " + "))
        }
        print(formula_str)
        
        # Run linear regression with error handling
        tryCatch({
            model <- lm(as.formula(formula_str),
                       weights = weights,
                       data = data_subset)
            print(summary(model))
            
            # Extract and store results
            coef_summary <- summary(model)$coefficients
            rnk[current_index] <- paste0(i, "th")
            print(rnk[current_index])
            estimate[current_index] <- coef_summary["cate_W", "Estimate"]
            lowCI[current_index] <- estimate[current_index] -
                                   1.96 * coef_summary["cate_W", "Std. Error"]
            highCI[current_index] <- estimate[current_index] +
                                   1.96 * coef_summary["cate_W", "Std. Error"]
            n_obs[current_index] <- nrow(data_subset)

            print("Estimate:",estimate[current_index])
            print("LowCI:",lowCI[current_index])
            print("HighCI:",highCI[current_index])
            print("N:",n_obs[current_index])

        }, error = function(e) {
            print(e)
            rnk[current_index] <- paste0(i, "th")
            estimate[current_index] <- NA
            lowCI[current_index] <- NA
            highCI[current_index] <- NA
            n_obs[current_index] <- nrow(data_subset)
        })
    }
    
    print("Results of cumulative analysis:")
    print(rnk)
    
    # Create plot data frame
    plot_data <- data.frame(
        Percentile = factor(rnk, 
            levels = paste0(seq(20, 100, by=10), "th")),
        Estimate = estimate,
        LowCI = lowCI,
        HighCI = highCI,
        N = n_obs,
        Quantile_Value = quantiles_used,
        Group = if(decreasing) "Bottom" else "Top"
    )
    
    # Create file name for csv
    df_file_name <- paste0(results_dir, "/","cate_cdf_", outcome_var, "_", ranking_var, ".csv")
    
    # Save plot dataframe to csv
    write.csv(plot_data, df_file_name, row.names = FALSE)
    
    # Create plot title with direction indication
    direction_text <- if(decreasing) "Bottom Groups (20-100)" else "Top Groups (20-100)"
    title_text <- sprintf("%s\n%s", outcome_var, direction_text)
    
    # Get global min and max values for consistent y-axis scaling
    y_min <- min(c(plot_data$LowCI, plot_data$HighCI), na.rm = TRUE)
    y_max <- max(c(plot_data$LowCI, plot_data$HighCI), na.rm = TRUE)
    
    # Add some padding to the y-axis limits
    y_range <- y_max - y_min
    y_min <- y_min - 0.1 * y_range
    y_max <- y_max + 0.1 * y_range
    
    xaxislabel <- paste0("Percentile Groups ranked by ", ranking_var)
    print(xaxislabel)
    
    # Create ggplot visualization
    p <- ggplot(plot_data, aes(x = Percentile, y = Estimate)) +
        geom_point(position=position_dodge(0.2), size=3) +
        geom_errorbar(aes(ymin = LowCI, ymax = HighCI),
                     width=.2, position=position_dodge(0.2)) +
        geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
        theme_minimal() +
        labs(title = title_text,
             y = "CATE: Change by Medicaid",
             x = xaxislabel) +
        theme(legend.position = "bottom",
              axis.text.x = element_text(angle = 45, hjust = 1),
              plot.title = element_text(hjust = 0.5)) +
        suppressMessages(coord_cartesian(ylim = c(y_min, y_max)))
    
    # Create file name for png
    png_file_name <- paste0(results_dir, "/","cate_cdf_", outcome_var, "_", ranking_var, ".png")
    
    # Save png plot to file
    ggsave(png_file_name, plot = p, width = 10, height = 6, dpi = 300)
    
    # Create file name for pdf
    pdf_file_name <- paste0(results_dir, "/","cate_cdf_", outcome_var, "_", ranking_var, ".pdf")
    
    # Save pdf plot to file
    ggsave(pdf_file_name, plot = p, width = 10, height = 6)
    
    return(list(plot = p, y_limits = c(y_min, y_max)))
}

Create combined increasing and decreasing plot function

#####STEP 5-3: Create combined increasing and decreasing plot function #####
create_cumulative_outcome_plots <- function(outcome, ranking_v, type) {
  print(paste("Processing outcome var:", outcome))
  print(paste("Processing ranking var:", ranking_v))
  
  # Add this check
  if (type == "clate" && length(clate_outcome_rankvar_pairs) == 0) {
    print("Skipping CLATE plot - no CLATE pairs defined")
    return(NULL)
  }
  
  result <- read_treatment_effect_datasets(outcome, ranking_v)
  
  #THIS IS THE COMBINED DATAFRAME. It contains the full csv for outcome and two columns "cate_rankings_selected" and "clate_rankings_selected" from the csv for raning variable.
  glimpse(result)
  
  if (type == "clate") {
     print(type)
     increasing_result <- create_cumulative_clate_plot(
        outcome_var = outcome,
        ranking_var = ranking_v,
        cdf_data = result,
        decreasing = FALSE
      )
      print("finished increasing")
      decreasing_result <- create_cumulative_clate_plot(
        outcome_var = outcome,
        ranking_var = ranking_v,
        cdf_data = result,
        decreasing = TRUE
      )
      print("finished decreasing")
  }
  else if (type == "cate") {
      print(type)
      increasing_result <- create_cumulative_cate_plot(
        outcome_var = outcome,
        ranking_var = ranking_v,
        cdf_data = result,
        decreasing = FALSE
      )
      print("finished increasing")
      decreasing_result <- create_cumulative_cate_plot(
        outcome_var = outcome,
        ranking_var = ranking_v,
        cdf_data = result,
        decreasing = TRUE
      )
      print("finished decreasing")
  }
 
  # Get overall y-axis limits
  y_min <- min(c(increasing_result$y_limits[1], decreasing_result$y_limits[1]))
  y_max <- max(c(increasing_result$y_limits[2], decreasing_result$y_limits[2]))
    
  # Update plots with consistent y-axis limits
  increasing_plot <- suppressMessages(
      increasing_result$plot + 
      coord_cartesian(ylim = c(y_min, y_max))
  )
    
  decreasing_plot <- suppressMessages(
      decreasing_result$plot + 
      coord_cartesian(ylim = c(y_min, y_max))
  )
    
  # Combine plots
  combined_plot <- grid.arrange(
      increasing_plot,
      decreasing_plot,
      ncol = 1
    )
  
  # Create file name for png
  png_file_name <- paste0(results_dir, "/","combined_cdf_", outcome, "_", ranking_v, "_", type, ".png")
  
  # Save png plot to file
  ggsave(png_file_name, plot = combined_plot, width = 10, height = 6, dpi = 300)

  # Create file name for pdf
  pdf_file_name <- paste0(results_dir, "/","combined_cdf_", outcome, "_", ranking_v, "_", type, ".pdf")
  
  # Save pdf plot to file
  ggsave(pdf_file_name, plot = combined_plot, width = 10, height = 6)
    
  return(combined_plot)
}

Create read data function

#####STEP 5-4: Create read data function #####
read_treatment_effect_datasets <- function(outcome, ranking_v) {
  print("#####Creating dataframe.#####")
  
  base_filename <- "/cate_clate_results_"
  
  if (outcome == ranking_v) {
    input_base <- sub("_lambda_.*", "", outcome)
    ranking_lambda <- sub(".*lambda_", "", ranking_v)
    cate_lambda_column <- paste0("cate_lambda_", ranking_lambda, "_ranking_20")
    clate_lambda_column <- paste0("clate_lambda_", ranking_lambda, "_ranking_20")

    print("Column called for lambda cate ranking")
    print(cate_lambda_column)
    print("Column called for lambda clate ranking")
    print(clate_lambda_column)

    filename <- paste0(processedpath, base_filename, input_base, ".csv")
    print("Filename:")
    print(filename)
    
    if (file.exists(filename)) {
      outcome_df <- read.csv(filename)
      
      if(input_base == "ohp_all_ever_inperson_cw0") {
        print("OHP analysis detected - excluding CLATE rankings")
        selected_ranking_df <- outcome_df[, c("person_id", cate_lambda_column)]
        colnames(selected_ranking_df)[2] <- "cate_rankings_selected"
      } else {
        print("Non-OHP analysis - including CLATE rankings")
        selected_ranking_df <- outcome_df[, c("person_id", cate_lambda_column, clate_lambda_column)]
        colnames(selected_ranking_df)[2] <- "cate_rankings_selected"
        colnames(selected_ranking_df)[3] <- "clate_rankings_selected"
      }
    } else {
      stop(sprintf("File does not exist: %s", filename))
    }
  } else {
    outcome_input_base <- sub("_lambda_.*", "", outcome)
    outcome_filename <- paste0(processedpath, base_filename, outcome_input_base, ".csv")
    print("outcome filename")
    print(outcome_filename)
    outcome_df <- read.csv(outcome_filename)

    ranking_input_base <- sub("_lambda_.*", "", ranking_v)
    ranking_lambda <- sub(".*lambda_", "", ranking_v)
    ranking_filename <- paste0(processedpath, base_filename, ranking_input_base, ".csv")
    print("ranking filename")
    print(ranking_filename)
    ranking_df <- read.csv(ranking_filename)
    
    cate_lambda_column <- paste0("cate_lambda_", ranking_lambda, "_ranking_20")
    clate_lambda_column <- paste0("clate_lambda_", ranking_lambda, "_ranking_20")
    
    print("Column called for lambda cate ranking")
    print(cate_lambda_column)
    print("Column called for lambda clate ranking")
    print(clate_lambda_column)

    if(outcome_input_base == "ohp_all_ever_inperson_cw0" || ranking_input_base == "ohp_all_ever_inperson_cw0") {
      print("OHP analysis detected - excluding CLATE rankings")
      selected_ranking_df <- ranking_df[, c("person_id", cate_lambda_column)]
      colnames(selected_ranking_df)[2] <- "cate_rankings_selected"
    } else {
      print("Non-OHP analysis - including CLATE rankings")
      selected_ranking_df <- ranking_df[, c("person_id", cate_lambda_column, clate_lambda_column)]
      colnames(selected_ranking_df)[2] <- "cate_rankings_selected"
      colnames(selected_ranking_df)[3] <- "clate_rankings_selected"
    }
  }

  print(paste("Dimensions of selected_ranking_df:", dim(selected_ranking_df)))
  glimpse(selected_ranking_df)
  print(paste("Dimensions of outcome_df:", dim(outcome_df)))
  glimpse(outcome_df)
  
  cdf_data <- merge(selected_ranking_df, outcome_df, by = "person_id")
  print("Dimensions of cdf_data")
  print(dim(cdf_data))
  
  return(cdf_data)
}

Loop over outcome and ranking variable pairs

#####STEP 5-5: Loop over outcome and ranking variable pairs #####
# Process CATE pairs
for (i in seq_along(cate_outcome_rankvar_pairs)) {
    outcome <- cate_outcome_rankvar_pairs[[i]][[1]]                 
    ranking_variable <- cate_outcome_rankvar_pairs[[i]][[2]]            
    create_cumulative_outcome_plots(outcome, ranking_variable, "cate")
}
## [1] "Processing outcome var: debt_neg_cw0_lambda_0"
## [1] "Processing ranking var: debt_neg_cw0_lambda_0"
## [1] "#####Creating dataframe.#####"
## [1] "Column called for lambda cate ranking"
## [1] "cate_lambda_0_ranking_20"
## [1] "Column called for lambda clate ranking"
## [1] "clate_lambda_0_ranking_20"
## [1] "Filename:"
## [1] "PP_Full_Analysis/Intermediate_data/Testing/empirical/cw_med_1/cate_clate_results_debt_neg_cw0.csv"
## [1] "Non-OHP analysis - including CLATE rankings"
## [1] "Dimensions of selected_ranking_df: 12094"
## [2] "Dimensions of selected_ranking_df: 3"    
## Rows: 12,094
## Columns: 3
## $ person_id               <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68, …
## $ cate_rankings_selected  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, 17…
## $ clate_rankings_selected <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, 13…
## [1] "Dimensions of outcome_df: 12094" "Dimensions of outcome_df: 66"   
## Rows: 12,094
## Columns: 66
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "Dimensions of cdf_data"
## [1] 12094    68
## Rows: 12,094
## Columns: 68
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ cate_rankings_selected    <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_rankings_selected   <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "cate"
## [1] "#####Running cate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1211 1208 1209 1210 1209 1209 1210 1209 1209 1210 
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.359 -0.534  0.433  0.507  1.160 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.515859   0.039907   12.93   <2e-16 ***
## cate_W        0.059110   0.020368    2.90   0.0037 ** 
## X.gender_inp -0.034739   0.020490   -1.70   0.0901 .  
## X.age_inp    -0.000245   0.000836   -0.29   0.7693    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 2415 degrees of freedom
## Multiple R-squared:  0.00466,    Adjusted R-squared:  0.00343 
## F-statistic: 3.77 on 3 and 2415 DF,  p-value: 0.0103
## 
## [1] "20th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.359 -0.520 -0.412  0.521  1.255 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.542269   0.031972   16.96   <2e-16 ***
## cate_W        0.054516   0.016601    3.28   0.0010 ** 
## X.gender_inp -0.047318   0.016685   -2.84   0.0046 ** 
## X.age_inp    -0.001093   0.000677   -1.61   0.1065    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 3624 degrees of freedom
## Multiple R-squared:  0.0058, Adjusted R-squared:  0.00498 
## F-statistic: 7.05 on 3 and 3624 DF,  p-value: 0.000101
## 
## [1] "30th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.354 -0.509 -0.420  0.530  1.256 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.527296   0.027553   19.14  < 2e-16 ***
## cate_W        0.050746   0.014354    3.54  0.00041 ***
## X.gender_inp -0.066337   0.014455   -4.59  4.6e-06 ***
## X.age_inp    -0.000677   0.000587   -1.15  0.24894    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 4834 degrees of freedom
## Multiple R-squared:  0.0071, Adjusted R-squared:  0.00648 
## F-statistic: 11.5 on 3 and 4834 DF,  p-value: 1.59e-07
## 
## [1] "40th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.299 -0.498 -0.411  0.535  1.303 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.492073   0.024546   20.05  < 2e-16 ***
## cate_W        0.056327   0.012812    4.40  1.1e-05 ***
## X.gender_inp -0.071317   0.012921   -5.52  3.5e-08 ***
## X.age_inp    -0.000199   0.000526   -0.38     0.71    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.55 on 6043 degrees of freedom
## Multiple R-squared:  0.00818,    Adjusted R-squared:  0.00769 
## F-statistic: 16.6 on 3 and 6043 DF,  p-value: 9.4e-11
## 
## [1] "50th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.258 -0.477 -0.398  0.556  1.501 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.69e-01   2.24e-02   20.90  < 2e-16 ***
## cate_W        4.71e-02   1.17e-02    4.04  5.4e-05 ***
## X.gender_inp -7.23e-02   1.18e-02   -6.14  8.9e-10 ***
## X.age_inp     3.15e-05   4.81e-04    0.07     0.95    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.55 on 7252 degrees of freedom
## Multiple R-squared:  0.00745,    Adjusted R-squared:  0.00703 
## F-statistic: 18.1 on 3 and 7252 DF,  p-value: 1.02e-11
## 
## [1] "60th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.271 -0.459 -0.387  0.573  1.954 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.53e-01   2.09e-02   21.72  < 2e-16 ***
## cate_W        4.13e-02   1.08e-02    3.84  0.00013 ***
## X.gender_inp -6.99e-02   1.09e-02   -6.42  1.4e-10 ***
## X.age_inp     7.37e-05   4.47e-04    0.16  0.86905    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.548 on 8462 degrees of freedom
## Multiple R-squared:  0.00661,    Adjusted R-squared:  0.00625 
## F-statistic: 18.8 on 3 and 8462 DF,  p-value: 4.02e-12
## 
## [1] "70th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.439 -0.458 -0.378  0.575  1.983 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.455508   0.019618   23.22  < 2e-16 ***
## cate_W        0.049495   0.010041    4.93  8.4e-07 ***
## X.gender_inp -0.074488   0.010170   -7.32  2.6e-13 ***
## X.age_inp    -0.000106   0.000419   -0.25      0.8    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.548 on 9671 degrees of freedom
## Multiple R-squared:  0.00802,    Adjusted R-squared:  0.00771 
## F-statistic: 26.1 on 3 and 9671 DF,  p-value: <2e-16
## 
## [1] "80th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.685 -0.468 -0.390  0.569  1.944 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.474858   0.018691   25.41  < 2e-16 ***
## cate_W        0.043409   0.009489    4.57  4.8e-06 ***
## X.gender_inp -0.076434   0.009612   -7.95  2.0e-15 ***
## X.age_inp    -0.000238   0.000401   -0.59     0.55    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 10879 degrees of freedom
## Multiple R-squared:  0.00775,    Adjusted R-squared:  0.00748 
## F-statistic: 28.3 on 3 and 10879 DF,  p-value: <2e-16
## 
## [1] "90th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.730 -0.480 -0.395  0.565  1.926 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.493817   0.017859   27.65  < 2e-16 ***
## cate_W        0.039988   0.009011    4.44  9.2e-06 ***
## X.gender_inp -0.087152   0.009094   -9.58  < 2e-16 ***
## X.age_inp    -0.000306   0.000385   -0.80     0.43    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 12090 degrees of freedom
## Multiple R-squared:  0.00921,    Adjusted R-squared:  0.00897 
## F-statistic: 37.5 on 3 and 12090 DF,  p-value: <2e-16
## 
## [1] "100th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by debt_neg_cw0_lambda_0"
## [1] "finished increasing"
## [1] "#####Running cate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1211 1208 1209 1210 1209 1209 1210 1209 1209 1210 
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.921 -0.544  0.400  0.516  1.571 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.610875   0.042965   14.22  < 2e-16 ***
## cate_W       -0.018750   0.020309   -0.92     0.36    
## X.gender_inp -0.114259   0.020224   -5.65  1.8e-08 ***
## X.age_inp    -0.000323   0.000970   -0.33     0.74    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.561 on 2415 degrees of freedom
## Multiple R-squared:  0.0134, Adjusted R-squared:  0.0121 
## F-statistic: 10.9 on 3 and 2415 DF,  p-value: 4.11e-07
## 
## [1] "20th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.905 -0.519 -0.408  0.544  1.786 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.58528    0.03450   16.96  < 2e-16 ***
## cate_W        0.02738    0.01655    1.65    0.098 .  
## X.gender_inp -0.12026    0.01655   -7.26  4.5e-13 ***
## X.age_inp    -0.00116    0.00076   -1.53    0.127    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.558 on 3624 degrees of freedom
## Multiple R-squared:  0.0154, Adjusted R-squared:  0.0146 
## F-statistic: 18.9 on 3 and 3624 DF,  p-value: 3.66e-12
## 
## [1] "30th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.771 -0.487 -0.394  0.570  1.940 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.535526   0.029517   18.14  < 2e-16 ***
## cate_W        0.029855   0.014259    2.09    0.036 *  
## X.gender_inp -0.109195   0.014316   -7.63  2.9e-14 ***
## X.age_inp    -0.000938   0.000644   -1.46    0.146    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.555 on 4834 degrees of freedom
## Multiple R-squared:  0.013,  Adjusted R-squared:  0.0124 
## F-statistic: 21.3 on 3 and 4834 DF,  p-value: 1.13e-13
## 
## [1] "40th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.688 -0.473 -0.382  0.589  1.987 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.501158   0.026017   19.26  < 2e-16 ***
## cate_W        0.027765   0.012691    2.19    0.029 *  
## X.gender_inp -0.103751   0.012789   -8.11  5.9e-16 ***
## X.age_inp    -0.000568   0.000566   -1.00    0.316    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 6043 degrees of freedom
## Multiple R-squared:  0.0117, Adjusted R-squared:  0.0112 
## F-statistic: 23.8 on 3 and 6043 DF,  p-value: 2.55e-15
## 
## [1] "50th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.670 -0.466 -0.370  0.593  2.013 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.474486   0.023413   20.27   <2e-16 ***
## cate_W        0.036951   0.011563    3.20   0.0014 ** 
## X.gender_inp -0.100638   0.011669   -8.62   <2e-16 ***
## X.age_inp    -0.000165   0.000510   -0.32   0.7465    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 7252 degrees of freedom
## Multiple R-squared:  0.0116, Adjusted R-squared:  0.0112 
## F-statistic: 28.4 on 3 and 7252 DF,  p-value: <2e-16
## 
## [1] "60th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.684 -0.472 -0.371  0.592  2.005 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.474766   0.021485   22.10  < 2e-16 ***
## cate_W        0.037096   0.010710    3.46  0.00054 ***
## X.gender_inp -0.103076   0.010818   -9.53  < 2e-16 ***
## X.age_inp    -0.000040   0.000468   -0.09  0.93194    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 8462 degrees of freedom
## Multiple R-squared:  0.0121, Adjusted R-squared:  0.0117 
## F-statistic: 34.4 on 3 and 8462 DF,  p-value: <2e-16
## 
## [1] "70th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.704 -0.469 -0.380  0.582  1.988 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.492651   0.019938   24.71  < 2e-16 ***
## cate_W        0.038078   0.010030    3.80  0.00015 ***
## X.gender_inp -0.099676   0.010124   -9.85  < 2e-16 ***
## X.age_inp    -0.000461   0.000434   -1.06  0.28870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.55 on 9671 degrees of freedom
## Multiple R-squared:  0.0115, Adjusted R-squared:  0.0112 
## F-statistic: 37.6 on 3 and 9671 DF,  p-value: <2e-16
## 
## [1] "80th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.731 -0.473 -0.389  0.570  1.955 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.504166   0.018782   26.84  < 2e-16 ***
## cate_W        0.040867   0.009480    4.31  1.6e-05 ***
## X.gender_inp -0.092679   0.009562   -9.69  < 2e-16 ***
## X.age_inp    -0.000671   0.000408   -1.64      0.1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.551 on 10880 degrees of freedom
## Multiple R-squared:  0.0105, Adjusted R-squared:  0.0102 
## F-statistic: 38.4 on 3 and 10880 DF,  p-value: <2e-16
## 
## [1] "90th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.730 -0.480 -0.395  0.565  1.926 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.493817   0.017859   27.65  < 2e-16 ***
## cate_W        0.039988   0.009011    4.44  9.2e-06 ***
## X.gender_inp -0.087152   0.009094   -9.58  < 2e-16 ***
## X.age_inp    -0.000306   0.000385   -0.80     0.43    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 12090 degrees of freedom
## Multiple R-squared:  0.00921,    Adjusted R-squared:  0.00897 
## F-statistic: 37.5 on 3 and 12090 DF,  p-value: <2e-16
## 
## [1] "100th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by debt_neg_cw0_lambda_0"
## [1] "finished decreasing"
## [1] "Processing outcome var: debt_neg_cw0_lambda_0"
## [1] "Processing ranking var: ohp_all_ever_inperson_cw0_lambda_0"
## [1] "#####Creating dataframe.#####"
## [1] "outcome filename"
## [1] "PP_Full_Analysis/Intermediate_data/Testing/empirical/cw_med_1/cate_clate_results_debt_neg_cw0.csv"
## [1] "ranking filename"
## [1] "PP_Full_Analysis/Intermediate_data/Testing/empirical/cw_med_1/cate_clate_results_ohp_all_ever_inperson_cw0.csv"
## [1] "Column called for lambda cate ranking"
## [1] "cate_lambda_0_ranking_20"
## [1] "Column called for lambda clate ranking"
## [1] "clate_lambda_0_ranking_20"
## [1] "OHP analysis detected - excluding CLATE rankings"
## [1] "Dimensions of selected_ranking_df: 12208"
## [2] "Dimensions of selected_ranking_df: 2"    
## Rows: 12,208
## Columns: 2
## $ person_id              <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68, 7…
## $ cate_rankings_selected <int> 6, 5, 15, 18, 16, 1, 2, 12, 14, 13, 10, 14, 18,…
## [1] "Dimensions of outcome_df: 12094" "Dimensions of outcome_df: 66"   
## Rows: 12,094
## Columns: 66
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "Dimensions of cdf_data"
## [1] 12094    67
## Rows: 12,094
## Columns: 67
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ cate_rankings_selected    <int> 6, 5, 15, 18, 16, 1, 2, 12, 14, 13, 10, 14, …
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "cate"
## [1] "#####Running cate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1214 1211 1213 1208 1210 1206 1203 1209 1210 1210 
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.069 -0.432 -0.326  0.590  1.426 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.02088    0.06104    0.34    0.732    
## cate_W        0.04655    0.01963    2.37    0.018 *  
## X.gender_inp -0.08886    0.02004   -4.43  9.7e-06 ***
## X.age_inp     0.00780    0.00122    6.42  1.7e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.532 on 2416 degrees of freedom
## Multiple R-squared:  0.0249, Adjusted R-squared:  0.0237 
## F-statistic: 20.5 on 3 and 2416 DF,  p-value: 3.88e-13
## 
## [1] "20th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.077 -0.433 -0.332  0.588  1.446 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.096636   0.043929    2.20  0.02788 *  
## cate_W        0.056563   0.016070    3.52  0.00044 ***
## X.gender_inp -0.091579   0.016235   -5.64  1.8e-08 ***
## X.age_inp     0.006512   0.000889    7.33  2.9e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.533 on 3625 degrees of freedom
## Multiple R-squared:  0.0238, Adjusted R-squared:  0.023 
## F-statistic: 29.5 on 3 and 3625 DF,  p-value: <2e-16
## 
## [1] "30th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.066 -0.428 -0.332  0.598  1.525 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.193988   0.033345    5.82  6.4e-09 ***
## cate_W        0.060562   0.013902    4.36  1.3e-05 ***
## X.gender_inp -0.105609   0.014044   -7.52  6.5e-14 ***
## X.age_inp     0.004685   0.000688    6.81  1.1e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.534 on 4828 degrees of freedom
## Multiple R-squared:  0.0219, Adjusted R-squared:  0.0213 
## F-statistic:   36 on 3 and 4828 DF,  p-value: <2e-16
## 
## [1] "40th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.176 -0.431 -0.351  0.599  1.586 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.320947   0.027268   11.77  < 2e-16 ***
## cate_W        0.060013   0.012521    4.79  1.7e-06 ***
## X.gender_inp -0.087196   0.012614   -6.91  5.3e-12 ***
## X.age_inp     0.001986   0.000575    3.46  0.00055 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.539 on 6034 degrees of freedom
## Multiple R-squared:  0.0126, Adjusted R-squared:  0.0121 
## F-statistic: 25.7 on 3 and 6034 DF,  p-value: <2e-16
## 
## [1] "50th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.194 -0.436 -0.356  0.598  1.575 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.353472   0.023801   14.85  < 2e-16 ***
## cate_W        0.052340   0.011457    4.57  5.0e-06 ***
## X.gender_inp -0.088193   0.011498   -7.67  1.9e-14 ***
## X.age_inp     0.001553   0.000504    3.09    0.002 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.54 on 7244 degrees of freedom
## Multiple R-squared:  0.0117, Adjusted R-squared:  0.0113 
## F-statistic: 28.5 on 3 and 7244 DF,  p-value: <2e-16
## 
## [1] "60th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.248 -0.440 -0.364  0.594  1.608 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.380336   0.021659   17.56  < 2e-16 ***
## cate_W        0.049287   0.010648    4.63  3.7e-06 ***
## X.gender_inp -0.076534   0.010692   -7.16  8.9e-13 ***
## X.age_inp     0.001053   0.000455    2.31    0.021 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.543 on 8452 degrees of freedom
## Multiple R-squared:  0.00918,    Adjusted R-squared:  0.00882 
## F-statistic: 26.1 on 3 and 8452 DF,  p-value: <2e-16
## 
## [1] "70th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.554 -0.445 -0.364  0.589  1.597 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.387371   0.020011   19.36  < 2e-16 ***
## cate_W        0.049036   0.009967    4.92  8.8e-07 ***
## X.gender_inp -0.084724   0.010031   -8.45  < 2e-16 ***
## X.age_inp     0.001160   0.000422    2.75    0.006 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.544 on 9665 degrees of freedom
## Multiple R-squared:  0.0107, Adjusted R-squared:  0.0104 
## F-statistic: 34.8 on 3 and 9665 DF,  p-value: <2e-16
## 
## [1] "80th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.639 -0.463 -0.380  0.577  2.005 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.428871   0.018897   22.69  < 2e-16 ***
## cate_W        0.046926   0.009457    4.96  7.1e-07 ***
## X.gender_inp -0.085713   0.009528   -9.00  < 2e-16 ***
## X.age_inp     0.000712   0.000403    1.77    0.077 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.55 on 10876 degrees of freedom
## Multiple R-squared:  0.01,   Adjusted R-squared:  0.00974 
## F-statistic: 36.7 on 3 and 10876 DF,  p-value: <2e-16
## 
## [1] "90th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.730 -0.480 -0.395  0.565  1.926 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.493817   0.017859   27.65  < 2e-16 ***
## cate_W        0.039988   0.009011    4.44  9.2e-06 ***
## X.gender_inp -0.087152   0.009094   -9.58  < 2e-16 ***
## X.age_inp    -0.000306   0.000385   -0.80     0.43    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 12090 degrees of freedom
## Multiple R-squared:  0.00921,    Adjusted R-squared:  0.00897 
## F-statistic: 37.5 on 3 and 12090 DF,  p-value: <2e-16
## 
## [1] "100th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by ohp_all_ever_inperson_cw0_lambda_0"
## [1] "finished increasing"
## [1] "#####Running cate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1214 1211 1213 1208 1210 1206 1203 1209 1210 1210 
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -2.141 -0.582  0.332  0.450  1.331 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.53796    0.04355   12.35  < 2e-16 ***
## cate_W       -0.02061    0.01973   -1.04  0.29637    
## X.gender_inp -0.11095    0.02021   -5.49  4.4e-08 ***
## X.age_inp     0.00407    0.00111    3.69  0.00023 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.546 on 2421 degrees of freedom
## Multiple R-squared:  0.0202, Adjusted R-squared:  0.0189 
## F-statistic: 16.6 on 3 and 2421 DF,  p-value: 1.12e-10
## 
## [1] "20th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -2.017 -0.536  0.351  0.498  1.558 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.517785   0.034300   15.10  < 2e-16 ***
## cate_W       -0.002390   0.016349   -0.15  0.88378    
## X.gender_inp -0.129066   0.016760   -7.70  1.7e-14 ***
## X.age_inp     0.003210   0.000839    3.83  0.00013 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 3634 degrees of freedom
## Multiple R-squared:  0.0217, Adjusted R-squared:  0.0209 
## F-statistic: 26.9 on 3 and 3634 DF,  p-value: <2e-16
## 
## [1] "30th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.971 -0.517  0.370  0.519  1.661 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.530841   0.029307   18.11   <2e-16 ***
## cate_W        0.009810   0.014246    0.69   0.4911    
## X.gender_inp -0.124747   0.014894   -8.38   <2e-16 ***
## X.age_inp     0.001903   0.000687    2.77   0.0056 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.556 on 4842 degrees of freedom
## Multiple R-squared:  0.0175, Adjusted R-squared:  0.0169 
## F-statistic: 28.7 on 3 and 4842 DF,  p-value: <2e-16
## 
## [1] "40th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.915 -0.502  0.373  0.537  1.728 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.523024   0.025597   20.43   <2e-16 ***
## cate_W        0.011338   0.012759    0.89   0.3743    
## X.gender_inp -0.124552   0.013281   -9.38   <2e-16 ***
## X.age_inp     0.001544   0.000593    2.60   0.0093 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.555 on 6052 degrees of freedom
## Multiple R-squared:  0.0166, Adjusted R-squared:  0.0161 
## F-statistic:   34 on 3 and 6052 DF,  p-value: <2e-16
## 
## [1] "50th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.867 -0.499 -0.430  0.542  1.782 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.532212   0.022824   23.32   <2e-16 ***
## cate_W        0.021422   0.011677    1.83    0.067 .  
## X.gender_inp -0.108271   0.012026   -9.00   <2e-16 ***
## X.age_inp     0.000426   0.000532    0.80    0.424    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.556 on 7258 degrees of freedom
## Multiple R-squared:  0.0118, Adjusted R-squared:  0.0114 
## F-statistic:   29 on 3 and 7258 DF,  p-value: <2e-16
## 
## [1] "60th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.832 -0.490 -0.418  0.553  1.852 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.526085   0.020794   25.30   <2e-16 ***
## cate_W        0.029040   0.010797    2.69   0.0072 ** 
## X.gender_inp -0.108621   0.011061   -9.82   <2e-16 ***
## X.age_inp     0.000020   0.000481    0.04   0.9668    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.555 on 8461 degrees of freedom
## Multiple R-squared:  0.0123, Adjusted R-squared:  0.0119 
## F-statistic:   35 on 3 and 8461 DF,  p-value: <2e-16
## 
## [1] "70th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.806 -0.487 -0.407  0.557  1.886 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.508026   0.019267   26.37  < 2e-16 ***
## cate_W        0.036084   0.010090    3.58  0.00035 ***
## X.gender_inp -0.104824   0.010321  -10.16  < 2e-16 ***
## X.age_inp     0.000116   0.000436    0.27  0.78986    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 9670 degrees of freedom
## Multiple R-squared:  0.012,  Adjusted R-squared:  0.0117 
## F-statistic: 39.2 on 3 and 9670 DF,  p-value: <2e-16
## 
## [1] "80th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.765 -0.486 -0.400  0.559  1.909 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.490636   0.018401   26.66  < 2e-16 ***
## cate_W        0.040989   0.009507    4.31  1.6e-05 ***
## X.gender_inp -0.094827   0.009670   -9.81  < 2e-16 ***
## X.age_inp     0.000122   0.000406    0.30     0.76    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 10880 degrees of freedom
## Multiple R-squared:  0.0106, Adjusted R-squared:  0.0103 
## F-statistic: 38.7 on 3 and 10880 DF,  p-value: <2e-16
## 
## [1] "90th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Y ~ cate_W + X.gender_inp + X.age_inp"
## 
## Call:
## lm(formula = as.formula(formula_str), data = data_subset, weights = weights)
## 
## Weighted Residuals:
##    Min     1Q Median     3Q    Max 
## -1.730 -0.480 -0.395  0.565  1.926 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.493817   0.017859   27.65  < 2e-16 ***
## cate_W        0.039988   0.009011    4.44  9.2e-06 ***
## X.gender_inp -0.087152   0.009094   -9.58  < 2e-16 ***
## X.age_inp    -0.000306   0.000385   -0.80     0.43    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 12090 degrees of freedom
## Multiple R-squared:  0.00921,    Adjusted R-squared:  0.00897 
## F-statistic: 37.5 on 3 and 12090 DF,  p-value: <2e-16
## 
## [1] "100th"
## <simpleError in print.default("Estimate:", estimate[current_index]): invalid printing digits 0>
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by ohp_all_ever_inperson_cw0_lambda_0"

## [1] "finished decreasing"

# Check if CLATE pairs exist and are not empty
if (length(clate_outcome_rankvar_pairs) > 0 && 
    !is.null(clate_outcome_rankvar_pairs[[1]]) && 
    length(clate_outcome_rankvar_pairs[[1]]) > 0) {
    
    for (i in seq_along(clate_outcome_rankvar_pairs)) {
        outcome <- clate_outcome_rankvar_pairs[[i]][[1]]                     
        ranking_variable <- clate_outcome_rankvar_pairs[[i]][[2]]                
        create_cumulative_outcome_plots(outcome, ranking_variable, "clate")
    }
} else {
    print("No CLATE pairs to process - skipping CLATE analysis")
}
## [1] "Processing outcome var: debt_neg_cw0_lambda_0"
## [1] "Processing ranking var: debt_neg_cw0_lambda_0"
## [1] "#####Creating dataframe.#####"
## [1] "Column called for lambda cate ranking"
## [1] "cate_lambda_0_ranking_20"
## [1] "Column called for lambda clate ranking"
## [1] "clate_lambda_0_ranking_20"
## [1] "Filename:"
## [1] "PP_Full_Analysis/Intermediate_data/Testing/empirical/cw_med_1/cate_clate_results_debt_neg_cw0.csv"
## [1] "Non-OHP analysis - including CLATE rankings"
## [1] "Dimensions of selected_ranking_df: 12094"
## [2] "Dimensions of selected_ranking_df: 3"    
## Rows: 12,094
## Columns: 3
## $ person_id               <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68, …
## $ cate_rankings_selected  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, 17…
## $ clate_rankings_selected <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, 13…
## [1] "Dimensions of outcome_df: 12094" "Dimensions of outcome_df: 66"   
## Rows: 12,094
## Columns: 66
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "Dimensions of cdf_data"
## [1] 12094    68
## Rows: 12,094
## Columns: 68
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ cate_rankings_selected    <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_rankings_selected   <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] "clate"
## [1] "#####Running clate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1210 1210 1208 1210 1214 1204 1210 1209 1209 1210 
## Rows: 2,419
## Columns: 68
## $ person_id                 <int> 5, 47, 196, 240, 243, 255, 287, 294, 333, 34…
## $ cate_rankings_selected    <int> 20, 19, 20, 11, 17, 18, 16, 15, 20, 14, 20, …
## $ clate_rankings_selected   <int> 20, 17, 19, 18, 17, 19, 17, 18, 19, 18, 19, …
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1,…
## $ X.age_inp                 <int> 60, 43, 51, 61, 57, 24, 30, 25, 51, 46, 56, …
## $ X.hispanic_inp            <int> 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ed_charg_tot_pre_ed     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ Y                         <int> 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0,…
## $ clate_W                   <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ Z                         <int> 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0,…
## $ weights                   <dbl> 1.1504, 1.0000, 1.5712, 1.1438, 1.0033, 1.00…
## $ folds                     <int> 8, 4, 1, 6, 3, 3, 3, 6, 8, 2, 6, 2, 4, 2, 1,…
## $ clate                     <dbl> 0.2218, 0.1845, 0.1973, 0.1875, 0.1784, 0.19…
## $ clate_se                  <dbl> 0.06976, 0.05760, 0.04286, 0.03214, 0.04930,…
## $ clate_ranking_5           <int> 5, 5, 5, 5, 4, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5,…
## $ clate_ranking_20          <int> 20, 18, 19, 18, 16, 19, 16, 18, 19, 19, 19, …
## $ cate_W                    <int> 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0,…
## $ cate                      <dbl> 0.05106, 0.04927, 0.05172, 0.03666, 0.04387,…
## $ cate_se                   <dbl> 0.007787, 0.014469, 0.013995, 0.019792, 0.02…
## $ cate_ranking_5            <int> 5, 5, 5, 3, 4, 5, 4, 4, 5, 4, 5, 4, 5, 4, 5,…
## $ cate_ranking_20           <int> 20, 19, 20, 11, 16, 18, 16, 15, 20, 14, 20, …
## $ cate_lambda_0             <dbl> 0.05106, 0.04927, 0.05172, 0.03666, 0.04387,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1845, 0.1973, 0.1875, 0.1784, 0.19…
## $ cate_lambda_0_ranking_5   <int> 5, 5, 5, 3, 5, 5, 4, 4, 5, 4, 5, 4, 5, 4, 5,…
## $ clate_lambda_0_ranking_5  <int> 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,…
## $ cate_lambda_0_ranking_20  <int> 20, 19, 20, 11, 17, 18, 16, 15, 20, 14, 20, …
## $ clate_lambda_0_ranking_20 <int> 20, 17, 19, 18, 17, 19, 17, 18, 19, 18, 19, …
## $ cate_lambda_1             <dbl> 0.04911, 0.04566, 0.04822, 0.03171, 0.03867,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1701, 0.1865, 0.1794, 0.1661, 0.18…
## $ cate_lambda_1_ranking_5   <int> 5, 5, 5, 3, 4, 5, 4, 4, 5, 4, 5, 4, 5, 4, 5,…
## $ clate_lambda_1_ranking_5  <int> 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5,…
## $ cate_lambda_1_ranking_20  <int> 20, 19, 20, 9, 15, 18, 15, 14, 20, 13, 20, 1…
## $ clate_lambda_1_ranking_20 <int> 20, 17, 19, 18, 17, 19, 15, 18, 19, 18, 19, …
## $ cate_lambda_2             <dbl> 0.04716, 0.04204, 0.04473, 0.02677, 0.03347,…
## $ clate_lambda_2            <dbl> 0.1870, 0.1557, 0.1758, 0.1714, 0.1537, 0.16…
## $ cate_lambda_2_ranking_5   <int> 5, 5, 5, 2, 4, 5, 4, 3, 5, 4, 5, 4, 5, 4, 5,…
## $ clate_lambda_2_ranking_5  <int> 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5,…
## $ cate_lambda_2_ranking_20  <int> 20, 19, 20, 8, 14, 17, 15, 12, 20, 13, 20, 1…
## $ clate_lambda_2_ranking_20 <int> 20, 17, 19, 19, 17, 18, 14, 19, 20, 17, 20, …
## $ cate_lambda_3             <dbl> 0.04522, 0.03842, 0.04123, 0.02182, 0.02827,…
## $ clate_lambda_3            <dbl> 0.1695, 0.1413, 0.1651, 0.1634, 0.1414, 0.14…
## $ cate_lambda_3_ranking_5   <int> 5, 5, 5, 2, 3, 5, 4, 3, 5, 4, 5, 5, 4, 4, 5,…
## $ clate_lambda_3_ranking_5  <int> 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5,…
## $ cate_lambda_3_ranking_20  <int> 20, 19, 20, 8, 12, 17, 14, 11, 19, 13, 20, 1…
## $ clate_lambda_3_ranking_20 <int> 20, 17, 19, 19, 17, 18, 13, 19, 20, 17, 20, …
## $ cate_lambda_4             <dbl> 0.04327, 0.03481, 0.03773, 0.01687, 0.02306,…
## $ clate_lambda_4            <dbl> 0.15208, 0.12687, 0.15439, 0.15533, 0.12910,…
## $ cate_lambda_4_ranking_5   <int> 5, 5, 5, 2, 3, 4, 4, 3, 5, 3, 5, 5, 4, 4, 5,…
## $ clate_lambda_4_ranking_5  <int> 5, 5, 5, 5, 5, 5, 3, 5, 5, 4, 5, 5, 5, 5, 5,…
## $ cate_lambda_4_ranking_20  <int> 20, 19, 20, 7, 11, 16, 13, 10, 19, 12, 19, 1…
## $ clate_lambda_4_ranking_20 <int> 19, 17, 19, 19, 17, 17, 12, 19, 20, 16, 20, …
## [1] 0.8
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.353 -0.515 -0.431  0.544  1.223 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.496344   0.042776   11.60   <2e-16 ***
## clate_W       0.099214   0.079595    1.25    0.213    
## X.gender_inp -0.057810   0.024258   -2.38    0.017 *  
## X.age_inp     0.000319   0.000787    0.41    0.685    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 2415    209.45  <2e-16 ***
## Wu-Hausman          1 2414      0.16    0.69    
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 2415 degrees of freedom
## Multiple R-Squared: 0.00489, Adjusted R-squared: 0.00365 
## Wald test:    2 on 3 and 2415 DF,  p-value: 0.112 
## 
## Rows: 3,628
## Columns: 68
## $ person_id                 <int> 5, 47, 57, 88, 113, 144, 195, 196, 210, 240,…
## $ cate_rankings_selected    <int> 20, 19, 12, 9, 7, 14, 12, 20, 13, 11, 17, 18…
## $ clate_rankings_selected   <int> 20, 17, 15, 15, 16, 16, 16, 19, 16, 18, 17, …
## $ X.numhh_list              <int> 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0,…
## $ X.age_inp                 <int> 60, 43, 46, 56, 59, 50, 46, 51, 28, 61, 57, …
## $ X.hispanic_inp            <int> 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.lessHS                  <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ed_charg_tot_pre_ed     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ Y                         <int> 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1,…
## $ Z                         <int> 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.150, 1.000, 1.003, 1.325, 1.708, 1.000, 1.…
## $ folds                     <int> 8, 4, 10, 2, 1, 4, 2, 1, 5, 6, 3, 3, 1, 6, 7…
## $ clate                     <dbl> 0.2218, 0.1845, 0.1681, 0.1683, 0.1724, 0.17…
## $ clate_se                  <dbl> 0.06976, 0.05760, 0.05733, 0.09286, 0.05619,…
## $ clate_ranking_5           <int> 5, 5, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 4, 5,…
## $ clate_ranking_20          <int> 20, 18, 15, 15, 16, 16, 17, 19, 16, 18, 16, …
## $ cate_W                    <int> 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.05106, 0.04927, 0.03821, 0.03428, 0.03169,…
## $ cate_se                   <dbl> 0.007787, 0.014469, 0.008896, 0.010848, 0.01…
## $ cate_ranking_5            <int> 5, 5, 3, 3, 2, 4, 3, 5, 3, 3, 4, 5, 5, 4, 5,…
## $ cate_ranking_20           <int> 20, 19, 12, 9, 7, 14, 12, 20, 12, 11, 16, 18…
## $ cate_lambda_0             <dbl> 0.05106, 0.04927, 0.03821, 0.03428, 0.03169,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1845, 0.1681, 0.1683, 0.1724, 0.17…
## $ cate_lambda_0_ranking_5   <int> 5, 5, 3, 3, 2, 4, 3, 5, 4, 3, 5, 5, 5, 4, 5,…
## $ clate_lambda_0_ranking_5  <int> 5, 5, 4, 4, 4, 4, 4, 5, 4, 5, 5, 5, 4, 4, 4,…
## $ cate_lambda_0_ranking_20  <int> 20, 19, 12, 9, 7, 14, 12, 20, 13, 11, 17, 18…
## $ clate_lambda_0_ranking_20 <int> 20, 17, 15, 15, 16, 16, 16, 19, 16, 18, 17, …
## $ cate_lambda_1             <dbl> 0.04911, 0.04566, 0.03598, 0.03157, 0.02749,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1701, 0.1537, 0.1451, 0.1583, 0.16…
## $ cate_lambda_1_ranking_5   <int> 5, 5, 4, 3, 2, 4, 4, 5, 4, 3, 4, 5, 5, 4, 5,…
## $ clate_lambda_1_ranking_5  <int> 5, 5, 4, 4, 4, 5, 4, 5, 4, 5, 5, 5, 4, 4, 4,…
## $ cate_lambda_1_ranking_20  <int> 20, 19, 13, 9, 7, 13, 13, 20, 13, 9, 15, 18,…
## $ clate_lambda_1_ranking_20 <int> 20, 17, 15, 13, 15, 17, 14, 19, 16, 18, 17, …
## $ cate_lambda_2             <dbl> 0.04716, 0.04204, 0.03376, 0.02885, 0.02330,…
## $ clate_lambda_2            <dbl> 0.1870, 0.1557, 0.1394, 0.1218, 0.1443, 0.15…
## $ cate_lambda_2_ranking_5   <int> 5, 5, 4, 3, 2, 3, 4, 5, 4, 2, 4, 5, 5, 4, 5,…
## $ clate_lambda_2_ranking_5  <int> 5, 5, 4, 3, 4, 5, 3, 5, 4, 5, 5, 5, 5, 4, 4,…
## $ cate_lambda_2_ranking_20  <int> 20, 19, 14, 10, 6, 12, 14, 20, 13, 8, 14, 17…
## $ clate_lambda_2_ranking_20 <int> 20, 17, 15, 11, 15, 17, 12, 19, 15, 19, 17, …
## $ cate_lambda_3             <dbl> 0.04522, 0.03842, 0.03153, 0.02614, 0.01911,…
## $ clate_lambda_3            <dbl> 0.16952, 0.14128, 0.12507, 0.09864, 0.13025,…
## $ cate_lambda_3_ranking_5   <int> 5, 5, 4, 3, 2, 3, 4, 5, 4, 2, 3, 5, 5, 3, 5,…
## $ clate_lambda_3_ranking_5  <int> 5, 5, 4, 3, 4, 5, 3, 5, 4, 5, 5, 5, 5, 4, 4,…
## $ cate_lambda_3_ranking_20  <int> 20, 19, 15, 11, 6, 11, 15, 20, 13, 8, 12, 17…
## $ clate_lambda_3_ranking_20 <int> 20, 17, 14, 10, 15, 18, 11, 19, 15, 19, 17, …
## $ cate_lambda_4             <dbl> 0.04327, 0.03481, 0.02931, 0.02343, 0.01491,…
## $ clate_lambda_4            <dbl> 0.15208, 0.12687, 0.11074, 0.07542, 0.11620,…
## $ cate_lambda_4_ranking_5   <int> 5, 5, 4, 3, 2, 3, 4, 5, 4, 2, 3, 4, 5, 3, 5,…
## $ clate_lambda_4_ranking_5  <int> 5, 5, 4, 2, 4, 5, 3, 5, 4, 5, 5, 5, 5, 4, 4,…
## $ cate_lambda_4_ranking_20  <int> 20, 19, 16, 11, 6, 10, 16, 20, 13, 7, 11, 16…
## $ clate_lambda_4_ranking_20 <int> 19, 17, 14, 8, 15, 18, 9, 19, 15, 19, 17, 17…
## [1] 0.7
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.549 -0.491 -0.391  0.563  1.324 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.477506   0.034654   13.78  < 2e-16 ***
## clate_W       0.212156   0.065087    3.26   0.0011 ** 
## X.gender_inp -0.083109   0.018937   -4.39  1.2e-05 ***
## X.age_inp     0.000253   0.000651    0.39   0.6974    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 3624    322.27  <2e-16 ***
## Wu-Hausman          1 3623      5.78   0.016 *  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.558 on 3624 degrees of freedom
## Multiple R-Squared: -0.011,  Adjusted R-squared: -0.0118 
## Wald test: 7.77 on 3 and 3624 DF,  p-value: 3.61e-05 
## 
## Rows: 4,838
## Columns: 68
## $ person_id                 <int> 5, 47, 57, 68, 76, 83, 88, 101, 113, 144, 19…
## $ cate_rankings_selected    <int> 20, 19, 12, 17, 17, 10, 9, 14, 7, 14, 12, 20…
## $ clate_rankings_selected   <int> 20, 17, 15, 14, 13, 14, 15, 13, 16, 16, 16, …
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,…
## $ X.age_inp                 <int> 60, 43, 46, 25, 60, 54, 56, 43, 59, 50, 46, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.lessHS                  <int> 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ed_charg_tot_pre_ed     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ Y                         <int> 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,…
## $ clate_W                   <int> 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ Z                         <int> 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1,…
## $ weights                   <dbl> 1.1504, 1.0000, 1.0033, 1.0000, 1.0000, 1.00…
## $ folds                     <int> 8, 4, 10, 6, 7, 10, 2, 8, 1, 4, 2, 1, 5, 7, …
## $ clate                     <dbl> 0.2218, 0.1845, 0.1681, 0.1665, 0.1582, 0.16…
## $ clate_se                  <dbl> 0.06976, 0.05760, 0.05733, 0.05982, 0.03965,…
## $ clate_ranking_5           <int> 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4,…
## $ clate_ranking_20          <int> 20, 18, 15, 14, 13, 14, 15, 13, 16, 16, 17, …
## $ cate_W                    <int> 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1,…
## $ cate                      <dbl> 0.05106, 0.04927, 0.03821, 0.04510, 0.04481,…
## $ cate_se                   <dbl> 0.007787, 0.014469, 0.008896, 0.021442, 0.01…
## $ cate_ranking_5            <int> 5, 5, 3, 5, 5, 3, 3, 4, 2, 4, 3, 5, 3, 3, 4,…
## $ cate_ranking_20           <int> 20, 19, 12, 17, 17, 10, 9, 14, 7, 14, 12, 20…
## $ cate_lambda_0             <dbl> 0.05106, 0.04927, 0.03821, 0.04510, 0.04481,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1845, 0.1681, 0.1665, 0.1582, 0.16…
## $ cate_lambda_0_ranking_5   <int> 5, 5, 3, 5, 5, 3, 3, 4, 2, 4, 3, 5, 4, 3, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4,…
## $ cate_lambda_0_ranking_20  <int> 20, 19, 12, 17, 17, 10, 9, 14, 7, 14, 12, 20…
## $ clate_lambda_0_ranking_20 <int> 20, 17, 15, 14, 13, 14, 15, 13, 16, 16, 16, …
## $ cate_lambda_1             <dbl> 0.04911, 0.04566, 0.03598, 0.03974, 0.04077,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1701, 0.1537, 0.1515, 0.1483, 0.14…
## $ cate_lambda_1_ranking_5   <int> 5, 5, 4, 4, 5, 3, 3, 4, 2, 4, 4, 5, 4, 3, 3,…
## $ clate_lambda_1_ranking_5  <int> 5, 5, 4, 4, 4, 4, 4, 3, 4, 5, 4, 5, 4, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 19, 13, 16, 17, 11, 9, 14, 7, 13, 13, 20…
## $ clate_lambda_1_ranking_20 <int> 20, 17, 15, 14, 14, 13, 13, 12, 15, 17, 14, …
## $ cate_lambda_2             <dbl> 0.04716, 0.04204, 0.03376, 0.03438, 0.03673,…
## $ clate_lambda_2            <dbl> 0.1870, 0.1557, 0.1394, 0.1365, 0.1384, 0.12…
## $ cate_lambda_2_ranking_5   <int> 5, 5, 4, 4, 4, 3, 3, 4, 2, 3, 4, 5, 4, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 5, 5, 4, 4, 4, 4, 3, 3, 4, 5, 3, 5, 4, 4, 3,…
## $ cate_lambda_2_ranking_20  <int> 20, 19, 14, 15, 16, 12, 10, 13, 6, 12, 14, 2…
## $ clate_lambda_2_ranking_20 <int> 20, 17, 15, 14, 14, 13, 11, 11, 15, 17, 12, …
## $ cate_lambda_3             <dbl> 0.04522, 0.03842, 0.03153, 0.02902, 0.03269,…
## $ clate_lambda_3            <dbl> 0.16952, 0.14128, 0.12507, 0.12159, 0.12851,…
## $ cate_lambda_3_ranking_5   <int> 5, 5, 4, 4, 4, 4, 3, 4, 2, 3, 4, 5, 4, 3, 3,…
## $ clate_lambda_3_ranking_5  <int> 5, 5, 4, 4, 4, 3, 3, 3, 4, 5, 3, 5, 4, 4, 3,…
## $ cate_lambda_3_ranking_20  <int> 20, 19, 15, 13, 16, 14, 11, 13, 6, 11, 15, 2…
## $ clate_lambda_3_ranking_20 <int> 20, 17, 14, 14, 15, 12, 10, 11, 15, 18, 11, …
## $ cate_lambda_4             <dbl> 0.04327, 0.03481, 0.02931, 0.02366, 0.02866,…
## $ clate_lambda_4            <dbl> 0.15208, 0.12687, 0.11074, 0.10663, 0.11860,…
## $ cate_lambda_4_ranking_5   <int> 5, 5, 4, 3, 4, 4, 3, 4, 2, 3, 4, 5, 4, 3, 3,…
## $ clate_lambda_4_ranking_5  <int> 5, 5, 4, 4, 4, 3, 2, 3, 4, 5, 3, 5, 4, 5, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 19, 16, 11, 15, 15, 11, 13, 6, 10, 16, 2…
## $ clate_lambda_4_ranking_20 <int> 19, 17, 14, 14, 16, 11, 8, 10, 15, 18, 9, 19…
## [1] 0.6
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.599 -0.490 -0.373  0.552  1.360 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.494068   0.029924   16.51  < 2e-16 ***
## clate_W       0.228178   0.057225    3.99  6.8e-05 ***
## X.gender_inp -0.105591   0.015636   -6.75  1.6e-11 ***
## X.age_inp    -0.000157   0.000572   -0.27     0.78    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 4834    417.24  <2e-16 ***
## Wu-Hausman          1 4833      9.34  0.0023 ** 
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.557 on 4834 degrees of freedom
## Multiple R-Squared: -0.0118, Adjusted R-squared: -0.0124 
## Wald test: 16.8 on 3 and 4834 DF,  p-value: 7.37e-11 
## 
## Rows: 6,042
## Columns: 68
## $ person_id                 <int> 5, 47, 57, 68, 76, 83, 88, 89, 101, 113, 144…
## $ cate_rankings_selected    <int> 20, 19, 12, 17, 17, 10, 9, 13, 14, 7, 14, 12…
## $ clate_rankings_selected   <int> 20, 17, 15, 14, 13, 14, 15, 11, 13, 16, 16, …
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.age_inp                 <int> 60, 43, 46, 25, 60, 54, 56, 39, 43, 59, 50, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0,…
## $ X.lessHS                  <int> 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 895.8, 0.…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 688.8, 0.…
## $ Y                         <int> 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0,…
## $ clate_W                   <int> 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ Z                         <int> 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,…
## $ weights                   <dbl> 1.1504, 1.0000, 1.0033, 1.0000, 1.0000, 1.00…
## $ folds                     <int> 8, 4, 10, 6, 7, 10, 2, 7, 8, 1, 4, 2, 1, 9, …
## $ clate                     <dbl> 0.2218, 0.1845, 0.1681, 0.1665, 0.1582, 0.16…
## $ clate_se                  <dbl> 0.06976, 0.05760, 0.05733, 0.05982, 0.03965,…
## $ clate_ranking_5           <int> 5, 5, 4, 4, 4, 4, 4, 3, 4, 4, 4, 5, 5, 3, 4,…
## $ clate_ranking_20          <int> 20, 18, 15, 14, 13, 14, 15, 11, 13, 16, 16, …
## $ cate_W                    <int> 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,…
## $ cate                      <dbl> 0.05106, 0.04927, 0.03821, 0.04510, 0.04481,…
## $ cate_se                   <dbl> 0.007787, 0.014469, 0.008896, 0.021442, 0.01…
## $ cate_ranking_5            <int> 5, 5, 3, 5, 5, 3, 3, 4, 4, 2, 4, 3, 5, 3, 3,…
## $ cate_ranking_20           <int> 20, 19, 12, 17, 17, 10, 9, 13, 14, 7, 14, 12…
## $ cate_lambda_0             <dbl> 0.05106, 0.04927, 0.03821, 0.04510, 0.04481,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1845, 0.1681, 0.1665, 0.1582, 0.16…
## $ cate_lambda_0_ranking_5   <int> 5, 5, 3, 5, 5, 3, 3, 4, 4, 2, 4, 3, 5, 3, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 5, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 5, 3, 4,…
## $ cate_lambda_0_ranking_20  <int> 20, 19, 12, 17, 17, 10, 9, 13, 14, 7, 14, 12…
## $ clate_lambda_0_ranking_20 <int> 20, 17, 15, 14, 13, 14, 15, 11, 13, 16, 16, …
## $ cate_lambda_1             <dbl> 0.04911, 0.04566, 0.03598, 0.03974, 0.04077,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1701, 0.1537, 0.1515, 0.1483, 0.14…
## $ cate_lambda_1_ranking_5   <int> 5, 5, 4, 4, 5, 3, 3, 3, 4, 2, 4, 4, 5, 3, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 5, 4, 4, 4, 4, 4, 3, 3, 4, 5, 4, 5, 3, 4,…
## $ cate_lambda_1_ranking_20  <int> 20, 19, 13, 16, 17, 11, 9, 12, 14, 7, 13, 13…
## $ clate_lambda_1_ranking_20 <int> 20, 17, 15, 14, 14, 13, 13, 11, 12, 15, 17, …
## $ cate_lambda_2             <dbl> 0.04716, 0.04204, 0.03376, 0.03438, 0.03673,…
## $ clate_lambda_2            <dbl> 0.1870, 0.1557, 0.1394, 0.1365, 0.1384, 0.12…
## $ cate_lambda_2_ranking_5   <int> 5, 5, 4, 4, 4, 3, 3, 3, 4, 2, 3, 4, 5, 3, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 5, 4, 4, 4, 4, 3, 3, 3, 4, 5, 3, 5, 2, 4,…
## $ cate_lambda_2_ranking_20  <int> 20, 19, 14, 15, 16, 12, 10, 12, 13, 6, 12, 1…
## $ clate_lambda_2_ranking_20 <int> 20, 17, 15, 14, 14, 13, 11, 11, 11, 15, 17, …
## $ cate_lambda_3             <dbl> 0.04522, 0.03842, 0.03153, 0.02902, 0.03269,…
## $ clate_lambda_3            <dbl> 0.16952, 0.14128, 0.12507, 0.12159, 0.12851,…
## $ cate_lambda_3_ranking_5   <int> 5, 5, 4, 4, 4, 4, 3, 3, 4, 2, 3, 4, 5, 3, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 5, 4, 4, 4, 3, 3, 3, 3, 4, 5, 3, 5, 2, 4,…
## $ cate_lambda_3_ranking_20  <int> 20, 19, 15, 13, 16, 14, 11, 12, 13, 6, 11, 1…
## $ clate_lambda_3_ranking_20 <int> 20, 17, 14, 14, 15, 12, 10, 11, 11, 15, 18, …
## $ cate_lambda_4             <dbl> 0.04327, 0.03481, 0.02931, 0.02366, 0.02866,…
## $ clate_lambda_4            <dbl> 0.15208, 0.12687, 0.11074, 0.10663, 0.11860,…
## $ cate_lambda_4_ranking_5   <int> 5, 5, 4, 3, 4, 4, 3, 3, 4, 2, 3, 4, 5, 3, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 3, 5, 2, 4,…
## $ cate_lambda_4_ranking_20  <int> 20, 19, 16, 11, 15, 15, 11, 12, 13, 6, 10, 1…
## $ clate_lambda_4_ranking_20 <int> 19, 17, 14, 14, 16, 11, 8, 11, 10, 15, 18, 9…
## [1] 0.5
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.519 -0.484 -0.375  0.554  1.974 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.489683   0.026850   18.24  < 2e-16 ***
## clate_W       0.198308   0.050617    3.92  9.0e-05 ***
## X.gender_inp -0.101395   0.013783   -7.36  2.1e-13 ***
## X.age_inp    -0.000220   0.000517   -0.43     0.67    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 6038    529.39  <2e-16 ***
## Wu-Hausman          1 6037      6.92  0.0086 ** 
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.555 on 6038 degrees of freedom
## Multiple R-Squared: -0.00174,    Adjusted R-squared: -0.00224 
## Wald test: 19.3 on 3 and 6038 DF,  p-value: 1.95e-12 
## 
## Rows: 7,256
## Columns: 68
## $ person_id                 <int> 5, 47, 57, 59, 68, 76, 77, 83, 88, 89, 101, …
## $ cate_rankings_selected    <int> 20, 19, 12, 13, 17, 17, 14, 10, 9, 13, 14, 9…
## $ clate_rankings_selected   <int> 20, 17, 15, 10, 14, 13, 10, 14, 15, 11, 13, …
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1,…
## $ X.age_inp                 <int> 60, 43, 46, 38, 25, 60, 35, 54, 56, 39, 43, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ Y                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1,…
## $ Z                         <int> 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1,…
## $ weights                   <dbl> 1.1504, 1.0000, 1.0033, 1.5389, 1.0000, 1.00…
## $ folds                     <int> 8, 4, 10, 7, 6, 7, 8, 10, 2, 7, 8, 2, 1, 4, …
## $ clate                     <dbl> 0.2218, 0.1845, 0.1681, 0.1448, 0.1665, 0.15…
## $ clate_se                  <dbl> 0.06976, 0.05760, 0.05733, 0.08090, 0.05982,…
## $ clate_ranking_5           <int> 5, 5, 4, 3, 4, 4, 3, 4, 4, 3, 4, 3, 4, 4, 3,…
## $ clate_ranking_20          <int> 20, 18, 15, 11, 14, 13, 10, 14, 15, 11, 13, …
## $ cate_W                    <int> 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1,…
## $ cate                      <dbl> 0.05106, 0.04927, 0.03821, 0.03956, 0.04510,…
## $ cate_se                   <dbl> 0.007787, 0.014469, 0.008896, 0.010091, 0.02…
## $ cate_ranking_5            <int> 5, 5, 3, 4, 5, 5, 4, 3, 3, 4, 4, 3, 2, 4, 3,…
## $ cate_ranking_20           <int> 20, 19, 12, 14, 17, 17, 14, 10, 9, 13, 14, 1…
## $ cate_lambda_0             <dbl> 0.05106, 0.04927, 0.03821, 0.03956, 0.04510,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1845, 0.1681, 0.1448, 0.1665, 0.15…
## $ cate_lambda_0_ranking_5   <int> 5, 5, 3, 4, 5, 5, 4, 3, 3, 4, 4, 3, 2, 4, 3,…
## $ clate_lambda_0_ranking_5  <int> 5, 5, 4, 3, 4, 4, 3, 4, 4, 3, 4, 3, 4, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 19, 12, 13, 17, 17, 14, 10, 9, 13, 14, 9…
## $ clate_lambda_0_ranking_20 <int> 20, 17, 15, 10, 14, 13, 10, 14, 15, 11, 13, …
## $ cate_lambda_1             <dbl> 0.04911, 0.04566, 0.03598, 0.03703, 0.03974,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1701, 0.1537, 0.1246, 0.1515, 0.14…
## $ cate_lambda_1_ranking_5   <int> 5, 5, 4, 4, 4, 5, 4, 3, 3, 3, 4, 3, 2, 4, 3,…
## $ clate_lambda_1_ranking_5  <int> 5, 5, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 4, 5, 2,…
## $ cate_lambda_1_ranking_20  <int> 20, 19, 13, 14, 16, 17, 14, 11, 9, 12, 14, 1…
## $ clate_lambda_1_ranking_20 <int> 20, 17, 15, 9, 14, 14, 9, 13, 13, 11, 12, 9,…
## $ cate_lambda_2             <dbl> 0.04716, 0.04204, 0.03376, 0.03451, 0.03438,…
## $ clate_lambda_2            <dbl> 0.18696, 0.15568, 0.13940, 0.10435, 0.13654,…
## $ cate_lambda_2_ranking_5   <int> 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 4, 3, 2, 3, 2,…
## $ clate_lambda_2_ranking_5  <int> 5, 5, 4, 2, 4, 4, 2, 4, 3, 3, 3, 3, 4, 5, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 19, 14, 15, 15, 16, 13, 12, 10, 12, 13, …
## $ clate_lambda_2_ranking_20 <int> 20, 17, 15, 8, 14, 14, 8, 13, 11, 11, 11, 9,…
## $ cate_lambda_3             <dbl> 0.04522, 0.03842, 0.03153, 0.03199, 0.02902,…
## $ clate_lambda_3            <dbl> 0.16952, 0.14128, 0.12507, 0.08412, 0.12159,…
## $ cate_lambda_3_ranking_5   <int> 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 4, 4, 2, 3, 2,…
## $ clate_lambda_3_ranking_5  <int> 5, 5, 4, 2, 4, 4, 2, 3, 3, 3, 3, 3, 4, 5, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 19, 15, 15, 13, 16, 13, 14, 11, 12, 13, …
## $ clate_lambda_3_ranking_20 <int> 20, 17, 14, 7, 14, 15, 8, 12, 10, 11, 11, 10…
## $ cate_lambda_4             <dbl> 0.04327, 0.03481, 0.02931, 0.02947, 0.02366,…
## $ clate_lambda_4            <dbl> 0.15208, 0.12687, 0.11074, 0.06390, 0.10663,…
## $ cate_lambda_4_ranking_5   <int> 5, 5, 4, 4, 3, 4, 4, 4, 3, 3, 4, 4, 2, 3, 2,…
## $ clate_lambda_4_ranking_5  <int> 5, 5, 4, 2, 4, 4, 2, 3, 2, 3, 3, 3, 4, 5, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 19, 16, 16, 11, 15, 13, 15, 11, 12, 13, …
## $ clate_lambda_4_ranking_20 <int> 19, 17, 14, 7, 14, 16, 7, 11, 8, 11, 10, 10,…
## [1] 0.4
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.447 -0.474 -0.363  0.552  2.021 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.458090   0.024550   18.66  < 2e-16 ***
## clate_W       0.195794   0.045934    4.26  2.0e-05 ***
## X.gender_inp -0.086945   0.012598   -6.90  5.6e-12 ***
## X.age_inp    -0.000159   0.000476   -0.33     0.74    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 7252    623.12  <2e-16 ***
## Wu-Hausman          1 7251      7.36  0.0067 ** 
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 7252 degrees of freedom
## Multiple R-Squared: -0.00202,    Adjusted R-squared: -0.00243 
## Wald test: 17.6 on 3 and 7252 DF,  p-value: 2.37e-11 
## 
## Rows: 8,466
## Columns: 68
## $ person_id                 <int> 5, 17, 47, 57, 59, 68, 76, 77, 83, 88, 89, 1…
## $ cate_rankings_selected    <int> 20, 8, 19, 12, 13, 17, 17, 14, 10, 9, 13, 14…
## $ clate_rankings_selected   <int> 20, 7, 17, 15, 10, 14, 13, 10, 14, 15, 11, 1…
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1,…
## $ X.age_inp                 <int> 60, 52, 43, 46, 38, 25, 60, 35, 54, 56, 39, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0,…
## $ X.lessHS                  <int> 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1,…
## $ X.HSorGED                 <int> 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,…
## $ Y                         <int> 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0,…
## $ Z                         <int> 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ weights                   <dbl> 1.1504, 1.2126, 1.0000, 1.0033, 1.5389, 1.00…
## $ folds                     <int> 8, 3, 4, 10, 7, 6, 7, 8, 10, 2, 7, 8, 2, 9, …
## $ clate                     <dbl> 0.2218, 0.1277, 0.1845, 0.1681, 0.1448, 0.16…
## $ clate_se                  <dbl> 0.06976, 0.05327, 0.05760, 0.05733, 0.08090,…
## $ clate_ranking_5           <int> 5, 2, 5, 4, 3, 4, 4, 3, 4, 4, 3, 4, 3, 2, 4,…
## $ clate_ranking_20          <int> 20, 7, 18, 15, 11, 14, 13, 10, 14, 15, 11, 1…
## $ cate_W                    <int> 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ cate                      <dbl> 0.05106, 0.03363, 0.04927, 0.03821, 0.03956,…
## $ cate_se                   <dbl> 0.007787, 0.016439, 0.014469, 0.008896, 0.01…
## $ cate_ranking_5            <int> 5, 2, 5, 3, 4, 5, 5, 4, 3, 3, 4, 4, 3, 3, 2,…
## $ cate_ranking_20           <int> 20, 8, 19, 12, 14, 17, 17, 14, 10, 9, 13, 14…
## $ cate_lambda_0             <dbl> 0.05106, 0.03363, 0.04927, 0.03821, 0.03956,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1277, 0.1845, 0.1681, 0.1448, 0.16…
## $ cate_lambda_0_ranking_5   <int> 5, 2, 5, 3, 4, 5, 5, 4, 3, 3, 4, 4, 3, 3, 2,…
## $ clate_lambda_0_ranking_5  <int> 5, 2, 5, 4, 3, 4, 4, 3, 4, 4, 3, 4, 3, 2, 4,…
## $ cate_lambda_0_ranking_20  <int> 20, 8, 19, 12, 13, 17, 17, 14, 10, 9, 13, 14…
## $ clate_lambda_0_ranking_20 <int> 20, 7, 17, 15, 10, 14, 13, 10, 14, 15, 11, 1…
## $ cate_lambda_1             <dbl> 0.04911, 0.02952, 0.04566, 0.03598, 0.03703,…
## $ clate_lambda_1            <dbl> 0.2044, 0.1143, 0.1701, 0.1537, 0.1246, 0.15…
## $ cate_lambda_1_ranking_5   <int> 5, 2, 5, 4, 4, 4, 5, 4, 3, 3, 3, 4, 3, 3, 2,…
## $ clate_lambda_1_ranking_5  <int> 5, 2, 5, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 2, 4,…
## $ cate_lambda_1_ranking_20  <int> 20, 8, 19, 13, 14, 16, 17, 14, 11, 9, 12, 14…
## $ clate_lambda_1_ranking_20 <int> 20, 8, 17, 15, 9, 14, 14, 9, 13, 13, 11, 12,…
## $ cate_lambda_2             <dbl> 0.04716, 0.02541, 0.04204, 0.03376, 0.03451,…
## $ clate_lambda_2            <dbl> 0.18696, 0.10102, 0.15568, 0.13940, 0.10435,…
## $ cate_lambda_2_ranking_5   <int> 5, 2, 5, 4, 4, 4, 4, 4, 3, 3, 3, 4, 3, 3, 2,…
## $ clate_lambda_2_ranking_5  <int> 5, 2, 5, 4, 2, 4, 4, 2, 4, 3, 3, 3, 3, 2, 4,…
## $ cate_lambda_2_ranking_20  <int> 20, 7, 19, 14, 15, 15, 16, 13, 12, 10, 12, 1…
## $ clate_lambda_2_ranking_20 <int> 20, 8, 17, 15, 8, 14, 14, 8, 13, 11, 11, 11,…
## $ cate_lambda_3             <dbl> 0.04522, 0.02130, 0.03842, 0.03153, 0.03199,…
## $ clate_lambda_3            <dbl> 0.16952, 0.08770, 0.14128, 0.12507, 0.08412,…
## $ cate_lambda_3_ranking_5   <int> 5, 2, 5, 4, 4, 4, 4, 4, 4, 3, 3, 4, 4, 3, 2,…
## $ clate_lambda_3_ranking_5  <int> 5, 2, 5, 4, 2, 4, 4, 2, 3, 3, 3, 3, 3, 2, 4,…
## $ cate_lambda_3_ranking_20  <int> 20, 7, 19, 15, 15, 13, 16, 13, 14, 11, 12, 1…
## $ clate_lambda_3_ranking_20 <int> 20, 8, 17, 14, 7, 14, 15, 8, 12, 10, 11, 11,…
## $ cate_lambda_4             <dbl> 0.04327, 0.01719, 0.03481, 0.02931, 0.02947,…
## $ clate_lambda_4            <dbl> 0.15208, 0.07438, 0.12687, 0.11074, 0.06390,…
## $ cate_lambda_4_ranking_5   <int> 5, 2, 5, 4, 4, 3, 4, 4, 4, 3, 3, 4, 4, 3, 2,…
## $ clate_lambda_4_ranking_5  <int> 5, 2, 5, 4, 2, 4, 4, 2, 3, 2, 3, 3, 3, 2, 4,…
## $ cate_lambda_4_ranking_20  <int> 20, 7, 19, 16, 16, 11, 15, 13, 15, 11, 12, 1…
## $ clate_lambda_4_ranking_20 <int> 19, 8, 17, 14, 7, 14, 16, 7, 11, 8, 11, 10, …
## [1] 0.3
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.358 -0.479 -0.356  0.554  2.050 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.445758   0.022768   19.58  < 2e-16 ***
## clate_W       0.163765   0.041833    3.91  9.1e-05 ***
## X.gender_inp -0.090709   0.011560   -7.85  4.8e-15 ***
## X.age_inp     0.000028   0.000440    0.06     0.95    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 8462    730.24  <2e-16 ***
## Wu-Hausman          1 8461      5.16   0.023 *  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.55 on 8462 degrees of freedom
## Multiple R-Squared: 0.00326, Adjusted R-squared: 0.0029 
## Wald test: 21.3 on 3 and 8462 DF,  p-value: 9.08e-14 
## 
## Rows: 9,674
## Columns: 68
## $ person_id                 <int> 5, 17, 18, 29, 47, 57, 59, 68, 70, 76, 77, 8…
## $ cate_rankings_selected    <int> 20, 8, 8, 6, 19, 12, 13, 17, 6, 17, 14, 10, …
## $ clate_rankings_selected   <int> 20, 7, 6, 6, 17, 15, 10, 14, 5, 13, 10, 14, …
## $ X.numhh_list              <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 52, 51, 23, 43, 46, 38, 25, 62, 60, 35, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.hbp_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0,…
## $ X.lessHS                  <int> 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1715.3, 5743.9, 0.0, 0.0, 0.0, 0.0…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1006.3, 4542.4, 0.0, 0.0, 0.0, 0.0…
## $ Y                         <int> 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1,…
## $ weights                   <dbl> 1.150, 1.213, 1.000, 1.000, 1.000, 1.003, 1.…
## $ folds                     <int> 8, 3, 10, 4, 4, 10, 7, 6, 5, 7, 8, 10, 2, 7,…
## $ clate                     <dbl> 0.2218, 0.1277, 0.1158, 0.1175, 0.1845, 0.16…
## $ clate_se                  <dbl> 0.06976, 0.05327, 0.03534, 0.05295, 0.05760,…
## $ clate_ranking_5           <int> 5, 2, 2, 2, 5, 4, 3, 4, 1, 4, 3, 4, 4, 3, 2,…
## $ clate_ranking_20          <int> 20, 7, 6, 6, 18, 15, 11, 14, 4, 13, 10, 14, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1,…
## $ cate                      <dbl> 0.05106, 0.03363, 0.03366, 0.03004, 0.04927,…
## $ cate_se                   <dbl> 0.007787, 0.016439, 0.008905, 0.012314, 0.01…
## $ cate_ranking_5            <int> 5, 2, 2, 2, 5, 3, 4, 5, 2, 5, 4, 3, 3, 4, 2,…
## $ cate_ranking_20           <int> 20, 8, 8, 6, 19, 12, 14, 17, 5, 17, 14, 10, …
## $ cate_lambda_0             <dbl> 0.05106, 0.03363, 0.03366, 0.03004, 0.04927,…
## $ clate_lambda_0            <dbl> 0.2218, 0.1277, 0.1158, 0.1175, 0.1845, 0.16…
## $ cate_lambda_0_ranking_5   <int> 5, 2, 2, 2, 5, 3, 4, 5, 2, 5, 4, 3, 3, 4, 2,…
## $ clate_lambda_0_ranking_5  <int> 5, 2, 2, 2, 5, 4, 3, 4, 2, 4, 3, 4, 4, 3, 2,…
## $ cate_lambda_0_ranking_20  <int> 20, 8, 8, 6, 19, 12, 13, 17, 6, 17, 14, 10, …
## $ clate_lambda_0_ranking_20 <int> 20, 7, 6, 6, 17, 15, 10, 14, 5, 13, 10, 14, …
## $ cate_lambda_1             <dbl> 0.04911, 0.02952, 0.03143, 0.02696, 0.04566,…
## $ clate_lambda_1            <dbl> 0.20440, 0.11434, 0.10697, 0.10425, 0.17008,…
## $ cate_lambda_1_ranking_5   <int> 5, 2, 3, 2, 5, 4, 4, 4, 2, 5, 4, 3, 3, 3, 2,…
## $ clate_lambda_1_ranking_5  <int> 5, 2, 2, 2, 5, 4, 3, 4, 2, 4, 3, 4, 4, 3, 2,…
## $ cate_lambda_1_ranking_20  <int> 20, 8, 9, 6, 19, 13, 14, 16, 7, 17, 14, 11, …
## $ clate_lambda_1_ranking_20 <int> 20, 8, 6, 6, 17, 15, 9, 14, 5, 14, 9, 13, 13…
## $ cate_lambda_2             <dbl> 0.04716, 0.02541, 0.02920, 0.02388, 0.04204,…
## $ clate_lambda_2            <dbl> 0.18696, 0.10102, 0.09813, 0.09101, 0.15568,…
## $ cate_lambda_2_ranking_5   <int> 5, 2, 3, 2, 5, 4, 4, 4, 2, 4, 4, 3, 3, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 5, 2, 2, 2, 5, 4, 2, 4, 2, 4, 2, 4, 3, 3, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 7, 10, 7, 19, 14, 15, 15, 8, 16, 13, 12,…
## $ clate_lambda_2_ranking_20 <int> 20, 8, 7, 6, 17, 15, 8, 14, 6, 14, 8, 13, 11…
## $ cate_lambda_3             <dbl> 0.04522, 0.02130, 0.02698, 0.02080, 0.03842,…
## $ clate_lambda_3            <dbl> 0.16952, 0.08770, 0.08930, 0.07778, 0.14128,…
## $ cate_lambda_3_ranking_5   <int> 5, 2, 3, 2, 5, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3,…
## $ clate_lambda_3_ranking_5  <int> 5, 2, 2, 2, 5, 4, 2, 4, 2, 4, 2, 3, 3, 3, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 7, 11, 7, 19, 15, 15, 13, 9, 16, 13, 14,…
## $ clate_lambda_3_ranking_20 <int> 20, 8, 8, 7, 17, 14, 7, 14, 6, 15, 8, 12, 10…
## $ cate_lambda_4             <dbl> 0.04327, 0.01719, 0.02475, 0.01772, 0.03481,…
## $ clate_lambda_4            <dbl> 0.15208, 0.07438, 0.08047, 0.06454, 0.12687,…
## $ cate_lambda_4_ranking_5   <int> 5, 2, 3, 2, 5, 4, 4, 3, 3, 4, 4, 4, 3, 3, 3,…
## $ clate_lambda_4_ranking_5  <int> 5, 2, 3, 2, 5, 4, 2, 4, 2, 4, 2, 3, 2, 3, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 7, 12, 7, 19, 16, 16, 11, 10, 15, 13, 15…
## $ clate_lambda_4_ranking_20 <int> 19, 8, 9, 7, 17, 14, 7, 14, 7, 16, 7, 11, 8,…
## [1] 0.2
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.457 -0.472 -0.353  0.560  2.058 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.445239   0.021695   20.52  < 2e-16 ***
## clate_W       0.171898   0.039894    4.31  1.7e-05 ***
## X.gender_inp -0.087489   0.010879   -8.04  9.9e-16 ***
## X.age_inp    -0.000109   0.000420   -0.26      0.8    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 9670    798.38  <2e-16 ***
## Wu-Hausman          1 9669      6.54   0.011 *  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 9670 degrees of freedom
## Multiple R-Squared: 0.00165, Adjusted R-squared: 0.00134 
## Wald test: 22.6 on 3 and 9670 DF,  p-value: 1.51e-14 
## 
## Rows: 10,884
## Columns: 68
## $ person_id                 <int> 5, 16, 17, 18, 29, 47, 57, 59, 68, 70, 76, 7…
## $ cate_rankings_selected    <int> 20, 4, 8, 8, 6, 19, 12, 13, 17, 6, 17, 14, 1…
## $ clate_rankings_selected   <int> 20, 3, 7, 6, 6, 17, 15, 10, 14, 5, 13, 10, 1…
## $ X.numhh_list              <int> 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,…
## $ X.gender_inp              <int> 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0,…
## $ X.age_inp                 <int> 60, 39, 52, 51, 23, 43, 46, 38, 25, 62, 60, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 5743.9, 0.0, 0.0, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 4542.4, 0.0, 0.0, …
## $ Y                         <int> 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1,…
## $ clate_W                   <int> 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1,…
## $ Z                         <int> 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ weights                   <dbl> 1.150, 1.000, 1.213, 1.000, 1.000, 1.000, 1.…
## $ folds                     <int> 8, 10, 3, 10, 4, 4, 10, 7, 6, 5, 7, 8, 10, 2…
## $ clate                     <dbl> 0.22184, 0.07944, 0.12765, 0.11580, 0.11749,…
## $ clate_se                  <dbl> 0.06976, 0.06904, 0.05327, 0.03534, 0.05295,…
## $ clate_ranking_5           <int> 5, 1, 2, 2, 2, 5, 4, 3, 4, 1, 4, 3, 4, 4, 3,…
## $ clate_ranking_20          <int> 20, 3, 7, 6, 6, 18, 15, 11, 14, 4, 13, 10, 1…
## $ cate_W                    <int> 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ cate                      <dbl> 0.05106, 0.02389, 0.03363, 0.03366, 0.03004,…
## $ cate_se                   <dbl> 0.007787, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 5, 1, 2, 2, 2, 5, 3, 4, 5, 2, 5, 4, 3, 3, 4,…
## $ cate_ranking_20           <int> 20, 4, 8, 8, 6, 19, 12, 14, 17, 5, 17, 14, 1…
## $ cate_lambda_0             <dbl> 0.05106, 0.02389, 0.03363, 0.03366, 0.03004,…
## $ clate_lambda_0            <dbl> 0.22184, 0.07944, 0.12765, 0.11580, 0.11749,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 2, 2, 2, 5, 3, 4, 5, 2, 5, 4, 3, 3, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 2, 2, 2, 5, 4, 3, 4, 2, 4, 3, 4, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 4, 8, 8, 6, 19, 12, 13, 17, 6, 17, 14, 1…
## $ clate_lambda_0_ranking_20 <int> 20, 3, 7, 6, 6, 17, 15, 10, 14, 5, 13, 10, 1…
## $ cate_lambda_1             <dbl> 0.04911, 0.02024, 0.02952, 0.03143, 0.02696,…
## $ clate_lambda_1            <dbl> 0.20440, 0.06218, 0.11434, 0.10697, 0.10425,…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 2, 3, 2, 5, 4, 4, 4, 2, 5, 4, 3, 3, 3,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 2, 2, 2, 5, 4, 3, 4, 2, 4, 3, 4, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 4, 8, 9, 6, 19, 13, 14, 16, 7, 17, 14, 1…
## $ clate_lambda_1_ranking_20 <int> 20, 3, 8, 6, 6, 17, 15, 9, 14, 5, 14, 9, 13,…
## $ cate_lambda_2             <dbl> 0.04716, 0.01658, 0.02541, 0.02920, 0.02388,…
## $ clate_lambda_2            <dbl> 0.18696, 0.04492, 0.10102, 0.09813, 0.09101,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 2, 3, 2, 5, 4, 4, 4, 2, 4, 4, 3, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 2, 2, 2, 5, 4, 2, 4, 2, 4, 2, 4, 3, 3,…
## $ cate_lambda_2_ranking_20  <int> 20, 4, 7, 10, 7, 19, 14, 15, 15, 8, 16, 13, …
## $ clate_lambda_2_ranking_20 <int> 20, 3, 8, 7, 6, 17, 15, 8, 14, 6, 14, 8, 13,…
## $ cate_lambda_3             <dbl> 0.045215, 0.012929, 0.021298, 0.026977, 0.02…
## $ clate_lambda_3            <dbl> 0.16952, 0.02766, 0.08770, 0.08930, 0.07778,…
## $ cate_lambda_3_ranking_5   <int> 5, 1, 2, 3, 2, 5, 4, 4, 4, 3, 4, 4, 4, 3, 3,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 2, 2, 2, 5, 4, 2, 4, 2, 4, 2, 3, 3, 3,…
## $ cate_lambda_3_ranking_20  <int> 20, 4, 7, 11, 7, 19, 15, 15, 13, 9, 16, 13, …
## $ clate_lambda_3_ranking_20 <int> 20, 3, 8, 8, 7, 17, 14, 7, 14, 6, 15, 8, 12,…
## $ cate_lambda_4             <dbl> 0.043268, 0.009275, 0.017188, 0.024751, 0.01…
## $ clate_lambda_4            <dbl> 0.15208, 0.01040, 0.07438, 0.08047, 0.06454,…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 2, 3, 2, 5, 4, 4, 3, 3, 4, 4, 4, 3, 3,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 2, 3, 2, 5, 4, 2, 4, 2, 4, 2, 3, 2, 3,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 7, 12, 7, 19, 16, 16, 11, 10, 15, 13,…
## $ clate_lambda_4_ranking_20 <int> 19, 3, 8, 9, 7, 17, 14, 7, 14, 7, 16, 7, 11,…
## [1] 0.1
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.715 -0.478 -0.355  0.556  2.052 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.450709   0.020851   21.62  < 2e-16 ***
## clate_W       0.163062   0.038379    4.25  2.2e-05 ***
## X.gender_inp -0.090634   0.010372   -8.74  < 2e-16 ***
## X.age_inp    -0.000120   0.000402   -0.30     0.77    
## 
## Diagnostic tests:
##                    df1   df2 statistic p-value    
## Weak instruments     1 10880    861.74  <2e-16 ***
## Wu-Hausman           1 10879      6.59    0.01 *  
## Sargan               0    NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 10880 degrees of freedom
## Multiple R-Squared: 0.0019,  Adjusted R-squared: 0.00163 
## Wald test: 25.9 on 3 and 10880 DF,  p-value: <2e-16 
## 
## Rows: 12,094
## Columns: 68
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ cate_rankings_selected    <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_rankings_selected   <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] 0
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.732 -0.493 -0.355  0.542  2.049 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.467062   0.020308   23.00   <2e-16 ***
## clate_W       0.166911   0.037776    4.42    1e-05 ***
## X.gender_inp -0.104776   0.009937  -10.54   <2e-16 ***
## X.age_inp    -0.000158   0.000388   -0.41     0.68    
## 
## Diagnostic tests:
##                    df1   df2 statistic p-value    
## Weak instruments     1 12090    894.72  <2e-16 ***
## Wu-Hausman           1 12089      8.91  0.0028 ** 
## Sargan               0    NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 12090 degrees of freedom
## Multiple R-Squared: 0.000642,    Adjusted R-squared: 0.000394 
## Wald test: 37.1 on 3 and 12090 DF,  p-value: <2e-16 
## 
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by debt_neg_cw0_lambda_0"
## [1] "finished increasing"
## [1] "#####Running clate function.#####"
## ranking_rescale
##   10   20   30   40   50   60   70   80   90  100 
## 1210 1210 1208 1210 1214 1204 1210 1209 1209 1210 
## Rows: 2,420
## Columns: 68
## $ person_id                 <int> 8, 16, 23, 24, 96, 127, 140, 213, 224, 260, …
## $ cate_rankings_selected    <int> 3, 4, 1, 1, 3, 3, 5, 1, 5, 3, 3, 4, 3, 3, 1,…
## $ clate_rankings_selected   <int> 2, 3, 1, 1, 3, 4, 4, 1, 4, 3, 4, 3, 4, 3, 1,…
## $ X.numhh_list              <int> 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 3,…
## $ X.gender_inp              <int> 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0,…
## $ X.age_inp                 <int> 41, 39, 32, 34, 32, 25, 53, 61, 49, 37, 37, …
## $ X.hispanic_inp            <int> 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0,…
## $ X.lessHS                  <int> 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 0.0, 1187.6, 2257.6, 0.0, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 0.0, 1046.7, 2257.6, 0.0, …
## $ Y                         <int> 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1,…
## $ clate_W                   <int> 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1,…
## $ Z                         <int> 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.0033, 1.2018, 1.0000, 1.83…
## $ folds                     <int> 1, 10, 9, 9, 6, 2, 10, 5, 5, 9, 6, 5, 6, 6, …
## $ clate                     <dbl> 0.06980, 0.07944, 0.05165, 0.02140, 0.09227,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.06055, 0.07712, 0.08061,…
## $ clate_ranking_5           <int> 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ clate_ranking_20          <int> 2, 3, 1, 1, 4, 5, 4, 1, 4, 3, 4, 3, 4, 3, 1,…
## $ cate_W                    <int> 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.010735, 0.007062, 0.02…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.013106, 0.015227, 0.01…
## $ cate_ranking_5            <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ cate_ranking_20           <int> 3, 4, 1, 1, 3, 4, 4, 1, 5, 3, 3, 4, 3, 3, 1,…
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.010735, 0.007062, 0.02…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.05165, 0.02140, 0.09227,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 1, 1, 3, 3, 5, 1, 5, 3, 3, 4, 3, 3, 1,…
## $ clate_lambda_0_ranking_20 <int> 2, 3, 1, 1, 3, 4, 4, 1, 4, 3, 4, 3, 4, 3, 1,…
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.007459, 0.003256, 0.01…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.036516, 0.002123, 0.07…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 1, 1, 3, 3, 4, 2, 6, 4, 2, 4, 2, 2, 1,…
## $ clate_lambda_1_ranking_20 <int> 2, 3, 1, 1, 3, 4, 4, 1, 5, 3, 4, 3, 4, 3, 1,…
## $ cate_lambda_2             <dbl> 1.417e-02, 1.658e-02, 4.182e-03, -5.513e-04,…
## $ clate_lambda_2            <dbl> 0.0238954, 0.0449228, 0.0213787, -0.0171568,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 1, 1, 3, 3, 4, 2, 6, 4, 2, 4, 2, 2, 1,…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 2, 1, 3, 4, 5, 1, 6, 3, 5, 3, 4, 4, 1,…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0009059, -0.0043581,…
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0062415, -0.0364368,…
## $ cate_lambda_3_ranking_5   <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 1, 1, 4, 3, 4, 3, 7, 5, 2, 4, 2, 2, 1,…
## $ clate_lambda_3_ranking_20 <int> 2, 3, 2, 1, 4, 4, 5, 2, 6, 3, 5, 3, 4, 4, 2,…
## $ cate_lambda_4             <dbl> 0.0069679, 0.0092752, -0.0023705, -0.0081649…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, -0.008896, -0.055717, 0…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 1, 1, 4, 3, 4, 3, 7, 5, 2, 4, 2, 2, 1,…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 2, 1, 3, 4, 6, 2, 7, 4, 5, 3, 4, 4, 3,…
## [1] 0.2
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.714 -0.531 -0.379  0.519  1.447 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.554555   0.059982    9.25  < 2e-16 ***
## clate_W       0.090669   0.106746    0.85     0.40    
## X.gender_inp -0.146847   0.025720   -5.71  1.3e-08 ***
## X.age_inp    -0.000487   0.001091   -0.45     0.66    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 2416    113.71  <2e-16 ***
## Wu-Hausman          1 2415      0.81    0.37    
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.558 on 2416 degrees of freedom
## Multiple R-Squared: 0.0107,  Adjusted R-squared: 0.00948 
## Wald test: 14.6 on 3 and 2416 DF,  p-value: 1.95e-09 
## 
## Rows: 3,628
## Columns: 68
## $ person_id                 <int> 8, 16, 18, 23, 24, 29, 70, 92, 96, 127, 140,…
## $ cate_rankings_selected    <int> 3, 4, 8, 1, 1, 6, 6, 8, 3, 3, 5, 6, 6, 1, 5,…
## $ clate_rankings_selected   <int> 2, 3, 6, 1, 1, 6, 5, 6, 3, 4, 4, 6, 5, 1, 4,…
## $ X.numhh_list              <int> 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1,…
## $ X.age_inp                 <int> 41, 39, 51, 32, 34, 23, 62, 34, 32, 25, 53, …
## $ X.hispanic_inp            <int> 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0, 1888, 1715, 0, 0, 5744, 1052, 0, 1188, 22…
## $ X.ed_charg_tot_pre_ed     <dbl> 0, 1888, 1006, 0, 0, 4542, 1052, 0, 1047, 22…
## $ Y                         <int> 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0,…
## $ clate_W                   <int> 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,…
## $ Z                         <int> 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.0000, 1.0033, 1.2018, 1.00…
## $ folds                     <int> 1, 10, 10, 9, 9, 4, 5, 5, 6, 2, 10, 2, 8, 5,…
## $ clate                     <dbl> 0.06980, 0.07944, 0.11580, 0.05165, 0.02140,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.03534, 0.06055, 0.07712,…
## $ clate_ranking_5           <int> 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1,…
## $ clate_ranking_20          <int> 2, 3, 6, 1, 1, 6, 4, 6, 4, 5, 4, 6, 5, 1, 4,…
## $ cate_W                    <int> 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033656, 0.010735, 0.00…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.008905, 0.013106, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2,…
## $ cate_ranking_20           <int> 3, 4, 8, 1, 1, 6, 5, 7, 3, 4, 4, 6, 6, 1, 5,…
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033656, 0.010735, 0.00…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.11580, 0.05165, 0.02140,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 2,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 1, 1, 6, 6, 8, 3, 3, 5, 6, 6, 1, 5,…
## $ clate_lambda_0_ranking_20 <int> 2, 3, 6, 1, 1, 6, 5, 6, 3, 4, 4, 6, 5, 1, 4,…
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.031430, 0.007459, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.106968, 0.036516, 0.00…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 3, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 9, 1, 1, 6, 7, 8, 3, 3, 4, 6, 5, 2, 6,…
## $ clate_lambda_1_ranking_20 <int> 2, 3, 6, 1, 1, 6, 5, 6, 3, 4, 4, 6, 5, 1, 5,…
## $ cate_lambda_2             <dbl> 1.417e-02, 1.658e-02, 2.920e-02, 4.182e-03, …
## $ clate_lambda_2            <dbl> 0.023895, 0.044923, 0.098134, 0.021379, -0.0…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 3, 1, 1, 2, 2, 3, 1, 1, 1, 2, 2, 1, 2,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 10, 1, 1, 7, 8, 9, 3, 3, 4, 6, 5, 2, 6…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 7, 2, 1, 6, 6, 6, 3, 4, 5, 5, 4, 1, 6,…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0269774, 0.0009059, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0893001, 0.0062415, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 3, 1, 1, 2, 3, 3, 1, 1, 1, 2, 2, 1, 2,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 11, 1, 1, 7, 9, 10, 4, 3, 4, 6, 5, 3, …
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 2, 1, 7, 6, 6, 4, 4, 5, 5, 4, 2, 6,…
## $ cate_lambda_4             <dbl> 0.0069679, 0.0092752, 0.0247512, -0.0023705,…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.080466, -0.008896, -0…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 3, 1, 1, 2, 3, 3, 1, 1, 1, 2, 2, 1, 2,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 3, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 12, 1, 1, 7, 10, 10, 4, 3, 4, 6, 5, 3,…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 9, 2, 1, 7, 7, 6, 3, 4, 6, 6, 4, 2, 7,…
## [1] 0.3
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.752 -0.516 -0.355  0.526  1.953 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.518541   0.045975   11.28  < 2e-16 ***
## clate_W       0.159063   0.084448    1.88     0.06 .  
## X.gender_inp -0.128535   0.020635   -6.23  5.2e-10 ***
## X.age_inp    -0.000735   0.000846   -0.87     0.39    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 3624    179.44  <2e-16 ***
## Wu-Hausman          1 3623      2.68     0.1    
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.563 on 3624 degrees of freedom
## Multiple R-Squared: -0.0028, Adjusted R-squared: -0.00363 
## Wald test: 14.9 on 3 and 3624 DF,  p-value: 1.2e-09 
## 
## Rows: 4,838
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 70, 92, 96, 106, …
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 6, 8, 3, 9, 6, 3, 5, 9,…
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 5, 6, 3, 8, 8, 4, 4, 7,…
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 62, 34, 32, 33, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 5, 5, 6, 9, 7, 2, 10,…
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 3, 2, 1, 2,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 4, 6, 4, 7, 9, 5, 4, 7,…
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 3, 2, 1, 1, 3,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 5, 7, 3, 9, 7, 4, 4, 9,…
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 3, 2, 1, 2, 3,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 6, 8, 3, 9, 6, 3, 5, 9,…
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 5, 6, 3, 8, 8, 4, 4, 7,…
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 2, 2, 1, 3, 2, 1, 1, 3,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 7, 8, 3, 9, 7, 3, 4, 10…
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 5, 6, 3, 7, 8, 4, 4, 7,…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 2, 3, 1, 3, 2, 1, 1, 3,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 8, 9, 3, 9, 7, 3, 4, 1…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 6, 6, 3, 7, 8, 4, 5, 7,…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 3, 3, 1, 3, 2, 1, 1, 3,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 9, 10, 4, 9, 8, 3, 4, …
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 6, 6, 4, 6, 8, 4, 5, 7,…
## $ cate_lambda_4             <dbl> 0.0069679, 0.0092752, 0.0171884, 0.0247512, …
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 3, 3, 1, 3, 2, 1, 1, 3,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 2, 2, 1, 2, 3, 1, 2, 2,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 10, 10, 4, 9, 8, 3, 4,…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 7, 6, 3, 6, 9, 4, 6, 7,…
## [1] 0.4
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.571 -0.475 -0.337  0.536  2.018 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.482741   0.036595   13.19  < 2e-16 ***
## clate_W       0.135554   0.067101    2.02    0.043 *  
## X.gender_inp -0.134803   0.016939   -7.96  2.2e-15 ***
## X.age_inp    -0.000292   0.000678   -0.43    0.667    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 4834    272.72  <2e-16 ***
## Wu-Hausman          1 4833      2.34    0.13    
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.555 on 4834 degrees of freedom
## Multiple R-Squared: 0.00636, Adjusted R-squared: 0.00574 
## Wald test: 23.6 on 3 and 4834 DF,  p-value: 3.94e-15 
## 
## Rows: 6,052
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 59, 70, 77, 92, 9…
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 13, 6, 14, 8, 3, 9, 9, …
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 10, 5, 10, 6, 3, 9, 8, …
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 38, 62, 35, 34, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 7, 5, 8, 5, 6, 2, 9, …
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 3, 1, 3, 2, 1, 3, 2, 3,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 11, 4, 10, 6, 4, 9, 7, …
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 2, 1, 3, 3, 2,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 14, 5, 14, 7, 3, 10, 9,…
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 2, 1, 3, 3, 2,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 2, 3, 2, 1, 3, 2, 2,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 13, 6, 14, 8, 3, 9, 9, …
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 10, 5, 10, 6, 3, 9, 8, …
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 2, 4, 2, 1, 3, 3, 2,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 2, 3, 2, 1, 3, 2, 2,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 14, 7, 14, 8, 3, 10, 9,…
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 9, 5, 9, 6, 3, 9, 7, 8,…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 2, 4, 3, 1, 3, 3, 2,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 3, 2, 2,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 15, 8, 13, 9, 3, 12, 9…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 8, 6, 8, 6, 3, 9, 7, 8,…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 3, 4, 3, 1, 4, 3, 2,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 3, 2, 2,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 15, 9, 13, 10, 4, 13, …
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 7, 6, 8, 6, 4, 10, 6, 8…
## $ cate_lambda_4             <dbl> 0.006968, 0.009275, 0.017188, 0.024751, -0.0…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 3, 4, 3, 1, 4, 3, 2,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 2, 2, 2, 2, 1, 3, 2, 3,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 16, 10, 13, 10, 4, 14,…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 7, 7, 7, 6, 3, 10, 6, 9…
## [1] 0.5
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.597 -0.474 -0.318  0.561  2.068 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.41e-01   3.13e-02   14.08  < 2e-16 ***
## clate_W       1.66e-01   5.80e-02    2.85   0.0043 ** 
## X.gender_inp -1.21e-01   1.50e-02   -8.07  8.3e-16 ***
## X.age_inp    -5.54e-05   5.90e-04   -0.09   0.9251    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 6048    359.96  <2e-16 ***
## Wu-Hausman          1 6047      3.95   0.047 *  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.553 on 6048 degrees of freedom
## Multiple R-Squared: 0.00162, Adjusted R-squared: 0.00113 
## Wald test: 22.6 on 3 and 6048 DF,  p-value: 1.42e-14 
## 
## Rows: 7,256
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 59, 70, 77, 89, 9…
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 13, 6, 14, 13, 8, 3, 9,…
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 10, 5, 10, 11, 6, 3, 9,…
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 38, 62, 35, 39, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 7, 5, 8, 7, 5, 6, 2, …
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 3, 1, 3, 3, 2, 1, 3, 2,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 11, 4, 10, 11, 6, 4, 9,…
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 4, 2, 1, 3, 3,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 14, 5, 14, 13, 7, 3, 10…
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 4, 2, 1, 3, 3,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 2, 3, 3, 2, 1, 3, 2,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 13, 6, 14, 13, 8, 3, 9,…
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 10, 5, 10, 11, 6, 3, 9,…
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 2, 4, 3, 2, 1, 3, 3,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 2, 3, 3, 2, 1, 3, 2,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 14, 7, 14, 12, 8, 3, 10…
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 9, 5, 9, 11, 6, 3, 9, 7…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 2, 4, 3, 3, 1, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 1, 3, 2,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 15, 8, 13, 12, 9, 3, 1…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 8, 6, 8, 11, 6, 3, 9, 7…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 3, 4, 3, 3, 1, 4, 3,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 1, 3, 2,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 15, 9, 13, 12, 10, 4, …
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 7, 6, 8, 11, 6, 4, 10, …
## $ cate_lambda_4             <dbl> 0.006968, 0.009275, 0.017188, 0.024751, -0.0…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 3, 4, 3, 3, 1, 4, 3,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 2, 2, 2, 3, 2, 1, 3, 2,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 16, 10, 13, 12, 10, 4,…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 7, 7, 7, 11, 6, 3, 10, …
## [1] 0.6
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.569 -0.475 -0.328  0.556  2.141 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.48e-01   2.79e-02   16.03   <2e-16 ***
## clate_W       1.47e-01   5.09e-02    2.89   0.0038 ** 
## X.gender_inp -1.17e-01   1.33e-02   -8.82   <2e-16 ***
## X.age_inp    -8.32e-05   5.31e-04   -0.16   0.8754    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 7252    472.90  <2e-16 ***
## Wu-Hausman          1 7251      2.97   0.085 .  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 7252 degrees of freedom
## Multiple R-Squared: 0.00708, Adjusted R-squared: 0.00667 
## Wald test: 26.8 on 3 and 7252 DF,  p-value: <2e-16 
## 
## Rows: 8,466
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 59, 68, 70, 76, 7…
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 13, 17, 6, 17, 14, 10, …
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 10, 14, 5, 13, 10, 14, …
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 38, 25, 62, 60, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 7, 6, 5, 7, 8, 10, 7,…
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 3, 4, 1, 4, 3, 4, 3, 2,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 11, 14, 4, 13, 10, 14, …
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 4, 5, 2, 5, 4, 3, 4, 2,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 14, 17, 5, 17, 14, 10, …
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 4, 5, 2, 5, 4, 3, 4, 2,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 4, 2, 4, 3, 4, 3, 2,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 13, 17, 6, 17, 14, 10, …
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 10, 14, 5, 13, 10, 14, …
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 2, 5, 4, 3, 3, 2,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 3, 4, 2, 4, 3, 4, 3, 2,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 14, 16, 7, 17, 14, 11, …
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 9, 14, 5, 14, 9, 13, 11…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 2, 4, 4, 3, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 4, 2, 4, 2, 4, 3, 2,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 15, 15, 8, 16, 13, 12,…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 8, 14, 6, 14, 8, 13, 11…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 3, 4, 4, 4, 3, 3,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 2, 4, 2, 4, 2, 3, 3, 2,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 15, 13, 9, 16, 13, 14,…
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 7, 14, 6, 15, 8, 12, 11…
## $ cate_lambda_4             <dbl> 0.006968, 0.009275, 0.017188, 0.024751, -0.0…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 3, 3, 4, 4, 4, 3, 3,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 2, 4, 2, 4, 2, 3, 3, 2,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 16, 11, 10, 15, 13, 15…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 7, 14, 7, 16, 7, 11, 11…
## [1] 0.7
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.617 -0.483 -0.322  0.551  2.158 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.461343   0.025264   18.26  < 2e-16 ***
## clate_W       0.164491   0.046669    3.52  0.00043 ***
## X.gender_inp -0.129456   0.012060  -10.73  < 2e-16 ***
## X.age_inp    -0.000255   0.000484   -0.53  0.59895    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 8462    568.72  <2e-16 ***
## Wu-Hausman          1 8461      5.23   0.022 *  
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.552 on 8462 degrees of freedom
## Multiple R-Squared: 0.00658, Adjusted R-squared: 0.00623 
## Wald test: 39.3 on 3 and 8462 DF,  p-value: <2e-16 
## 
## Rows: 9,675
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 57, 59, 68, 70, 7…
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 12, 13, 17, 6, 17, 14, …
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 15, 10, 14, 5, 13, 10, …
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 46, 38, 25, 62, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 10, 7, 6, 5, 7, 8, 10…
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 4, 3, 4, 1, 4, 3, 4, 4,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 15, 11, 14, 4, 13, 10, …
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 3, 4, 5, 2, 5, 4, 3, 3,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 12, 14, 17, 5, 17, 14, …
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 3, 4, 5, 2, 5, 4, 3, 3,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 4, 3, 4, 2, 4, 3, 4, 4,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 12, 13, 17, 6, 17, 14, …
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 15, 10, 14, 5, 13, 10, …
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 4, 2, 5, 4, 3, 3,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 4, 3, 4, 2, 4, 3, 4, 4,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 13, 14, 16, 7, 17, 14, …
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 15, 9, 14, 5, 14, 9, 13…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 4, 2, 4, 4, 3, 3,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 2, 4, 2, 4, 3,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 14, 15, 15, 8, 16, 13,…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 15, 8, 14, 6, 14, 8, 13…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 4, 3, 4, 4, 4, 3,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 4, 2, 4, 2, 4, 2, 3, 3,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 15, 15, 13, 9, 16, 13,…
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 14, 7, 14, 6, 15, 8, 12…
## $ cate_lambda_4             <dbl> 0.006968, 0.009275, 0.017188, 0.024751, -0.0…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 4, 4, 3, 3, 4, 4, 4, 3,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 4, 2, 4, 2, 4, 2, 3, 2,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 16, 16, 11, 10, 15, 13…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 14, 7, 14, 7, 16, 7, 11…
## [1] 0.8
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.709 -0.482 -0.321  0.552  2.159 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.457884   0.023171   19.76  < 2e-16 ***
## clate_W       0.193390   0.042997    4.50  6.9e-06 ***
## X.gender_inp -0.127966   0.011155  -11.47  < 2e-16 ***
## X.age_inp    -0.000213   0.000447   -0.48     0.63    
## 
## Diagnostic tests:
##                   df1  df2 statistic p-value    
## Weak instruments    1 9671     683.5  <2e-16 ***
## Wu-Hausman          1 9670      10.6  0.0011 ** 
## Sargan              0   NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 9671 degrees of freedom
## Multiple R-Squared: -0.000795,   Adjusted R-squared: -0.00111 
## Wald test:   44 on 3 and 9671 DF,  p-value: <2e-16 
## 
## Rows: 10,884
## Columns: 68
## $ person_id                 <int> 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68, 7…
## $ cate_rankings_selected    <int> 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, 17, …
## $ clate_rankings_selected   <int> 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, 13, …
## $ X.numhh_list              <int> 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1,…
## $ X.age_inp                 <int> 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, 25, …
## $ X.hispanic_inp            <int> 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.race_white_inp          <int> 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,…
## $ X.race_black_inp          <int> 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1,…
## $ X.lessHS                  <int> 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,…
## $ X.HSorGED                 <int> 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 5743.9, …
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 4542.4, …
## $ Y                         <int> 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0,…
## $ clate_W                   <int> 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1,…
## $ Z                         <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0,…
## $ weights                   <dbl> 0.8975, 1.0000, 1.2126, 1.0000, 1.0033, 1.20…
## $ folds                     <int> 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7, 8,…
## $ clate                     <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ clate_se                  <dbl> 0.09180, 0.06904, 0.05327, 0.03534, 0.06055,…
## $ clate_ranking_5           <int> 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3, 4,…
## $ clate_ranking_20          <int> 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, 13, …
## $ cate_W                    <int> 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0,…
## $ cate                      <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ cate_se                   <dbl> 0.014411, 0.014614, 0.016439, 0.008905, 0.01…
## $ cate_ranking_5            <int> 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4, 3,…
## $ cate_ranking_20           <int> 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, 17, …
## $ cate_lambda_0             <dbl> 0.021378, 0.023889, 0.033628, 0.033656, 0.01…
## $ clate_lambda_0            <dbl> 0.06980, 0.07944, 0.12765, 0.11580, 0.05165,…
## $ cate_lambda_0_ranking_5   <int> 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4, 3,…
## $ clate_lambda_0_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3, 4,…
## $ cate_lambda_0_ranking_20  <int> 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, 17, …
## $ clate_lambda_0_ranking_20 <int> 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, 13, …
## $ cate_lambda_1             <dbl> 0.017776, 0.020236, 0.029518, 0.031430, 0.00…
## $ clate_lambda_1            <dbl> 0.046846, 0.062183, 0.114336, 0.106968, 0.03…
## $ cate_lambda_1_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4, 3,…
## $ clate_lambda_1_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3, 4,…
## $ cate_lambda_1_ranking_20  <int> 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, 17, …
## $ clate_lambda_1_ranking_20 <int> 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 14, 9…
## $ cate_lambda_2             <dbl> 0.0141732, 0.0165822, 0.0254081, 0.0292035, …
## $ clate_lambda_2            <dbl> 0.02390, 0.04492, 0.10102, 0.09813, 0.02138,…
## $ cate_lambda_2_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4, 3,…
## $ clate_lambda_2_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2, 4,…
## $ cate_lambda_2_ranking_20  <int> 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8, 16,…
## $ clate_lambda_2_ranking_20 <int> 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 14, 8…
## $ cate_lambda_3             <dbl> 0.0105705, 0.0129287, 0.0212983, 0.0269774, …
## $ clate_lambda_3            <dbl> 0.0009444, 0.0276625, 0.0877004, 0.0893001, …
## $ cate_lambda_3_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2, 3,…
## $ cate_lambda_3_ranking_20  <int> 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9, 16,…
## $ clate_lambda_3_ranking_20 <int> 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 15, 8…
## $ cate_lambda_4             <dbl> 0.006968, 0.009275, 0.017188, 0.024751, -0.0…
## $ clate_lambda_4            <dbl> -0.022007, 0.010402, 0.074383, 0.080466, -0.…
## $ cate_lambda_4_ranking_5   <int> 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2, 3,…
## $ cate_lambda_4_ranking_20  <int> 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10, 15…
## $ clate_lambda_4_ranking_20 <int> 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 16, 7…
## [1] 0.9
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.715 -0.484 -0.333  0.549  2.124 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.51e-01   2.15e-02   20.96  < 2e-16 ***
## clate_W       1.87e-01   4.05e-02    4.63  3.7e-06 ***
## X.gender_inp -1.19e-01   1.05e-02  -11.32  < 2e-16 ***
## X.age_inp     2.33e-06   4.16e-04    0.01        1    
## 
## Diagnostic tests:
##                    df1   df2 statistic p-value    
## Weak instruments     1 10880     772.7  <2e-16 ***
## Wu-Hausman           1 10879      10.6  0.0011 ** 
## Sargan               0    NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 10880 degrees of freedom
## Multiple R-Squared: -0.00062,    Adjusted R-squared: -0.000896 
## Wald test: 42.7 on 3 and 10880 DF,  p-value: <2e-16 
## 
## Rows: 12,094
## Columns: 68
## $ person_id                 <int> 5, 8, 16, 17, 18, 23, 24, 29, 47, 57, 59, 68…
## $ cate_rankings_selected    <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_rankings_selected   <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ X.numhh_list              <int> 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ X.gender_inp              <int> 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0,…
## $ X.age_inp                 <int> 60, 41, 39, 52, 51, 32, 34, 23, 43, 46, 38, …
## $ X.hispanic_inp            <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.race_white_inp          <int> 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1,…
## $ X.race_black_inp          <int> 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,…
## $ X.race_nwother_inp        <int> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ast_dx_pre_lottery      <int> 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0,…
## $ X.dia_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.hbp_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
## $ X.chl_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.ami_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.chf_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.emp_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.kid_dx_pre_lottery      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ X.cancer_dx_pre_lottery   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,…
## $ X.dep_dx_pre_lottery      <int> 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,…
## $ X.lessHS                  <int> 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,…
## $ X.HSorGED                 <int> 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0,…
## $ X.charg_tot_pre_ed        <dbl> 0.0, 0.0, 1888.2, 0.0, 1715.3, 0.0, 0.0, 574…
## $ X.ed_charg_tot_pre_ed     <dbl> 0.0, 0.0, 1888.2, 0.0, 1006.3, 0.0, 0.0, 454…
## $ Y                         <int> 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,…
## $ clate_W                   <int> 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,…
## $ Z                         <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ weights                   <dbl> 1.1504, 0.8975, 1.0000, 1.2126, 1.0000, 1.00…
## $ folds                     <int> 8, 1, 10, 3, 10, 9, 9, 4, 4, 10, 7, 6, 5, 7,…
## $ clate                     <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ clate_se                  <dbl> 0.06976, 0.09180, 0.06904, 0.05327, 0.03534,…
## $ clate_ranking_5           <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 1, 4, 3,…
## $ clate_ranking_20          <int> 20, 2, 3, 7, 6, 1, 1, 6, 18, 15, 11, 14, 4, …
## $ cate_W                    <int> 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0,…
## $ cate                      <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ cate_se                   <dbl> 0.007787, 0.014411, 0.014614, 0.016439, 0.00…
## $ cate_ranking_5            <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ cate_ranking_20           <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 14, 17, 5, …
## $ cate_lambda_0             <dbl> 0.051056, 0.021378, 0.023889, 0.033628, 0.03…
## $ clate_lambda_0            <dbl> 0.22184, 0.06980, 0.07944, 0.12765, 0.11580,…
## $ cate_lambda_0_ranking_5   <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 3, 4, 5, 2, 5, 4,…
## $ clate_lambda_0_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_0_ranking_20  <int> 20, 3, 4, 8, 8, 1, 1, 6, 19, 12, 13, 17, 6, …
## $ clate_lambda_0_ranking_20 <int> 20, 2, 3, 7, 6, 1, 1, 6, 17, 15, 10, 14, 5, …
## $ cate_lambda_1             <dbl> 0.049109, 0.017776, 0.020236, 0.029518, 0.03…
## $ clate_lambda_1            <dbl> 0.204401, 0.046846, 0.062183, 0.114336, 0.10…
## $ cate_lambda_1_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 5, 4,…
## $ clate_lambda_1_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 3, 4, 2, 4, 3,…
## $ cate_lambda_1_ranking_20  <int> 20, 3, 4, 8, 9, 1, 1, 6, 19, 13, 14, 16, 7, …
## $ clate_lambda_1_ranking_20 <int> 20, 2, 3, 8, 6, 1, 1, 6, 17, 15, 9, 14, 5, 1…
## $ cate_lambda_2             <dbl> 0.0471620, 0.0141732, 0.0165822, 0.0254081, …
## $ clate_lambda_2            <dbl> 0.18696, 0.02390, 0.04492, 0.10102, 0.09813,…
## $ cate_lambda_2_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 2, 4, 4,…
## $ clate_lambda_2_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_2_ranking_20  <int> 20, 3, 4, 7, 10, 1, 1, 7, 19, 14, 15, 15, 8,…
## $ clate_lambda_2_ranking_20 <int> 20, 2, 3, 8, 7, 2, 1, 6, 17, 15, 8, 14, 6, 1…
## $ cate_lambda_3             <dbl> 0.0452152, 0.0105705, 0.0129287, 0.0212983, …
## $ clate_lambda_3            <dbl> 0.1695211, 0.0009444, 0.0276625, 0.0877004, …
## $ cate_lambda_3_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 4, 3, 4, 4,…
## $ clate_lambda_3_ranking_5  <int> 5, 1, 1, 2, 2, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_3_ranking_20  <int> 20, 3, 4, 7, 11, 1, 1, 7, 19, 15, 15, 13, 9,…
## $ clate_lambda_3_ranking_20 <int> 20, 2, 3, 8, 8, 2, 1, 7, 17, 14, 7, 14, 6, 1…
## $ cate_lambda_4             <dbl> 0.043268, 0.006968, 0.009275, 0.017188, 0.02…
## $ clate_lambda_4            <dbl> 0.152081, -0.022007, 0.010402, 0.074383, 0.0…
## $ cate_lambda_4_ranking_5   <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 4, 3, 3, 4, 4,…
## $ clate_lambda_4_ranking_5  <int> 5, 1, 1, 2, 3, 1, 1, 2, 5, 4, 2, 4, 2, 4, 2,…
## $ cate_lambda_4_ranking_20  <int> 20, 4, 4, 7, 12, 1, 1, 7, 19, 16, 16, 11, 10…
## $ clate_lambda_4_ranking_20 <int> 19, 2, 3, 8, 9, 2, 1, 7, 17, 14, 7, 14, 7, 1…
## [1] 1
## [1] "Y ~ clate_W + X.gender_inp + X.age_inp | Z + X.gender_inp + X.age_inp"
## 
## Call:
## ivreg(formula = as.formula(formula_str), data = data_subset, 
##     weights = weights)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -1.732 -0.493 -0.355  0.542  2.049 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.467062   0.020308   23.00   <2e-16 ***
## clate_W       0.166911   0.037776    4.42    1e-05 ***
## X.gender_inp -0.104776   0.009937  -10.54   <2e-16 ***
## X.age_inp    -0.000158   0.000388   -0.41     0.68    
## 
## Diagnostic tests:
##                    df1   df2 statistic p-value    
## Weak instruments     1 12090    894.72  <2e-16 ***
## Wu-Hausman           1 12089      8.91  0.0028 ** 
## Sargan               0    NA        NA      NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.554 on 12090 degrees of freedom
## Multiple R-Squared: 0.000642,    Adjusted R-squared: 0.000394 
## Wald test: 37.1 on 3 and 12090 DF,  p-value: <2e-16 
## 
## [1] "Results of cumulative analysis:"
## [1] "20th"  "30th"  "40th"  "50th"  "60th"  "70th"  "80th"  "90th"  "100th"
## [1] "Percentile Groups ranked by debt_neg_cw0_lambda_0"
## [1] "finished decreasing"