Think solar is a poor investment? Guess again.

A new study by the NC Clean Energy Technology Center finds that in all but 4 of the 50 largest cities in the U.S., installing a fully-financed 5 kilowatt solar panel system makes more financial sense than investing in a popular stock market index fund. Further, the same system would beat the costs of buying energy from local utilities in 42 of those 50 cities.

“(S)olar is now not just an option for the rich, but a real opportunity for anyone looking to take greater control over their monthly utility bills and make a long-term, relatively low-risk investment,” concludes the study which was done under funding by the U.S. Department of Energy.

A key qualifier in this good news study is that the benefits of installing residential solar photovoltaic systems are greatest when homeowners finance the systems (at an assumed annual interest rate of 5 percent) rather than buying them upfront. And the study does not investigate the availability of such loans. The study finds that in upfront purchases of solar, residents in just 14 out of the 50 largest U.S. cities would pay less for electricity than if they buy from their local utility. That upfront investment would be a better investment than the broad stock market index fund in 20 of the 50 cities.

Among the factors that make residential solar PV a more and more attractive option are the rapidly falling costs of purchasing and installing solar components, the projections for increased costs of buying electricity from utilities in the years ahead, and the range of financial incentives offered by the federal and state governments and by utilities looking to meet requirements that they get a set percentage of their power from renewable sources.

In the last 15 years, the median cost of residential solar has fallen to $4.70 per watt from $12 a watt, according to the Lawrence Berkeley National Laboratory. And the cost has fallen further in 2014, to between $3.70 a watt and $4.24, according to EnergySage.

A recent study by Deutsche Bank predicts that solar will reach grid parity (a cost equal to or less than grid-supplied electricity) in all 50 states by 2016.

Looking at the levelized cost of energy for solar PV systems (the average cost per kilowatt over the expected 25-year life span), the NC Clean Energy Technology Center’s study found that nearly 21 million homeowners in 42 of the nation’s largest cities would save money with financed solar systems over getting their power from the grid. More than 9 million homeowners in 14 of the cities would save money even if they pay upfront for solar systems.

For average homeowners, the study concludes, “solar can generate both significant monthly savings and long-term investment value, and not infrequently, cost less than energy from some of America’s largest electric utilities.”