Compare growing food at home against buying it.
Growing food has a large one-off cost and a small recurring one, so the answer depends entirely on how many years you spread the setup across. Beds, tools and irrigation last a decade or more; seeds, compost and water are the modest annual cost. Amortising the setup gives an annualised figure that divides into your harvest to produce a real cost per kilogram, and the break-even harvest tells you the minimum yield that makes the year worthwhile. The first-year cash outlay is shown separately because it is the number that actually leaves your account, and it is almost always higher than a year of buying the same produce.
Annualised cost
Annual = setup cost / years to amortise + annual inputs
Cost per kg and break-even
Per kg = annualised / harvest kg; break-even kg = annualised / shop price per kg
Because raised beds, tools and irrigation serve many seasons. Charging the whole cost against the first harvest makes gardening look uneconomic; ignoring it entirely makes it look free. Spreading it over the realistic life of the equipment gives a figure you can compare against shop prices year on year.
Ones with a high shop price per kilogram and a high yield per square metre — salad leaves, herbs, tomatoes, courgettes and soft fruit. Staples such as potatoes and onions are so cheap to buy that home growing rarely competes on cost alone, whatever else it offers.