Sometimes we borrow money from the bank because we plan to spend more than we expect to get in income. And sometimes we borrow money from the bank because our stock of money is too small relative to our flows of planned spending and expected income.
Here is a rough sketch of a simple model that captures that idea. It is an ISLM model, except it has two LM curves. One LM curve is horizontal ("Keynesian"), and the other LM curve is vertical ("monetarist"). You can only ignore the vertical "monetarist" LM curve if you are willing to assume fully rational expectations and full information, so each individual agent knows what every other agent is planning to do, and can solve the model for the equilibrium level of output, which he knows with certainty.
At the beginning of the period, all agents announce the prices at which they will sell goods. Prices are fixed in advance. Output is demand-determined at those fixed prices.
Next, the bank opens, announces a rate of interest, and offers to lend or borrow money at that same rate of interest. Agents choose how much money they will hold given that rate of interest. The bank than closes.
Next, Nature tosses a coin for each agent, which determines the order in which they go shopping. There is a very large number of agents, so exactly half the agents are early shoppers, who will spend money before they earn it. And half the agents are late shoppers, who will earn money before they spend it. The early shoppers buy from the late shoppers, then the late shoppers buy from the early shoppers.
The early shoppers will want to ensure their stock of money is sufficient to satisfy their cash-in-advance constraint. The late shoppers will want a zero stock of money, unless they plan to spend more than they expect to earn. But agents do not know whether they will be early shoppers or late shoppers until after the bank closes. They choose a stock of money which depends on how much they plan to spend, on how much income they expect to earn, and on the rate of interest (because that is the opportunity cost of having unspent balances at the end of the period).
What would the aggregate demand function look like in this economy? There are two different ways we could write the AD function:
1. Yd = F(Ye,r). Output demanded Yd is an increasing function of expected income Ye, and a decreasing function of the rate of interest r set by the bank. This is how we would write the demand function before the bank has closed its doors and before we know M/P.
2. Yd = H(M/P). The early shoppers spend all their money (their cash-in advance constraint will be binding, if r>0), which determines the income of the late shoppers, and how much they will spend. This is how we would write the demand function after the bank has closed its doors and after we know M/P.
(Both demand functions will also depend on expected income and expected interest rates and expected prices in all future periods, but I have ignored those expectations of future periods here.)
With rational expectations, and identical agents (except for Nature's coin toss to determine who shops when), each agent could solve for Ye=Y=Yd from the first AD function, given the rate of interest set by the bank. Solving the first AD function gives us a standard IS curve, with Y a decreasing function of r. That IS curve, plus the horizontal LM curve, with the bank setting r, lets us solve the model. The second AD function isn't needed, unless we want to solve for M/P.
But suppose agents cannot solve the model to learn Y with certainty, because Nature also adds some aggregate shocks and agent-specific shocks, and individual agents cannot separate the two, and so do not know how much other agents are planning to spend, and so do not know how much income the late shoppers will earn from the early shoppers? Then the second aggregate demand function will matter too. The late shoppers will find that their expectations of income from the early shoppers may not be realised, and will revise their planned expenditures. If the early agents actually hold less money than the late agents expected them to hold, and so spend less than the late agents expected them to spend, some late agents may find their cash-in-advance constraints binding, and all late agents will buy less than they had planned to buy, because they have learned that their incomes are lower than they had expected them to be.
Under rational expectations and full information (except for the coin toss) we can ignore the second AD function. We set Ye=Yd=Y, solve the first AD function for the standard IS curve, add a horizontal LM curve for r, and those two curves determine Y.
Otherwise, if we take expected Y as given, M/P will be a function of Ye and r, and we need the second AD function to determine Yd and Y given M/P. Output is determined by the vertical LM curve.
The standard IS curve, which assumes Ye=Yd=Y, is an ex-ante IS curve. It tells us what agents would rationally expect the level of output to be, given the horizontal LM curve. And those two curves determine the rationally expected stock of money, and where agents rationally expect the vertical LM curve to be. Agents with model-consistent expectations expect all three curves to cross at the same point.
But if the representative agent has false expectations, because he does not know he is the representative agent, and so plans to spend more or less than he expects to earn, the actual vertical LM curve will not be where he expects it to be, because agents actually hold either more money or less money than he expected them to hold. And it is that actual vertical LM curve that determines actual output demanded and actual output. And this period's actual output will in turn affect expectations of future income in future periods.
The trouble with Keynesians is........they assume rational expectations and full information. Without even realising it.