Where rats live depends a great deal on the species of rat.

Rat

Common Rats prefer to live at ground level in underground burrows located under buildings and under debris located at ground-level. These rats are terrestrial by nature.
Roof rats prefer to live above ground in the roof section of structures, in leaves, trees or some other protected harborage site above ground. Roof rats are arboreal by nature.