We propose a bilevel transit network frequency setting problem in which the upper level consists of analytical route cost functions and the lower level is an activity-based market equilibrium derived using MATSim-NYC. The use of MATSim in the lower-level problem incorporates sensitivity of the design process to competition from other modes, including ride-hail, and can support large-scale optimization. The proposed method is applied to the existing Brooklyn bus network, which includes 78 bus routes, 650,000 passengers per day, 550 route-km, and 4,696 bus stops. MATSim-NYC modeling of the existing bus network has a ridership-weighted average error per route of 21%. The proposed algorithm is applied to a benchmark network and confirms their predicted 20% growth in ridership using their benchmark design. Applying our proposed algorithm to their network with 78 routes and 24 periods, we have a problem with 3,744 decision variables. The algorithm converged within 10 iterations to a delta of 0.064%. Compared with the existing scenario, we increased ridership by 20% and reduced operating cost by 25%. We improved the farebox recovery ratio from the existing 0.22 to 0.35, 0.06 more than the benchmark design. Analysis of mode substitution effects suggest that 2.5% of trips would be drawn from ride-hail while 74% would come from driving.