0% found this document useful (0 votes)
26 views5 pages

Capm-1 1

The document estimates the beta of VIPCLOTHNG stock using the CAPM model against the Nifty 50 index from 2020-2023 on a weekly basis. It loads necessary packages, obtains the daily price data for both stocks, converts it to weekly data, calculates weekly returns, runs a regression analysis, and estimates beta to be 0.934841 based on the slope of the regression line.

Uploaded by

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

Capm-1 1

The document estimates the beta of VIPCLOTHNG stock using the CAPM model against the Nifty 50 index from 2020-2023 on a weekly basis. It loads necessary packages, obtains the daily price data for both stocks, converts it to weekly data, calculates weekly returns, runs a regression analysis, and estimates beta to be 0.934841 based on the slope of the regression line.

Uploaded by

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

FRAM

2023-11-26

Part 1.1 - Estimating Beta using the CAPM model


Company - VIPCLOTHNG TIME FRAME - DAILY

# Load necessary packages


library(quantmod)

## Loading required package: xts

## Loading required package: zoo

##
## Attaching package: ’zoo’

## The following objects are masked from ’package:base’:


##
## as.Date, as.Date.numeric

## Loading required package: TTR

## Registered S3 method overwritten by ’quantmod’:


## method from
## as.zoo.data.frame zoo

# Set global options for knitr


knitr::opts_chunk$set(echo = TRUE)

# Getting the data for Nifty 50 and VIPCLOTHNG.NS


NSE <- getSymbols("ˆNSEI", src = "yahoo", from = "2020-11-02", to = "2023-10-26", auto.assign = FALSE)

## Warning: ^NSEI contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.

VIPCLOTHNG <- getSymbols("VIPCLOTHNG.NS", src = "yahoo", from = "2020-11-02", to = "2023-10-26", verbose

## Warning: VIPCLOTHNG.NS contains missing values. Some functions will not work if
## objects contain missing values in the middle of the series. Consider using
## na.omit(), na.approx(), na.fill(), etc to remove or replace them.

1
# Convert daily data to weekly data
NSE_weekly <- to.weekly(NSE$NSEI.Close, indexAt = "endof", drop.time = TRUE)

## Warning in to.period(x, "weeks", name = name, ...): missing values removed from
## data

VIPCLOTHNG_weekly <- to.weekly(VIPCLOTHNG$VIPCLOTHNG.NS.Close, indexAt = "endof", drop.time = TRUE)

## Warning in to.period(x, "weeks", name = name, ...): missing values removed from
## data

# Making a data frame of the closing prices for weekly data


Close_weekly <- cbind(NSE_weekly, VIPCLOTHNG_weekly)

# Calculating the returns for weekly data


Returns_weekly <- as.xts(tail(data.frame(Close_weekly), -1) / head(data.frame(Close_weekly), -1) - 1)
head(Returns_weekly, 5)

## NSE.NSEI.Close.Open NSE.NSEI.Close.High NSE.NSEI.Close.Low


## 2020-11-13 0.067862645 0.039597066 0.067862645
## 2020-11-14 NA NA NA
## 2020-11-20 NA NA NA
## 2020-11-27 0.004058505 0.009035255 0.006788462
## 2020-12-04 0.014126044 0.015580013 0.019493048
## NSE.NSEI.Close.Close VIPCLOTHNG.VIPCLOTHNG.NS.Close.Open
## 2020-11-13 0.037216010 NA
## 2020-11-14 NA NA
## 2020-11-20 NA 0.18713443
## 2020-11-27 0.008546541 0.01970451
## 2020-12-04 0.022330228 0.00000000
## VIPCLOTHNG.VIPCLOTHNG.NS.Close.High
## 2020-11-13 NA
## 2020-11-14 NA
## 2020-11-20 0.05128205
## 2020-11-27 0.02926831
## 2020-12-04 0.09952608
## VIPCLOTHNG.VIPCLOTHNG.NS.Close.Low
## 2020-11-13 NA
## 2020-11-14 NA
## 2020-11-20 0.188235339
## 2020-11-27 -0.009901027
## 2020-12-04 0.035000038
## VIPCLOTHNG.VIPCLOTHNG.NS.Close.Close
## 2020-11-13 NA
## 2020-11-14 NA
## 2020-11-20 0.05128205
## 2020-11-27 0.02926831
## 2020-12-04 0.09952608

# Running the regression model on weekly returns


regression_weekly <- lm(VIPCLOTHNG_weekly ~ NSE_weekly, data = data.frame(Returns_weekly))
# Slope parameter = beta in CAPM model
summary(regression_weekly)

2
## Response VIPCLOTHNG$VIPCLOTHNG.NS.Close.Open :
##
## Call:
## lm(formula = ‘VIPCLOTHNG$VIPCLOTHNG.NS.Close.Open‘ ~ NSE_weekly,
## data = data.frame(Returns_weekly))
##
## Residuals:
## VIPCLOTHNG$VIPCLOTHNG.NS.Close.Open
## Min -19.7617
## 1Q -4.3948
## Median 0.2708
## 3Q 5.5463
## Max 19.1111
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.290e+01 6.455e+00 -11.293 <2e-16 ***
## NSE_weeklyNSE$NSEI.Close.Open 3.078e-03 6.149e-03 0.501 0.617
## NSE_weeklyNSE$NSEI.Close.High -3.864e-03 6.978e-03 -0.554 0.581
## NSE_weeklyNSE$NSEI.Close.Low 6.634e-03 6.877e-03 0.965 0.336
## NSE_weeklyNSE$NSEI.Close.Close 2.379e-04 6.205e-03 0.038 0.969
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 7.654 on 151 degrees of freedom
## Multiple R-squared: 0.6632, Adjusted R-squared: 0.6542
## F-statistic: 74.32 on 4 and 151 DF, p-value: < 2.2e-16
##
##
## Response VIPCLOTHNG$VIPCLOTHNG.NS.Close.High :
##
## Call:
## lm(formula = ‘VIPCLOTHNG$VIPCLOTHNG.NS.Close.High‘ ~ NSE_weekly,
## data = data.frame(Returns_weekly))
##
## Residuals:
## VIPCLOTHNG$VIPCLOTHNG.NS.Close.High
## Min -21.0028
## 1Q -4.3314
## Median -0.2625
## 3Q 5.5359
## Max 18.0766
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.400e+01 6.585e+00 -11.237 <2e-16 ***
## NSE_weeklyNSE$NSEI.Close.Open 2.773e-03 6.273e-03 0.442 0.659
## NSE_weeklyNSE$NSEI.Close.High -4.207e-03 7.119e-03 -0.591 0.555
## NSE_weeklyNSE$NSEI.Close.Low 7.893e-03 7.015e-03 1.125 0.262
## NSE_weeklyNSE$NSEI.Close.Close -2.312e-04 6.330e-03 -0.037 0.971
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 7.808 on 151 degrees of freedom

3
## Multiple R-squared: 0.6655, Adjusted R-squared: 0.6566
## F-statistic: 75.1 on 4 and 151 DF, p-value: < 2.2e-16
##
##
## Response VIPCLOTHNG$VIPCLOTHNG.NS.Close.Low :
##
## Call:
## lm(formula = ‘VIPCLOTHNG$VIPCLOTHNG.NS.Close.Low‘ ~ NSE_weekly,
## data = data.frame(Returns_weekly))
##
## Residuals:
## VIPCLOTHNG$VIPCLOTHNG.NS.Close.Low
## Min -19.006236
## 1Q -4.373676
## Median 0.005198
## 3Q 5.120752
## Max 15.978886
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -72.442893 6.233505 -11.622 <2e-16 ***
## NSE_weeklyNSE$NSEI.Close.Open 0.002049 0.005938 0.345 0.731
## NSE_weeklyNSE$NSEI.Close.High -0.004816 0.006739 -0.715 0.476
## NSE_weeklyNSE$NSEI.Close.Low 0.007596 0.006641 1.144 0.255
## NSE_weeklyNSE$NSEI.Close.Close 0.001206 0.005992 0.201 0.841
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 7.391 on 151 degrees of freedom
## Multiple R-squared: 0.6742, Adjusted R-squared: 0.6655
## F-statistic: 78.11 on 4 and 151 DF, p-value: < 2.2e-16
##
##
## Response VIPCLOTHNG$VIPCLOTHNG.NS.Close.Close :
##
## Call:
## lm(formula = ‘VIPCLOTHNG$VIPCLOTHNG.NS.Close.Close‘ ~ NSE_weekly,
## data = data.frame(Returns_weekly))
##
## Residuals:
## VIPCLOTHNG$VIPCLOTHNG.NS.Close.Close
## Min -20.1306
## 1Q -4.2040
## Median -0.2816
## 3Q 5.6635
## Max 17.1565
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -73.381617 6.439056 -11.396 <2e-16 ***
## NSE_weeklyNSE$NSEI.Close.Open 0.002685 0.006134 0.438 0.662
## NSE_weeklyNSE$NSEI.Close.High -0.006053 0.006961 -0.870 0.386
## NSE_weeklyNSE$NSEI.Close.Low 0.007597 0.006860 1.107 0.270
## NSE_weeklyNSE$NSEI.Close.Close 0.001931 0.006190 0.312 0.756

4
## ---
## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1
##
## Residual standard error: 7.635 on 151 degrees of freedom
## Multiple R-squared: 0.6694, Adjusted R-squared: 0.6607
## F-statistic: 76.45 on 4 and 151 DF, p-value: < 2.2e-16

BETA IS 0.934841

You might also like