Todays graph will be highlighting how much this recession has impacted unemployment in Detroit versus the recessions of 2001 and 1990. As you can see unemployment has risen and remains unholy.
Detroit has been hit particularly hard due to the already struggling automotive industry, so the recession just brought about more reasons of layoffs. The last four unemployment numbers have been very positive however.
Keep dancin'
Steven J.
Wednesday, January 4, 2012
Tuesday, January 3, 2012
Graphical Representations of Recessionary Woes: ISM PMI
Today, The Institute of Suppy Management Purchasing Managers Index was released. As you can see from the graph, we are finally above the average PMI for 27 quarters after a recession begins. Thats something to be cheery about.
Overall though the number aren't that spectacular and remain, well, average. The readings for todays release are clearly above 50 which means more managers plan on expanding their operations versus contracting them. Overall this number casts good news over the U.S. sput sputtering economy.
Please Keep Dancin'
Steven J.
Overall though the number aren't that spectacular and remain, well, average. The readings for todays release are clearly above 50 which means more managers plan on expanding their operations versus contracting them. Overall this number casts good news over the U.S. sput sputtering economy.
Please Keep Dancin'
Steven J.
Graphical Representations of Recessionary Woes: Oil Prices
Today on the Dancing Economist we will exploit a graphical tool in FRED that allows us to benchmark movements in an time-series with their historical recessionary past. Todays graph is one of the West Texas Intermediate Spot Oil Price.
Notice how in the past recessionary oil prices didn't get as high as they historically have gotten and that they have also fallen more and rebounded with less vigor than the usual. In fact as the above graph shows, they are lower now than any point in time after any previous recession. The recessionary periods I have chosen to include in the min and max calculations are all but the 1973 one as the artificial price ceiling employed then distorts the numbers. Keep dancin' and I'll keep posting,
Steven J.
Notice how in the past recessionary oil prices didn't get as high as they historically have gotten and that they have also fallen more and rebounded with less vigor than the usual. In fact as the above graph shows, they are lower now than any point in time after any previous recession. The recessionary periods I have chosen to include in the min and max calculations are all but the 1973 one as the artificial price ceiling employed then distorts the numbers. Keep dancin' and I'll keep posting,
Steven J.
Labels:
Commodities,
FRED,
Oil Prices,
West Texas Intermediate
Monday, January 2, 2012
Monetary Policy & Credit Easing pt. 8: Econometrics Tests in R
Hello, folks its time to cover some important econometrics tests you can do in R.
The Akaike information criterion is a measure of the relative goodness of fit of a statistical model. If you have 10 models and order them by AIC, the one with the smallest AIC is your best model, ceterus paribus.
The following code can figure the AIC and a similar version called BIC:
> AIC(srp1.gls)
[1] 100.7905
> BIC(srp1.gls)
[1] 140.7421
Say we wish to see if our model has an error term that follows a relatively normal distribution. For this we can perform the Jarque-Bera which tests kurtosis as well as skewness. This function requires that you load the FitAR package.
> JarqueBeraTest(srp1.gls$res[-(1)])
$LM
[1] 19.2033
$pvalue
[1] 6.761719e-05
To see if the mean of the residual values is 0 and to see the standard deviation the following code works:
> mean(srp1.gls$res[-(1)])
[1] 0.003354243
> sd(srp1.gls$res[-(1)])
[1] 0.3666269
Other tests like the Breusch-Pagan and Goldfeld-Quandt provide facts like wether autocorrelation is present and give us a hint as to wether our residual variance is stable or not. In order for these to work you have to load the lmtest package. Also you can only run these for the lm objects or for your Ordinary Least Squares Regressions for any Generalized Least Squares regressions you'll have to perform these test manually, and if you know of an easier or softer way please share.
> bptest(srp1.lm)
studentized Breusch-Pagan test
data: srp1.lm
BP = 48.495, df = 12, p-value = 2.563e-06
> gqtest(srp1.lm)
Goldfeld-Quandt test
data: srp1.lm
GQ = 0.1998, df1 = 40, df2 = 40, p-value = 1
You can also use the Durbin-Watson to test for first order autocorrelation:
> dwtest(srp1.lm)
Durbin-Watson test
data: srp1.lm
DW = 1.4862, p-value = 0.0001955
alternative hypothesis: true autocorrelation is greater than 0
Wish to get confidence intervals for your parameter estimates? Then use the confint() function as shown below for the Generalized Least Squares regression on long-term risk premia from 2001-2011.
I hope this mini-series has been informative to all that tuned in. For more info on anything you see here please don't be shy to comment and keep dancin',
Steven J.
The Akaike information criterion is a measure of the relative goodness of fit of a statistical model. If you have 10 models and order them by AIC, the one with the smallest AIC is your best model, ceterus paribus.
The following code can figure the AIC and a similar version called BIC:
> AIC(srp1.gls)
[1] 100.7905
> BIC(srp1.gls)
[1] 140.7421
Say we wish to see if our model has an error term that follows a relatively normal distribution. For this we can perform the Jarque-Bera which tests kurtosis as well as skewness. This function requires that you load the FitAR package.
> JarqueBeraTest(srp1.gls$res[-(1)])
$LM
[1] 19.2033
$pvalue
[1] 6.761719e-05
To see if the mean of the residual values is 0 and to see the standard deviation the following code works:
> mean(srp1.gls$res[-(1)])
[1] 0.003354243
> sd(srp1.gls$res[-(1)])
[1] 0.3666269
Other tests like the Breusch-Pagan and Goldfeld-Quandt provide facts like wether autocorrelation is present and give us a hint as to wether our residual variance is stable or not. In order for these to work you have to load the lmtest package. Also you can only run these for the lm objects or for your Ordinary Least Squares Regressions for any Generalized Least Squares regressions you'll have to perform these test manually, and if you know of an easier or softer way please share.
> bptest(srp1.lm)
studentized Breusch-Pagan test
data: srp1.lm
BP = 48.495, df = 12, p-value = 2.563e-06
> gqtest(srp1.lm)
Goldfeld-Quandt test
data: srp1.lm
GQ = 0.1998, df1 = 40, df2 = 40, p-value = 1
You can also use the Durbin-Watson to test for first order autocorrelation:
> dwtest(srp1.lm)
Durbin-Watson test
data: srp1.lm
DW = 1.4862, p-value = 0.0001955
alternative hypothesis: true autocorrelation is greater than 0
Wish to get confidence intervals for your parameter estimates? Then use the confint() function as shown below for the Generalized Least Squares regression on long-term risk premia from 2001-2011.
> confint(p2lrp.gls)
2.5 % 97.5 %
yc -0.1455727340 0.1498852728
default 0.2994818014 1.0640354237
Volatility 0.0336077958 0.0617798767
CorporateProfit -0.0010916473 0.0006628209
FF -0.1788624533 0.0931406285
ER 0.0001539035 0.0016060804
Fedmbs -0.0061554994 0.0085638593
Support -0.1499342096 0.1615652273
FedComm -0.0108567077 0.0750407328
FedGdp -0.1347070955 0.2528217710
ForeignDebt -0.0441198164 0.1042805549
govcredit 0.1090847204 0.6796839003
FedBalance -2.0940925835 0.0370114069
UGAP -0.4821566147 0.3188891550
OGAP -0.2239749029 0.1073611677
Another nice feature is finding the log-likelihood of your estimation:
> logLik(lrp2.lm)
'log Lik.' 23.05106 (df=17)
Want to see if you have a unit-root in your residual values? Then perform the augmented Dickey-Fuller. For this you'll have to load the 'tseries' package.
> adf.test(lrp2.gls$res[-(1:4)])
Augmented Dickey-Fuller Test
data: lrp2.gls$res[-(1:4)]
Dickey-Fuller = -7.4503, Lag order = 3, p-value = 0.01
alternative hypothesis: stationary
Warning message:
In adf.test(lrp2.gls$res[-(1:4)]) : p-value smaller than printed p-value
> adf.test(lrp2.lm$res) I hope this mini-series has been informative to all that tuned in. For more info on anything you see here please don't be shy to comment and keep dancin',
Steven J.
Sunday, January 1, 2012
Monetary Policy & Credit Easing pt. 7: R Econometrics Tests
In post 6 we introduced some econometrics code that will help those working with time-series to gain asymptoticly efficient results. In this post we look at the different commands and libraries necessary for testing our assumptions and such.
Testing our Assumptions and Meeting the Gauss-Markov Theorem
In this section we will seek to test and verify the assumptions of the simple linear regression model. These assumptions are laid out as follows and are extracted from Hill, Griffiths and Lim 2008:
SR1. The value of y, for each value of x, is
y= ß_{1}+ß_{2}x+µ
SR2. The expected value of the random error µ is
E(µ)=0
which is equivalent to assuming
E(y)= ß_{1}+ß_{2}x
SR3. The variance of the random error µ is
var(µ)=sigma^2 = var(y)
The random variables y and µ have the same variance because they differ only by a constant.
SR4. The covariance between any pair of random errors µ_{i} and µ_{j} is
cov(µ_{i}, µ_{j})=cov(y_{i},y_{j})=0
SR5. The variable x is not random and must take at least two different values.
SR6. The values of µ are normally distributed about their mean
µ ~ N(0, sigma^2)
if the y values are normally distributed and vice-versa
Central to this topics objective is meeting the conditions set forth by the Gauss-Markov Theorem. The Gauss-Markov Theorem states that if the error term is stationary and has no serial correlation, then the OLS parameter estimate is the Best Linear Unbiased Estimate or BLUE, which implies that all other linear unbiased estimates will have a larger variance. An estimator that has the smallest possible variance is called an "efficient" estimator. In essence, the Gauss-Markov theorem states that the error term must have no structure; the residual levels must exhibit no trend and the variance must be constant through time.
When the error term in the regression does not satisfy the assumptions set forth by Gauss-Markov, OLS is still unbiased, but fails to be BLUE as it fails to give the most efficient parameter estimates. In this scenario, a strategy which transforms the regressions variables so that the error has no structure is in order. In time-series analysis, the problem of autocorrelation between the residual values is a common one. There are several ways to approach the transformations necessary to ensure BLUE estimates, and the previous post used the following method to gain asymptotic efficiency and improve our estimates:
1. Estimate the OLS regression
2. Fit OLS residual to an AR(p) process using the Yule-Walker Method and find the value of p.
3. Re-estimate model using Generalized Least Squares fit by Maximum Likelihood estimation, using the estimated p from 2, as the order for your correlation residual term.
4. Fit the GLS estimated residuals to an AR(p) process and use the estimated p's as the final parameter estimates for the error term.
What have we done? First we have to find out what the error term autocorrelation process is. What order is p? In order to find this out we fit the OLS residuals to an AR(p) using the Yule-Walker method. Then we take the order p of our estimated error term and run a GLS regression with an AR(p) error term. This will give us better estimates for our model. Research has shown that GLS estimators are asymptotically more efficient than OLS estimates almost one-hundred percent of the time. If you notice in every single regression, the GLS estimator with a twice iterated AR(p) error terms consistently results in a lower standard deviation of the residual value. Therefore the model has gained efficiency which translates into improved confidence intervals. Additionally, by fitting the GLS residuals to an AR(p) we remove any autocorrelation(or structure) that may have been present in the residual.
Testing For Model Miss-specification and Omitted Variable Bias
The Ramsey RESET test (Regression Specification Error Test) is designed to detect omitted variable bias and incorrect functional form. Rejection of H_{0} implies that the original model is inadequate and can be improved. A failure to reject H_{0} conveys that the test has not been able to detect any miss-specification.
Unfortunately our models of short-term risk premia over both estimation periods reject the null hypothesis, and thus suggest that a better model is out there somewhere. Correcting for this functional miss-specification or omitted variable bias will not be pursued here, but we must keep in mind that our model can be improved upon and is thus not BLUE.
In R you can run the Ramsey Reset test for standard lm functions using the library lmtest:
>library(lmtest)
> resettest(srp1.lm)
RESET test
data: srp1.lm
RESET = 9.7397, df1 = 2, df2 = 91, p-value = 0.0001469
For GLS objects however you'll need to do it manually and that procedure will not be outline here. Although if you really want to know please feel free to email or leave a comment below.
Addressing Multicollinearity
In the original formulation of the model there existed an independent variable called CreditMarketSupport, that was very similar to our FedBalance variable. Both variables are percentages and shared the same numerator while also having very similar denominators. As a result we had suffered from a condition called exact collinearity as the correlation between these two variables was nearly one.
> cor(FedBalance1,CreditMarketSupport1)
0.9994248
With exact collinearity we were unable to obtain a least squares estimate of our ß coefficients and these variables were behaving opposite of what we were expecting. This violated one of our least squares assumptions SR5 which states that values of x_{ik} are not exact linear functions of the other explanatory variables. To remedy this problem, we removed CreditMarketSupport from the models and we are able to achieve BLUE estimates.
Suspected Endogeniety
In our estimation of long-term risk premia over the first time period we suspect endogeniety in the cyclical variable Output Gap. In order to remedy this situation we replace it with an instrumental variable - the percentage change in S&P 500 and perform the Hausman Test which is laid out as follows:
H_{0}: delta = 0 (no correlation between x_{i} and µ_{i})
H_{1}: delta ≠ 0 (correlation between x_{i} and µ_{i})
When we perform the Hausman Test using S&P 500 as our instrumental variable our delta ≠ 0 and is statistically significant. This means that our Output Gap variable is indeed endogenous and correlated with the residual term. If you want to learn more about the Hausman Test and how to perform it in R please leave a comment or email me and i'll make sure to get the code over to you. When we perform the Two Stage Least Squares Regression to correct for this not a single term is significant. This can be reasonably be attributed to the problem of weak instruments. The 2 Stage Least Squares Estimation is provided below. Since, the percentage change in the S&P500 was only correlated with the Output Gap 0.110954, there is strong reason to suspect that weak instruments are the source of the problem. We will choose to not locate a proper instrumental variable to emulate the Output Gap, instead we will keep in mind that we have an endogenous variable when interpreting our coefficient estimates which will now end up being slightly biased.
Below is how to perform a two-stage least squares regression in R when your replacing an endogenous variable with an exogenous one. First you'll need to load the library sem into R. In the below regression the first part includes all the variables from the original model and the second part lists all of our exogenous and instrumental variables which in this case is just the percentage change in the S&P 500.
> tSLRP1<-tsls(lrp1~yc1+CP1+FF1+default1+Support1+ER1+FedGDP1+FedBalance1+govcredit1+ForeignDebt1+UGAP1+OGAP1,~ yc1+CP1+FF1+default1+Support1+ER1+FedGDP1+FedBalance1+govcredit1+ForeignDebt1+sp500ch+OGAP1 )
> summary(tSLRP1)
2SLS Estimates
Model Formula: lrp1 ~ yc1 + CP1 + FF1 + default1 + Support1 + ER1 + FedGDP1 +
FedBalance1 + govcredit1 + ForeignDebt1 + UGAP1 + OGAP1
Instruments: ~yc1 + CP1 + FF1 + default1 + Support1 + ER1 + FedGDP1 + FedBalance1 +
govcredit1 + ForeignDebt1 + sp500ch + OGAP1
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-9.030 -1.870 0.021 0.000 2.230 7.310
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.28137 44.06906 -0.11984 0.9049
yc1 -1.48564 10.60827 -0.14005 0.8889
CP1 -0.01584 0.09206 -0.17204 0.8638
FF1 0.20998 2.43849 0.08611 0.9316
default1 -7.16622 65.35728 -0.10965 0.9129
Support1 6.39893 47.72244 0.13409 0.8936
ER1 4.56290 35.91837 0.12704 0.8992
FedGDP1 1.86392 9.16081 0.20347 0.8392
FedBalance1 0.73087 12.96474 0.05637 0.9552
govcredit1 0.17051 0.89452 0.19062 0.8492
ForeignDebt1 -0.22396 1.41749 -0.15799 0.8748
UGAP1 4.55897 35.33446 0.12902 0.8976
OGAP1 0.01331 0.09347 0.14235 0.8871
Residual standard error: 3.3664 on 93 degrees of freedom
Notice that our model now doesn't have any significant terms. This is why we will choose to ignore the endogeniety of our Output Gap and probably Unemployment Gap variables. Correcting for endogeniety does more harm than good in this case.
Results and Concluding Thoughts
As this paper hopefully shows, the Feds actions did directly impact the easing of broader credit conditions in the financial markets.
Over our first estimation period from 1971 to 1997 we find that the Fed's support of Depository Institutions as a percentage of savings and time deposits is positively related to the short-term risk premia. Specifically we find that a 1 percentage point increase in Support leads to a 2.1 percent increase in short-term risk premia. This was as expected because Depository Institutions would only borrow from the Fed if no other options existed. We also find that a 1 percentage point increase in the federal funds rate leads to a .19 percentage increase in short-term risk premia. This is consistent with our original hypothesis as an increased FF puts positive pressure on short-term rates like the 3 month commercial paper rate, thus resulting in an widened spread. With respect to long-term risk premia, we find that a 1 percentage point increase in FF leads the long-term risk premia to decrease by .66 percentage points and a 1 percent increase in the federal funds rate leads to a .07 decrease in the long-term risk premia.
Over our second estimation period the composition of the Feds balance sheet is considered. We see that the CCLF did decrease short-term risk premiums, with every one percent increase translating to a decrease in short-term risk premia by .1145 percentage points. Another important result is that Fed purchases of Agency Debt and Agency MBS did have a significant, although almost negligible effect on short-term risk premia. One surprising result with the estimation of the long-term risk premia is that our Fed balance sheet size variable has a sign that is opposite of what we expected and its significance is particularly surprising. This may be expected since this period is largely characterized by both a shrinking balance sheet and narrowing risk premia as investments were considered relatively safe. However towards the end of the period risk premiums shot up and only after did the size of the balance sheet also increase, thus the sample period may place too much weight towards the beginning of the time period and not enough towards the end. This is a reasonable assumption given that our estimate of the balance sheet size showed a large negative impact on risk premia over our longer estimation period.
Please people keep dancing and we'll delve further into some additional econometrics tests next week.
Labels:
Federal Reserve,
Gauss Markov,
Monetary Policy,
R,
Risk Premiums
Friday, December 30, 2011
Monetary Policy and Credit Easing pt. 6: Empirical Estimation and Methodology
IT is now appropriate to lay out our two regression models in full for empirical estimation over our two separate time periods. The first estimation is from 4/1/71 to 7/1/97 and the second is from 4/1/01 to 4/1/11. The methodology employed in the estimation of these two models is a procedure using Generalized Least Squares with a Cochrane-Orcutt, style iterated residual value. For those that wish to perform the same regressions at home I have provided the following links to my data. This is for the estimation period from 1971 to 1997 and this one is for the 2001 to 2011 estimations. The following four steps were taken for each estimation:
1. Estimate the OLS regression
2. Fit OLS residual to an AR(p) process using the Yule-Walker Method and find the value of p.
3. Re-estimate model using Generalized Least Squares fit by Maximum Likelihood estimation, using the estimated p from 2, as the order for your correlation residual term.
4. Fit the GLS estimated residuals to an AR(p) process using the Yule-Walker Method and use the estimated p's as the final parameter estimates for the error term.
The end goal of the above procedure is to have our models be asymptotically BLUE or the Best Linear Unbiased Estimators. The implies that they have the smallest variance out of all the models that meet the rest of the Gauss-Markov assumptions. A little background behind the methodology is in order. First we will perform the standard Ordinary Least Squares (OLS) regression on our dependent variables. This will give us at the very least unbiased estimators. Second we take the residuals from the first step and fit them to an AR(p) process as selected by the Yule-Walker Method. This method selects the optimal lag that characterizes the autocorrelation in the residuals. We automatically take this step, due to the well known fact that most time-series suffer from autocorrelation problems as verified by our correlograms. Then we re-estimate the regression using Generalized Least Squares which adjusts each term and divides them by their individual variances, while also incorporating the AR(p) lag that we discovered during the previous step. The final step, which fits our GLS models residuals to an AR(p) process is what leads to our asymptoticly efficient results. We lay out our first estimation period models below.
First Estimation: 4/1/71 to 7/1/97
1. Monetary Policies Impact On Short-term Risk Premiums
Our first model which seeks to answer how monetary policy impacts the risk premia on short-term commercial paper as estimated over our first time period 4/1/71 to 7/1/97 is as follows:
SR^{premium}_{t}=ß_{0}+ß_{1}*FedBalance^{size}_{t}+ß_{2}*Support_{t} + ß_{3}*UGAP_{t}+ ß_{4}*FF_{t}+ ß_{5}*ER_{t}+ ß_{6}*YC_{t}+ ß_{7}*Default^{spread}_{t}+ ß_{8}*CP_{t}+ ß_{9}*OGAP_{t} + ß_{10}*FedGDP_{t}+ ß_{11}*govcredit_{t}+ ß_{12}*ForeignDebt_{t} + µ_{t}
Where,
SR^{premium}_{t} = Short-term Risk Premium at time, t
Support_{t}= Fed's funds at depository institutions as a percentage of their main financing streams at time, t
FedBalance^{size}_{t}= The Fed's credit market asset holdings as percentage of the total credit market assets at time, t
FF_{t}= Federal Funds rate at time, t
ER_{t}= Excess Reserves of Depository Institutions at time, t
YC_{t}= Yield curve at time, t
Default^{spread}_{t}= Default Spread between BAA_{t} & AAA_{t} rated bonds at time, t
CP_{t} = Corporate Profits After Tax at time, t
FedGDP_{t}= Fed's holdings of total public debt as a percentage of GDP at time, t
govcredit_{t}= Government Holdings Of Domestic Credit Market Debt As A Percentage Of The Total at time, t
ForeignDebt_{t}= Foreign Holdings of Federal Debt As A Percentage Of The Total at time, t
UGAP_{t} = Unemployment gap at time, t
OGAP_{t} = Output gap at time, t
µ_{t}= error term at time, t
1. Estimate the OLS regression
2. Fit OLS residual to an AR(p) process using the Yule-Walker Method and find the value of p.
3. Re-estimate model using Generalized Least Squares fit by Maximum Likelihood estimation, using the estimated p from 2, as the order for your correlation residual term.
4. Fit the GLS estimated residuals to an AR(p) process using the Yule-Walker Method and use the estimated p's as the final parameter estimates for the error term.
The end goal of the above procedure is to have our models be asymptotically BLUE or the Best Linear Unbiased Estimators. The implies that they have the smallest variance out of all the models that meet the rest of the Gauss-Markov assumptions. A little background behind the methodology is in order. First we will perform the standard Ordinary Least Squares (OLS) regression on our dependent variables. This will give us at the very least unbiased estimators. Second we take the residuals from the first step and fit them to an AR(p) process as selected by the Yule-Walker Method. This method selects the optimal lag that characterizes the autocorrelation in the residuals. We automatically take this step, due to the well known fact that most time-series suffer from autocorrelation problems as verified by our correlograms. Then we re-estimate the regression using Generalized Least Squares which adjusts each term and divides them by their individual variances, while also incorporating the AR(p) lag that we discovered during the previous step. The final step, which fits our GLS models residuals to an AR(p) process is what leads to our asymptoticly efficient results. We lay out our first estimation period models below.
First Estimation: 4/1/71 to 7/1/97
1. Monetary Policies Impact On Short-term Risk Premiums
Our first model which seeks to answer how monetary policy impacts the risk premia on short-term commercial paper as estimated over our first time period 4/1/71 to 7/1/97 is as follows:
SR^{premium}_{t}=ß_{0}+ß_{1}*FedBalance^{size}_{t}+ß_{2}*Support_{t} + ß_{3}*UGAP_{t}+ ß_{4}*FF_{t}+ ß_{5}*ER_{t}+ ß_{6}*YC_{t}+ ß_{7}*Default^{spread}_{t}+ ß_{8}*CP_{t}+ ß_{9}*OGAP_{t} + ß_{10}*FedGDP_{t}+ ß_{11}*govcredit_{t}+ ß_{12}*ForeignDebt_{t} + µ_{t}
Where,
SR^{premium}_{t} = Short-term Risk Premium at time, t
Support_{t}= Fed's funds at depository institutions as a percentage of their main financing streams at time, t
FedBalance^{size}_{t}= The Fed's credit market asset holdings as percentage of the total credit market assets at time, t
FF_{t}= Federal Funds rate at time, t
ER_{t}= Excess Reserves of Depository Institutions at time, t
YC_{t}= Yield curve at time, t
Default^{spread}_{t}= Default Spread between BAA_{t} & AAA_{t} rated bonds at time, t
CP_{t} = Corporate Profits After Tax at time, t
FedGDP_{t}= Fed's holdings of total public debt as a percentage of GDP at time, t
govcredit_{t}= Government Holdings Of Domestic Credit Market Debt As A Percentage Of The Total at time, t
ForeignDebt_{t}= Foreign Holdings of Federal Debt As A Percentage Of The Total at time, t
UGAP_{t} = Unemployment gap at time, t
OGAP_{t} = Output gap at time, t
µ_{t}= error term at time, t
R DATA WORK
So now it is time for the long awaited econometrics work in R. First thing you'll want to do is read the data into R from your data file which is in this case is the Earlreg file.
> earl<- read.csv("/Users/stevensabol/Desktop/R/earlreg.csv",header = TRUE, sep = ",")
Then you define your variable names so you can easily manipulate your data in R. So when you open the official .csv data file take a look at the variable names and rename them using the following procedure.
>yc1<-earl[,"yc"]
After you define what you call everything you're then free to go crazy and run regressions. Below is how you run the standard Ordinary Least Squares regression. The lm function enables you to run linear regressions:
1. Estimate the OLS regression
>srp1.lm=lm(srp1~yc1+CP1+FF1+default1+Support1+ER1+FedGDP1+FedBalance1+govcredit1+ForeignDebt1+UGAP1+OGAP1)
In order to get the output you have to use the summary function:
> summary(srp1.lm)
Call:
lm(formula = srp1 ~ yc1 + CP1 + FF1 + default1 + Support1 + ER1 +
FedGDP1 + FedBalance1 + govcredit1 + ForeignDebt1 + UGAP1 +
OGAP1)
Residuals:
Min 1Q Median 3Q Max
-1.04289 -0.20145 -0.04041 0.15230 1.21044
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.7591194 1.0359966 -2.663 0.00912 **
yc1 0.1320996 0.0580500 2.276 0.02516 *
CP1 -0.0022773 0.0073773 -0.309 0.75825
FF1 0.1699788 0.0340654 4.990 2.81e-06 ***
default1 0.4382965 0.1876685 2.335 0.02167 *
Support1 2.2383850 0.6660140 3.361 0.00113 **
ER1 0.3351508 0.3017644 1.111 0.26959
FedGDP1 0.3031938 0.2558144 1.185 0.23895
FedBalance1 0.4014920 0.3477547 1.155 0.25124
govcredit1 -0.0928817 0.0401603 -2.313 0.02294 *
ForeignDebt1 -0.0068900 0.0215393 -0.320 0.74977
UGAP1 -0.0912273 0.0520491 -1.753 0.08295 .
OGAP1 0.0006669 0.0014895 0.448 0.65536
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3789 on 93 degrees of freedom
Multiple R-squared: 0.6474, Adjusted R-squared: 0.6019
F-statistic: 14.23 on 12 and 93 DF, p-value: 2.642e-16
Next we perform step 2 which is:
2. Fit OLS residual to an AR(p) process using the Yule-Walker Method and find the value of p.
> srp.lmfit<-ar.yw(srp1.lm$res)
> srp.lmfit
Call:
ar.yw.default(x = srp1.lm$res)
Coefficients:
1
0.2535
Order selected 1 sigma^2 estimated as 0.1201
So the Yule-Walker methodology fits the residual series to an AR(1) process.
3. Re-estimate model using Generalized Least Squares fit by Maximum Likelihood estimation, using the estimated p from 2, as the order for your correlation residual term.
In order to run a GLS regression your going to need to load the nlme package:
> library(nlme)
Then you can go crazy:
>srp1.gls=gls(srp1~yc1+CP1+FF1+default1+Support1+ER1+FedGDP1+FedBalance1+govcredit1+ForeignDebt1+UGAP1+OGAP1, corr=corARMA(p=1,q=0),method="ML")
> summary(srp1.gls)
The following output is produced:
Generalized least squares fit by maximum likelihood
Model: srp1 ~ yc1 + CP1 + FF1 + default1 + Support1 + ER1 + FedGDP1 + FedBalance1 + govcredit1 + ForeignDebt1 + UGAP1 + OGAP1
Data: NULL
AIC BIC logLik
100.7905 140.7421 -35.39526
Correlation Structure: AR(1)
Formula: ~1
Parameter estimate(s):
Phi
0.3696665
Coefficients:
Value Std.Error t-value p-value
(Intercept) -3.0219486 1.2595942 -2.399145 0.0184
yc1 0.1929605 0.0640627 3.012054 0.0033
CP1 -0.0060642 0.0071791 -0.844700 0.4004
FF1 0.1918066 0.0362894 5.285466 0.0000
default1 0.5292204 0.2060591 2.568293 0.0118
Support1 2.1086204 0.7405128 2.847514 0.0054
ER1 0.5651430 0.2770125 2.040135 0.0442
FedGDP1 0.1028773 0.3143122 0.327309 0.7442
FedBalance1 0.7845392 0.4130914 1.899190 0.0606
govcredit1 -0.1240196 0.0524191 -2.365922 0.0201
ForeignDebt1 0.0009822 0.0278623 0.035252 0.9720
UGAP1 -0.1266050 0.0657633 -1.925161 0.0573
OGAP1 -0.0014094 0.0014328 -0.983623 0.3279
Correlation:
(Intr) yc1 CP1 FF1 deflt1 Spprt1 ER1 FdGDP1 FdBln1 gvcrd1
yc1 -0.267
CP1 0.054 -0.062
FF1 -0.308 0.726 -0.012
default1 0.081 -0.208 0.235 -0.342
Support1 -0.005 -0.109 -0.107 -0.419 0.137
ER1 -0.208 0.077 -0.081 0.067 -0.180 0.028
FedGDP1 -0.728 -0.059 -0.048 0.083 -0.057 -0.002 -0.308
FedBalance1 0.461 0.250 0.020 0.208 0.036 -0.081 0.445 -0.887
govcredit1 -0.570 -0.233 -0.095 -0.291 -0.261 0.072 0.068 0.666 -0.784
ForeignDebt1 -0.475 0.132 0.006 -0.092 0.093 0.219 0.057 0.059 -0.045 0.227
UGAP1 -0.048 -0.193 -0.062 0.085 -0.447 0.150 0.090 0.045 0.064 -0.053
OGAP1 -0.029 0.092 0.295 0.062 -0.208 -0.024 0.053 -0.021 0.013 0.056
FrgnD1 UGAP1
yc1
CP1
FF1
default1
Support1
ER1
FedGDP1
FedBalance1
govcredit1
ForeignDebt1
UGAP1 -0.016
OGAP1 0.064 0.041
Standardized residuals:
Min Q1 Med Q3 Max
-3.08026826 -0.62589269 -0.08409222 0.39781537 3.24233325
Residual standard error: 0.3634024
Degrees of freedom: 106 total; 93 residual
After you perform this step you have to refit the residuals in order to get serially uncorrelated terms.
4. Fit the GLS estimated residuals to an AR(p) process using the Yule-Walker Method and use the estimated p's as the final parameter estimates for the error term.
> s1glsres.ar<-ar.yw(srp1.gls$res)
> s1glsres.ar
Call:
ar.yw.default(x = srp1.gls$res)
Coefficients:
1
0.3718
Order selected 1 sigma^2 estimated as 0.1163
In order to see the results of these actions please refer to image below:
The Ljung-box Q is a test for autocorrelation between the lags in the error terms. Ideally in order to meet the BLUE criteria we have to reject the the null hypothesis for autocorrelation at each lag. We can see that both our original OLS and GLS estimations fail to pass the Ljung-Box Q. However when we readjust the error terms the final time we get residuals that are serially uncorrelated with each other.
In order to get the above graph you have to first load the package that will allow you to perform the Ljung-Box Q plot:
> library(FitAR)
Then you can proceed from there and define how many plots should be in one picture. In the above image we have 9 therefore:
> par(mfrow=c(3,3))
Then you can start adding in your plots. Below is the code for producing the plots for the fitted GLS residuals.
> acf(s1glsres.ar$res[-(1)])
> pacf(s1glsres.ar$res[-(1)])
> LBQPlot(s1glsres.ar$res[-(1)])
We include the [-(1)] because exclude the first observation since we have an AR(1) process.
The same steps above can be applied to any time-series regression model. In the next post we will discuss how to get some summary statistics. Please keep dancin'
Steven J.
Monetary Policy & Credit Easing pt. 5: Explanatory Variables Continued...
Capturing Treasury Supply Effects
WE will need to account for things other than the Fed that influenced risk premia as they relate to Treasury supply. The following three variables are meant to accomplish such a thing:
1. Federal Reserves holdings of total public debt as a percentage of GDP
2. Total government holdings of domestic credit market debt as a percentage of the total
3. Foreign holdings of government debt as a percentage of total public debt
1. Fed's holdings of total public debt as a percentage of GDP
Federal Reserve holdings of total public debt as a percentage of GDP is important because it controls for how much Federal Government support the Fed is accounting for. It is especially pertinent to our second estimation as the Feds holdings of total public debt relative to GDP increased sharply. Operationally, we define this variable as:
FedGDP_{t}= {GovDebt_{t}^{Fed}\ GDP_{t}}x 100
Where,
GovDebt_{t}^{Fed}=Federal Debt Held by Federal Reserve Banks (FDHBFRBN) at time, t
GDP_{t} = Gross Domestic Product, 1 Decimal (GDP) at time, t
We expect that this variable will move in line with both short-term and long-term risk premiums. Therefore:
H_{0}: ß ≤ 0 vs. H_{a}: ß > 0
Data Issues
The time-series necessary for this variable is provided by FRED and the details are as listed:
(a) Federal Debt Held by Federal Reserve Banks (FDHBFRBN), Quarterly, End of Period, Not Seasonally Adjusted, 1970-01-01 to 2011-0
(b) Gross Domestic Product, 1 Decimal (GDP), Quarterly, Seasonally Adjusted Annual Rate, 1947-01-01 to 2011-07-01
2. Government Holdings Of Domestic Credit Market Debt As A Percentage Of The Total
It would be wise to include a variable that account for fiscal policies support of the financial markets. This we can define as Federal Government holdings of credit market assets as a percentage of the total outstanding. To account for total government support of the financial markets we will use the following variable: govcredit.
govcredit_{t}={ CAssets_{t}^{Gov}\ CAssets_{t}^{Total} }x 100
Where,
CAssets_{t}^{Gov} = Total Credit Market Assets Held by Domestic Nonfiancial Sectors - Federal Government (FGTCMAHDNS) at time, t
CAssets_{t}^{Total} = Total Credit Market Assets Held by Domestic Nonfiancial Sectors (TCMAHDNS) at time, $t$
We expect that this variable will reduce both short-term and long-term risk premiums. Therefore:
H0: ß ≥ 0 vs. Ha: ß < 0
Data Issues
The time-series necessary for this variable is provided by FRED and the details are as listed:
(a) Total Credit Market Assets Held by Domestic Nonfiancial Sectors - Federal Government (FGTCMAHDNS), Quarterly, End of Period, Not Seasonally Adjusted, 1949-10-01 to 2011-04-01
(b) Total Credit Market Assets Held by Domestic Nonfiancial Sectors (TCMAHDNS), Quarterly, End of Period, Not Seasonally Adjusted, 1949-10-01 to 2011-04-01
3. Foreign Holdings of Federal Debt As A Percentage Of The Total
This variable labeled ForeignDebt_{t} seeks to capture the impact that foreign holdings of United States government debt have on both short-term and long-term risk premia. Theory would suggest that as foreign holdings go up risk-premia would go down. Operationally this variable is defined as follows:
ForeignDebt_{t} = {GovDebt_{t}^{Foreign}\ total public debt_{t}} x 100
Where,
GovDebt_{t}^{Foreign}= Federal Debt Held by Foreign & International Investors (FDHBFIN) at time, t
total public debt_{t}= Federal Government Debt: Total Public Debt (GFDEBTN) at time, t
Our ß coefficient on this variable is expected to be negative for both short-term and long-term risk premia and therefore:
H_{0}: ß ≥ 0 vs. H_{a}: ß < 0
Data Issues
The following data comes from FRED and the details are as follows:
(a) Federal Debt Held by Foreign & International Investors (FDHBFIN), Quarterly, End of Period, Not Seasonally Adjusted, 1970-01-01 to 2011-04-01
(b) Federal Government Debt: Total Public Debt (GFDEBTN), Quarterly, End of Period, Not Seasonally Adjusted, 1966-01-01 to 2011-04-01
Accounting For Cyclicality
We include two variables to help account for cyclicality in the overall economy. Both are relevant as the Fed uses these variables in its decision making process. For example in setting the federal funds rate, the Fed is said to have used a Taylor Rule that incorporated both the output gap and unemployment gap in its objective function. Thus incorporating these variables may present a problem of endogeneity over a short-part of our sample(like when a taylor-rule was said to be used), but these effects we will choose to ignore. The two cyclical variables we shall use are the output gap and the unemployment gap. The output gap is defined,
OGAP_{t}= Potential GDP_{t} – GDP_{t} at time, t
Where,
Potential GDP_{t}=Nominal Potential Gross Domestic Product (NGDPPOT) at time, t
GDP_{t}=Gross Domestic Product, 1 Decimal (GDP) at time, t
Our unemployment gap is defined in a similar fashion:
UGAP_{t}= NROU_{t} – UNRATE_{t} at time, t
Where,
NROU_{t}= Natural Rate of Unemployment (NROU) at time, t
UNRATE_{t}= Civilian Unemployment Rate (UNRATE) at time, t
Theoretically we assume that over the long-run as both of these variables increase the long-term risk premia increase. Over the short-run regressions we would expect these variables to have almost no significant effect as that time period is cluttered with many short-term things impacting risk-premia. Additionally for the short-term risk premia we would expect either a negative relationship or no relationship. This is because many things that impact the long-term risk premia one way have an opposite sign with respect to the short-term risk premia.
Data Issues
The data for these cyclical variables is provided by FRED and their details are laid out as follows:
(a) Civilian Unemployment Rate (UNRATE), Monthly, Seasonally Adjusted, 1948-01-01 to 2011-10-01
(b) Natural Rate of Unemployment (NROU), Quarterly, 1949-01-01 to 2021-10-01
(c) Nominal Potential Gross Domestic Product (NGDPPOT), Quarterly, 1949-01-01 to 2021-10-01
(d) Gross Domestic Product, 1 Decimal (GDP), Quarterly, Seasonally Adjusted Annual Rate, 1947-01-01 to 2011- 07-01
The next post gets into the R analysis and lays out our model in full.
Subscribe to:
Posts (Atom)





