In: Statistics and Probability
Solve it by R
Use the “d_logret_6stocks” dataset to answer the questions. Test by using α= .01. (General Motor: GenMotor).
(1) Regress the return of General Motor on the returns of Citigroup (with intercept). Report the estimated coefficients. Is there any evidence to show strong linear relationship between these two variables at significance level 5%?
(2) Suppose we “know” the return of Citigroup tomorrow is 0.05, what is the predicted return of General Motor tomorrow?
(3) Compute the correlation of General Motor and Citigroup, and test if their correlation is zero.
Here is “d_logret_6stocks” dataset. I bring this by this code.
rawdata <- read.table("d_logret_6stocks.txt",header=T)
rawdata
Date Pfizer Intel Citigroup AmerExp Exxon GenMotor
1 1-Aug-00 -0.001438612 0.049981263 0.044275101 0.017410003
0.0102248940 0.093294017
2 1-Sep-00 0.017489274 -0.255619266 -0.033536503 0.012656982
0.0379890200 -0.032209239
3 2-Oct-00 -0.017046116 0.034546736 -0.011645582 -0.004897625
0.0003305550 -0.019602167
4 1-Nov-00 0.012012934 -0.072550667 -0.022674793 -0.038275870
-0.0036500200 -0.094891600
5 1-Dec-00 0.016278701 -0.102497868 0.010708311 0.000000000
-0.0052520490 0.012461253
6 2-Jan-01 -0.008063083 0.090223122 0.039900620 -0.066129678
-0.0141692430 0.022971579
Solution-1:
use lm fucntion in R to fit a linea rmodel
coeffcient function to get the coefficients
summary to get the summary of the model
Rcode;
df1 =read.table(header = TRUE, text ="
sno Date Pfizer Intel Citigroup AmerExp Exxon GenMotor
1 1-Aug-00 -0.001438612 0.049981263 0.044275101 0.017410003
0.0102248940 0.093294017
2 1-Sep-00 0.017489274 -0.255619266 -0.033536503 0.012656982
0.0379890200 -0.032209239
3 2-Oct-00 -0.017046116 0.034546736 -0.011645582 -0.004897625
0.0003305550 -0.019602167
4 1-Nov-00 0.012012934 -0.072550667 -0.022674793 -0.038275870
-0.0036500200 -0.094891600
5 1-Dec-00 0.016278701 -0.102497868 0.010708311 0.000000000
-0.0052520490 0.012461253
6 2-Jan-01 -0.008063083 0.090223122 0.039900620 -0.066129678
-0.0141692430 0.022971579
"
)
df1
linmod <- lm(GenMotor~Citigroup,data=df1)
coefficients(linmod)
summary(linmod)
Output:
coefficients(linmod)
(Intercept) Citigroup
-0.0103812 1.6395016
> summary(linmod)
Call:
lm(formula = GenMotor ~ Citigroup, data = df1)
Residuals:
1 2 3 4 5 6
0.031086 0.033155 0.009872 -0.047335 0.005286 -0.032064
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.01038 0.01525 -0.681 0.5335
Citigroup 1.63950 0.50654 3.237 0.0318 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.03695 on 4 degrees of freedom
Multiple R-squared: 0.7237, Adjusted R-squared:
0.6546
F-statistic: 10.48 on 1 and 4 DF, p-value: 0.0317
Regression equation is
Genmotor= -0.0103812 +1.6395016 *citigroup
Ho:There is no linear relationship beteween Genmotor and citigroup
Ha::There is a linear relationship beteween Genmotor and citigroup
F= 10.48
p=0.0317
p<0.05
Reject Ho
Accept Ha
Conclusion:
There is suffcient statisitical evidence at 5% level of
significance to conclude that there is strong linear
relationship between these two variables
(2) Suppose we “know” the return of Citigroup tomorrow is 0.05, what is the predicted return of General Motor tomorrow?
WIth predict fucntion in R we can predict
attach(df1)
newdata=data.frame(Citigroup=0.05)
predict(linmod,newdata)
Output:
1
0.07159388
Predicted returm for General Motor is
0.07159388
Solution-c:
perform cor.test in R
cor.test(df1$GenMotor,df1$Citigroup)
Output:
data: df1$GenMotor and df1$Citigroup
t = 3.2367, df = 4, p-value = 0.03177
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.1264003 0.9833561
sample estimates:
cor
0.8506958
Correlation coefficent=0.8506958
Ho:correlation=0
Ha:correlation not =0
alpha=0.05
t = 3.2367
, p-value = 0.03177
p<0.05
Reject Ho
Accept Ha
There is suffcient statistcal evidence at 5% level of significance to conclude that there is relationship between
Genmotors and citi group