As speculation mounts over John B. Anderson's selection of a vice presidential running mate, his supporters, by a 3-to-1 ratio, say they would prefer that the independent presidential candidate choose a Democrat rather than a Republican to round out his ticket.

In a nationwide Gallup Poll completed last Sunday, 47 percent of registered voters who choose Anderson in a test election against Ronald Reagan and President Carter say they would be more likely to vote for the Illinois congressman if he selected a Democratic for the No. 2 spot on his ticket, while 16 percent indicate their preference for a Republican. Of the balance, 29 percent say the political affiliation of Anderson's running mate will not affect their feelings and 8 percent had no opinion.

Anderson is expected to name his vice presidential choice soon. At least 20 names have been advanced as possibilities. Those mentioned prominently include New York Gov. Hugh Carey and Boston Mayor Kevin White, both Democrats.

Anderson's choice of a running mate may be particularly relevant -- even crucial -- at the time. In the latest test election Anderson receives 14 percent of the vote to 45 percent for Reagan and 31 percent for Carter. This is the first time support for Anderson has fallen much below the 20 percent plateau he had maintained in the course of eight earlier Gallup trial heats.

While the fall-off in the Anderson vote from the previous test election has occurred among all population groups, it is most pronounced among registered voters who identify themselves as political independents, dropping from 33 percent in a mid-July Gallup Poll to 22 percent in the current survey.

Not only has the Anderson vote dropped sharply in the latest test election, but only 14 percent of Anderson backers now say they strongly support him, compared to 31 percent who made the same claim in the mid-July survey, a decline of 17 points. The comparable drop in enthusiastic support for Carter is 10, and for Reagan, 3 percentage points.

Another campaign development that adds urgency to Anderson's need to generate more public support for his candidacy is that, to qualify for a forthcoming series of televised debates sponsored by the League of Women Voters, he must demonstrate substantial public backing at the end of this month.

Some analysts feel that Anderson's sagging political fortunes can be bolstered by the selection of a strong vice presidential running mate. On the strength of the survey evidence at hand, it would appear that a Democrat would best fill that need.

In the current survey, 18 percent of registered voters express a preference for a Democrat for the No. 2 spot on Anderson's ticket compared to 12 percent who would like to see a Republican in that role. However, six voters in 10, 62 percent, say either that they do not plan to back Anderson anyway or that the political affiliation of his running mate is immaterial to them.

Among college-educated and younger voters, both groups in which Anderson's candidacy has enjoyed its greatest support, opinion is more evenly divided but still favors a Democrat. However, among independents, who have provided much of the backbone for Anderson's quest for the presidency, the weight of opinion leans toward a Republican vice presidential choice.

The results are based on in-person interviews with 938 registered voters out of a total sample of 1,261 adults, 18 and older, conducted in scientifically selected localities across the nation during the period Aug. 1-3.