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.

Friday, October 19, 2012

Peak Oil Forecast and Global Warming

Peak Oil is the point where the rate of petroleum extraction starts declining because the resource is being exhausted.  US domestic Peak Oil production was reached in 1970. World oil production may have peaked in 2011, but it is too early to establish that as fact. In this post, I will forecast World oil production using the WL20 model to see whether the model thinks the World system has reached Peak Oil.

If you've "peaked" at the graphic above you probably can determine that the answer will be "Yes"! However, there's much more at stake here than the simple conclusion, however controversial, that we have reached Peak Oil.

After seeing my Global Warming forecast (here), one of my readers wondered whether anyone had combined Peak Oil models and Global Warming models. He reasoned, correctly, that the  WL20 model was capable of exploring the link between Peak Oil and Global Warming. This post will explore that relationship.

The underlying theoretical model linking Peak Oil and Global Warming is pretty simple: (Oil Production) -> (CO2 Emissions) -> (Global Warming). You might disagree with this linear causal model, but assume for the moment that it is correct. Then, anything that reduces oil production, like Peak Oil, will reduce Global Warming. My Global Warming forecast (here) shows Global temperature peaking sometime between 2040 and 2060. My Peak Oil Forecast above shows that oil production has reached its peak and is likely to collapse entirely around 2040. The result would seem to confirm the simple theoretical model, but how are these two forecasts related within the WL20 model?

The WL20 model model is a state-space model with three state variables (these state variables were not imposed on the model a priori but were the result of the statistical analysis): the first state variable measures overall growth in the World system; the second state variable measures declining biodiversity; and, the third state variable measures increasing resource constraints in the commodity markets related to the Ecological Footprint. The three state variables are interrelated: increasing biodiversity is related to declining global temperature while  increased resource extraction through commodity markets and overall economic growth are related to positive increases in global temperature.

The early peak in oil production is just one of a number of negative feedback loops within the model. The negative feedback loops limit overall growth in the World system around 2040 (see the WL20 state-variable forecast here). Global temperature takes a few more decades to peak after that, but it is really the end of overall growth, not just Peak Oil, that eventually limits global temperature growth, at least in the WL20 model.

There seem to be very few studies that have pursued the link between Peak Oil and Global Warming possibly because there are many alternative, high-carbon sources of energy (tar sands and synfuel from coal being two examples) that could be substituted for oil. Others, such as Amory Lovins (here) have argued that "Efficiency is cheaper than fuel" and will, for economic reasons, eventually limit emissions along with cheaper green energy. The WL20 model is capable of making projections of economic efficiency, a topic I will have to return to in a future post. The difficulty with the "substitution" argument is the important extent to which the entire World system is built on the oil economy. Even though we switched from a coal- to an oil-based economy in the 20th Century, it's not clear that the next energy conversion will be that easy given the larger scale of the present World system.

`
The prediction of Peak Oil was initially made by M. King Hubbert, a Shell geoscientist who died in 1989. The Hubbert curve or Hubbert peak for the World system is displayed above (from this source). His forecast, based on logistic curve modeling, predicted that the peak in World oil production would occur in the year 2000. It serves as a warning that no forecasting model can really see into the future. The models are simply attempts to explore the future implications of the data and models available when the forecast was made.

Thursday, October 18, 2012

Using the WL20 Package

The WL20 (W stands for World and L20 stands for Late 20th Century) package is an aggregate, state-space model of the World system. It contains 14 variables thought to be important to measuring the state of the World system, to include population growth, urbanization, commodity markets, carbon emissions, global temperature, biodiversity, globalization and the Ecological Footprint.

Unlike other World models, such as the DICE model, the Wonderland Model, or the System Dynamics World Models, WL20 was not derived from purely theoretical considerations. Rather, it was based on a 1979 paper by R. E. Kalman titled A system-theoretic critique of dynamic economic models. In the paper, Kalman argues that, until complex social systems are better understood, it is important to work from

data -> model

rather than from first-principle, theoretical considerations. In this approach, the primary emphasis is the selection of the data to describe the system followed by the use of state-space models to describe the dynamic behavior of the system. There is some theory used to make the selection of data that I have already discussed (here) and will discuss more fully in a future post. This post will concentrate on the computing details of the model.

The WL20 state-space model was estimated using the dse package (here) and the matlab package (here) in the public domain (it's free) R statistical language (here). Documentation, procedures and the WL20 model are available here.  They should be downloaded to a directory on your computer with the absolute path described by (see below). The remainder of this post describes how to use the WL20 model using the R statistical language.


When you start R on your computer, the R console window will display the version number, copyright information and platform. On my computer:

R version 2.14.2 (2012-02-29)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

A number of  commands that you might find useful will also be displayed



R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

To use the WL20 package,  the dse and matlab packages must also be installed (use the "Package Installer" menu choice and be sure to check the box marked "Install Dependencies" after you get the list of "CRAN (binaries)", you can then select matlab and dse and click "Install Selected"). You can then run R and enter the commands below in the R console window (the is the R prompt). 


W <- "a character string describing the working directory location"

> setwd(W)
> source("LibraryLoad.R")
> load(file="ws_procedures")

> load(file="WL20v3_model")
> WL20.est

The first two commands assign and set the working directory to the file folder where you have downloaded the WL20 package. For example, on my computer, is set to:

W <- "/Users/georgepa/Desktop/R/Papers/WL20 v3/"

The next command will source the dse and matlab packages (if you get error messages, these packages have not been installed properly). The two load commands load the ws (world system) procedures and the model (if you get error messages here, you have probably not specified properly). The final command displays the state-space model matrices for the WL20 model. These matrices are defined in the dse documentation that you can display with the following command:

help(SS)

Data for the WL20 model were gathered from a number of sources, but mostly from the Earth Policy Institute's Data Highlights (here). The complete list of the data sources is available in the documentation (Appendix F, here). You can look at the first few lines of the data set using the following commands:

> head(WL20.data)
          N   OIL  QA GWP P.Wheat. P.Oil.  TEMP   CO2 Carbon
[1,] 2555.0 10.42 631 7.4     1.89   1.71 13.83 311.3   1630
[2,] 2597.5 11.73 655 7.9     2.03   1.71 13.98 311.7   1767
[3,] 2641.2 12.34 680 8.3     1.93   1.92 14.04 312.2   1795
[4,] 2686.2 13.15 705 8.6     1.89   2.01 14.12 312.7   1841
[5,] 2732.5 13.74 730 8.9     1.98   2.11 13.91 313.2   1865
[6,] 2780.0 15.41 759 9.4     1.81   2.11 13.92 313.7   2043
     TotalFootprint    Earths WorldGlobal LivingPlanet    URBAN
[1,]       5.292910 0.4597521    23.37150     1.000000 705.4807
[2,]       5.493554 0.4797747    23.94942     1.002878 730.5622
[3,]       5.694199 0.4997972    24.52735     1.005581 756.4242
[4,]       5.894843 0.5198197    25.10527     1.007935 783.1143
[5,]       6.095488 0.5398423    25.68320     1.009766 810.6524
[6,]       6.296133 0.5598648    26.26112     1.010900 839.0286

The data set runs from 1950 to 2008, which you can verify with the following commands:

start(WL20.data)
[1] 1950    1
> end(WL20.data)
[1] 2008    1

There are commands in the dse package that you can use to evaluate this model. For example:

roots(WL20.est)
[1] 1.0000000+0.000000i 0.9982313+0.027957i 0.9982313-0.027957i
[4] 0.9140820+0.000000i
attr(,"class")
[1] "roots"

displays the eigenvalues of the system matrix. The first eigenvalue (1.0000000+0.000000i) is unity because the model includes a constant. The other eigenvalues are all less than unity and have imaginary parts indicating that the model is stable but cyclical.

You can also check the model fit using:

tfplot(WL20.est)

The results are displayed above. The dotted line displays the fitted values (one step ahead predictions) and the solid lines display the actual state variables.

The WL20 model has three state variables labelled W1, W2 and W3 in the graphic above. The state variables were constructed using Principal Components Analysis (PCA). The measurement model from the PCA is displayed with the following command:

> measurementModel(WL20.index)
               N        OIL          QA         GWP  P.Wheat.
[1,]  0.28446020  0.2711239  0.28207253  0.28243781 0.2362789
[2,] -0.01609311  0.2410390  0.09853503 -0.14131911 0.4113772
[3,] -0.11117409 -0.2412009 -0.08825703  0.02134276 0.4610974
         P.Oil.       TEMP         CO2      Carbon TotalFootprint
[1,] 0.24295530  0.2514421  0.28373276  0.28328608      0.2752374
[2,] 0.06595202 -0.2352280 -0.09832577  0.09252815      0.1816798
[3,] 0.71181845  0.1901141 -0.02009544 -0.09553557     -0.2925719
         Earths WorldGlobal LivingPlanet       URBAN
[1,]  0.2787654  0.28189899  -0.18387870  0.28400812
[2,]  0.1484351 -0.09256627   0.77050207 -0.08681005
[3,] -0.2311710 -0.09431697  -0.05760175 -0.07067596

The rows of this matrix display the weights used to calculate W1, W2 and W3. The weights were constructed from standard scores of the input data. The weight attached to each indicator variable for each state variable are displayed in the columns. By construction, the state variables are independent and uncorrelated.

The pattern of the weights indicated that W1 measures overall secular growth in the World system (this can also be seen from the time plot of W1 above). The second measure is most heavily weighted on the Living Planet Index (0.77050207)wheat prices (0.4113772)oil production (0.2410390) and the Ecological Footprint (number of Earths used by the World System, 0.1484351)The W2 state variable thus measures biodiversity. Finally, the W3 state variable is weighted most heavily on oil prices (0.71181845), wheat prices (0.4610974), Total Ecological Footprint (-0.2925719), and oil production (-0.2412009). The W3 state variable thus measures the effect of commodity markets and the Ecological Footprint.

> WL20.index$measurement$output$fraction.variance
 [1] 0.8740847 0.9413934 0.9725388 0.9864508 0.9949011 0.9980068
 [7] 0.9987371 0.9993400 0.9997902 0.9999405 0.9999802 0.9999923
[13] 0.9999986 1.0000000

Taken together, the World system state variables explain 97% of the variation in the underlying indicators.

One important use of the WL20 model is to forecast future states of the World system. The following commands create and display a 100 year forecast of the state variables:

> f <- forecast(WL20.est,horizon=100)
> tfplot(f)


The results of the forecast, displayed above, indicate that growth in the World system is expected to peak between 2040 and 2050 (W1)  associated with continuing losses of biodiversity (W2) and increasing pressure on commodity markets (W3). You can obtain the entire forecast to use as input to there times series models with the following command:

> fx <- merge.forecast(f)

The WL20 forecast and the time series are already available to you as data files named WL20.f and WL20.fx, respectively. 

I have already used forecasts from the WL20 model to predict global climate change and other indicators (here and here). In future posts, I will make the forecasting models models available as state-space models that can also be loaded into your R workspace and run on your machine.

TECHNICAL NOTE: In the Kalman article (here), emphasis is placed on the importance of observability and controllability in the selection of state space models. For the WL20, these two features can be checked with the following commands:

> observability(WL20.est)
[1] 2.5510918 2.2200285 1.8375940 0.6061376
> reachability(WL20.est)
Singular values of reachability matrix for noise:  2.424642 2.20612 1.628193 1.202821e-16 

The commands display the singular values of certain state-space matrices (use help for more information). If all the singular values are greater than zero, the model is both observable and controllable. The WL20 model is completely observable but might not be totally controllable (the 1.202821e-16 principal value is effectively zero). 

Thursday, January 12, 2012

US Real GDP Growth in 2012

The Financial Forecast Center (FFC here) produces a forecast for US nominal GDP. From the graphic above, FFC is expecting little growth in the first two quarters of 2012. FFC presents two confidence bands for each value. For example, in Jan 2012, FFC is forecasting nominal GDP at $15,333B. The 50% correct band would be +/- 112 while the 80% correct band would be +/- 225. The bands get bigger over time as expected but the GDP value stays at $15,433B through June of 2012, the end of the FFC forecast period.
I would prefer to forecast real GDP since it would not be clear for a nominal GDP forecast how much trends would be affected simply by prices (the GDP deflator). I would also rather forecast the attractor value since we are just coming out of the Subprime Mortgage Bubble and Collapse.

My attractor forecast for real GDP taken from the BEA (here) is presented in the graphic above. The bubble and collapse is clearly displayed. Currently we are at the lower 98% prediction interval for the attractor. This suggests that GDP will be drawn higher in 2012 (a return to the attractor value) unless other events (such as the EU sovereign debt crisis) continue to weight down the US economy (the mechanism of transmission here could be either a reduction in US exports to the EU or more financial contagion).


The FFC does produce a US Real GDP growth rate forecast (here and in the graphic above). The FFC is predicting a reduction in real GDP growth down to around 0.6% in the second quarter on 2012 (50% +/- 1.1% and 80% correct +/-2.4%).

My average annualized growth rate forecast for 2012 is 1.5% which is close to the FFC forecast of 1.6% for the first quarter of 2012. The FFC forecast of 0.5% growth in the second quarter of 2012 is possible but not that likely since the economy is not on its attractor value in the first quarter of 2010.

As a comparison, my mean annualized attractor growth rate for the period 2004-2007 was 1.6% while the actual mean annualized growth rate was 2.5%, 1 full point being attributable to the bubble.

NOTE: The attractor value results from a free simulation of GDPC96 starting in 1960 being driven by the state variables from the WL20 model. The WL20 model produces the best attractor as determined by the AIC criterion. A typical forecast predicts from year to year. The prior year contains shock and bubble values that bias the forecast.

Tuesday, December 20, 2011

Canada Backs Out of Kyoto

On Monday, December 12, as an NPR Marketplace piece documents, Canada pulled out of the Kyoto Protocol blaming the lack of participation of the US and China in the accord. Under the Kyoto Protocol, Canada pledged to reduce its CO2 emissions by 6% compared to 1990 levels. In 2011, Canada decided to move the goal post and seek a 17% reduction from 2005 levels by 2020 (read the history here).
Unfortunately, Canada is nowhere close to meeting either of these goals and appears on a future path of increased emissions as long as I would feel comfortable forecasting into the future (attractor forecast above, dashed red line with 98% prediction intervals).

What's interesting is that Canadian CO2 emissions are being driven predominantly by the North American regional system, that is, by the combined productive power of the US and Canada. What is also interesting is that while US emissions have a chance of stabilizing by 2040 (see my forecast here), Canada's emissions do not.

The Canadian government is basically accurate in the reasons given for pulling out of Kyoto. If US energy demand (and thus CO2 emissions) is ever reduced, Canada will just continue exporting whatever hydrocarbons it can produce to China, India or whomever needs oil. The export orientation of Canada's economy is probably the reason that CO2 emissions are unlikely either to be reduced through international protocols or technological change.

Monday, November 28, 2011

US CO2 Emission Reductions Unlikely as a Result of COP17

COP17 (17th Conference of the Parties to the UNFCCC) started today in Durban, South Africa and a salient topic of discussion was what will happen when the Kyoto Protocol 2012 Emission Targets expire next year. Of particular concern is what the US will do. The graphic above is an attractor forecast out to 2050 for US CO2 emissions. It's useful to discuss the forecast in terms of the Kyoto Protocol.

The Kyoto Protocol was initially adopted in December of 1997, went into force in February of 2005 and is scheduled to expire in 2012. The US Executive Branch ratified the protocol but it was never signed by the US Congress. Had the protocol been signed, it would have committed the US to a 7% GHG (Greenhouse Gas) reduction below 1990 emission levels.

In 1990, the US emitted 4992.3 million metric tons of CO2 according to the US EIA (here). In 2006, the US emitted 5981.6 million metric tons of CO2. Current emission levels are lower as a result of the 2007 Financial Crisis. According to the Earth Policy Institute (here):

Between 2007 and 2011, carbon emissions from coal use in the United States dropped 10 percent. During the same period, emissions from oil use dropped 11 percent. In contrast, carbon emissions from natural gas use increased by 6 percent. The net effect of these trends was that U.S. carbon emissions dropped 7 percent in four years. And this is only the beginning.

The initial fall in coal and oil use was triggered by the economic downturn, but now powerful new forces are reducing the use of both. For coal, the dominant force is the Beyond Coal campaign, an impressive national effort coordinated by the Sierra Club involving hundreds of local groups that oppose coal because of its effects on human health.

In other words, it is possible for the US to reduce emission levels by 7%. However, it's important to add that the reduction was the result of the worst financial crash since the Great Depression. My forecast, above, suggests that the probability of getting back to 1990 emission levels is effectively zero for the foreseeable future.

The best short-term forecast for US emissions can be made directly from a simple Impact Model, the type used by the IPCC to create global emission scenarios:

In the Impact model, CO2 emissions are simply a function of production levels, Q -> CO2. Just for round numbers, in 1990 about 1 million metric tons of CO2 were emitted for every 5 trillion dollars of US real GDP. US GDP went from a low of 12.8 trillion US$ in 2009 to about 13.2 trillion US$ in 2011. You can do the math (or look at my GDP forecast here).

The graph above constructs the attractor for US CO2 emissions from the state of the US economy, not just GDP. The results show emissions increasing until at least 2030 before reductions become probable (the dashed lines are the 98% bootstrap confidence intervals). Getting back to 1990 levels are really unlikely for the foreseeable future.

The relationship between CO2 emissions and US GDP should be plain to see from eye balling the historical data. GDP fell during the Financial Crisis and CO2 emissions fell (from the attractor model, you can see that emissions were above their attractor during the bubble). I think US policy makers are keenly aware of this relationship. And, for that reason alone, there is no chance that the US Congress will ever ratify an international protocol limiting GHG emissions. It would mean effectively limiting GDP growth.

In the IPCC scenarios (here) and in the underlying scientific literature, it is typically assumed that reductions will result from technological change (reductions in emission intensity). That issue will have to be dealt with in a later post. The current problems developing a US Solar energy policy (here) suggests to me, at least, that "We Cannot 'Techno-Fix' Our Way to a Sustainable Future."

Friday, November 4, 2011

US Unemployment 2012 and Beyond


Today the US Labor department released the October unemployment rate and it fell from 9.1 to 9 percent (here). President Barack Obama said the improvement was "positive" but that the economy is still growing way too slowly. His hope, of course, is that the unemployment rate will continue dropping right up to the 2012 election.

If President Obama is looking at some readily available forecasts, however, he must be anxious. The Financial Forecast Center (FFC) is forecasting (here) a huge increase in US unemployment for next year (graphic above).
My own forecast (above) shows unemployment stabilizing around 9% for the rest of 2011. Also of interest is that my forecasting model shows that US unemployment is primarily being driven by the world economy and world commodity markets (particularly the price of oil). The FFC forecasts are based on artificial intelligence techniques (here) which do not have an underlying causal model, so it's not entirely clear why they are forecasting such a large increase in unemployment next year. It will be interesting to revisit these forecasts before the 2012 election.

The FFC long-range forecasts (available by subscription) are only made out to 36 months. Commentators are concerned that the US is in for a "New Jobless Era". Jobs have been permanently lost to technology and globalization. The 2000 Financial Crisis swept away all the jobs created by the housing bubble. The jobs created by the bubble may simply never return.
To look at the real long-range, out to 2050, my model predicts an increase in US unemployment that is in line with the FFC forecast, anything from just over 9% to well above 11%. My guess is that the FFC artificial intelligence model is "seeing" the trend happen a little too quickly give the severity of the financial collapse.

We should also keep in mind that the BLS unemployment data is thought to be biased downward (here). Actual unemployment may be above 18% when considering underemployment and discouraged job seekers.

Wednesday, November 2, 2011

World Impact Forecasts

In the 3F blog, I have been primarily using state space models to make macro forecasts for the world system and countries within that system. The approach is a dynamic realization of ImPACT models developed by the Human Environment Program at Rockefeller University (here) in an article by Waggoner and Ausubel (2002). ImPACT models include the Kaya Identity used by the IPCC and the EIA and the I=PAT identity used for studying population growth impacts (here). Included in the class of ImPACT models is the neoclassical economic growth model (see note below) which has been used by William Nordhaus and Resources for the Future (here) to make climate change forecasts.

Whether or not state space models provide better forecasts than ImPACT models is an open question. The advantage of ImPACT models is that they can be calculated by hand. The disadvantage is that, as explained below, ImPACT models do not include feedback effects.


The directed graph above describes the causality underlying ImPACT models. Under long-run, full employment conditions, population growth (N) leads to greater aggregate production (Q)--more people mean more workers and, as long as the workers are fully employed, more workers mean more output and more demand. Output creates greater energy consumption (E). Energy consumption leads to greater CO2 emissions. And finally, great CO2 emissions leader to increases in global temperature (T).

The extent of these changes depends on the values of the lower case letters, called coefficients or intensive variables (the upper case letters are the extensive variables). In equation form:

T = N*(Q/N)*(E/Q)*(CO2/E)*(T/E) = N*q*e*c*t

where T is global temperature, N is global population, Q is world GDP, E is primary energy consumption, CO2 is global CO2 emissions, q = Q/N per-capita output, e = E/Q energy intensity of production, c = CO2/E carbon intensity of energy and t = T/CO2 is the climate sensitivity to radiative forcing.

The ImPACT formulation is very general. For example, if you think that CO2 emissions have no impact on global temperature, you can set t=0. In other words, if you can provide values for [N,q,e,c,t] then you can make global climate change forecasts using a hand calculator.

There are two problems with such forecasts: (1) you need to come up with reasonable values for population growth and for the other intensive variables (discussed below) and (2) you have to assume that there are no system feedbacks (for example from environmental degradation to population growth or to agricultural production). Said another way, will the intensive variables change over time?

Discussions of energy emissions or global temperature change all seem to rely on the assumption that population growth, energy intensity, and emissions intensity will all decrease over time and decrease enough to make up for increases in per capita GDP (improving standards of living). Generally, the climate sensitivity parameter is assumed to be constant.

Coming up with values for intensive variables in ImPACT models is thus yet another forecasting problem. Below I provide business-as-usual (BAU) forecast for each intensive variable using the WL20 model (data definitions are available in Appendix F). World population forecasts from the United Nations can be found here.
The BAU forecast for real per capita GWP (Gross World Product) is displayed above. Values in 2100 (the usual end-point of long-run forecasts) range anywhere from about 0.02 to 0.09 with a mid-range value of about 0.05 - 0.06.
The BAU forecast for energy intensity in millions of tons of oil equivalent is more difficult to forecast. Energy intensity will not go to zero as predicted by the model so values between 50 and 150 for e = E/Q would seem reasonable.
The BAU forecast for emission intensity (atmospheric CO2 concentrations in ppmv) is displayed above. Values seem to be stabilizing around 0.05.
Finally, BAU forecasts for climate sensitivity (degrees C) provide another surprise. Rather than being a constant as assumed by the IPCC, there would appear to be an observable time trend where climate sensitivity is decreasing. The decrease over time is possibly the result of feedback mechanisms. It is certainly not zero as assumed by global warming skeptics.

The observed trends in energy intensity and climate sensitivity might suggest that using ImPACT models to make long-run projections is an uncertain business. Since imPACT models are identities (true by definition), my suggestion would be to use ImPACT models to make the following types of assertions: (1) if other things remain equal, an increase in population growth would have the following impacts on production, carbon emissions and global temperature or (2) changes in intensive variables necessary to limit global warming to 2 degrees C would involve limiting per capita income growth or reducing energy intensity or decreasing carbon intensity.


NOTE: Neoclassical Economic Growth Models are a form of ImPACT model, which can be demonstrated using directed graphs.


In the standard neoclassical growth model, full employment and growth in autonomous technical change (A) drive growth in output. The Capital Stock, K, is an endogenous variable based on saving from output, K(t) = K(t-w) + ( sQ - d K ) where d is depreciation and s is saving.
Using graph theoretic rules, endogenous variables can be eliminated from the model. Technological change can also be endogenized assuming learning by doing. These two assumptions result in the graph above.

The neoclassical growth model is thus equivalent (nonparametrically) to a dynamic version of the ImPACT model displayed in the graph above.