Safest position to ride on roads with cars What is a hard and fast rule on where to ride within a lane, if one exists at all?

I've heard people say that you should ride as far over as you can while avoiding drains, potholes, small children etc.. and keeping out of the way of motorists. I have also read that further out into the lane is safer causing motorists to give you a wider berth and increasing your visibility.

Which is correct and are there any meaningful statistics to be found?

Related: Best ways to avoid getting hit by cars?
The hard and fast rule is to do whatever it takes to keeps you safe.

The first thing is to ride with lights at night and reflective gear.

Generally, what I do is, if theres a wide enough shoulder I will use it. If there isn't, I take the lane. Being in a corner of a lane is a problem since motorists will try to sneak past and can't always judge the room needed to do so safely (at least a 3 foot margin from you). The side of the road is generally bad as debris tends to collect there, so you increase your risk of punctures and what not. 

Note that there may be legal things to do -- The Washington state bicycling guide says cyclists must be as far right as it is safe not as far right as is possible (my personal policy also follows this). Check with your local area to see what the legal policy is (if any). 

To quote the Washington state bicycling guide:
"Washington State law requires cyclists 
to ride as far to the right as is safe, 
not as far to the right as is possible. 
There is a crucial difference. Assess the 
situation to decide how far towards the 
center of the lane you need to travel 
to be safe versus unduly delaying 
motorized traffic. Taking the full lane 
is generally safest when traveling for 
short stretches on lower speed roads 
(20-25mph). On higher speed roads, it 
may be safer to reduce your speed and 
stay further to the right rather than 
compete with faster vehicles for the 
full lane.

You may find it necessary to take 
the lane in the following kinds of 
situations:

•    when traveling at traffic speed and 
you need to prevent motorists from 
inadvertently cutting you off;

•    when descending a hill and you 
need extra space (for reaction time) 
due to your speed;

•    when lane width does not permit 
a motorized vehicle behind you to 
safely pass;

•    when road conditions (potholes, 
road debris or parked cars) preclude 
you from riding farther to the right.
Be aware that many motorists neither 
understand that you have the right to 
take the lane in these situations (or at 
all), nor may they see road condition 
hazards which you are trying to avoid."

Another thing to note is that part of safety (aside from abiding from the law) is dealing with harassment. From the same guide: "Most motorists are courteous and happy to share the road with cyclists, but 
unfortunately, the small minority of drivers who are rude or threatening 
stand out. Harassment can make a commute unenjoyable or even dangerous. 
Fortunately, it rarely occurs. If harassed, try to keep your cool and remember 
that your safety is the priority. You will rarely convince an irate motorist to share 
the road, and besides, you don’t want to provoke a person unstable enough to 
harass you in the first place. Your best bet is to develop your riding skills, know 
your rights, ride legally and try to keep calm in the event you are harassed. 
Noting a car’s license plate, description and occupants may help when reporting 
an incident to the authorities."