Preheat the oven to 350°F. Oil a large, shallow casserole.
Prepare the spaghetti according to the package directions, drain, and transfer to the casserole. Cover with 2 cups of sauce, sprinkle with salt and pepper, to taste, and toss to coat. Spread the spaghetti evenly in the casserole.
Heat a large skillet over medium heat, add the beef and onion, and cook to brown the meat, breaking it up with a wooden spoon. Remove from the heat and spoon off as much of the fat as possible. Return the skillet to the heat and add the remaining 3 cups of sauce. Cover and simmer for 4 to 5 minutes. Remove from the heat.
In a small bowl, combine the ricotta cheese, sour cream, Parmesan cheese, basil, and salt and pepper, to taste, and mix to blend. Drop dollops on the spaghetti and spread with the back of a spoon. Cover with meat sauce and sprinkle with the mozzarella and cheddar cheeses. Bake for 35 to 40 minutes, or until bubbly.