I left school with a burning urge to lead the life of a writer: travelling like Byron, feted like Wilde before his fall, creating laughter like Wodehouse and crafting sentences like Nabokov. I had no professional contacts, so I wrote my masterpieces speculatively, and every path I went down ended with a rejection slip or total silence. The perceived wisdom then, as now, was that earning a living as a writer was about as likely as winning a lottery.

Then I discovered the secret of marketing: instead of writing things and trying to persuade people to buy them, I would find out what writing services people needed and offer to provide them. So, at the same time as begging publishers and editors for commissions, I made myself available to anyone who might want to write an article or a book but did not feel able to do it for themselves.

I have just finished a three-year stint on the management committee of The Society of Authors; I know how hard it is for many writers to make a living. But it has never been easy.

I have now spent over 40 years as a freelance author and ghostwriter, during which time I have kept a meticulous record of every penny earned and can, with hindsight, see exactly how my personal experiment has panned out.

Although it was about 10 years before I could support myself fully from my writing, over the course of those 40 years I have earned around £4m. Obviously there were some feasts and famines along the way, but by and large the graph has travelled upwards year upon year. From a starting point of about £1,000 a year, 20 years later I hit six figures for the first time, and for the last decade the annual figure has wavered between £150,000 and £200,000. That puts me roughly on a par with the prime minister – but with fewer perks and fewer responsibilities – a level I am more than content with.

The vast majority of that money has come from ghostwriting, some from fees paid by wealthy individuals and some in royalties from books that became bestsellers. Every time I agreed to a split in royalties instead of a fee, I was taking a gamble; sometimes I would end up writing a whole book for virtually nothing. Looking back now, however, it was also these gambles that paid off the most handsomely. One book, for instance, has earned me more than half a million. Quite a few have earned me more than £100,000. It is possible to ghost four books a year – although three is more comfortable – which means that in most years the ones that earned nothing have been compensated for by the successes.

By making my primary living from selling writing services, I have been able to risk taking the time out to write speculative “passion projects” – in my case, novels. Two of these novels have ghostwriters as narrators and were inspired by people I met and places I gained access to as a ghost. In Pretty Little Packages, the narrator is plunged into the world of people-trafficking and sex-slavery, while Secrets of the Italian Gardener is set in the palace of a Middle Eastern dictator who is telling his story to a ghostwriter during the outbreak of the Arab spring. I wonder how many palaces and brothels I would have got to see if I had stayed in my garret and written the books I dreamed of writing as a teenager, and whether I would ever have been able to earn a living and support a family.

What would I say to the young person setting out to be a writer today? First, I would ask if they want to write for their own pleasure and fulfilment, or whether they want to use writing to support themselves financially. If it is the latter, they must furnish their brains with something that they can write about, gain access to information that other people are willing to pay for or provide a service that others need to buy.

The odds that your passion projects alone will ever make enough money to support you in any decent style are about the same as when you buy a lottery ticket, so you are inevitably going to have to do something else to earn money in the coming years. But there is an advantage to moving into crafts such as journalism or ghostwriting: they give you access to experiences. The more varied and interesting your life and experiences, the more likely that you will have something worth writing about. The more time you spend honing your writing skills through these crafts, the sharper those skills will be when the time comes for you to try to sell your passion projects to an uninterested world.

When we get to the later years of our lives it is good to have some stories, adventures and interesting experiences with which to regale our grandchildren – hopefully something more than a sorry tale of sitting at a computer screen, making up stories that not many people ever wanted to buy.