Well, there is more to it than just the compression ratio. It's a lot more complicated than that.
Air-cooled engines tend to run at much higher cylinder head temperatures than liquid-cooled engines, and that tends to promote detonation.
Small-bore engines are less prone to detonation than large-bore engines. Doesn't matter number of cylinders, the bore size is what counts. With small diameter cylinders, there is a shorter distance from the spark plug to the furthest reaches of the combustion chamber. Within the engine, if you burn the mixture via the flame front before it has a chance to detonate, it doesn't detonate. Modern 600cc sport bike engines commonly have compression ratio in the 13:1 range nowadays. Don't try that on a Chevrolet V8 if you want to fill it up at the corner gas station.
High-revving engines are less prone to detonation. If the piston goes down the cylinder quickly enough, the cylinder pressure drops fast enough that the end gas doesn't reach detonation conditions. Also there is a time-lag before self-ignition occurs, and these engines again want to burn the mixture via the flame front before that time lag happens.
The design of the combustion chamber matters. 4-valve DOHC with spark plug dead center minimizes the distance the flame front has to travel.
The design of the intake runners matter. Some modern engines promote high "tumble" charge motion which helps the mixture burn normally via the (turbulent) flame front before detonation can occur. Case study: the new Chrysler Pentastar "upgrade" (3.6 litre DOHC-4v, 11.3:1 compression
http://www.allpar.com/mopar/V6/PUG-2015.php and also the Renault TCe90
https://www.youtube.com/watch?v=XNvRhWL1stQ
The cam timing matters. Long-duration intake cams let some of the charge back out of the cylinder which reduces cylinder pressure which makes the engine "think" it has lower compression than it actually is. The Atkinson-cycle engines in many of the newer hybrid cars (notably, Prius, but it's not the only one) takes advantage of this. But if you just simply sacrifice low-end torque by using long-duration cams, the same thing happens. The aforementioned 600cc sport bikes are doing this.
(yes, I'm a mechanical engineer; yes, I'm a powertrain junkie. I don't actually work in powertrain engineering myself, but I have a friend who spent way too much time in postgraduate studies and now works in powertrain engineering and knows way too much about all this stuff)