ASS1
ASS1
a
library(quantmod)
getSymbols("VTI", from = "2018-12-31", to="2023-12-31")
## [1] "VTI"
## [1] "VXUS"
VTI = VTI$VTI.Adjusted;
VXUS = VXUS$VXUS.Adjusted
L = length(VTI)
rtn.VTI = as.numeric(VTI[-1])/as.numeric(VTI[-L]) - 1
rtn.VXUS = as.numeric(VXUS[-1])/as.numeric(VXUS[-L]) - 1
data.frame(VTI=c(min_return_VTI,max_return_VTI),
VXUS=c(min_return_VXUS,max_return_VXUS),
row.names = c("minimum","maximum"))
## VTI VXUS
## minimum -0.11380873 -0.11131825
## maximum 0.09489762 0.08380962
b
hist(rtn.VTI, breaks = 100, main = "Histogram of VTI Returns", xlab =
"Daily Returns", ylab = "Frequency", col = "blue")
The histogram of VTI approximates normal distribution
hist(rtn.VXUS, breaks = 100, main = "Histogram of VXUS Returns", xlab
= "Daily Returns", ylab = "Frequency", col = "red")
The histogram of VXUS approximates normal distribution
c
mean_VTI <- mean(rtn.VTI)
sd_VTI <- sd(rtn.VTI)
data.frame(percentage_within_VTI,percentage_within_VXUS)
## percentage_within_VTI percentage_within_VXUS
## 1 95.54849 96.26391
The percentage of difference of two standard deviations from the mean value of VTI and
VXUS is 95.54849% and 96.26391%, respectively. They’re all at 95%
d
cumulative_returns_VTI <- cumprod(1 + rtn.VTI)
cumulative_returns_VXUS <- cumprod(1 + rtn.VXUS)
e
regression_model <- lm(rtn.VXUS ~ rtn.VTI)
summary(regression_model)
##
## Call:
## lm(formula = rtn.VXUS ~ rtn.VTI)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0289434 -0.0033635 0.0002782 0.0033015 0.0295912
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0001647 0.0001586 -1.038 0.299
## rtn.VTI 0.8055945 0.0116667 69.051 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005619 on 1256 degrees of freedom
## Multiple R-squared: 0.7915, Adjusted R-squared: 0.7913
## F-statistic: 4768 on 1 and 1256 DF, p-value: < 2.2e-16
The coefficient of the slope (VTI) is 0.8055940. The coefficient is very significant (p value <
2e-16), indicating a strong positive correlation between VTI and VXUS returns. This slope
indicates that for every 1% increase in VTI returns, VXUS returns are expected to increase
by about 0.8056%. R squared is 0.7915, which suggests that about 79.15% of the variance
in VXUS returns is explained by VTI returns.
plot(rtn.VTI, rtn.VXUS, main = "Scatter plot of VXUS vs VTI", xlab =
"VTI Returns", ylab = "VXUS Returns", col = "blue")
abline(regression_model, col = "red")
f
regression_model_vti_on_vxus <- lm(rtn.VTI ~ rtn.VXUS)
summary(regression_model_vti_on_vxus)
##
## Call:
## lm(formula = rtn.VTI ~ rtn.VXUS)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.037717 -0.003625 0.000076 0.003437 0.030360
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0002975 0.0001750 1.699 0.0895 .
## rtn.VXUS 0.9825050 0.0142287 69.051 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006206 on 1256 degrees of freedom
## Multiple R-squared: 0.7915, Adjusted R-squared: 0.7913
## F-statistic: 4768 on 1 and 1256 DF, p-value: < 2.2e-16
The coefficient of the slope (VXUS) is 0.9825051. The coefficient is very significant (p value
< 2e-16), indicating a strong positive correlation between VXUS and VTI returns. This slope
indicates that for every 1% increase in VXUS returns, VTI returns are expected to increase
by about 0.9825%. The R squared is 0.7915, which indicates that about 79.15% of the
variance in the VTI return is explained by the VXUS return.
Comparison with previous models:
The intercepts are different because they should be different because they represent the
expected value of the dependent variable when the independent variable is zero.
The slope is different, and the slope of the second model (0.9825) is higher than that of the
first model (0.8056), which indicates that the return of VTI and VXUS is closer than that of
VTI and VXUS.
Goodness of Fit: The R-squared value is the same in both models because it is a measure of
the strength of the linear relationship and is independent of variables that are considered
relevant.
2
a
baseball = read.csv("baseball.csv")
model = lm(RPG~OBP,data=baseball,subset = (League=="American"))
confint(model,level = 0.9)[2,]
## 5 % 95 %
## 29.00410 48.63044
b
The slope coefficient (OBP) has a p value of 1.34 × 10−5, which is much smaller than the
significance level of 0.10. This means that we have enough evidence to reject the null
hypothesis of a 10% significance level.
c
From the regression output, R2 has a value of 0.8055, and since the slope coefficient of OBP
is positive (38.817), the correlation between RPG and OBP is positive, with a correlation of
about 0.897. This shows a strong positive relationship between RPG and OBP.
d
new_data <- data.frame(OBP = c(0.4, 0.5, 0.6))
prediction_intervals <- predict(model, newdata = new_data, interval =
"predict", level = 0.95)
rownames(prediction_intervals) <- c(0.4,0.5,0.6)
prediction_intervals
e
beta_0 = 30
s_model = summary(model)
t_statistic = (s_model$coefficients[2,1] - beta_0) /
s_model$coefficients[2,2]
critical_value = qnorm(0.95)
## [1] 0.2307154
b
z_score_fund1 = (0.1 - 0.0130) / 0.073
z_score_fund2 = (0.1 - 0.0139) / 0.086
## [1] 0.01847807
c
H 0 :α =0 (Fund I does not deliver a positive alpha beyond the market.)
H 1 : α > 0 (Fund I delivers a positive alpha beyond the market.)
From Figure 2, the intercept for Fund I is estimated to be 0.003998 with a standard error of
0.001813.
Estimate of α 0.003998
t= = ≈ 2.205
Standard Error of α 0.001813
We can use 2 to approximate the critical value of 1.96 for the 5% significance level. Since
the calculated t statistic (2.205) is greater than the critical value of 2, we reject the null
hypothesis and conclude that fund I provides positive alpha above the market.
d
H 0 : β=1 (Fund II has a market beta of 1.)
H 1 : β ≠ 1 (Fund II does not have a market beta of 1.)
From Figure 2, the slope (beta) for Fund II is estimated to be 1.080677 with a standard
error of 0.025258.
Estimate of β−1 1.080677−1
t= = ≈ 3.192
Standard Error of β 0.025258
We can use 2 to approximate the critical value of 1.96 for the 5% significance level. Since
the calculated t statistic (3.192) is greater than the critical value of 2, we reject the null
hypothesis and conclude that the market beta of Fund II at the 5% significance level is not
1.
e
beta_fundI = 0.913229
beta_fundII = 1.080677
sd_fundI = 0.073
sd_fundII = 0.086