The number of people in Bay Area hospitals with COVID-19 or suspected of having the illness has declined over the past few weeks, a sign that early and aggressive social restrictions in the region may have calmed the spread of the virus, public health experts said.

Throughout California, however, the number of people who have tested positive and are in hospitals has continued to climb.

State data reviewed by The Chronicle for the month of April show that the number of people in hospitals for COVID-19 in the nine-county Bay Area fell from a high of 471 on April 7 to 403 on April 19. The number of people in the hospital with symptoms consistent with the respiratory disease, but who had not been tested or had pending results, dropped from 360 to 203 during the two-week period.

Hospital counts provide a better view into the scope of the outbreak than case counts since they are not as dependent on the availability of tests. Epidemiologists call the trend encouraging, but caution that things could still quickly change.

“We may be very lucky in the Bay Area in dodging that surge,” said Dr. Monica Gandhi, a professor of medicine at UCSF. “No one can say we’re completely out of the woods yet, but we have been very fortunate in terms of our hospitalization rates. We have been in control so far.”

The data, released by the California Department of Public Health, show only the total number of people who are in the hospital for the disease each day, not new admissions — a metric public health experts say would be a better indicator of how many people are getting seriously sick over time.

The figures in the Bay Area differ across the region. In Alameda and Contra Costa counties, for example, the number of people who tested positive for COVID-19 and were in the hospital increased during the first week and a half of April, but recently leveled off and started to drop slightly.

In San Francisco, the number of positive patients this month peaked on April 12 at 92, then began to steadily decline until reaching 73 cases by April 19. Gandhi warned things could worsen, particularly in light of the nearly 100 people who recently tested positive for COVID-19 at the city’s largest homeless shelter.

“We don’t yet know if the shelter situation will cause more hospitalizations,” she said.

The data show that in almost every Bay Area county, the number of suspected cases is falling faster than the number of confirmed cases.

The trends for the Bay Area are somewhat different from California as a whole. In April, both experienced a large drop in the number of suspected COVID-19 cases in the hospital, which might be due to the waning flu season and a recent increase in testing.

“Obviously, whether someone is a confirmed or suspected case depends in part on whether testing for the virus is available,” said Dr. Arthur Reingold, division head of epidemiology and biostatistics at UC Berkeley’s School of Public Health. “If there aren’t enough tests, a higher proportion of the cases will be suspected.”

Meanwhile, the number of people who tested positive for the virus and had to be hospitalized has slowly increased in California while it has stayed relatively flat in the Bay Area.

“We are not seeing that downward trend we need to see to provide more clarity on that road map to recovery,” Gov. Gavin Newsom said Monday about the California numbers.

The difference is driven partially by Los Angeles County, which experienced a sharp increase in hospital counts in April. The county of 10 million, which has become an epicenter of California’s outbreak, makes up a quarter of the state’s population, but it accounted for more than half of all confirmed COVID-19 patients in hospitals on April 19, according to state data.

Health officials have told The Chronicle that the timing of social restrictions may have played a role in slowing the rate of infection in the Bay Area, which announced its shelter-in-place order three days before Los Angeles.

Many Bay Area tech companies also asked employees to work from home, and some schools closed shortly after the first cases were confirmed in San Francisco on March 5, Gandhi said.

“California is a very diverse and large state: Los Angeles, San Diego, the rural north, they may not all be in exactly the same place as the Bay Area,” Reingold said, adding that he hoped there would be a continued drop in hospitalizations in the coming weeks.

“Obviously, one unknown is the extent in which people who have been avoiding crowds, washing their hands, sheltering in place will continue to do that,” Reingold added. “Or will they feel emboldened and go back to behaviors that increase their risk.”

Joaquin Palomino is a San Francisco Chronicle staff writer. Email: jpalomino@sfchronicle.com Twitter: @JoaquinPalomino