0% found this document useful (0 votes)
1 views9 pages

ASS1

The document presents an analysis of financial data for VTI and VXUS, including return calculations, histograms, regression models, and correlation assessments. It also discusses a baseball dataset, examining the relationship between RPG and OBP through regression analysis. Additionally, it covers statistical tests related to fund performance, including alpha and beta calculations, and probabilities of significant losses.

Uploaded by

詠芯謝
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views9 pages

ASS1

The document presents an analysis of financial data for VTI and VXUS, including return calculations, histograms, regression models, and correlation assessments. It also discusses a baseball dataset, examining the relationship between RPG and OBP through regression analysis. Additionally, it covers statistical tests related to fund performance, including alpha and beta calculations, and probabilities of significant losses.

Uploaded by

詠芯謝
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1

a
library(quantmod)
getSymbols("VTI", from = "2018-12-31", to="2023-12-31")

## [1] "VTI"

getSymbols("VXUS", from = "2018-12-31", to="2023-12-31")

## [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

max_return_VTI <- max(rtn.VTI)


min_return_VTI <- min(rtn.VTI)

max_return_VXUS <- max(rtn.VXUS)


min_return_VXUS <- min(rtn.VXUS)

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)

mean_VXUS <- mean(rtn.VXUS)


sd_VXUS <- sd(rtn.VXUS)

lower_bound_VTI <- mean_VTI - 2 * sd_VTI


upper_bound_VTI <- mean_VTI + 2 * sd_VTI

lower_bound_VXUS <- mean_VXUS - 2 * sd_VXUS


upper_bound_VXUS <- mean_VXUS + 2 * sd_VXUS

percentage_within_VTI <- sum(rtn.VTI >= lower_bound_VTI & rtn.VTI <=


upper_bound_VTI) / length(rtn.VTI) * 100
percentage_within_VXUS <- sum(rtn.VXUS >= lower_bound_VXUS & rtn.VXUS
<= upper_bound_VXUS) / length(rtn.VXUS) * 100

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)

plot(cumulative_returns_VTI, type = 'l', col = "blue", xlab = "Time",


ylab = "Cumulative Returns", main = "Cumulative Returns for VTI and
VXUS")
lines(cumulative_returns_VXUS, type = 'l', col = "red")

legend("topleft", legend=c("VTI", "VXUS"), col=c("blue", "red"),


lty=1)

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

## fit lwr upr


## 0.4 7.279572 6.503333 8.055811
## 0.5 11.161299 9.285710 13.036887
## 0.6 15.043025 11.991567 18.094483

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)

if (t_statistic > critical_value) {


print("Reject the null hypothesis: The slope coefficient is
significantly greater than 30.")
} else {
print("Fail to reject the null hypothesis: The slope coefficient is
not significantly greater than 30.")
}

## [1] "Fail to reject the null hypothesis: The slope coefficient is


not significantly greater than 30."
3
a
sd_2_months = sqrt(2) * 0.077
z_score = (0.1 - 2 * 0.0099) / sd_2_months
probability = pnorm(z_score, lower.tail = FALSE)
probability

## [1] 0.2307154

b
z_score_fund1 = (0.1 - 0.0130) / 0.073
z_score_fund2 = (0.1 - 0.0139) / 0.086

probability_fund1 = pnorm(z_score_fund1, lower.tail = FALSE)


probability_fund2 = pnorm(z_score_fund2, lower.tail = FALSE)

combined_probability = probability_fund1 * probability_fund2


combined_probability

## [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

expected_drop_fundI = beta_fundI * (-0.1)


expected_drop_fundII = beta_fundII * (-0.1)

z_fundI = (expected_drop_fundI - (-0.1)) / sd_fundI


z_fundII = (expected_drop_fundII - (-0.1)) / sd_fundII

probability_fundI = pnorm(z_fundI, lower.tail = TRUE)


probability_fundII = pnorm(z_fundII, lower.tail = TRUE)

joint_probability = probability_fundI * probability_fundII

print(paste("Probability Fund I loses 10% or more: ",


probability_fundI))

## [1] "Probability Fund I loses 10% or more: 0.54730860026877"

print(paste("Probability Fund II loses 10% or more: ",


probability_fundII))

## [1] "Probability Fund II loses 10% or more: 0.462629859194088"

print(paste("Joint probability both funds lose 10% or more: ",


joint_probability))

## [1] "Joint probability both funds lose 10% or more:


0.253201300678054"

You might also like