Stockpiling ahead of Brexit could boost Scotland’s economic growth in 2018-19 but the measure will have a negative effect in the medium term, the Scottish Government’s top economist has said.

Dr Gary Gillespie said analysis suggests the building of stock inventories by firms ahead of the UK’s departure from the EU could potentially increase Scottish GDP by 0.4%.

However, the chief economist added such growth “would be more than offset” by a slowing of output in subsequent quarters.

He has published his latest State of the Economy report, summarising key data and providing analysis of the performance of and outlook for the Scottish economy.

Dr Gillespie found while the economy continued to strengthen in the first half of the year, with less than six months to go to the March deadline Brexit remains a key concern in many sectors.

“Businesses may delay or defer decisions on new investment and consumers reduce or postpone spending,” the report states.

“At the same time, the nature of investment may change as firms seek to bring forward investment to protect supply chains and identify alternative routes to service customers and key markets.”

The report adds: “As noted previously, building stock inventories in advance of March 2019 may bring forward economic activity to this side of EU exit.

“Our new analysis suggests that while this could potentially boost Scottish GDP growth in 2018-19 by up to 0.4 percentage points, this would be more than offset by a slowing of output in subsequent quarters.

“The overall effect of stockpiling on the economy is negative in the medium term.”

The Centre for Economics and Business Research (CEBR) said last month that UK firms will have stockpiled an extra £38 billion of goods by the time Brexit happens.

The think tank said the measure was the “driving force” behind GDP growth in the second quarter of the year.

Meanwhile, Dr Gillespie’s analysis also shows overall consumer sentiment has been negative since the EU referendum.

“Despite sentiment regarding individual household finances strengthening, attitudes to spending remain weak and households’ expect the economy to deteriorate over the next year,” the report adds.

“Therefore a broader Brexit risk remains, which if transmitted into a significant fall in household confidence and consumption could have a material impact on the economy.”

The report notes Scottish GDP grew 0.5% between April and June 2018, a marginal increase on the 0.4% the previous quarter and above the rate of the UK as a whole at 0.4%.

The improvement was attributed to strong export growth on the back of a weaker pound and the rising value of oil.

Scotland’s labour market has also performed well, with unemployment close to record lows.

Economy Secretary Derek Mackay said: “With Scotland’s economy continuing to grow throughout the year, it’s good to see the improving outlook for the oil and gas sector coming to fruition alongside the continued strong performance in our labour market.”

He added: “We are using the powers we have to boost the economy and ensure our economic potential is realised at the same time as we try to mitigate the damage Brexit will cause.”