关键词 > ECOM30001/ECOM90001
ECOM30001/ECOM90001: Basic Econometrics Semester 1, 2022 Solutions: Tutorial 4
发布时间:2022-07-16
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
ECOM30001/ECOM90001: Basic Econometrics
Semester 1, 2022
SoLUTIoNs: TUToRIAL 4
Introduction
This tutorial provides practice using the econometrics software package R that we will be using in this subject. Specifically, this tutorial reviews:
- running an OLS regression in R
- testing for the significance of an OLS regression using an F test
- testing joint linear restrictions using an F test
- testing single linear restrictions using a t test
This tutorial requires one (1) data file:
- tut4 .csv
This file can be obtained from the Canvas subject page.
In addition the R script file tut4 .R provides the program code necessary to complete the exercises. This R script file uses the following packages which need to be installed prior to running the R script file:
stargazer : for easily generating summary statistics for an R data file car : for easily conducting hypothesis tests in R
These can be installed directly in RSTUDIo from the packages tab or by using the com- mand install .packages() and inserting the name of the package in the brackets.
Note: The first question does not require the use of R. Instead the separate parts provide an example of a question that might reasonably appear on a mid-semester test or a final exam.
Question 1—Based on Hill, Griffiths & Lim Exercise 6.3 [4th Ed.]
Consider the econometric model:
yi = β0 + β1 X1i + β2 X2i + εi
Suppose you estimate this model using a sample of 20 observations and obtain the fol- lowing fitted values:
yˆi = 0.96587 + 0.69914 X1i + 1.7769 X2i
with an estimated covariance matrix:
- V十AR [b0] C十OV [b0 , b1]
' C十OV [b2 , b0] C十OV [b2 , b1]
C十OV(C十OV)
= -
V十AR [b2] ' ' 上0.050301
0.019195 0.048526
0.031223
上0.050301 -
上 '
with the estimated error variance 2 = 2.5193 and the sample standard deviation of the dependent variable s = 6.4971
a) Use this information to find the R2 and the adjusted 2 .
Solution The R2 is defined as:
R2 = 1 上
In order to calculate the R2 , both the residual sum of squares (RSS) and the total sum of squares are required. The RSS may be calculated from the estimate of the
error variance:
2 =
(N R上K(SS)上 1)
where 2 = 2.5193. Therefore:
RSS = 2 * (N 上 K 上 1) = (2.5193 * 17) = 42.8281
The total sum of squares (TSS) may be calculated using the sample standard de- viation in y . Recall:
s = 上(上)
= | (N(T)上(S)S1) = 6.4971
which implies:
TSS =3 (yi 上 y¯)2 = s2 * (N 上 1) = [(6.4971)2] * 19 = 802.0339
We can calculate the R2 as
R2 = 1 上 = 1 上
= 0.9466
Similarly, the adjusted R2 may be calculated as:
2 = 1 上
R TS(SS/)/(N)
(上N 上(K) 1(上) 1) = 1 上 = 0.9403
b) Use a t-test to test the hypothesis H0 : β1 > 1 against the alternative HA : β1 < 1, at a 5% level of significance.
Solution: The null and alternative hypotheses for this one-sided test may be stated as:
H0 : β1 > 1 HA : β1 < 1
The test statistic will be distributed as a t random variable with 17 degrees of freedom when H0 is true. This is a one-sided test, so tc = 1.7396 at the 5% level of significance. The decision rule is to reject H0 if the sample value of the test statistic
t < 上1.7396.
The sample test statistic is:
t =
se(b1 )
with b1 = 0.69914. The standard error se(b1 ) may be obtained from the variance- covariance matrix:
se(b1 ) =^VAR(b1 ) = 0.22029
The sample test statistic is:
b1 上 1 0.69914 上 1
and conclude there is insufficient evidence to support the hypothesis that β1 < 1.
Alternatively, using R to calculate the p-value for this one-sided test provides p = 0.0949. Since p > 0.05 then do not reject H0 .
c) Test the hypothesis β1 = β2 = 0 at a 5% level if significance.
Solution: The null and alternative hypotheses for this test may be stated as:
H0 : β1 = β2 = 0 HA : β1 0 and/or β2
0
The test statistic will be distributed as an F random variable with 2 numerator degrees of freedom and 17 denominator degrees of freedom when H0 is true. Using the F-tables, Fc = 3.59 at the 5% level of significance. The decision rule is to reject
H 上 0 if the sample value of the test statistic F > 3.59.
The sample test statistic is:
(RSSR 上 RSSUR )/M
RSSUR /(N 上 K 上 1)
In this case the restricted model becomes:
yi = β0 + εi
We know that the residual sum of squares in this restricted model RSSR = TSS . Therefore, we can calculate the sample F-statistic as:
(TSS 上 RSSUR )/2 (802.0339 上 42.8281)/2
Note that we have calculated RSS = 42.8281 and TSS = 802.0339 in part a) above.
Alternatively, use:
F = = = 150.68
d) Use a two-sided t-test to test the hypothesis β2 = 2 β1 at a 5% level of significance.
Hint You may find the following result useful. If X , Y , and Z are random variables:
VAR(aX 上 bY) = a2 VAR(X) + b2 VAR(Y) 上 2 a b COV(X, Y)
Solution: The null and alternative hypotheses for this two-sided test may be stated as:
H0 : β2 上 2 β1 = 0 HA : β2 上 2 β1 0
The test statistic will be distributed as a t random variable with 17 degrees of freedom when H0 is true. This is a two-sided test, so tc = 2.1098 at the 5% level of significance. The decision rule is to reject H0 if t > 2.1098 or t ≤ 上2.1098.
The sample test statistic is:
(b2 上 2 b1 ) 上 (β2 上 2 β1 ) (b2 上 2 b1 ) 上 0
se(b2 上 2 b1 ) se(b2 上 2 b1 )
In order to calculate this test statistic, we need to know se(b2 上 2 b1 ): se(b2 上 2 b1 ) =^VAR(b2 上 2 b1 )
Applying the result in the hint with a = 1 and b = 2:
se(b2 上 2 b1 ) =^VAR(b2 上 2 b1 )
= ,V十AR (b2 ) + 4 V十AR (b1 ) 上 (2 * 2) C十OV (b1 , b2 )
=^0.037120 + (4 * 0.048526) 上 (4 * 上0.031223)
= ^0.35612
The sample t-statistic becomes:
b2 上 2 b1 1.7769 上 (2 * 0.69914)
se(b2 上 2 b1 ) ^0.35612
since 上tc < t < tc , we cannot reject H0 that β2 = 2 β1 .
Alternatively, using R to calculate the p-value for this one-sided test provides p = 0.5342. Since p > 0.05 then do not reject H0 .
Question 2
Consider a firm that uses both labour Lt and physical capital Kt to produce output Yt . Standard production theory implies that the labour/capital ratio will be related to its relative price. This suggests the following econometric model:
ln ╱ 、 = β0 + β1 ln ╱
、 + β2 ln Yt + et (1)
where:
Lt = the quantity of labour used to produce output Yt
Kt = the quantity of capital used to produce output Yt
Yt = the quantity of output produced
wt = the price (per-unit) of labour
rt = the price (per-unit) of capital
ln = natural logarithm
The data file tut4 .csv provides annual time-series data data covering the period 1948- 1979 that can be used to estimate the econometric model (1).
a) What is the economic interpretation of the parameters β1 and β2 in the model (1)?
Solution: Note that both the dependent variable and all the explanatory variables are measured in natural logarithms. The parameter β1 is the elasticity of the labour/capital ratio with respect to the relative price, holding output constant— the percentage change in the (expected) labour-capital ratio associated with a 1% change in the relative factor price ratio, holding output constant:
β1 = │Y held constant 生
│Y held constant
Similarly the parameter β2 is the elasticity of the labour/capital ratio with respect to output, holding the relative price constant——the percentage change in the (expected) labour-capital ratio associated with a 1% change in the level of output, holding the relative factor price ratio constant
β2 = │(w/r) held constant 生
│(w/r) held constant
b) Using a 5% significance level, test the hypothesis that the relative price w/r has a negative effect upon the labour/capital ratio. Your answer should clearly state the null and alternative hypotheses, the distribution of test statistic, and your decision.
Hint: You will need to estimate the econometric model (1) by OLS. Before, esti- mating the model, you will need to generate the required (log) transformations of the raw data (see the R script file tut4 .R).
uor0lRet1esgaerhesatdspiw(e)/(1)r(.))willreducethe
labour/capital ratio by 5.8%. Similarly, the estimates suggest that a 10% increase in the level of output will reduce the labour/capital ratio by 2.4%. Note that b2 < 0 so that increases in output will be associated with proportionately more capital and proportionately less labour.
This is a one-sided test with H0 : β1 > 0 against the alternative HA : β1 < 0. The test statistic will follow a t-distribution with 29 degrees of freedom. The critical
value will be tc = 1.6991. The decision rule—reject H0 if t < 上1.6991.
The sample test-statistic:
b1 上 0 上0.5801842
that the labour/capital ratio is inversely related to the factor price ratio w/r .
Alternatively, using R to calculate the p-value for this one-sided test provides p = 0.0000. Since p < 0.05 then reject H0 .
c) Using a 5% significance level, test the hypothesis that the level of output has a significant effect upon the labour/capital ratio. Your answer should clearly state the null and alternative hypotheses, the distribution of the test statistic, and your decision.
Solution: This is a two-sided test with H0 : β2 = 0 against the alternative HA : β2 0. The test statistic will follow a t-distribution with 29 degrees of freedom. The critical value will be tc = 2.0452. The decision rule—reject H0 if t < -2.0452 or t > 2.0452. The sample test-statistic:
b2 - 0 -0.2379183
se(b2 ) 0.0510928
Since t < -tc —reject H0 . The sample evidence is consistent with the level of output having a (statistically) significant effect upon the labour/capital ratio.
Alternatively, using R to calculate the p-value for this one-sided test provides p = 0.0000. Since p < 0.05 then reject H0 .
d) What proportion of the variation in the (log) labour/capital ratio is explained by movements in ln(w/r) and ln Y?
Solution: The value of R2 = 0.9300 implies that 93% of the variation in ln(L/K) is explained by variation in the log of the relative price ratio ln(w/r) and the log of output ln(Y).
e) Using a 5% level of significance, test the hypothesis that the relative price and output have no effect upon the labour/capital ratio. Your answer should clearly state the null and alternative hypotheses, the test statistic, and your decision.
Hint: The R script file tut4 .R provides five (5) different ways to answer this question.
- Using statistics generated by the lm command in R
- Using the car package in R
- Estimating a restricted version of model (1) imposing the restriction under the null hypothesis H0 : β1 = β2 = 0. In this case, the restricted model only contains an intercept term. This restricted (intercept only) model can be estimated in R as follows:
reg rest1 <- lm(lnlabcap X 1, data=tut4)
The sample F statistic is calculated as:
(RSSR - RSSUR )/K
RSSUR /N - K - 1
- Calculating the Total Sum of Squares (TSS) for the dependent variable in the
unrestricted model (1). In this case, the sample F statistic is calculated as:
(TSS - RSSUR )/K
F =
- Calculating the R2 for the unrestricted model (1). In this case, the sample F statistic is calculated as:
R2 /K
F =
Solution: The null and alternative hypothesis are given by:
H0 : β1 = β2 = 0 HA : β1 0 and/or β2
0
The test statistic will follow a F distribution with (2, 29) degrees of freedom. The F critical value is given by Fc = 3.328. The decision rule is to reject H0 if the sample value of the F test statistic exceeds this critical value. Alternatively, reject H0 if the p-value associated with the sample value of the F test statistic is less than the desired level of significance p < 0.05.
The estimation results provided after the lm command provide a sample value for F test statistic of 192.69 with a p-value of p = 0.000. Since p < 0.05—reject H0 . The sample evidence is consistent with the hypothesis that the relative factor price ratio and the level of output jointly have a significant effect upon the labour-capital ratio.
Using the car package in R, test the significance of the model using an F-test at the 5% level of significance.
Linear hypothesis test
Hypothesis:
lnwr = 0
lny = 0
Model 1: restricted model
Model 2: lnlabcap ~ lnwr + lny
Res.Df RSS Df Sum of Sq F Pr(>F)
1 31 10.4080
2 29 0.7284 2 9.6796 192.69 < 0.00000000000000022 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘ . ’ 0.1 ‘ ’ 1
Figure 2: Linear Hypothesis H0 : β1 = β2 = 0
Solution: The output from the car package is provided in Figure 2. The results provided in Figure 2 provide a sample value for F test statistic of 192.69 with a p-value of p = 0.000. Since p < 0.05—reject H0 . The sample evidence is consistent with the hypothesis that the relative factor price ratio and the level of output jointly have a significant effect upon the labour-capital ratio.
The residual sum of squares for the unrestricted model (1) is given by RSSUR = 0.7283834. The residual sum of squares for the restricted (intercept only) model, imposing the restrictions β1 = β2 = 0 is given by RSSR = 10.40797. The sample F statistic may be calculated as:
(RSSR - RSSUR )/K
RSSUR /N - K - 1
(10.40797 - 0.7283834)/2
0.7283834/29
= 192.6925
This provides a sample F-statistic of F = 192.69 with a p-value of 0.0000. Since p < 0.05—reject H0 . The sample evidence is consistent with the hypothesis that the relative factor price ratio and the level of output jointly have a significant effect upon the labour-capital ratio.
The sample value of the F test statistic may be calculated as:
(TSS 上 RSSUR )/K
RSSUR /N 上 K 上 1
In order to calculate the sample F-test statistic, the total sum of squares (TSS) for the unrestricted model is required. This can be calculated from the sample standard deviation of the dependent variable:
lnlabcap sd <-sd(tut4$lnlabcap)
This provides a sample standard deviation of the dependent variable of s = 0.5794317.
The TSS can be calculated as TSS = (N 上 1) * (lnlabcap
sd)2 . Calculating the
F =
=
Finally, the sample value of the F test statistic may be calculated as:
F =
In order to calculate the sample F statistic, the R2 for the unrestricted model is required. This can be computed by R which provides R2 = 0.9300168. The sample F-test statistic is given by:
R2 /K
(1 上 R2 )/N 上 K 上 1
(1 上 0.9300168/29
= 192.6925
This provides a sample F-statistic of F = 192.69 with a p-value of 0.0000. Since p < 0.05—reject H0 . The sample evidence is consistent with the hypothesis that the relative factor price ratio and the level of output jointly have a significant effect upon the labour-capital ratio.
Regardless of the method used to calculate the sample value of the test statistic (and you only need to use one), the value of test statistic and the p-value are always the same.
f) A popular restricted version of model (1) is the Cobb-Douglas production function. If the underlying production function is Cobb-Douglas, the labour/capital ratio will be given by:
ln ╱ 、 = β0 上 ln ╱
、 + εt
i) What restrictions on β1 and β2 does the Cobb-Douglas production function impose upon the econometric model (1)?
It is clear that the Cobb-Douglas production function imposes the restriction
β1 = 上1 and β2 = 0.
ii) At the 5% level, test the hypothesis that the data are consistent with a Cobb- Douglas production function. Your answer should clearly state the null and alternative hypotheses, the test statistic, and your decision.
The restricted model is obtained by imposing the restrictions under the null hypothesis. This restricted model is given by:
{ln ╱ 、 + ln ╱
、} = β0 + εt
This restricted model may be estimated by defining a new dependent variable and estimating an intercept only model.
Hint: The R script file tut4 .R provides two (2) different ways to answer this question.
- Using the car package in R
- Estimating a restricted version of model (1) imposing the restriction under the null hypothesis. The sample F statistic is calculated as:
(RSSR 上 RSSUR )/M
RSSUR /N 上 K 上 1
Solution: The null hypothesis is given by
H0 : β1 = 上1 and β2 = 0
while HA is that at least one of these restrictions does not hold. This is a joint test so the test-statistic will follow an F-distribution under H0 with (2, 29) degrees of freedom. The F critical value is given by Fc = 3.328. The decision rule is to reject H0 if the sample value of the F test statistic exceeds this critical value. Alternatively, reject H0 if the p-value associated with the sample value of the F test statistic is less than the desired level of significance p < 0.05.
Linear hypothesis test
Hypothesis:
lnwr = - 1
lny = 0
Model 1: restricted model
Model 2: lnlabcap ~ lnwr + lny
Res.Df RSS Df Sum of Sq F Pr(>F)
1 31 1.56306
2 29 0.72838 2 0.83468 16.616 0.00001554 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘ . ’ 0.1 ‘ ’ 1
Figure 3: Linear Hypothesis H0 : β1 = 上1 and β2 = 0
The output from the car package is provided in Figure 3. The results provided in Figure 3 provide a sample value for F test statistic of 16.616 with a p-value of p = 0.000. Since p < 0.05—reject H0 and conclude that the data are not
consistent with a Cobb-Douglas production function.
The sample F statistic is calculated as:
(RSSR 上 RSSUR )/M
RSSUR /N 上 K 上 1
In order to calculate the sample value of test statistic the residual sum of squares is required for both the unrestricted model (1) and the restricted (Cobb-Douglas) model imposing the restrictions under H0 . The residual sum of squares for the unrestricted model (1) is given by RSSUR = 0.7283834. The residual sum of squares for the restricted model, imposing the restrictions
β1 = 上1 and β2 = 0 is given by RSSR = 1.563064. The sample F statistic
F = (RSSR 上 RSSUR )/M
RSSUR /N 上 K 上 1
=
This provides a sample F-statistic of F = 16.616 with a p-value of 0.0000. Since p < 0.05—reject H0 and conclude that the data are not consistent with a Cobb-Douglas production function.
Regardless of the method used to calculate the sample value of the test statistic (and you only need to use one), the value of test statistic and the p-value are always the same.