State Space Models

All state space models are written and estimated in the R programming language. The models are available here with instructions and R procedures for manipulating the models here here.

Thursday, April 17, 2025

Boiler Plate

  


State Space Model Estimation

The Measurement Matrix for the state space models was constructed using Principal Components Analysis with standardized data from the World Development Indicators. The statistical analysis was conducted in an extension of the dse package. The package is currently supported by an online portal (here) and can be downloaded, with the R-programming language, for any personal computer hereCode for the state space Dynamic Component models (DCMs) is available on my Google drive (here) and referenced in each post.


Atlanta Fed Economy Now

My approach to forecasting is similar to the EconomyNow model used by the Atlanta Federal Reserve. Since the new Republican Administration is signaling that they would like to eliminate the Federal Reserve, the app might well not be available in the future.


While the app is still available, there have been some interesting developments. In earlier forecasts, the Atlanta Fed was showing GDP growth predictions outside the Blue Chip Consensus. Right now, after unorthodox economic policies from the Trump II Administration, the EconomyNow model is predicting a drastic drop in GDP (the Financial Forecast Center is only predicting a slight drop here).

Climate Change

Another comparison for what I have presented above are the IPCC Emission Scenarios. These scenarios are for the World System. Needless to say, (1) the new Right-Wing Republican administration plans on withdrawing the US from all attempts to study or ameliorate Climate Change and (2) the IPCC does not produce any RW modes for the World System (but seem my forecasts here).


World System

The longest running set of data we have for the World-System is the Maddison Project based on the work of Angus Maddison (more information is available here). Data on production (Q) and population (N) for most countries and regions runs from years 0-2000. More data becomes available as we near the year 2000. 


Available data were entered in a spreadsheet (see Population above, double click to enlarge). Missing data were interpolated with nonlinear spline smoothing using the R programming Language.


In cases where initial values were not available (see GDP above), the E-M Algorithm was used to estimate initial conditions.

From the graph of GDP above (W_Q) for the World System, it can be seen that economic growth from the year 0-1500 was basically flat. The period of British Capitalism (after 1500) had a small plateau of growth. Takeoff does not happen until the Nineteenth Century.



From a system's perspective, the only model that can be tested for the entire period is Kenneth Boulding's Malthusian Systems Model [Q,N] = f[Q,N].



When developed as a State Space model (measurement matrix above) there are two components: W1=Growth and W2=(Q-N), the Malthusian Controller. When more data is available, the Malthusian Controller can be generalized to other SocioEconomic theories.

What the Malthusian Controller shows (plotted as Q-N above) is that a long-developing Malthusian Crisis (Q<N) started in the Late Middle Ages and accelerated through the period of British Capitalism (Dark Satanic Mills) and was reversed spectacularly during the Nineteenth Century.  Takeoff in response to a deepening Malthusian Crisis would not be an unreasonable way to view Modern Economic Growth.

Error Correcting Controllers (ECC)


In another post (here), I presented Leibenstein's Malthusian Error Correcting Controller (ECC). It can be generalized to the dominant ECCs in most theoretical economic models (above). These controllers can be further generalized. For example, (X-U) and (L-U) can be generalized to (N-U), a more general Urbanization Controller which describes market expansion for economic growth. In countries and periods with limited data, (N-U) might subsume all these processes. ECCs describe important feedback processes in SocioTechnical System that are typically not recognized as such in academic literature.

Kaya Identity



The basic theoretical model underlying all the World-System models I crate is the Kaya Identity. There are a number of advantages to starting theoretical development with the Kaya Identity: (1) An "identity" is true by definition Adding other variables to the model ensure that theory construction is on a solid footing. (2) The Kaya Identity is also used as the foundation for the IPCC Emissions Scenarios allowing a linkage between World-Systems Theory and the work of the IPCC.


World Development Indicators (WDI)



After WWII, extensive data sets on all countries in the World-System became available from the World Bank (here). The indicators above where chose to construct the state space for each WDI-based model. Addition indicators can be added for specific forecasts and analyses.

Thursday, January 12, 2017

Is the Trump Rally a "Sugar High"?

Controversy has erupted between stock analyst Jim Cramer and economist Larry Summers over how to interpret the "Trump Rally," a surge in the stock market that started after Donald Trump won the November presidential election in the US. Jim Cramer has argued (here) that business conditions in the US are improving and, as long as that continues, the Trump Rally should continue. Larry Summers, on the other hand (here), has argued that post-election stock market surges (especially when right-wing candidates win) are driven by expectations of a bright new future that never materializes.

The Random Stock Walker finds these controversies interesting for what they reveal about how the stock market works and how irrational factors might drive stock performance. The graph above displays the attractor path for the S&P500 from 2014 through 2018 (red dashed line) and the 98% bootstrap prediction intervals (green and blue dashed lines). The actual path of the S&P 500 is displayed in black. The start of the "Trump Rally" is displayed as a solid vertical red line in November of 2016. The attractor path is the free-simulation of the S&P500 state space model starting in 1950, a path that is not influenced by the random fluctuations that have driven the stock market over the late 20th and early 21st Century. Some of those random fluctuations are on clear display starting in 2014. 

Conventional stock market technical analysis, however, boils down to drawing projection lines and confidence intervals based on optimistic predictions of future stock prices and short-run behavior of indexes. For example all through 2014, the market boom led analysts to make irrationally exuberant projections (solid arrow starting at the end of 2014) for the future. When the stock market failed to perform as expected, all of 2015 was viewed as a complete disappointment based on a long list of negative factors (China's slowdown, the Greek Debt Crisis, the weak EU Stimulus plan and broader anticipated slow downs in emerging markets). All these negative developments are quite beside the point: the market was in a bubble, well above the upper 98% bootstrap prediction interval until it finally returned to the attractor path, with a slight over-correction late in 2015. Performance was then within what might be expected from random fluctuations until the middle of 2016. 

Yes, there was a Trump Rally. Yes it could go on for a long time. No, it is not justified by better business conditions. The attractor path for the S&P500 is driven by the state of the US economy. It suggests that there will be another correction at some point in the future. Again, any correction will be attributed to random events in the world-system and may well have been triggered by such events. However, the short-run, straight-line optimistic predictions of stock analysts are wrong and have always been wrong. Optimist stock forecasts increase sales. Sales benefit analysts and their employers. They are not reliable predictions of the future.

If you are an investor, what should you do about the Trump Rally? First, you should not be buying based on the news. If you are looking at a stock that is driven by the S&P500, the Trump Rally is pushing it above it's attractor path. You are buying high and you can expect the stock to decline. If you are a trader, should you be selling? Yes, gradually. It's time to take profits and wait for the return to the attractor path when you can get back in again. If you are a long-term investor, wait it out. In all cases, you will need to estimate a state space model for your stock and plot the attractor path to know whether there is anything to consider in the Trump rally.

In future posts I'll look at individual stocks that have been mentioned in discussions of the Trump Rally. If you have any stocks you are interested in, let me know. We can take a quick look at the attractor paths.

Wednesday, December 7, 2016

$FB: Buy and Hold Forever?

Dec 7, 2016: Fox Business News just published (here) a very optimistic article on Facebook stock (FB) saying "..by nearly any measure...FB...has unlimited upside as the world transitions to digital." Glowing optimistic forecasts about technology stocks always interest the Random Stock Walker given their gee-whiz appeal, so lets run FB through our models.

The Random Stock Walker forecast through next year is displayed above (the black line is the stock price, the green dashed line is the upper 98% bootstrap prediction interval, the dashed red line is the attractor path, and the dashed blue line is the lower 98% bootstrap prediction interval). The attractor graph looks pretty good with small deviations around the attractor path (time to take earnings above the attractor path, time to buy below the attractor path). With the stock below the lower prediction interval right now, it would seem to be a good time to buy.
However, if we extend the forecast out to 2060, things do not look so good. The upside (upper 98% prediction interval) does indeed look great, but the downside (lower 98% prediction interval) is essentially zero. In other words, there is an equal chance that if you buy FB right now, at anytime in the future it could be worthless. One can invent any number of reason why this might happen but wide variability prediction intervals (high risk) is an essential feature of most tech stocks.

NOTE: One positive side of the FB state-space prediction model is that the stock price is being driven by growth in the world system. A negative side, as has been mentioned above, is that FB is a tech stock.