Heat the oven to 350°F and grease a 9- by 13-inch pan.
Put the flour, coconut, walnuts (if desired), baking powder, salt, cinnamon, cloves, and allspice in a large bowl and stir to combine.
Beat ¾ cup (1½ sticks) butter, the oil, and the brown sugar with the paddle attachment of a stand mixer (or with a handheld mixer) until light and fluffy.
Add the eggs and 2 teaspoons vanilla extract and beat for 2 minutes.
Gently stir in the flour mixture, then fold in the carrots.
Transfer the batter to the greased pan and bake until a knife inserted into the center of the cake comes out clean, 30 to 40 minutes.
Cool the cake.
Meanwhile, beat the remaining ¼ cup (½ stick) butter and the cream cheese with the paddle attachment of a stand mixer (or with a handheld mixer) until well combined.
Add the powdered sugar and beat on low speed to combine, then add the remaining 1 tablespoon vanilla.
Beat for at least 10 minutes.
Spread the frosting on the cake and serve.
(Store leftover cake in an airtight container at room temperature for up to a few days.)
