farmers_markets <- read.csv("C:/Users/susha/Downloads/NYC_Farmers_Markets_20241107.csv")
head(farmers_markets)
## Borough Market.Name
## 1 Manhattan Harvest Home East Harlem Farmers Market
## 2 Brooklyn Seeds in the Middle - Flatbush - Hillel Plaza Farm Stand
## 3 Bronx Morris Heights Farmstand
## 4 Bronx 170 Farm Stand
## 5 Bronx JBOLC Garden Community Farmers Market
## 6 Queens Perez Farm Stand
## Street.Address Community.District Latitude
## 1 E. 104th St. & 3rd Ave. 111 40.79030
## 2 Flatbush/Nostrand Triangle 314 40.63262
## 3 University Ave. and W. 179th St. 205 40.85457
## 4 1406 Townsend Ave. 204 40.84014
## 5 Sedgwick Ave. & Goulden Ave. 207 40.88265
## 6 134-20 Jamaica Ave., by the Axel Building 409 40.70236
## Longitude Days.of.Operation Hours.of.Operations Season.Begin
## 1 -73.94563 Thursday 8AM - 3PM 06/15/2023 12:00:00 AM
## 2 -73.94744 Wednesday 4PM - 7PM 01/01/2023 12:00:00 AM
## 3 40.85457 Wednesday 11AM - 3PM 03/27/2023 12:00:00 AM
## 4 -73.91659 Wednesday 2PM - 6PM 07/12/2023 12:00:00 AM
## 5 -73.88656 Saturday 10AM - 3PM 06/17/2023 12:00:00 AM
## 6 -73.81853 Wednesday 10AM - 4PM 06/14/2023 12:00:00 AM
## Season.End Accepts.EBT Distributes.Health.Bucks. Open.Year.Round
## 1 11/16/2023 12:00:00 AM Yes Yes No
## 2 12/31/2023 12:00:00 AM Yes Yes No
## 3 11/29/2023 12:00:00 AM Yes Yes No
## 4 11/22/2023 12:00:00 AM Yes Yes No
## 5 10/28/2023 12:00:00 AM Yes Yes No
## 6 11/01/2023 12:00:00 AM Yes Yes No
## Cooking.Demonstrations Location.Point Zip.Code
## 1 No (40.7903, -73.945635) 10029
## 2 No (40.63262, -73.947439) 11210
## 3 No (40.854567, 40.854567) 10453
## 4 Yes (40.840138, -73.916591) 10452
## 5 No (40.882647, -73.886562) 10468
## 6 No (40.70236, -73.818531) 11418
colnames(farmers_markets)
## [1] "Borough" "Market.Name"
## [3] "Street.Address" "Community.District"
## [5] "Latitude" "Longitude"
## [7] "Days.of.Operation" "Hours.of.Operations"
## [9] "Season.Begin" "Season.End"
## [11] "Accepts.EBT" "Distributes.Health.Bucks."
## [13] "Open.Year.Round" "Cooking.Demonstrations"
## [15] "Location.Point" "Zip.Code"
table(farmers_markets$Accepts.EBT)
##
## No TBD yes Yes
## 7 3 1 152
farmers_markets <- farmers_markets %>%
mutate(accepts_ebt = case_when(
Accepts.EBT %in% c("Yes", "yes") ~ 1,
Accepts.EBT %in% c("No", "TBD") ~ 0,
TRUE ~ NA_real_))
farmers_markets$accepts_ebt <- as.factor(farmers_markets$accepts_ebt)
table(farmers_markets$accepts_ebt)
##
## 0 1
## 10 153
farmers_markets <- farmers_markets %>%
mutate(
open_year_round = ifelse(Open.Year.Round == "Yes", 1, 0),
open_year_round = as.factor(open_year_round),
distributes_health_bucks = ifelse(Distributes.Health.Bucks. == "Yes", 1, 0),
distributes_health_bucks = as.factor(distributes_health_bucks),
borough = as.factor(Borough)
)
table(farmers_markets$distributes_health_bucks)
##
## 0 1
## 18 145
table(farmers_markets$open_year_round)
##
## 0 1
## 134 29
table(farmers_markets$accepts_ebt)
##
## 0 1
## 10 153
table(farmers_markets$borough)
##
## Bronx Brooklyn Manhattan Queens Staten Island
## 31 61 42 24 5
# Model 1:
model1 <- glm(accepts_ebt ~ borough, data = farmers_markets, family = binomial)
# Model 2:
model2 <- glm(accepts_ebt ~ borough + open_year_round, data = farmers_markets, family = binomial)
# Model 3:
model3 <- glm(accepts_ebt ~ borough + open_year_round + distributes_health_bucks, data = farmers_markets, family = binomial)
anova(model1, model2, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: accepts_ebt ~ borough
## Model 2: accepts_ebt ~ borough + open_year_round
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 158 67.165
## 2 157 62.652 1 4.5132 0.03363 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(model2, model3, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: accepts_ebt ~ borough + open_year_round
## Model 2: accepts_ebt ~ borough + open_year_round + distributes_health_bucks
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 157 62.652
## 2 156 18.867 1 43.785 3.665e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(model3, model1, test = "Chisq")
## Analysis of Deviance Table
##
## Model 1: accepts_ebt ~ borough + open_year_round + distributes_health_bucks
## Model 2: accepts_ebt ~ borough
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 156 18.867
## 2 158 67.165 -2 -48.298 3.252e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(model1)
##
## Call:
## glm(formula = accepts_ebt ~ borough, family = binomial, data = farmers_markets)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.957e+01 1.931e+03 0.010 0.992
## boroughBrooklyn -1.660e+01 1.931e+03 -0.009 0.993
## boroughManhattan -1.700e+01 1.931e+03 -0.009 0.993
## boroughQueens -1.796e+01 1.931e+03 -0.009 0.993
## boroughStaten Island -1.077e-08 5.183e+03 0.000 1.000
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 75.197 on 162 degrees of freedom
## Residual deviance: 67.165 on 158 degrees of freedom
## AIC: 77.165
##
## Number of Fisher Scoring iterations: 18
summary(model2)
##
## Call:
## glm(formula = accepts_ebt ~ borough + open_year_round, family = binomial,
## data = farmers_markets)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 20.4740 3144.3156 0.007 0.995
## boroughBrooklyn -17.7225 3144.3156 -0.006 0.996
## boroughManhattan -18.2768 3144.3156 -0.006 0.995
## boroughQueens -19.0271 3144.3156 -0.006 0.995
## boroughStaten Island -0.2113 8240.8353 0.000 1.000
## open_year_round1 18.1390 3182.0549 0.006 0.995
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 75.197 on 162 degrees of freedom
## Residual deviance: 62.652 on 157 degrees of freedom
## AIC: 74.652
##
## Number of Fisher Scoring iterations: 19
summary(model3)
##
## Call:
## glm(formula = accepts_ebt ~ borough + open_year_round + distributes_health_bucks,
## family = binomial, data = farmers_markets)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 19.37 6899.76 0.003 0.998
## boroughBrooklyn -19.78 6899.76 -0.003 0.998
## boroughManhattan -20.47 6899.76 -0.003 0.998
## boroughQueens -20.06 6899.76 -0.003 0.998
## boroughStaten Island -19.72 22234.77 -0.001 0.999
## open_year_round1 19.15 7145.94 0.003 0.998
## distributes_health_bucks1 22.62 3734.21 0.006 0.995
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 75.197 on 162 degrees of freedom
## Residual deviance: 18.867 on 156 degrees of freedom
## AIC: 32.867
##
## Number of Fisher Scoring iterations: 21
AIC(model1, model2, model3)
## df AIC
## model1 5 77.16525
## model2 6 74.65206
## model3 7 32.86697
BIC(model1, model2, model3)
## df BIC
## model1 5 92.63400
## model2 6 93.21457
## model3 7 54.52322
# Simulate coefficients for model3
sim_coefs <- sim(model3)
# Compute AME for 'distributes_health_bucks'
sim_est <- sim_ame(sim_coefs, var = "distributes_health_bucks", contrast = "rd", verbose = FALSE)
# Summarize the results
summary(sim_est)
## Estimate 2.5 % 97.5 %
## E[Y(0)] 5.78e-01 1.45e-01 7.03e-01
## E[Y(1)] 1.00e+00 2.22e-16 1.00e+00
## RD 4.22e-01 -4.97e-01 6.41e-01
plot (sim_est)
# Create the set values dataframe
set_values <- data.frame(
borough = factor(c("Manhattan", "Brooklyn"), levels = levels(farmers_markets$borough)),
open_year_round = factor(c(1, 0), levels = c(0, 1)), # 1: Yes, 0: No
distributes_health_bucks = factor(c(1, 0), levels = c(0, 1)) # 1: Yes, 0: No
)
# Simulate predictions at these set values
sim_predictions <- sim_setx(sim_coefs, x = set_values)
# Check the results
summary(sim_predictions)
## Estimate
## borough = "Manhattan", open_year_round = "1", distributes_health_bucks = "1" 1.00e+00
## borough = "Brooklyn", open_year_round = "0", distributes_health_bucks = "0" 4.00e-01
## 2.5 %
## borough = "Manhattan", open_year_round = "1", distributes_health_bucks = "1" 2.22e-16
## borough = "Brooklyn", open_year_round = "0", distributes_health_bucks = "0" 1.08e-01
## 97.5 %
## borough = "Manhattan", open_year_round = "1", distributes_health_bucks = "1" 1.00e+00
## borough = "Brooklyn", open_year_round = "0", distributes_health_bucks = "0" 7.99e-01
plot(sim_predictions)
In analyzing the factors that influence farmers’ markets in New York City accepting EBT (Electronic Benefit Transfer), I initially started by looking at the boroughs where the markets are located. At first glance, the borough didn’t seem to play a big role in whether a market accepted EBT. The results showed that the likelihood of accepting EBT was nearly the same across all boroughs, with p-values greater than 0.99 for each one. This was surprising, as I expected the location to have some influence. But what stood out was the effect of whether the market operated year-round. When I added this to the analysis, the results became clearer. The model revealed that markets open year-round were significantly more likely to accept EBT, which made sense because consistent operation throughout the year could provide more stable access for low-income communities.
Adding another layer to the analysis, I looked at whether markets participate in the Health Bucks program, which offers discounts for EBT users at farmers’ markets. This model (Model 3) really showed some interesting results. It was clear that markets participating in the Health Bucks program were much more likely to accept EBT, with a highly significant p-value (less than 1e-11). It was exciting to see how much this factor strengthened the model. The AIC and BIC values also showed a much better fit, which made me realize how essential programs like Health Bucks are in increasing access to healthy food for people who rely on EBT. It was a powerful reminder of how important such community-driven initiatives are.
Reflecting on these results, I’ve realized how crucial year-round operation and programs like Health Bucks are in improving food access for low-income New Yorkers. While the borough itself didn’t matter as much, these other factors really drive EBT acceptance. Moving forward, I would advocate for policies that encourage more farmers’ markets to operate year-round and to expand programs like Health Bucks. These findings give valuable insights into how we can help bridge the gap in food security for underserved communities, and I’m excited to share this perspective with others who might want to push for these kinds of changes in policy.