1 Overview

1.1 Summary

This report provides an introductory examination of the Food Stamps participation trends from 1968 to 1988 using the PSID data, which assesses economic, social, and health aspects throughout the life span of families across multiple generations. First, data cleaning was performed so that the analysis is focused on the subset of survey takers who participated in the Food Stamps program. The variables I looked at are only those relevant to Food Stamps program such as income, state, family size, annual amount paid for food stamps, annual amount saved from using food stamps, annual food standards, and annual food bill. The number of observations is not constant across the years as families kept expanding.

1.2 Variable descriptions

Variable Descriptions
Variable Description
participation Number of food stamps participants in each year from 1969 to 1988 except 1973
weight Weight of the sruvey
size Family size
state State where the family currently lives recoded to be the actual states names
food_std Annual food needs based on the USDA Low Cost plan estimates of the weekly food costs
food_bill Annual food expenditures excluding alcohol and cigarettes in nominal value
saved_FS Money saved by using food stamps, which is the difference between the money spent on food stamps and the value of the food stamps purchased
income Total annual family Money Income
paid_monthly_FS Money spent on food stamps last month
saved_monthly_FS Money saved using food stamps last month
avg_size Weighted average family size across the years from 1968 to 1988 except 1973
avg_income Weighted average nominal income across the years from 1967 to 1988 except 1973
avg_food_bill Weighted average annual food expenditures across the years from 1968 to 1988 except 1972, 1987, and 1988
avg_saved_FS Weighted average money saved annually from using food stamps across the years from 1967 to 1988 except 1972
avg_paid_FS Weighted average money spent annually on food stamps across the years from 1974 to 1978
avg_paid_monthly_FS Weighted average money spent monthly on food stamps across the years from 1975 to 1979
avg_saved_monthly_FS Weighted average money saved monthly from using food stamps across the years from 1975 to 1987
year Year from 1968 to 1988

2 Data Cleaning

# Data Cleaning for all datasets and renaming variables 

#participation vector to store number of food stamps participants 
participation <- c()

#1968----
PSID_1968$weight = na.omit(weights$Weight1968)
design_68 <- svydesign(ids = ~1, weights = PSID_1968$weight, data = PSID_1968)
PSID_1968$STATE <-recode(PSID_1968$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_68 <- as.factor(PSID_1968$STATE)
PSID_68 <- subset(PSID_1968, PSID_1968$`YRLY FOOD STAMPS` > 0)
weight_68 <- as.numeric(PSID_68$weight)
participation <- append(participation, nrow(PSID_68))
size_68<- as.numeric(PSID_68$"FAMILY SIZE")
food_std_68= as.numeric(PSID_68$"YRLY FOOD STD.")
food_bill_68= as.numeric(PSID_68$"YRLY FOOD BILL")
saved_FS_67= as.numeric(PSID_68$"YRLY FOOD STAMPS")
income_67=as.numeric(PSID_68$"TOTAL INCOME")
state_68= as.factor(na.omit(PSID_68$"STATE"))

#Computing 1968 averages ----
avg_size_68= mean(size_68, design=design_68)
avg_food_std_68= mean(food_std_68, design=design_68)
avg_food_bill_68= mean(food_bill_68, design=design_68)
avg_saved_FS_67= mean(saved_FS_67, design=design_68)
avg_income_67= mean(income_67, design=design_68)




#1969----
PSID_1969$weight = na.omit(weights$Weight1969)
design_69 <- svydesign(ids = ~1, weights = PSID_1969$weight, data = PSID_1969)
PSID_1969$STATE <-recode(PSID_1969$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_69 <- as.factor(PSID_1969$STATE)
particip_68 <- nrow(subset(PSID_1969, PSID_1969$`FOOD STAMPS?` == 1))
PSID_69 <- subset(PSID_1969, PSID_1969$`SAVD FOOD STMP` > 0)
weight_69 <- as.numeric(PSID_69$weight)
participation<- append(participation, nrow(PSID_69))
size_69<- as.numeric(PSID_69$"FAMILY SIZE")
food_std_69= as.numeric(PSID_69$"YRLY FOOD STD")
food_bill_69_est= as.numeric(PSID_69$"YRLY FOOD BILL")
saved_FS_68= as.numeric(PSID_69$"SAVD FOOD STMP")
income_68=as.numeric(PSID_69$"TOTAL INCOME")
used_FS_68= as.numeric(PSID_69$"FOOD STAMPS?")
FS_participants_68= sum(used_FS_68 == 1)  
state_69= as.factor(PSID_69$"STATE")


#Computing 1969 averages ----
avg_size_69= mean(size_69,design=design_69)
avg_food_std_69= mean(food_std_69, design=design_69)
avg_saved_FS_68= mean(saved_FS_68, design=design_69)
avg_income_68=mean(income_68, design=design_69)

#1970----
PSID_1970$weight = na.omit(weights$Weight1970)
design_70 <- svydesign(ids = ~1, weights = PSID_1970$weight, data = PSID_1970)
PSID_1970$STATE <-recode(PSID_1970$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_70 <- as.factor(PSID_1970$STATE)
particip_69_paid <- nrow(subset(PSID_1970, PSID_1970$`AMT PAID FOOD STAMPS`>0 & PSID_1970$`AMT PAID FOOD STAMPS` < 4681))
PSID_70 <- subset(PSID_1970, PSID_1970$`$  FOOD BOUGHT W/ STAMPS`>0)
weight_70 <- as.numeric(PSID_70$weight)
participation<- append(participation, nrow(PSID_70))
size_70<- as.numeric(PSID_70$"FAMILY SIZE")
food_std_70= as.numeric(PSID_70$"YRLY FOOD STD")
food_bill_69= as.numeric(PSID_70$"YRLY FOOD BILL")
saved_FS_69= as.numeric(PSID_70$"SAVD FOOD STMP")
income_69=as.numeric(PSID_70$"TOTAL INCOME")
paid_FS_69=as.numeric(PSID_70$"AMT PAID FOOD STAMPS")
value_FS_69=as.numeric(PSID_70$"$  FOOD BOUGHT W/ STAMPS")
FS_participants_70= sum(paid_FS_69>0)
state_70= as.factor(PSID_70$STATE)


#Computing 1970 averages ----
avg_size_70= mean(size_70, design=design_70)
avg_food_std_70= mean(food_std_70, design=design_70)
avg_food_bill_69= mean(food_bill_69, design=design_70)
avg_saved_FS_69= mean(saved_FS_69,design=design_70)
avg_income_69= mean(income_69, design=design_70)
avg_paid_FS_69= mean(paid_FS_69, design=design_70)
avg_value_FS_69= mean(value_FS_69, design=design_70)


#1971----
PSID_1971$weight = na.omit(weights$Weight1971)
design_71 <- svydesign(ids = ~1, weights = PSID_1971$weight, data = PSID_1971)
PSID_1971$STATE <-recode(PSID_1971$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_71 <- as.factor(PSID_1971$STATE)
PSID_71 <- subset(PSID_1971, PSID_1971$"SAVD FOOD STMP"> 0)
weight_71 <- as.numeric(PSID_71$weight)
participation<- append(participation, nrow(PSID_71))
size_71<- as.numeric(PSID_71$"FAMILY SIZE")
food_std_71= as.numeric(PSID_71$"YRLY FOOD STD")
food_bill_70= as.numeric(PSID_71$"YRLY FOOD BILL")
saved_FS_70= as.numeric(PSID_71$"SAVD FOOD STMP")
income_70=as.numeric(PSID_71$"TOTAL INCOME")
state_71= as.factor(PSID_71$STATE)

#Computing 1971 averages ----
avg_size_71= mean(size_71, design=design_71)
avg_food_std_71= mean(food_std_71, design=design_71)
avg_food_bill_70= mean(food_bill_70, design=design_71)
avg_saved_FS_70= mean(saved_FS_70, design=design_71)
avg_income_70= mean(income_70, design=design_71)


#1972----
PSID_1972$weight = na.omit(weights$Weight1972)
design_72 <- svydesign(ids = ~1, weights = PSID_1972$weight, data = PSID_1972)
PSID_1972$STATE <-recode(PSID_1972$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_72 <- as.factor(PSID_1972$STATE)
PSID_72 <- subset(PSID_1972, PSID_1972$`$  SAVD FD STMP`> 0)
PSID_72 <- filter(PSID_72, STATE != 0)
weight_72 <- as.numeric(PSID_72$weight)
participation<- append(participation, nrow(PSID_72))
size_72<- as.numeric(PSID_72$"FAMILY SIZE")
food_std_72= as.numeric(PSID_72$"YRLY FOOD STD")
food_bill_71= as.numeric(PSID_72$"YRLY FOOD BILL")
saved_FS_71= as.numeric(PSID_72$"$  SAVD FD STMP")
income_71=as.numeric(PSID_72$"TOTAL INCOME")
state_72= as.factor(PSID_72$"STATE")


#Computing 1972 averages ----
avg_size_72=mean(size_72, design=design_72)
avg_food_std_72=mean(food_std_72, design=design_72)
avg_food_bill_71=mean(food_bill_71, design=design_72)
avg_saved_FS_71=mean(saved_FS_71, design=design_72)
avg_income_71=mean(income_71, design=design_72)


#1973----
PSID_1973$weight = na.omit(weights$Weight1973)
design_73 <- svydesign(ids = ~1, weights = PSID_1973$weight, data = PSID_1973)
participation<- append(participation, NA)
size_73<- as.numeric(PSID_1973$"FAMILY SIZE")
food_std_73= as.numeric(PSID_1973$"YRLY FOOD STD")
income_72=as.numeric(PSID_1973$"TOTAL INCOME")
state_73= as.factor((PSID_1973$"STATE"))
state_73 <-recode(state_73, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")


#Computing 1973 averages ----
avg_size_73=mean(size_73,  design=design_73)
avg_food_std_73=mean(food_std_73, design=design_73)
avg_income_72=mean(income_72, design=design_73)



#1974----
PSID_1974$weight = na.omit(weights$Weight1974)
design_74 <- svydesign(ids = ~1, weights = PSID_1974$weight, data = PSID_1974)
PSID_1974$STATE <-recode(PSID_1974$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_74 <- as.factor(PSID_1974$STATE)
PSID_74 <- subset(PSID_1974, PSID_1974$`AMT SAVD FD STMP`> 0)
PSID_74 <- filter(PSID_74, STATE != 0)
weight_74 <- as.numeric(PSID_74$weight)
participation<- append(participation, nrow(PSID_74))
particip_73 <- nrow(subset(PSID_1974, PSID_1974$`FREQ USE FD STAMPS` != 0 & PSID_1974$`FREQ USE FD STAMPS` != 9 & PSID_1974$`FREQ USE FD STAMPS` != 5))
#yielded a different number of observations
size_74<- as.numeric(PSID_74$"FAMILY SIZE")
food_std_74= as.numeric(PSID_74$"YRLY FOOD STD")
food_bill_73= as.numeric(PSID_74$"YRLY FOOD BILL")
income_73=as.numeric(PSID_74$"TOTAL INCOME")
saved_FS_73= as.numeric(PSID_74$"AMT SAVD FD STMP")
frequency_FS_73= as.numeric(PSID_74$"FREQ USE FD STAMPS")
FS_participants_73= sum((frequency_FS_73) != 0 & (frequency_FS_73) != 5)
state_74= as.factor((PSID_74$STATE))


#Computing 1974 averages ----
avg_size_74=mean(size_74, design=design_74)
avg_food_std_74=mean(food_std_74, design=design_74)
avg_food_bill_73=mean(food_bill_73, design=design_74)
avg_income_73=mean(income_73, design=design_74)
avg_saved_FS_73=mean(saved_FS_73, design=design_74)

#1975----
PSID_1975$weight = na.omit(weights$Weight1975)
design_75 <- svydesign(ids = ~1, weights = PSID_1975$weight, data = PSID_1975)
PSID_1975$STATE <-recode(PSID_1975$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_75 <- as.factor(PSID_1975$STATE)
PSID_75 <- subset(PSID_1975, PSID_1975$`$  SAVD FDST`> 0)
PSID_75 <- filter(PSID_75, STATE != 0)
weight_75 <- as.numeric(PSID_75$weight)
participation<- append(participation, nrow(PSID_75))
particip_74_paid <- nrow(subset(PSID_1975, PSID_1975$"$  FD STMP">0))
size_75<- as.numeric(PSID_75$"FAMILY SIZE")
food_std_75= as.numeric(PSID_75$"YRLY FOOD STD")
food_bill_74= as.numeric(PSID_75$"YRLY FOOD BILL")
income_74=as.numeric(PSID_75$"TOTAL INCOME")
monthly_paid_FS_75= as.numeric(PSID_75$`$FD STMP LASTMO`)
monthly_saved_FS_75= as.numeric(PSID_75$`$ SAVD LASMO FDST`)
paid_FS_74=as.numeric(PSID_75$"$  FD STMP")
saved_FS_74= as.numeric(PSID_75$"$  SAVD FDST")
state_75= as.factor(PSID_75$STATE)


#Computing 1975 averages ----
avg_size_75=mean(size_75, design=design_75)
avg_food_std_75=mean(food_std_75, design=design_75)
avg_food_bill_74=mean(food_bill_74, design=design_75)
avg_income_74=mean(income_74, design=design_75)
avg_paid_FS_74=mean(paid_FS_74, design=design_75)
avg_saved_FS_74=mean(saved_FS_74, design=design_75)
avg_monthly_paid_FS_75=mean(monthly_paid_FS_75, design=design_75)
avg_monthly_saved_FS_75=mean(monthly_saved_FS_75, design=design_75)


#1976----
PSID_1976$weight = na.omit(weights$Weight1976)
design_76 <- svydesign(ids = ~1, weights = PSID_1976$weight, data = PSID_1976)
PSID_1976$STATE <-recode(PSID_1976$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_76 <- as.factor(PSID_1976$STATE)
#Why is this yielding a different number of participants
particip_75_mos <- nrow(subset(PSID_1976, PSID_1976$`# MO FDSTAMP IN 75`> 0))
particip_75_paid <- nrow(subset(PSID_1976, PSID_1976$`SPENT FDSTA 75`> 0))
PSID_76 <- subset(PSID_1976, PSID_1976$`SAVD FDSTA 75`> 0)
PSID_76 <- filter(PSID_76, STATE != 0)
weight_76 <- as.numeric(PSID_76$weight)
participation<- append(participation, nrow(PSID_76))
size_76<- as.numeric(PSID_76$"FAMILY SIZE")
food_std_76= as.numeric(PSID_76$"YRLY FOOD STD")
food_bill_75= as.numeric(PSID_76$"YRLY FOOD BILL")
income_75=as.numeric(PSID_76$"TOTAL INCOME")
paid_FS_75=as.numeric(PSID_76$"SPENT FDSTA 75")
saved_FS_75= as.numeric(PSID_76$"SAVD FDSTA 75")
monthly_paid_FS_76= as.numeric(PSID_76$"$PAID FOR STAMPS")
monthly_saved_FS_76= as.numeric(PSID_76$"$SAV FDSTAM LASTMO")
frequency_FS_75= as.numeric(PSID_76$"# MO FDSTAMP IN 75")
FD_recipients_family_75=  as.numeric(PSID_76$"NUMBER FD RECIPIENTS")
FS_participants_75= sum(((frequency_FS_75) != 0 & (frequency_FS_75) != 5))
state_76= as.factor((PSID_76$STATE))

#computing 1976 averages----
avg_size_76=mean(size_76, design=design_76)
avg_food_std_76=mean(food_std_76, design=design_76)
avg_food_bill_75=mean(food_bill_75, design=design_76)
avg_income_75=mean(income_75, design=design_76)
avg_paid_FS_75=mean(paid_FS_75, design=design_76)
avg_saved_FS_75=mean(saved_FS_75, design=design_76)
avg_monthly_paid_FS_76=mean(monthly_paid_FS_76, design=design_76)
avg_monthly_saved_FS_76=mean(monthly_saved_FS_76, design=design_76) 
avg_frequency_FS_75= mean(frequency_FS_75, design=design_76)


#1977----
PSID_1977$weight = na.omit(weights$Weight1977)
design_77 <- svydesign(ids = ~1, weights = PSID_1977$weight, data = PSID_1977)
PSID_1977$STATE <-recode(PSID_1977$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii") 
STATE_77 <- as.factor(PSID_1977$STATE)
PSID_77 <- subset(PSID_1977, PSID_1977$`BONUS $  FD STAMPS 76` > 0)
particip_76 <- nrow(subset(PSID_1977, PSID_1977$"WTR FD STMPS IN 76" == 1))
particip_76_mos <- nrow(subset(PSID_1977, PSID_1977$`# MONTHS USED STAMPS  76`> 0 & PSID_1977$`# MONTHS USED STAMPS  76`< 13))
particip_76_paid <- nrow(subset(PSID_1977, PSID_1977$`$  PAID FD STAMPS 76` >0))
PSID_77 <- filter(PSID_77, STATE != 0)
weight_77 <- as.numeric(PSID_77$weight)
participation<- append(participation, nrow(PSID_77))
size_77<- as.numeric(PSID_77$"FAMILY SIZE")
food_std_77= as.numeric(PSID_77$"YRLY FOOD STD")
food_bill_76= as.numeric(PSID_77$"ANNUAL FOOD$  EXCL FDSTMP")
income_76=as.numeric(PSID_77$"TOTAL FAMILY INCOME")
paid_FS_76=as.numeric(PSID_77$"$  PAID FD STAMPS 76")
saved_FS_76= as.numeric(PSID_77$"BONUS $  FD STAMPS 76")
monthly_paid_FS_77= as.numeric(PSID_77$"$  PAID FD STAMP LAST MO")
monthly_saved_FS_77= as.numeric(PSID_77$"$  BONUS FD STAMP LAST MO")
frequency_FS_76= as.numeric(PSID_77$"# MONTHS USED STAMPS  76")
FS_participants_76= sum((frequency_FS_76) != 0)
state_77= as.factor((PSID_77$STATE))
eligibility_76= as.factor(PSID_1977$`WTR ELIG FD STMPS`)

#computing 1977 averages ---- 
avg_size_77=mean(size_77, design=design_77)
avg_food_std_77=mean(food_std_77, design=design_77)
avg_food_bill_76=mean(food_bill_76, design=design_77)
avg_income_76=mean(income_76, design=design_77)
avg_paid_FS_76=mean(paid_FS_76, design=design_77)
avg_saved_FS_76=mean(saved_FS_76, design=design_77)
avg_monthly_paid_FS_77=mean(monthly_paid_FS_77, design=design_77)
avg_monthly_saved_FS_77=mean(monthly_saved_FS_77, design=design_77)



#1978----
PSID_1978$weight = na.omit(weights$Weight1978)
design_78 <- svydesign(ids = ~1, weights = PSID_1978$weight, data = PSID_1978)
PSID_1978$STATE <-recode(PSID_1978$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_78 <- as.factor(PSID_1978$STATE)
PSID_78 <- subset(PSID_1978, PSID_1978$`BONUS FDSTMP 77`> 0)
particip_77_mos <- nrow(subset(PSID_1978, PSID_1978$`# MONTHS USED FDSTMP 77` > 0))
particip_77_paid <- nrow(subset(PSID_1978, PSID_1978$`PAID FDSTMP 77` > 0))
PSID_78 <- filter(PSID_78, STATE != 0)
weight_78 <- as.numeric(PSID_78$weight)
participation<- append(participation, nrow(PSID_78))
size_78<- as.numeric(PSID_78$"FAMILY SIZE" )
food_std_78= as.numeric(PSID_78$"YRLY FOOD STD")
food_bill_77= as.numeric(PSID_78$"ANN FD $  EXCL FDSTMP")
income_77=as.numeric(PSID_78$"TOTAL FAMILY INCOME")
paid_FS_77=as.numeric(PSID_78$"PAID FDSTMP 77")
saved_FS_77= as.numeric(PSID_78$"BONUS FDSTMP 77")
monthly_paid_FS_78= as.numeric(PSID_78$"$  PAID FD ST LAST MO")
monthly_saved_FS_78= as.numeric(PSID_78$"$  BONUS PD ST LAST MO")
frequency_FS_77= as.numeric(PSID_78$"# MONTHS USED FDSTMP 77")
FD_recipients_family_78=  as.numeric(PSID_78$"# FD ST ISSUED FOR")
FS_participants_77= sum((frequency_FS_77) != 0)
state_78= as.factor((PSID_78$STATE))


#computing 1978 averages ----
avg_size_78=mean(size_78, design=design_78)
avg_food_std_78=mean(food_std_78, design=design_78)
avg_food_bill_77=mean(food_bill_77, design=design_78)
avg_income_77=mean(income_77, design=design_78)
avg_paid_FS_77=mean(paid_FS_77, design=design_78)
avg_saved_FS_77=mean(saved_FS_77, design=design_78)
avg_monthly_paid_FS_78=mean(monthly_paid_FS_78, design=design_78)
avg_monthly_saved_FS_78=mean(monthly_saved_FS_78, design=design_78)


#1979----
PSID_1979$weight = na.omit(weights$Weight1979)
design_79 <- svydesign(ids = ~1, weights = PSID_1979$weight, data = PSID_1979)
PSID_1979$STATE <-recode(PSID_1979$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_79 <- as.factor(PSID_1979$STATE)
PSID_79 <- subset(PSID_1979, PSID_1979$`BONUS FDSTMP 78`> 0)
particip_78_mos <- nrow(subset(PSID_1979, PSID_1979$`# MOS USED FDSTMP 78`> 0 &  PSID_1979$`# MOS USED FDSTMP 78` < 13))
particip_78_paid <-nrow(subset(PSID_1979, PSID_1979$`PAID FDSTMP 78`> 0 ))
PSID_79 <- filter(PSID_79, STATE != 0)
weight_79 <- as.numeric(PSID_79$weight)
participation<- append(participation, nrow(PSID_79))
size_79<- as.numeric(PSID_79$"FAMILY SIZE")
food_std_79= as.numeric(PSID_79$"YRLY FOOD STD")
food_bill_78= as.numeric(PSID_79$"ANN FD $  EXCL FDSTMP")
income_78=as.numeric(PSID_79$"TOTAL FAMILY INCOME")
paid_FS_78=as.numeric(PSID_79$"PAID FDSTMP 78")
saved_FS_78= as.numeric(PSID_79$"BONUS FDSTMP 78")
monthly_paid_FS_79= as.numeric(PSID_79$"$  PD FD ST LAST MO" )
monthly_saved_FS_79= as.numeric(PSID_79$"$  BONUS PD LAST MO")
frequency_FS_78= as.numeric(PSID_79$"# MOS USED FDSTMP 78")
FD_recipients_family_79=as.numeric(PSID_79$"# FD ST ISSUED FOR")
FS_participants_78= sum(frequency_FS_78 != 0)
state_79= as.factor(PSID_79$STATE)


#computing 1979 averages ----
avg_size_79=mean(size_79, design=design_79)
avg_food_std_79=mean(food_std_79, design=design_79)
avg_food_bill_78=mean(food_bill_78, design=design_79)
avg_income_78=mean(income_78, design=design_79)
avg_paid_FS_78=mean(paid_FS_78, design=design_79)
avg_saved_FS_78=mean(saved_FS_78, design=design_79)
avg_monthly_paid_FS_79=mean(monthly_paid_FS_79, design=design_79)
avg_monthly_saved_FS_79=mean(monthly_saved_FS_79, design=design_79)



#1980----
PSID_1980$weight = na.omit(weights$Weight1980)
design_80 <- svydesign(ids = ~1, weights = PSID_1980$weight, data = PSID_1980)
PSID_1980$STATE <-recode(PSID_1980$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
PSID_1980 <- PSID_1980 %>% rename('WTR ELIG FD STMPS' = `ELGBL FOR FD STMPS`)
STATE_80 <- as.factor(PSID_1980$STATE)
PSID_80 <- subset(PSID_1980, PSID_1980$`VALUE FD ST 79`> 0)
particip_79_mos <- nrow(subset(PSID_1980, PSID_1980$`# MOS USED FD STMP 79`> 0 & PSID_1980$`# MOS USED FD STMP 79`< 13 ))
PSID_80 <- filter(PSID_80, STATE != 0)
weight_80 <- as.numeric(PSID_80$weight)
participation<- append(participation, nrow(PSID_80))
size_80<- as.numeric(PSID_80$"FAMILY SIZE")
food_std_80= as.numeric(PSID_80$"YRLY FOOD STD")
food_bill_79= as.numeric(PSID_80$"ANN FD $  EXCL FD STMP")
income_79=as.numeric(PSID_80$"TOTAL FAMILY INCOME")
saved_FS_79= as.numeric(PSID_80$"VALUE FD ST 79")
monthly_saved_FS_80= as.numeric(PSID_80$"$ VLUE FD ST LST MO")
frequency_FS_79= as.numeric(PSID_80$"# MOS USED FD STMP 79")
FD_recipients_family_80=as.numeric(PSID_80$"# FD ST ISSUED FOR")
FS_participants_79= sum(frequency_FS_79 != 0)
eligibility_79= as.factor(PSID_1980$`WTR ELIG FD STMPS`)
state_80= as.factor(PSID_80$STATE)

#computing 1980 averages ----
avg_size_80=mean(size_80, design=design_80)
avg_food_std_80=mean(food_std_80, design=design_80)
avg_food_bill_79=mean(food_bill_79, design=design_80)
avg_income_79=mean(income_79, design=design_80)
avg_saved_FS_79=mean(saved_FS_79, design=design_80)
avg_monthly_saved_FS_80=mean(monthly_saved_FS_80, design=design_80)


#1981----
PSID_1981$weight = na.omit(weights$Weight1981)
design_81 <- svydesign(ids = ~1, weights = PSID_1981$weight, data = PSID_1981)
PSID_1981$STATE <-recode(PSID_1981$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
PSID_1981 <- PSID_1981 %>%rename('WTR ELIG FD STMPS'= `WTR ELGBL FOOD STAMP`)
STATE_81 <- as.factor(PSID_1981$STATE)
PSID_81 <- subset(PSID_1981, PSID_1981$`VALUE FOOD STMPS 80`> 0)
particip_80_mos <- nrow(subset(PSID_1981, PSID_1981$`# MOS USED FD ST`> 0 & PSID_1981$`# MOS USED FD ST`< 13))
PSID_81 <- filter(PSID_81, STATE != 0)
weight_81 <- as.numeric(PSID_81$weight)
participation<- append(participation, nrow(PSID_81))
size_81= as.numeric(PSID_81$"FAMILY SIZE")
food_std_81= as.numeric(PSID_81$"YRLY FOOD STD")
food_bill_80= as.numeric(PSID_81$"ANN FD $ $  EXC FD STMP")
income_80=as.numeric(PSID_81$"TOTAL FAMILY INCOME")
saved_FS_80= as.numeric(PSID_81$"VALUE FOOD STMPS 80")
monthly_saved_FS_81= as.numeric(PSID_81$"$ $  VALU FD ST LST MO")
frequency_FS_80= as.numeric(PSID_81$"# MOS USED FD ST")
FD_recipients_family_81=as.numeric(PSID_81$"# PERSONS GOT FOOD STAMP")
eligibility_80= as.factor(PSID_1981$`WTR ELIG FD STMPS`)
FS_participants_80= sum(frequency_FS_80 != 0)
state_81= as.factor(PSID_81$STATE)


#computing 1981 averages ----
avg_size_81=mean(size_81, design=design_81)
avg_food_std_81=mean(food_std_81, design=design_81)
avg_food_bill_80=mean(food_bill_80, design=design_81)
avg_income_80=mean(income_80, design=design_81)
avg_saved_FS_80=mean(saved_FS_80, design=design_81)
avg_monthly_saved_FS_81=mean(monthly_saved_FS_81, design=design_81)


#1982----
PSID_1982$weight = na.omit(weights$Weight1982)
design_82 <- svydesign(ids = ~1, weights = PSID_1982$weight, data = PSID_1982)
PSID_1982$STATE <-recode(PSID_1982$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_82 <- as.factor(PSID_1982$STATE)
PSID_82 <- subset(PSID_1982, PSID_1982$`VALUE FD ST 81`> 0)
particip_81_mos <- nrow(subset(PSID_1982, PSID_1982$`# MOS USED FD ST 81`> 0 & PSID_1982$`# MOS USED FD ST 81`< 13 ))
PSID_82 <- filter(PSID_82, STATE != 0)
weight_82 <- as.numeric(PSID_82$weight)
participation<- append(participation, nrow(PSID_82))
size_82= as.numeric(PSID_82$"FAMILY SIZE")
food_std_82= as.numeric(PSID_82$"ANNUAL FOOD STD")
food_bill_81= as.numeric(PSID_82$"ANN FOOD COST EXC FD ST" )
income_81=as.numeric(PSID_82$"TOTAL FAMILY INCOME")
saved_FS_81= as.numeric(PSID_82$"VALUE FD ST 81")
monthly_saved_FS_82= as.numeric(PSID_82$"VALUE FD ST LAST MO")
frequency_FS_81= as.numeric(PSID_82$"# MOS USED FD ST 81")
FD_recipients_family_82=as.numeric(PSID_82$"# PERSONS GOT FOOD STAMP")
FS_participants_81= sum(frequency_FS_81 != 0)
state_82= as.factor(PSID_82$STATE)

#computing 1982 averages ----
avg_size_82=mean(size_82, design=design_82)
avg_food_std_82=mean(food_std_82, design=design_82)
avg_food_bill_81=mean(food_bill_81, design=design_82)
avg_income_81=mean(income_81, design=design_82)
avg_saved_FS_81=mean(saved_FS_81, design=design_82)
avg_monthly_saved_FS_82=mean(monthly_saved_FS_82, design=design_82)



#1983----
PSID_1983$weight = na.omit(weights$Weight1983)
design_83 <- svydesign(ids = ~1, weights = PSID_1983$weight, data = PSID_1983)
PSID_1983$STATE <-recode(PSID_1983$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
PSID_1983 <- PSID_1983 %>% rename('WTR ELIG FD STMPS'= `IG FD STMP 82`)
STATE_83 <- as.factor(PSID_1983$STATE)
PSID_83 <- subset(PSID_1983, PSID_1983$`VALUE FD ST 82`> 0)
particip_82_mos <- nrow(subset(PSID_1983, PSID_1983$`# MOS USED FD ST 82`> 0 & PSID_1983$`# MOS USED FD ST 82`< 13))
PSID_83 <- filter(PSID_83, STATE != 0)
weight_83 <- as.numeric(PSID_83$weight)
participation<- append(participation, nrow(PSID_83))
size_83= as.numeric(PSID_83$"FAMILY SIZE")
food_std_83= as.numeric(PSID_83$"ANNUAL FOOD STD")
food_bill_82= as.numeric(PSID_83$"ANN FOOD COST EXC FD ST")
income_82=as.numeric(PSID_83$"TOTAL FAMILY INCOME")
saved_FS_82= as.numeric(PSID_83$"VALUE FD ST 82")
monthly_saved_FS_83= as.numeric(PSID_83$"VALUE FD ST LAST MO" )
frequency_FS_82= as.numeric(PSID_83$"# MOS USED FD ST 82")
FD_recipients_family_83=as.numeric(PSID_83$"# PERSONS GOT FOOD STAMP")
FS_participants_82= sum(frequency_FS_82 != 0)
eligibility_82= as.factor(PSID_1983$`WTR ELIG FD STMPS`)
state_83= as.factor(PSID_83$STATE)

#computing 1983 averages ----
avg_size_83=mean(size_83, design=design_83)
avg_food_std_83=mean(food_std_83, design=design_83)
avg_food_bill_82=mean(food_bill_82, design=design_83)
avg_income_82=mean(income_82, design=design_83)
avg_saved_FS_82=mean(saved_FS_82, design=design_83)
avg_monthly_saved_FS_83=mean(monthly_saved_FS_83, design=design_83)



#1984----
PSID_1984$weight = na.omit(weights$Weight1984)
design_84 <- svydesign(ids = ~1, weights = PSID_1984$weight, data = PSID_1984)
PSID_1984$STATE <-recode(PSID_1984$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_84 <- as.factor(PSID_1984$STATE)
PSID_84 <- subset(PSID_1984, PSID_1984$`VALUE FD ST 83`> 0)
particip_83_mos <- nrow(subset(PSID_1984, PSID_1984$`# MOS USED FD ST 83`> 0 &  PSID_1984$`# MOS USED FD ST 83`< 13))
PSID_84 <- filter(PSID_84, STATE != 0)
weight_84 <- as.numeric(PSID_84$weight)
participation<- append(participation, nrow(PSID_84))
size_84= as.numeric(PSID_84$"FAMILY SIZE")
food_std_84= as.numeric(PSID_84$"ANNUAL FOOD STD")
food_bill_83= as.numeric(PSID_84$"ANN FOOD COST EXC FD ST")
income_83=as.numeric(PSID_84$"TOTAL FAMILY INCOME")
saved_FS_83= as.numeric(PSID_84$"VALUE FD ST 83")
monthly_saved_FS_84= as.numeric(PSID_84$"VALUE FD ST LAST MO")
frequency_FS_83= as.numeric(PSID_84$"# MOS USED FD ST 83")
FD_recipients_family_84=as.numeric(PSID_84$"# PERS GOT FD ST LAST MO")
FS_participants_83= sum(frequency_FS_83 != 0)
state_84= as.factor(PSID_84$STATE)


#computing 1984 averages ----
avg_size_84=mean(size_84, design=design_84)
avg_food_std_84=mean(food_std_84, design=design_84)
avg_food_bill_83=mean(food_bill_83, design=design_84)
avg_income_83=mean(income_83, design=design_84)
avg_saved_FS_83=mean(saved_FS_83, design=design_84)
avg_monthly_saved_FS_84=mean(monthly_saved_FS_84, design=design_84)



#1985----
PSID_1985$weight = na.omit(weights$Weight1985)
design_85 <- svydesign(ids = ~1, weights = PSID_1985$weight, data = PSID_1985)
PSID_1985$STATE <-recode(PSID_1985$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_85 <- as.factor(PSID_1985$STATE)
PSID_85 <- subset(PSID_1985, PSID_1985$`VALUE FD ST 84`> 0)
particip_84_mos <- nrow(subset(PSID_1985, PSID_1985$`# MOS USED FD ST 84`> 0 & PSID_1985$`# MOS USED FD ST 84`< 13))
weight_85 <- as.numeric(PSID_85$weight)
participation<- append(participation, nrow(PSID_85))
size_85= as.numeric(PSID_85$"FAMILY SIZE")
food_std_85= as.numeric(PSID_85$"YRLY FOOD STD")
food_bill_84= as.numeric(PSID_85$"ANN FOOD COST EXC FD ST")
income_84=as.numeric(PSID_85$"TOTAL FAMILY INCOME")
saved_FS_84= as.numeric(PSID_85$"VALUE FD ST 84")
monthly_saved_FS_85= as.numeric(PSID_85$"VALUE FD ST LAST MO")
frequency_FS_84= as.numeric(PSID_85$"# MOS USED FD ST 84")
FD_recipients_family_85=as.numeric(PSID_85$"# PERSONS GOT FOOD STAMP")
FS_participants_84= sum(frequency_FS_84 != 0)
state_85= as.factor(PSID_85$STATE)

#computing 1985 averages ----
avg_size_85=mean(size_85, design=design_85)
avg_food_std_85=mean(food_std_85, design=design_85)
avg_food_bill_84=mean(food_bill_84, design=design_85)
avg_income_84=mean(income_84, design=design_85)
avg_saved_FS_84=mean(saved_FS_84, design=design_85)
avg_monthly_saved_FS_85=mean(monthly_saved_FS_85, design=design_85)


#1986----
PSID_1986$weight = na.omit(weights$Weight1986)
design_86 <- svydesign(ids = ~1, weights = PSID_1986$weight, data = PSID_1986)
PSID_1986$STATE <-recode(PSID_1986$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_86 <- as.factor(PSID_1986$STATE)
PSID_86 <- subset(PSID_1986, PSID_1986$`VALUE FD ST 85`> 0)
particip_85_mos <- nrow(subset(PSID_1986, PSID_1986$`# MOS USED FD ST 85`> 0 & PSID_1986$`# MOS USED FD ST 85`< 13))
weight_86 <- as.numeric(PSID_86$weight)
participation<- append(participation, nrow(PSID_86))
size_86= as.numeric(PSID_86$"FAMILY SIZE")
food_std_86= as.numeric(PSID_86$"YRLY FOOD STD")
food_bill_85= as.numeric(PSID_86$"ANN FOOD COST EXC FD ST")
income_85=as.numeric(PSID_86$"TOTAL FAMILY INCOME")
saved_FS_85= as.numeric(PSID_86$"VALUE FD ST 85")
monthly_saved_FS_86= as.numeric(PSID_86$"VALUE FD ST LAST MO" )
frequency_FS_85= as.numeric(PSID_86$"# MOS USED FD ST 85")
FD_recipients_family_86=as.numeric(PSID_86$"# PERSONS GOT FOOD STAMP" )
FS_participants_85= sum(frequency_FS_85 != 0)
state_86= as.factor(PSID_86$STATE)

#computing 1986 averages ----
avg_size_86=mean(size_86, design=design_86)
avg_food_std_86=mean(food_std_86, design=design_86)
avg_food_bill_85=mean(food_bill_85, design=design_86)
avg_income_85=mean(income_85, design=design_86)
avg_saved_FS_85=mean(saved_FS_85, design=design_86)
avg_monthly_saved_FS_86=mean(monthly_saved_FS_86, design=design_86)


#1987----
PSID_1987$weight = na.omit(weights$Weight1987)
design_87 <- svydesign(ids = ~1, weights = PSID_1987$weight, data = PSID_1987)
PSID_1987$STATE <-recode(PSID_1987$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
PSID_1987 <- PSID_1987 %>% rename('WTR ELIG FD STMPS'= `ELIG FOR FD STMPS 86`)
STATE_87 <- as.factor(PSID_1987$STATE)
PSID_87 <- subset(PSID_1987, PSID_1987$`VALUE FD ST 86`> 0)
particip_86_mos <- nrow(subset(PSID_1987, PSID_1987$`# MOS USED FD ST 86`> 0 & PSID_1987$`# MOS USED FD ST 86`< 13 ))
weight_87 <- as.numeric(PSID_87$weight)
participation<- append(participation, nrow(PSID_87))
size_87= as.numeric(PSID_87$"FAMILY SIZE")
food_std_87= as.numeric(PSID_87$"YRLY FOOD STD")
food_bill_86= as.numeric(PSID_87$"ANN FOOD COST EXC FD ST")
income_86=as.numeric(PSID_87$"TOTAL FAMILY INCOME")
saved_FS_86= as.numeric(PSID_87$"VALUE FD ST 86")
monthly_saved_FS_87= as.numeric(PSID_87$"VALUE FD ST LAST MO" )
frequency_FS_86= as.numeric(PSID_87$"# MOS USED FD ST 86")
FD_recipients_family_87=as.numeric(PSID_87$"# PERSONS GOT FOOD STAMP")
FS_participants_86= sum(frequency_FS_86 != 0)
state_87= as.factor(PSID_87$STATE)
eligibility_86= as.factor(PSID_1987$`WTR ELIG FD STMPS`)


#computing 1987 averages ----
avg_size_87=mean(size_87, design=design_87)
avg_food_std_87=mean(food_std_87, design=design_87)
avg_food_bill_86=mean(food_bill_86, design=design_87)
avg_income_86=mean(income_86, design=design_87)
avg_saved_FS_86=mean(saved_FS_86, design=design_87)
avg_monthly_saved_FS_87=mean(monthly_saved_FS_87, design=design_87)


#1988----
PSID_1988$weight = na.omit(weights$Weight1988)
design_88 <- svydesign(ids = ~1, weights = PSID_1988$weight, data = PSID_1988)
PSID_1988$STATE <-recode(PSID_1988$STATE, "1"= "Alabama", "2"= "Arizona", "3"= "Arkansas", "4"= "California", "5"= "Colorado", "6"= "Connecticut", "7"= "Delaware", "8"= "District of Columbia", "9"= "Florida", "10"= "Georgia", "11"= "Idaho", "12"= "Illinois", "13"= "Indiana", "14"= "Iowa", "15"= "Kansas", "16"= "Kentucky", "17"= "Louisiana", "18"= "Maine", "19"= "Maryland", "20"= "Massachusetts", "21"= "Michigan", "22"= "Minnesota", "23"= "Mississippi", "24"= "Missouri", "25"= "Montana", "26"= "Nebraska", "27"= "Nevada", "28"= "New Hampshire", "29"= "New Jersey", "30"= "New Mexico", "31"= "New York", "32"= "North Carolina", "33"= "North Dakota", "34"= "Ohio", "35"= "Oklahoma", "36"= "Oregon", "37"= "Pennsylvania", "38"= "Rhode Island", "39"= "South Carolina", "40"= "South Dakota", "41"= "Tennessee", "42"= "Texas", "43"= "Utah", "44"= "Vermont", "45"= "Virginia", "46"= "Washington", "47"= "West Virginia", "48"= "Wisconsin", "49"= "Wyoming", "50"= "Alaska", "51"= "Hawaii")
STATE_88 <- as.factor(PSID_1988$STATE)
PSID_88 <- subset(PSID_1988, PSID_1988$`VALUE FD ST 87`> 0)
particip_87_mos <- nrow(subset(PSID_1988, PSID_1988$`# MOS USED FD ST 87`> 0 & PSID_1988$`# MOS USED FD ST 87`< 13 ))
weight_88 <- as.numeric(PSID_88$weight)
participation<- append(participation, nrow(PSID_88))
size_88= as.numeric(PSID_88$"FAMILY SIZE")
food_std_88= as.numeric(PSID_88$"YRLY FOOD STD")
income_87=as.numeric(PSID_88$"TOTAL FAMILY INCOME")
saved_FS_87= as.numeric(PSID_88$"VALUE FD ST 87")
frequency_FS_87= as.numeric(PSID_88$"# MOS USED FD ST 87")
FS_participants_87= sum(frequency_FS_87 != 0)
state_88= as.factor(PSID_88$STATE)


#computing 1988 averages ----
avg_size_88=mean(size_88, design=design_88)
avg_food_std_88=mean(food_std_88, design=design_88)
avg_income_87=mean(income_87, design=design_88)
avg_saved_FS_87=mean(saved_FS_87, design=design_88)


#1989----
PSID_1989$weight = na.omit(weights$Weight1989)
design_89 <- svydesign(ids = ~1, weights = PSID_1989$weight, data = PSID_1989)
PSID_89 <- subset(PSID_1989, PSID_1989$`VALUE FD ST 88`> 0)
particip_88_mos <- nrow(subset(PSID_1989, PSID_1989$`# MOS USED FD ST 88`> 0 & PSID_1989$`# MOS USED FD ST 88`< 13))
weight_89 <- as.numeric(PSID_89$weight)
participation<- append(participation, nrow(PSID_89))
income_88=as.numeric(PSID_89$"TOTAL FAMILY INCOME")
saved_FS_88= as.numeric(PSID_89$"VALUE FD ST 88" )
frequency_FS_88= as.numeric(PSID_89$"# MOS USED FD ST 88")
FS_participants_89= sum(frequency_FS_88 != 0)


#computing 1989 averages ----
avg_income_88=mean(income_88, design=design_89)
avg_saved_FS_88=mean(saved_FS_88, design=design_89)
#average family size
avg_size<- c(NA, avg_size_68, avg_size_69, avg_size_70, avg_size_71, avg_size_72, avg_size_73, avg_size_74, avg_size_75, avg_size_76, avg_size_77,  avg_size_78,  avg_size_79,  avg_size_80,  avg_size_81, avg_size_82, avg_size_83, avg_size_84, avg_size_85, avg_size_86, avg_size_87, avg_size_88)

#average total family income
avg_income <- c(avg_income_67, avg_income_68, avg_income_69,avg_income_70, avg_income_71, avg_income_72, avg_income_73, avg_income_74, avg_income_75, avg_income_76, avg_income_77, avg_income_78, avg_income_79, avg_income_80, avg_income_81, avg_income_82, avg_income_83, avg_income_84, avg_income_85, avg_income_86, avg_income_87, avg_income_88)

#average annual food bill
avg_food_bill<- c(NA, avg_food_bill_68, avg_food_bill_69, avg_food_bill_70, avg_food_bill_71, NA , avg_food_bill_73, avg_food_bill_74, avg_food_bill_75, avg_food_bill_76, avg_food_bill_77, avg_food_bill_78, avg_food_bill_79, avg_food_bill_80, avg_food_bill_81, avg_food_bill_82, avg_food_bill_83, avg_food_bill_84, avg_food_bill_85, avg_food_bill_86, NA , NA)

#average amount saved by using food stamps 
avg_saved_FS<- c(avg_saved_FS_67, avg_saved_FS_68, avg_saved_FS_69, avg_saved_FS_70, avg_saved_FS_71, NA, avg_saved_FS_73, avg_saved_FS_74, avg_saved_FS_75, avg_saved_FS_76, avg_saved_FS_77, avg_saved_FS_78, avg_saved_FS_79, avg_saved_FS_80, avg_saved_FS_81, avg_saved_FS_82, avg_saved_FS_83, avg_saved_FS_84, avg_saved_FS_85, avg_saved_FS_86, avg_saved_FS_87, avg_saved_FS_88)

#average amount paid for food stamps 
avg_paid_FS<- c(NA, NA, NA, NA, NA, NA, NA, avg_paid_FS_74, avg_paid_FS_75, avg_paid_FS_76, avg_paid_FS_77, avg_paid_FS_78, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0)

#average amount paid monthly for food stamps 
avg_paid_monthly_FS <-c(NA, NA, NA, NA, NA, NA, NA, NA, avg_monthly_paid_FS_75, avg_monthly_paid_FS_76, avg_monthly_paid_FS_77, avg_monthly_paid_FS_78, avg_monthly_paid_FS_79, 0, 0, 0, 0, 0, 0, 0, 0, 0)

#average amount saved monthly by using food stamps
avg_saved_monthly_FS<-c(NA, NA, NA, NA, NA, NA, NA, NA, avg_monthly_saved_FS_75, avg_monthly_saved_FS_76, avg_monthly_saved_FS_77, avg_monthly_saved_FS_78, avg_monthly_saved_FS_79, avg_monthly_saved_FS_80, avg_monthly_saved_FS_81, avg_monthly_saved_FS_82, avg_monthly_saved_FS_83, avg_monthly_saved_FS_84, avg_monthly_saved_FS_85, avg_monthly_saved_FS_86, avg_monthly_saved_FS_87, NA)

#year variable
year<- c(1967:1988)

#creating a data frame for necessary variables
df <- data.frame(year, participation, avg_size, avg_income, avg_food_bill, avg_saved_FS, avg_paid_FS, avg_paid_monthly_FS, avg_saved_monthly_FS)

3 Graphs and Figures

# Figures

# participation by year
participation_plot <- ggplot(data=df) +
  geom_point(aes(x=year, y=participation)) +
  # ggtitle("Number of Food Stamp Participants in the PSID data") +
  theme_classic()


#average amount of money paid annually for food stamps
FS_paid_plot_1 <- ggplot(df, aes(year, avg_paid_FS)) +
  geom_point(aes(colour = cut(avg_paid_FS, c(-Inf, 0, Inf)))) +
  scale_color_manual(values = c("(-Inf,0]" = "red","(0, Inf]" = "black"),
                     labels = c("estimated", "actual")) +
  theme_classic()


#average amount of money paid monthly for food stamps
FS_paid_plot_2 <- ggplot(df, aes(year, avg_paid_monthly_FS)) +
  geom_point(aes(colour = cut(avg_paid_monthly_FS, c(-Inf, 0, Inf)))) +
  scale_color_manual(values = c("(-Inf,0]" = "red","(0, Inf]" = "black"),
                     labels = c("estimated", "actual")) +
  theme_classic()


#average amount of money saved annualy from stamps by year
FS_saved_plot_1 <- ggplot(data=df) +
  geom_point(aes(x=year, y=avg_saved_FS)) +
  theme_classic()


#average amount of money saved monthly from stamps by year
FS_saved_plot_2 <- ggplot(data=df) +
  geom_point(aes(x=year, y=avg_saved_monthly_FS)) +
  theme_classic()
# Computing income threshold levels based on the eligibility status 

threshold_income_76 <- min(PSID_1977$'TOTAL FAMILY INCOME'[PSID_1977$`WTR ELIG FD STMPS`== 5 & PSID_1977$'TOTAL FAMILY INCOME' != 1])
threshold_income_79 <- min(PSID_1980$'TOTAL FAMILY INCOME'[PSID_1980$`WTR ELIG FD STMPS`== 5 & PSID_1980$'TOTAL FAMILY INCOME' != 1])
threshold_income_80 <- min(PSID_1981$'TOTAL FAMILY INCOME' [PSID_1981$`WTR ELIG FD STMPS`== 5 & PSID_1981$'TOTAL FAMILY INCOME' != 1])
threshold_income_82 <- min(PSID_1983$`TOTAL FAMILY INCOME`[PSID_1983$`WTR ELIG FD STMPS`== 5 & PSID_1983$`TOTAL FAMILY INCOME` != 1])
threshold_income_86 <- min(PSID_1987$`TOTAL FAMILY INCOME`[PSID_1987$`WTR ELIG FD STMPS`== 5 & PSID_1987$`TOTAL FAMILY INCOME` != 1])



cols <- c("year", "thresold nominal income")
inc_76<-c("1976", threshold_income_76)
inc_79<-c("1979", threshold_income_79)
inc_80<-c("1980", threshold_income_80)
inc_82<-c("1982", threshold_income_82)
inc_86<-c("1986", threshold_income_86)


table4 <- rbind(cols, inc_76, inc_79, inc_80, inc_82, inc_86)
#Function to calculate overall participation arte 
calculate_rate <- function(data) 
{
  total_participating <- nrow(data)
  total_weighted_families <- sum(data$weight, na.rm = TRUE)
  participation_rate <- (total_participating / total_weighted_families) * 100
  return(participation_rate)
}

# Auxilary function to calculate participation rates
calculate_participation_rate <- function(data) 
{
  total_participating <- nrow(data)
  total_weighted_families <- sum(data$weight, na.rm = TRUE)
  participation_rate <- (total_participating / total_weighted_families) * 100
  return(data.frame(participation_rate = participation_rate))
}

generate_and_plot_map <- function(data, year) 
{
  state_participation <- data %>%
    group_by(state= data$"STATE") %>%
    group_modify(~calculate_participation_rate(.))
  
   temp <- plot_usmap(data = state_participation, values = "participation_rate", color = "grey") +
    scale_fill_continuous(low = "lightblue2", high = "blue3", na.value = "white") +
    theme(legend.position = "right")
    assign(paste0("map_19", year), temp, envir = .GlobalEnv)
}

# calculating overall participation rates and creating maps showing participation rate by state
overallParticipation <- c()
for (year in 67:88) 
{
 if (year != 73 & year != 67) 
  {
  data <- get(paste0("PSID_", year))
  p= calculate_rate(data)
  overallParticipation<- append(overallParticipation, p)
  generate_and_plot_map(data, year)
 }
  else 
  {
    overallParticipation<- append(overallParticipation, NA)
  }
}
df$overallParticipation= overallParticipation
# overall participation by year
overall_participation_plot <- ggplot(data=df) +
  geom_point(aes(x=year, y=overallParticipation)) +
  # ggtitle("Number of Food Stamp Participants in the PSID data") +
  theme_classic()
# Create income buckets
PSID_1968$income_bucket <- cut(PSID_1968$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1968 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1968)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`YRLY FOOD STAMPS` > 0, 1, 0), ~income_bucket, design = design_1968, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`YRLY FOOD STAMPS\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_68 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1969$income_bucket <- cut(PSID_1969$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1969 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1969)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`SAVD FOOD STMP` > 0, 1, 0), ~income_bucket, design = design_1969, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`SAVD FOOD STMP\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_69 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1970$income_bucket <- cut(PSID_1970$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1970 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1970)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`SAVD FOOD STMP` > 0, 1, 0), ~income_bucket, design = design_1970, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`SAVD FOOD STMP\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_70 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1971$income_bucket <- cut(PSID_1971$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1971 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1971)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`SAVD FOOD STMP` > 0, 1, 0), ~income_bucket, design = design_1971, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`SAVD FOOD STMP\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_71 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1972$income_bucket <- cut(PSID_1972$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1972 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1972)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`$  SAVD FD STMP` > 0, 1, 0), ~income_bucket, design = design_1972, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`$  SAVD FD STMP\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_72 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate LOLL")
# Create income buckets
PSID_1974$income_bucket <- cut(PSID_1974$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1974 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1974)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`AMT SAVD FD STMP` > 0, 1, 0), ~income_bucket, design = design_1974, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`AMT SAVD FD STMP\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_74 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate LOLL")
# Create income buckets
PSID_1975$income_bucket <- cut(PSID_1975$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1975 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1975)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`$  SAVD FDST` > 0, 1, 0), ~income_bucket, design = design_1975, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`$  SAVD FDST\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_75 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate LOLL")
# Create income buckets
PSID_1976$income_bucket <- cut(PSID_1976$"TOTAL INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1976 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1976)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`SAVD FDSTA 75` > 0, 1, 0), ~income_bucket, design = design_1976, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`SAVD FDSTA 75\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_76 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate LOLL")
# Create income buckets
PSID_1977$income_bucket <- cut(PSID_1977$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1977 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1977)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`BONUS $  FD STAMPS 76` > 0, 1, 0), ~income_bucket, design = design_1977, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`BONUS $  FD STAMPS 76\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_77 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1978$income_bucket <- cut(PSID_1978$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1978 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1978)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`BONUS FDSTMP 77` > 0, 1, 0), ~income_bucket, design = design_1978, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`BONUS FDSTMP 77\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_78 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1979$income_bucket <- cut(PSID_1979$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1979 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1979)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`BONUS FDSTMP 78` > 0, 1, 0), ~income_bucket, design = design_1979, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`BONUS FDSTMP 78\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_79 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1980$income_bucket <- cut(PSID_1980$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1980 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1980)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 79` > 0, 1, 0), ~income_bucket, design = design_1980, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 79\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_80 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1981$income_bucket <- cut(PSID_1981$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1981 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1981)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FOOD STMPS 80` > 0, 1, 0), ~income_bucket, design = design_1981, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FOOD STMPS 80\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_81 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1982$income_bucket <- cut(PSID_1982$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1982 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1982)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 81` > 0, 1, 0), ~income_bucket, design = design_1982, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 81\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_82 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1983$income_bucket <- cut(PSID_1983$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1983 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1983)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 82` > 0, 1, 0), ~income_bucket, design = design_1983, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 82\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_83 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1984$income_bucket <- cut(PSID_1984$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1984 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1984)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 83` > 0, 1, 0), ~income_bucket, design = design_1984, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 83\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_84 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1985$income_bucket <- cut(PSID_1985$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1985 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1985)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 84` > 0, 1, 0), ~income_bucket, design = design_1985, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 84\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_85 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1986$income_bucket <- cut(PSID_1986$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1986 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1986)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 85` > 0, 1, 0), ~income_bucket, design = design_1986, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 85\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_86 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1987$income_bucket <- cut(PSID_1987$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1987 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1987)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 86` > 0, 1, 0), ~income_bucket, design = design_1987, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 86\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_87 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")
# Create income buckets
PSID_1988$income_bucket <- cut(PSID_1988$"TOTAL FAMILY INCOME", breaks = c(0, 10000, 20000, 30000, 40000, 50000, Inf), labels = c("0-10k", "10k-20k", "20k-30k", "30k-40k", "40k-50k", "50k+"), include.lowest = TRUE)

# Create survey design
design_1988 <- svydesign(ids = ~1, weights = ~weight, data = PSID_1988)

# Calculate participation rates within each income level using survey functions
participation_by_income <- svyby(~ifelse(`VALUE FD ST 87` > 0, 1, 0), ~income_bucket, design = design_1988, svymean, na.rm = TRUE)

# Convert result to a data frame and calculate percentage rate
participation_by_income_df <- as.data.frame(participation_by_income)
participation_by_income_df$percentage_participation <- participation_by_income_df$`ifelse(\`VALUE FD ST 87\` > 0, 1, 0)` * 100

# Create the plot
income_participation_plot_88 <- ggplot(data = participation_by_income_df) +
  geom_line(aes(x = income_bucket, y = percentage_participation, group = 1, color = income_bucket)) +
  theme_classic() +
  labs(color = "Income Level", y = "Weighted Participation Rate")

4 Potential limitations to consider

The number of food stamps participants was calculated based on the variables available for each year. For consistency, I consider those who saved an amount of money greater than 0 from using food stamps in a particular year to be food stamps participants for that year. “The SAVD_FS” variable was available in PSID for all years from 1967 to 1990 except 1973.

It is worth mentioning that there were other variables that tracked food stamps participation such as the number of months a family used food stamps or the amount of money spent on food stamps. I expected that calculating the number of participants who saved a positive amount of money from using food stamps in a specific year would yield the the same result as calculating the number of participants who used food stamps in at least one month throughout the same year. However, that was not always the case. I tried comparing the number of participants using other variables in addition to the number of months but there have been some discrepancies, which are illustrated in the table below.

4.1 Food Stamps participants according to different variables

Calculation of Food Stamps participants
saved_FS used_FS? # Months used FS paid_FS
291 291
834 522
730 674
865 828
931 360 903
892 895 884 854
811 814 778
847 840 758
1013 1003
1067 1059
1064 1058
1144 1124
1090 1067
966 949
915 903
939 935
898 884
821 818

5 Eligibility VS Participation based on PSID data

I was interested to know how many people in the sample knew that there were eligible each year and compare that number to the total number of food stamps participants in the same sample. Eligibility for Food Stamps Program was recorded in the PSID data only for 1976, 1979, 1980, 1982, and 1986.

Food Stamps eligibility vs actual participation
year participated eligible maybe eligible Don’t know if eligible
1976 892 1564 214 316
1979 1013 1689 219 430
1980 1067 1727 179 454
1979 1064 1733 188 335
1986 939 1536 177 258

6 Income threshold levels obtained from PSID data

After running initial simple comparison to calculate the minimum income of those who reported that they were ineligible for food stamps in 1976, 1979, 1980, 1982, and 1986. The minimum value was $1 or less in all 5 years. Upon exclusion of the value $1, new income threshold levels were obtained. They are displayed in the table below.

Income Threshold levels for Food Stamps Program Eligibility
year thresold nominal income
1976 150
1979 61
1980 90
1982 200
1986 71

7 Participation rates across income brackets

I have explored weighted participation rates across income brackets. Using categorized income levels, ranging from 0 to 10k and beyond, the plots reveal how participation varies by income levels. Calculated with survey functions and accounting for sample weights, these line graphs offer insights into the relationship between income and food stamps program participation rates.

Food Stamps Participation rates by income in 1967

Food Stamps Participation rates by income in 1967

Food Stamps Participation rates by income in 1968

Food Stamps Participation rates by income in 1968

Food Stamps Participation rates by income in 1969

Food Stamps Participation rates by income in 1969

Food Stamps Participation rates by income in 1970

Food Stamps Participation rates by income in 1970

Food Stamps Participation rates by income in 1971

Food Stamps Participation rates by income in 1971

Food Stamps Participation rates by income in 1973

Food Stamps Participation rates by income in 1973

Food Stamps Participation rates by income in 1974

Food Stamps Participation rates by income in 1974

Food Stamps Participation rates by income in 1975

Food Stamps Participation rates by income in 1975

Food Stamps Participation rates by income in 1976

Food Stamps Participation rates by income in 1976

Food Stamps Participation rates by income in 1977

Food Stamps Participation rates by income in 1977

Food Stamps Participation rates by income in 1978

Food Stamps Participation rates by income in 1978

Food Stamps Participation rates by income in 1979

Food Stamps Participation rates by income in 1979

Food Stamps Participation rates by income in 1980

Food Stamps Participation rates by income in 1980

Food Stamps Participation rates by income in 1981

Food Stamps Participation rates by income in 1981

Food Stamps Participation rates by income in 1982

Food Stamps Participation rates by income in 1982

Food Stamps Participation rates by income in 1983

Food Stamps Participation rates by income in 1983

Food Stamps Participation rates by income in 1984

Food Stamps Participation rates by income in 1984

Food Stamps Participation rates by income in 1985

Food Stamps Participation rates by income in 1985

Food Stamps Participation rates by income in 1986

Food Stamps Participation rates by income in 1986

Food Stamps Participation rates by income in 1987

Food Stamps Participation rates by income in 1987

8 Participation rates by State

The following maps show Food Stamps participation rates by State as per the PSID data every year from 1967 to 1988 except 1972 in a chronological order

Food Stamps Participation rates across the US in 1968

Food Stamps Participation rates across the US in 1968

Food Stamps Participation rates across the US in 1969

Food Stamps Participation rates across the US in 1969

Food Stamps Participation rates across the US in 1970

Food Stamps Participation rates across the US in 1970

Food Stamps Participation rates across the US in 1971

Food Stamps Participation rates across the US in 1971

Food Stamps Participation rates across the US in 1972

Food Stamps Participation rates across the US in 1972

Food Stamps Participation rates across the US in 1974

Food Stamps Participation rates across the US in 1974

Food Stamps Participation rates across the US in 1975

Food Stamps Participation rates across the US in 1975

Food Stamps Participation rates across the US in 1976

Food Stamps Participation rates across the US in 1976

Food Stamps Participation rates across the US in 1977

Food Stamps Participation rates across the US in 1977

Food Stamps Participation rates across the US in 1978

Food Stamps Participation rates across the US in 1978

Food Stamps Participation rates across the US in 1979

Food Stamps Participation rates across the US in 1979

Food Stamps Participation rates across the US in 1980

Food Stamps Participation rates across the US in 1980

Food Stamps Participation rates across the US in 1981

Food Stamps Participation rates across the US in 1981

Food Stamps Participation rates across the US in 1982

Food Stamps Participation rates across the US in 1982

Food Stamps Participation rates across the US in 1983

Food Stamps Participation rates across the US in 1983

Food Stamps Participation rates across the US in 1984

Food Stamps Participation rates across the US in 1984

Food Stamps Participation rates across the US in 1985

Food Stamps Participation rates across the US in 1985

Food Stamps Participation rates across the US in 1986

Food Stamps Participation rates across the US in 1986

Food Stamps Participation rates across the US in 1987

Food Stamps Participation rates across the US in 1987

Food Stamps Participation rates across the US in 1988

Food Stamps Participation rates across the US in 1988