**The Dancing Economist**, and kindly contributed to R-bloggers)

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**

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

*p*) process using the Yule-Walker Method and find the value of

*p*.

*p*from 2, as the order for your correlation residual term.

*p*) process and use the estimated

*p*‘s as the final parameter estimates for the error term.

*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**

*lmtest:*

*>library(lmtest)*

*> resettest(srp1.lm)*

*RESET test*

*data: srp1.lm*

*RESET = 9.7397, df1 = 2, df2 = 91, p-value = 0.0001469*

**Addressing Multicollinearity**

*> cor(FedBalance1,CreditMarketSupport1)*

*0.9994248*

**Suspected Endogeniety**

*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*

**Results and Concluding Thoughts**

**leave a comment**for the author, please follow the link and comment on their blog:

**The Dancing Economist**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...