Francisco Javier Parra Rodríguez

Universidad de Cantabria (UNICAN), España

parra_fj@cantabria.es

Abstract The capital asset pricing model provides a theoretical structure for the pricing of assets with uncertain returns. The security market line (SML) and its relation to expected return (the difference between the expected rate of return and the risk-free rate) and systematic risk (\(\beta\)) show how the market must price individual securities in relation to their security risk class. The value of \(\beta\) may be calculated in regression analysis utilizing historic data, assuming uncorrelacted the expected return market and the random term on OLS.

In this paper, a multivariate model is estimated by Regression Band Spectrum (RBS) when the random term are correlated to the market premium.

Classification JEL (Journal of Economic Literature): E22, E44,G11

The CAPM Model

The CAPM was introduced by Jack Treynor (1961, 1962),[4] William F. Sharpe (1964), John Lintner (1965a,b) and Jan Mossin (1966) independently, building on the earlier work of Harry Markowitz on diversification and modern portfolio theory.

The CAPM is a model for pricing an individual security or portfolio. For individual securities, we make use of the security market line (SML) and its relation to expected return and systematic risk (beta) to show how the market must price individual securities in relation to their security risk class. The SML enables us to calculate the reward-to-risk ratio for any security in relation to that of the overall market.

The equilibrium relationship to decribe CAPM is:

\(E(r_i)=r_f+\beta_{i}(E(r_m) - r_f)\)

where: . \(E(r_i)\) is the expected return on the capital asset . \(r_f\) is the risk-free rate of interest such as interest arising from government bonds . \(\beta-{i}\)(the beta) is the sensitivity of the expected excess asset returns to the expected excess market returns, or also \(\frac {Cov(r_i,r_m)}{Var(r_m)}\), . \(r_m\) is the expected return of the market . \(E(r_m)-r_f\) is sometimes known as the market premium (the difference between the expected market rate of return and the risk-free rate of return). . \(E(r_i)-r_f\) is also known as the risk premium

Restated, in terms of risk premium, we find that:

\(E(r_i)-r_f=\beta_{i}(E(r_m) - r_f)\)

which states that the individual risk premium equals the market premium times \(\beta\).

The market risk premium is determined from the slope of the SML. The intercept is the nominal risk-free rate available for the market, while the slope is the market premium, \(E(r_m)-r_f\). The securities market line can be regarded as representing a single-factor model of the asset price, where \(\beta\) is exposure to changes in value of the Market. The equation of the SML is thus:

\(SML: E(r_i)=r_f+\beta_i(E(r_m)-r_f)\)

The CAPM implies that all securities and portfolios will plot along SML line. It shows that expected returns will be linearly related to market risk.

The value of \(\beta\) may be given an interpretation similar to that found in regression analysis utilizing historic data (\(\beta\) exceeding one signify more than average “riskiness”;\(\beta\) below one indicate lower than average), although in the context of the CAPM it is to be interpreted strictly as an ex ante value based on probabilistic beliefs about future outcomes (Sharpe,1990). The relationship between \(\bar R_i\) and \(\bar R_m\), the stochastic returns on security i and the market portfolio, respectively, can be written as:

\(\bar R_i = \alpha_i +\beta_{im} \bar R_m + \epsilon_i\) (1)

Given the manner in which \(\beta_{im}\), is defined, it must be the case that \(\epsilon_i\) is uncorrelated \(\bar R_m\) . Moreover, \(\alpha_i\) can be defined so that the expected value of \(\epsilon_i\), is zero.

CAPM decomposes the overall risk of the Markowitz portfolio (\(\sigma^2 = \sum_i \sum_j X(j) X(k) \sigma [R(j) ; R(k)]\) ) by:

\(\sigma_{i}^2 = \beta_{im}^2\sigma_m^2+\sigma_{\epsilon_i}^2\)

The expresion \(\beta_{im}^2\sigma_m^2\) is the systematic risk and \(\sigma_{\epsilon_i}^2\) is the unsystematic risk. The systematic risk or undiversificable risk, is the portion of an asset’s risk cannot be eliminated via diversification, and unisystematic risk, which is also called firm-specific or diversificable risk, is the portion of an asset’s total risk that can be eliminated by including the security as a part of a diversificable portfolio.

The key implications of the CAPM (Sharpe, 1990) are that:

  1. the market portfolio will be efficient,

  2. all efficient portfolios will be equivalent to investment in the market portfolio plus, possibly, lending or borrowing, and

  3. there will be a linear relationship between expected return and beta.

Example

The historical monthly return data from December 1977 through December 1987, can be downloaded from Berndt’s The Practice of Econometrics. Here is the csv file of the returns: http://web.stanford.edu/~clint/berndt/

# testCAPM.r
#
# author: Eric Zivot
# created: November 24, 2003
# updated: December 2, 2008
#
# comments
# 1. requires data in file berndt.csv

# read prices from csv file
berndt.df = read.csv(file="berndtc1.csv",sep=";",dec=",", stringsAsFactors=F)
colnames(berndt.df)
##  [1] "Año"    "MOBIL"  "TEXACO" "IBM"    "DEC"    "DATGEN" "CONED" 
##  [8] "PSNH"   "WEYER"  "BOISE"  "MOTOR"  "TANDY"  "PANAN"  "DELTA" 
## [15] "CONTIL" "CITGRP" "GERBER" "GENMIL" "MARKET" "RKFREE"
#[1] "Año"    "MOBIL"  "TEXACO" "IBM"    "DEC"    "DATGEN" "CONED"  "PSNH"   "WEYER"  "BOISE" 
#[11] "MOTOR"  "TANDY"  "PANAN"  "DELTA"  "CONTIL" "CITGRP" "GERBER" "GENMIL" "MARKET" "RKFREE

# create zooreg object - regularly spaced zoo object

library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
berndt.z = zooreg(berndt.df[,-1], start=c(1978, 1), end=c(1987,12),
                  frequency=12)
index(berndt.z) = as.yearmon(index(berndt.z))

start(berndt.z)
## [1] "ene. 1978"
end(berndt.z)
## [1] "dic. 1987"
nrow(berndt.z)
## [1] 120
# create excess returns by subtracting off risk free rate
# note: coredata() function extracts data from zoo object
returns.mat = as.matrix(coredata(berndt.z))
excessReturns.mat = returns.mat - returns.mat[,"RKFREE"]
excessReturns.df = as.data.frame(excessReturns.mat)

We also calculated the excess return data set for our further usage in this excess return csv file.The excess return is equal to monthly return minus monthly RKFREE interest rate (30-day U.S. Treasure bills).

# CAPM regression for IBM using 1st 5 years of data
capm.fit = lm(IBM~MARKET,data=excessReturns.df,subset=1:60)
summary(capm.fit)
## 
## Call:
## lm(formula = IBM ~ MARKET, data = excessReturns.df, subset = 1:60)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.106814 -0.044604 -0.000958  0.030984  0.139757 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.0002481  0.0068359  -0.036  0.97117    
## MARKET       0.3390122  0.0887990   3.818  0.00033 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05239 on 58 degrees of freedom
## Multiple R-squared:  0.2008, Adjusted R-squared:  0.1871 
## F-statistic: 14.58 on 1 and 58 DF,  p-value: 0.0003298
# plot data and regression line
plot(excessReturns.df$MARKET,excessReturns.df$IBM,
     main="CAPM regression for IBM",
ylab="Excess returns on IBM",
xlab="Excess returns on MARKET")
abline(capm.fit)                    # plot regression line
abline(h=0,v=0)                 # plot horizontal and vertical lines at 0

We can conduct the regression on the excess returns of each stock and the excess return of market.

The CAPM formula of IBM is:

\(\bar R_{IBM} = \alpha_{IBM} +\beta_{IBM,m} \bar R_m + \epsilon_{IBM}\),

that is,

Expected excess return of IBM = \(\beta_{IBM}\) * Expected excess return of MARKET,

# compute average returns over 1st 5 years
mu.hat = colMeans(excessReturns.mat[1:60,c(3,18)])
mu.hat
##         IBM      MARKET 
## 0.003548167 0.011198167
mu.hat = colMeans(excessReturns.mat[1:60,c(18,19)])

The expected excess return of MARKET is the mean value is \(0.011198167\).

So, the \(Expected excess return of IBM = 0.3390122 * 0.011198167 = 0.003796315\).

# compute average returns over 1st 5 years
var.hat = diag(var(excessReturns.mat[1:60,-c(18,19)]))
var.hat
##       MOBIL      TEXACO         IBM         DEC      DATGEN       CONED 
## 0.007349944 0.006736332 0.003375956 0.007249466 0.017875233 0.002766001 
##        PSNH       WEYER       BOISE       MOTOR       TANDY       PANAN 
## 0.002265528 0.007630441 0.011344264 0.007617433 0.020289765 0.016774746 
##       DELTA      CONTIL      CITGRP      GERBER      GENMIL 
## 0.009598779 0.008188550 0.006039591 0.006491960 0.003606599

According to CAPM, the variance of IBM is:

\(\sigma_{IBM}^2 = \beta_{IBM}\sigma_M^2+\sigma_e^2\)

Where,

\(\sigma_M^2\) is the variance of NYSE, which is \(0.005899188\), \(\sigma_e^2\) is the variance of residual standard error, which is \(0.05239^2\), as shown in the above output.

So, \(\sigma_{IBM}^2= 0.3390122 * 0.005899188 + 0.05239^2 = 0.004744609\)

Based on the above results, we can further calculate the covariance in pairs of the four stocks by the formula of \(\sigma_{ij}= \beta_i \beta_j \sigma_M^2\) . So, for the covariance between IBM and CITCRP:

# CAPM regression for CITCRP (citicorp) using 1st 5 years of data
capm.fit = lm(CITGRP~MARKET,data=excessReturns.df,subset=1:60)
summary(capm.fit)
## 
## Call:
## lm(formula = CITGRP ~ MARKET, data = excessReturns.df, subset = 1:60)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.139865 -0.035204  0.006723  0.034690  0.253231 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.0005967  0.0091775   0.065 0.948382    
## MARKET      0.4466308  0.1192159   3.746 0.000415 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.07033 on 58 degrees of freedom
## Multiple R-squared:  0.1948, Adjusted R-squared:  0.181 
## F-statistic: 14.04 on 1 and 58 DF,  p-value: 0.000415
# plot data and regression line
plot(excessReturns.df$MARKET,excessReturns.df$CITCRP,
main="CAPM regression for CITCRP",
ylab="Excess returns on CITCRP",
xlab="Excess returns on MARKET")
abline(capm.fit)                    # plot regression line
abline(h=0,v=0)                 # plot horizontal and vertical lines at 0

\(\sigma_{IBM,CITCRP} = \beta_{IBM} \beta_{CITCRP} \sigma_M^2 = 0.3390122 * 0.4466308 * 0.005899188 = 0.0008932155\).

In Zivot, E (2008), cab obtain a testCAPM.r porgram to evaluate the coefficients estimated in CAPM model, and calculate SML.

# estimate CAPM and test alpha=0 for all assets using 1st 5 years of data
# trick use S-PLUS function apply to do this all at once

capm.tstats = function(r,market) {
    capm.fit = lm(r~market)                 # fit capm regression
    capm.summary = summary(capm.fit)        # extract summary info
    t.stat = coef(capm.summary)[1,3]        # t-stat on intercept
    t.stat
}
# test function
tmp = capm.tstats(excessReturns.mat[1:60,1],
excessReturns.mat[1:60,"MARKET"])
tmp
## [1] 0.08595583
# check out apply function

colnames(excessReturns.mat[,-c(18,19)])
##  [1] "MOBIL"  "TEXACO" "IBM"    "DEC"    "DATGEN" "CONED"  "PSNH"  
##  [8] "WEYER"  "BOISE"  "MOTOR"  "TANDY"  "PANAN"  "DELTA"  "CONTIL"
## [15] "CITGRP" "GERBER" "GENMIL"
tstats = apply(excessReturns.mat[1:60,-c(18,19)],2,
               FUN=capm.tstats,
               market=excessReturns.mat[1:60,"MARKET"])
tstats
##       MOBIL      TEXACO         IBM         DEC      DATGEN       CONED 
##  0.08595583 -0.40444639 -0.03630053  0.03092165 -1.04296670  1.21411728 
##        PSNH       WEYER       BOISE       MOTOR       TANDY       PANAN 
## -0.27454911 -0.51999713 -0.11656027  0.59618507  1.99703362 -0.89396008 
##       DELTA      CONTIL      CITGRP      GERBER      GENMIL 
##  0.62136933 -0.67030349  0.06501986 -0.06884828  0.54110492
# test H0: alpha = 0 using 5% test
abs(tstats) > 2
##  MOBIL TEXACO    IBM    DEC DATGEN  CONED   PSNH  WEYER  BOISE  MOTOR 
##  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE 
##  TANDY  PANAN  DELTA CONTIL CITGRP GERBER GENMIL 
##  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
any(abs(tstats) > 2)
## [1] FALSE
#
# plot average return against beta
#


# compute beta over 1st 5 years
capm.betas = function(r,market) {
    capm.fit = lm(r~market)                 # fit capm regression
    capm.beta = coef(capm.fit)[2]               # extract coefficients
    capm.beta
}

betas = apply(excessReturns.mat[1:60,-c(18,19)],2,
              FUN=capm.betas,
              market=excessReturns.mat[1:60,"MARKET"])
betas
##      MOBIL     TEXACO        IBM        DEC     DATGEN      CONED 
## 0.67977729 0.64326107 0.33901221 0.70677295 1.00561709 0.14049874 
##       PSNH      WEYER      BOISE      MOTOR      TANDY      PANAN 
## 0.21801661 0.70788726 0.88464464 0.55595797 1.03081022 0.74664275 
##      DELTA     CONTIL     CITGRP     GERBER     GENMIL 
## 0.39209800 0.38854870 0.44663080 0.46316113 0.09873775
# compute average returns over 1st 5 years
mu.hat = colMeans(excessReturns.mat[1:60,-c(18,19)])
mu.hat
##        MOBIL       TEXACO          IBM          DEC       DATGEN 
##  0.008381500  0.003714833  0.003548167  0.008181500 -0.003718500 
##        CONED         PSNH        WEYER        BOISE        MOTOR 
##  0.009798167  0.000831500  0.003248167  0.008648167  0.012198167 
##        TANDY        PANAN        DELTA       CONTIL       CITGRP 
##  0.042664833 -0.005301833  0.012014833 -0.003185167  0.005598167 
##       GERBER       GENMIL 
##  0.004531500  0.005348167
# plot average returns against betas
plot(betas,mu.hat,main="Ave return vs. beta")

# estimate regression of ave return on beta
sml.fit = lm(mu.hat~betas)
sml.fit
## 
## Call:
## lm(formula = mu.hat ~ betas)
## 
## Coefficients:
## (Intercept)        betas  
##   0.0008966    0.0107175
summary(sml.fit)
## 
## Call:
## lm(formula = mu.hat ~ betas)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0153928 -0.0040759 -0.0009818  0.0033933  0.0307205 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0008966  0.0057814   0.155    0.879
## betas       0.0107175  0.0093424   1.147    0.269
## 
## Residual standard error: 0.01048 on 15 degrees of freedom
## Multiple R-squared:  0.08066,    Adjusted R-squared:  0.01937 
## F-statistic: 1.316 on 1 and 15 DF,  p-value: 0.2693
# intercept should be zero and slope should be excess return on market
mean(excessReturns.mat[1:60,"MARKET"])
## [1] 0.01119817
plot(betas,mu.hat,main="TRUE and Estimated SML")
abline(sml.fit)
abline(a=0,b=mean(excessReturns.mat[1:60,"MARKET"]),lty=1, col="orange", lwd=2)
legend(0.2, 0.04, legend=c("Estimated SML","TRUE SML"),
       lty=c(1,1), col=c("black","orange"))

# compute average returns over 2nd 5 years
mu.hat2 = colMeans(excessReturns.mat[61:120,-c(18,19)])
mu.hat2
##        MOBIL       TEXACO          IBM          DEC       DATGEN 
##  0.010324667  0.006491333  0.002008000  0.017641333  0.005008000 
##        CONED         PSNH        WEYER        BOISE        MOTOR 
##  0.013541333 -0.022942000  0.002341333  0.011024667  0.010441333 
##        TANDY        PANAN        DELTA       CONTIL       CITGRP 
## -0.006325333 -0.001342000 -0.002308667 -0.012692000  0.004441333 
##       GERBER       GENMIL 
##  0.014591333  0.014141333
betas2 = apply(excessReturns.mat[61:120,-c(18,19)],2,
               FUN=capm.betas,
               market=excessReturns.mat[61:120,"MARKET"])
betas2
##      MOBIL     TEXACO        IBM        DEC     DATGEN      CONED 
## 0.78146833 0.57241684 0.65448596 1.09928950 1.09229391 0.02001884 
##       PSNH      WEYER      BOISE      MOTOR      TANDY      PANAN 
## 0.18050799 1.01411692 1.03227574 1.33812449 1.03501175 0.72584473 
##      DELTA     CONTIL     CITGRP     GERBER     GENMIL 
## 0.63952500 1.29443411 1.03701118 0.91216187 0.56697377
# plot average returns against betas
plot(betas2,mu.hat2,main="Ave return vs. beta")

# estimate regression of ave return on beta
sml.fit2 = lm(mu.hat2~betas2)
sml.fit2
## 
## Call:
## lm(formula = mu.hat2 ~ betas2)
## 
## Coefficients:
## (Intercept)       betas2  
##   0.0008614    0.0036970
summary(sml.fit2)
## 
## Call:
## lm(formula = mu.hat2 ~ betas2)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0244707 -0.0048868  0.0001084  0.0065742  0.0127159 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0008614  0.0067792   0.127    0.901
## betas2      0.0036970  0.0075801   0.488    0.633
## 
## Residual standard error: 0.01092 on 15 degrees of freedom
## Multiple R-squared:  0.01561,    Adjusted R-squared:  -0.05002 
## F-statistic: 0.2379 on 1 and 15 DF,  p-value: 0.6328
# intercept should be zero and slope should be excess return on market
mean(excessReturns.mat[61:120,"MARKET"])
## [1] 0.003108
plot(betas2,mu.hat2,main="TRUE and Estimated SML")
abline(sml.fit2)
abline(a=0,b=mean(excessReturns.mat[61:120,"MARKET"]),lwd=2, col="orange")
legend(0.2, -0.01, legend=c("Estimated SML","TRUE SML"),
       lty=c(1,1), col=c("black","orange"))

#
# prediction test II of CAPM
# estimate beta using 1st 5 years of data and
# compute average returns using 2nd 5 years of data
#

# estimate regression of 2nd period ave return on 
# 1st period beta
sml.fit12 = lm(mu.hat2~betas)
sml.fit12
## 
## Call:
## lm(formula = mu.hat2 ~ betas)
## 
## Coefficients:
## (Intercept)        betas  
##    0.002414     0.002684
summary(sml.fit12)
## 
## Call:
## lm(formula = mu.hat2 ~ betas)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0259406 -0.0057593  0.0008292  0.0065358  0.0133310 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.002414   0.006053   0.399    0.696
## betas       0.002684   0.009782   0.274    0.788
## 
## Residual standard error: 0.01098 on 15 degrees of freedom
## Multiple R-squared:  0.004993,   Adjusted R-squared:  -0.06134 
## F-statistic: 0.07527 on 1 and 15 DF,  p-value: 0.7876
plot(betas,mu.hat2,main="TRUE and Estimated SML",
xlab="1st period betas",ylab="2nd period ave returns")
abline(sml.fit12)
abline(a=0,b=mean(excessReturns.mat[61:120,"MARKET"]),lty=2,col="orange")
legend(0.2, -0.01, legend=c("Estimated SML","TRUE SML"),
lty=c(1,2))

Extension

The initial approach to capital asset pricing in Sharpe (1961), assumed that returns were generated by a model with the condition that the residual values were uncorrelated across securities. Other approaches to portfolio selection, assumed that returns were generated by a model similar to that of equation (1), made a similar assumption. Such a “single index” or “single factor” model represents a special case of a factor model of security returns. Multi-factor models have been explored by a number of researchers and currently enjoy widespread use in financial practice .

A factor model of security returns identifies a relatively few key factors to which a security’s return is assumed to be linearly related, in the following manner(Sharpe, 1990):

\(\bar R_i = \alpha_i +\sum \beta_{il} \bar F_{il} + \epsilon_i\) (2)

In such a model the \(\epsilon_i\) values are assumed to be uncorrelated across securities.

Bollerslev, R., Engle, R. and J. Wooldridge (1988), propose a multivariate, generalized-autoregressive, conditional, heteroscedastic (GARCH) proccess, that agent update their estimates of the means and covariances of returns each period using the newly revealed surprises in last period’s assets returns. In this model b_i change time depending.

From another point of view, if \(b_i\) change time depending. We can think to the \(\beta_i\) oscillates around this center of gravity (the market premium ) with cyclical patterns, periodic and no-periodic.

The relationship (1) when ,would be specified by a Fourier development:

\(\bar R_i = \alpha_i +\beta_{im} \bar R_m + \sum_{s=1}^S [a_s\cos(\omega_s)+b_j\sin(\omega_s) + \epsilon_{i}\) (3)

were, \(S=\frac{T}{2}\), \(\omega_s = 2 \pi \frac {j}{S}\),and \(\upsilon_j\) a random variable with zero mean, constant variance, \(\sigma^2\), and independent (\(cov(e_j,e_s)=0\)).

The function (3) contain cycles of different frequencies and amplitudes and such combinations of frequencies and amplitudes may yield cyclical patterns which appear non-periodic with irregular amplitude. Given the error term uncorrelated, the more frequent cyclical variations on the tendency line (\(\beta_{im}\)) could be considerate as a part of the systematic risk.

To estimate (3) is presented below a series of functions based R (Parra, 2015), the target is make a regression band spectrum (RBS) (Engle, 1974), using the Durbin test (Durbin, 1969) to select the oscillations band.

Test based on residuals from frequency domain regresion

Durbin (1967 and 1969) desing a technique for studying the general nature of the serial dependence in a satacionary time series.

Suppose \(\hat \beta\) is an estimator of \(\beta\). The n x 1 vector of residuals is then defined by

\[\hat u=y-X\hat \beta \]

\(p_j\) denotes the ordinate of the periodogram de \(\hat u\) at frequency \(\lambda_j=2\pi j/n\), and \(\hat v_j\) denote the \(j-th\) element of \(\hat v\), then

\[ p_j=\hat v_{2j}^{2}+\hat v_{2j+1}^{2}\]

\(j = 1,...\frac{n}{2}-1\) to \(n\) even, and \(j=1,...\frac{n-1}{2}\) to \(n\) odd,

\[ p_j=\hat v_{2j}^{2}\]

\(j = \frac{n}{2}-1\) \(n\) even

\[p_0=\hat v_{1}^{2}\]

As regards test statistics, if \(\hat \beta\) is the OLS estimator of \(\beta\) then the elements of \({\hat v}\) may be used directly in Durbin’s cumulative periodogram test. This test is based on the quantities

\[ s_j=\frac{\sum_{r=1} ^j p_r}{\sum_{r=1}^m p_r}\]

where \(m=\frac{1}{2}n\) for n even and \(\frac{1}{2}(n-1)\) for n odd. The procedure is a bounds test and upper and lower critical values may be constructed using the tables provided in Durbin (1969). Note that po does not enter into the test statistic as \(p_o\) does not enter in to test statitstic as \(p_o=\hat v_1=0\).

X0.1 <- c(0.4  ,0.35044  ,0.35477   ,0.33435    ,0.31556    ,0.30244    ,0.28991    ,0.27828    ,0.26794    ,0.25884    ,0.25071    ,0.24325    ,0.23639    ,0.2301 ,0.2243 ,0.21895    ,0.21397    ,0.20933    ,0.20498    ,0.20089    ,0.19705    ,0.19343    ,0.19001    ,0.18677    ,0.1837 ,0.18077    ,0.17799    ,0.17037    ,0.1728 ,0.17037    ,0.16805    ,0.16582    ,0.16368    ,0.16162    ,0.15964    ,0.15774    ,0.1559 ,0.15413    ,0.15242    ,0.15076    ,0.14916    ,0.14761    ,0.14011    ,0.14466    ,0.14325    ,0.14188    ,0.14055    ,0.13926    ,0.138  ,0.13678    ,0.13559    ,0.13443    ,0.133  ,0.13221    ,0.13113    ,0.13009    ,0.12907    ,0.12807    ,0.1271 ,0.12615    ,0.12615    ,0.12431    ,0.12431    ,0.12255    ,0.12255    ,0.12087    ,0.12087    ,0.11926    ,0.11926    ,0.11771    ,0.11771    ,0.11622    ,0.11622    ,0.11479    ,0.11479    ,0.11341    ,0.11341    ,0.11208    ,0.11208    ,0.11079    ,0.11079    ,0.10955    ,0.10955    ,0.10835    ,0.10835    ,0.10719    ,0.10719    ,0.10607    ,0.10607    ,0.10499    ,0.10499    ,0.10393    ,0.10393    ,0.10291    ,0.10291    ,0.10192    ,0.10192    ,0.10096    ,0.10096    ,0.10002)

X0.05 <- c(0.45,0.44306,0.41811,0.39075 ,0.37359    ,0.35522    ,0.33905    ,0.32538    ,0.31325    ,0.30221    ,0.29227    ,0.2833 ,0.27515    ,0.26767    ,0.26077    ,0.25439    ,0.24847    ,0.24296    ,0.23781    ,0.23298    ,0.22844    ,0.22416    ,0.22012    ,0.2163 ,0.21268    ,0.20924    ,0.20596    ,0.20283    ,0.19985    ,0.197  ,0.19427    ,0.19166    ,0.18915    ,0.18674    ,0.18442    ,0.18218    ,0.18003    ,0.17796    ,0.17595    ,0.17402    ,0.17215    ,0.17034    ,0.16858    ,0.16688    ,0.16524    ,0.16364    ,0.16208    ,0.16058    ,0.15911    ,0.15769    ,0.1563 ,0.15495    ,0.15363    ,0.15235    ,0.1511 ,0.14989    ,0.1487 ,0.14754    ,0.14641    ,0.1453 ,0.1453 ,0.14361    ,0.14361    ,0.14112    ,0.14112    ,0.13916    ,0.13916    ,0.13728    ,0.13728    ,0.13548    ,0.13548    ,0.13375    ,0.13375    ,0.13208    ,0.13208    ,0.13048    ,0.13048    ,0.12894    ,0.12894    ,0.12745    ,0.12745    ,0.12601    ,0.12601    ,0.12464    ,0.12464    ,0.12327    ,0.12327    ,0.12197    ,0.12197    ,0.12071    ,0.12071    ,0.11949    ,0.11949    ,0.11831    ,0.11831    ,0.11716    ,0.11716    ,0.11604    ,0.11604    ,0.11496)

X0.025 <- c(0.475   ,0.50855    ,0.46702    ,0.44641    ,0.42174    ,0.40045    ,0.38294    ,0.3697 ,0.35277    ,0.34022    ,0.32894    ,0.31869    ,
0.30935 ,0.30081    ,0.29296    ,0.2857 ,0.27897    ,0.2727 ,0.26685    ,0.26137    ,0.25622    ,0.25136    ,0.24679    ,0.24245    ,0.23835    ,0.23445    ,0.23074    ,0.22721    ,0.22383    ,0.22061    ,0.21752    ,0.21457    ,0.21173    ,0.20901    ,0.20639    ,0.20337    ,0.20144    ,0.1991 ,0.19684    ,0.19465    ,0.19254    ,0.1905 ,0.18852    ,0.18661    ,0.18475    ,0.18205    ,0.1812 ,0.1795 ,0.17785    ,0.17624    ,0.17468    ,0.17361    ,0.17168    ,0.17024    ,0.16884    ,0.16748    ,0.16613    ,0.16482    ,0.16355    ,0.1623 ,0.1623 ,0.1599 ,0.1599 ,0.1576 ,0.1576 ,0.1554 ,0.1554 ,0.15329    ,0.15329    ,0.15127    ,0.15127    ,0.14932    ,0.14932    ,0.14745    ,0.14745    ,0.14565    ,0.14565    ,0.14392    ,0.14392    ,0.14224    ,0.14224    ,0.14063    ,0.14063    ,0.13907    ,0.13907    ,0.13756    ,0.13756    ,0.1361 ,0.1361 ,0.13468    ,0.13468    ,0.13331    ,0.13331    ,0.13198    ,0.13198    ,0.1307 ,0.1307 ,0.12944    ,0.12944    ,0.12823)

X0.01 <- c(  0.49   ,0.56667    ,0.53456    ,0.50495    ,0.47629    ,0.4544 ,0.43337    ,0.41522    ,0.39922    ,0.38481    ,0.37187    ,0.36019    ,0.34954    ,0.3398 ,0.33083    ,0.32256    ,0.31489    ,0.30775    ,0.30108    ,0.29484    ,0.28898    ,0.28346    ,0.27825    ,0.27333    ,0.26866    ,0.26423    ,0.26001    ,0.256  ,0.25217    ,0.24851    ,0.24501    ,0.24165    ,0.23843    ,0.23534    ,0.23237    ,0.22951    ,0.22676    ,0.2241 ,0.22154    ,0.21906    ,0.21667    ,0.21436    ,0.21212    ,0.20995    ,0.20785    ,0.20581    ,0.20383    ,0.2119 ,0.20003    ,0.19822    ,0.19645    ,0.19473    ,0.19305    ,0.19142    ,0.18983    ,0.18828    ,0.18677    ,0.18529    ,0.18385    ,0.18245    ,0.18245    ,0.17973    ,0.17973    ,0.17713    ,0.17713    ,0.17464    ,0.17464    ,0.17226    ,0.17226    ,0.16997    ,0.16997    ,0.16777    ,0.16777    ,0.16566    ,0.16566    ,0.16363    ,0.16363    ,0.16167    ,0.16167    ,0.15978    ,0.15978    ,0.15795    ,0.15795    ,0.15619    ,0.15619    ,0.15449    ,0.15449    ,0.15284    ,0.15284    ,0.15124    ,0.15124    ,0.1497 ,0.1497 ,0.1482 ,0.1482 ,0.14674    ,0.14674    ,0.14533    ,0.14533    ,0.14396)

X0.005 <- c(0.495   ,0.59596    ,0.579  ,0.5421 ,0.51576    ,0.48988    ,0.4671 ,0.44819    ,0.43071    ,0.41517    ,0.40122    ,0.38856    ,0.37703    ,0.36649    ,0.35679    ,0.34784    ,0.33953    ,0.33181    ,0.32459    ,0.31784    ,0.31149    ,0.30552    ,0.29989    ,0.29456    ,0.28951    ,0.28472    ,0.28016    ,0.27582    ,0.27168    ,0.26772    ,0.26393    ,0.2603 ,0.25348    ,0.25348    ,0.25027    ,0.24718    ,0.24421    ,0.24134    ,0.23857    ,0.23589    ,0.2331 ,0.23081    ,0.22839    ,0.22605    ,0.22377    ,0.22377    ,0.21943    ,0.21753    ,0.21534    ,0.21337    ,0.21146    ,0.20961    ,0.2078 ,0.20604    ,0.20432    ,0.20265    ,0.20101    ,0.19942    ,0.19786    ,0.19635    ,0.19635    ,0.19341    ,0.19341    ,0.19061    ,0.19061    ,0.18792    ,0.18792    ,0.18534    ,0.18534    ,0.18288    ,0.18288    ,0.18051    ,0.18051    ,0.17823    ,0.17823    ,0.17188    ,0.17188    ,0.17392    ,0.17392    ,0.17188    ,0.17188    ,0.16992    ,0.16992    ,0.16802    ,0.16802    ,0.16618    ,0.16618    ,0.1644 ,0.1644 ,0.16268    ,0.16268    ,0.16101    ,0.16101    ,0.1594 ,0.1594 ,0.15783    ,0.15783    ,0.15631    ,0.15631    ,0.15483)
 

TestD <- data.frame(X0.1,X0.05,X0.025,X0.01,X0.005)

Fuction td (a,b)

Calculates and shows the results of testing Durbin (Durbin, 1969), applied to the variable \(a\) and the significance level \(b\) to \(b=0.1\)(significance=1); \(b=0.05\) (significance=2); \(b=0.025\) (significance=3); \(b=0.01\) (significance=4) and \(b=0.005\) (significance=5) (Durbin; 1969)

td <- function(y,significance) {
# Author: Francisco Parra Rodríguez
# Some ideas from:
#Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.
# DURBIN, J., "Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals," Biometrika, 56, (No. 1, 1969), 1-15.
# http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/ 
per <- periodograma(y)
p <- as.numeric(per$densidad)
n <- length(p)
s <- p[1]
t <- 1:n
for(i in 2:n) {s1 <-p[i]+s[(i-1)]
s <- c(s,s1)
s2 <- s/s[n]
}
while (n > 100) n <- 100
if (significance==1) c<- c(TestD[n,1]) else {if (significance==2) c <- c(TestD[n,2]) else {if (significance==3) c <- c(TestD[n,3]) else {if (significance==4) c <- c(TestD[n,4]) 
c <- c(TestD[n,5])}}}
min <- -c+(t/length(p))
max <- c+(t/length(p))
data.frame(s2,min,max)
} 
  1. Fuction gtd (a,b)

Plot to the Durbin test (Durbin, 1969), applied to the variable \(a\) and the significance level \(b\).

gtd <- function (y,significance) {
S <- td(y,significance)
plot(ts(S), plot.type="single", lty=1:3,main = "Test Durbin", 
ylab = "densidad acumulada",
xlab="frecuencia")
}

Alternatively you can use the cpgram function from MASS package (src/library/stats/R/cpgram.R).

  1. Function rdf (y,x, significance)

Consider now the linear regression model

\(y_t=\beta_tx_t+u_t\)

where \(x_t\) is an n x 1 vector of fixed observations on the independent variable, \(\beta_t\) is a n x 1 vector of parameters,\(y\) is an n x 1 vector of observations on the dependent variable, and \(u_t\) is an n x 1 vector de errores distribuidos con media cero y varianza constante.

Whit the assumption that any series, \(y_t\),\(x_t\),\(\beta_t\) and \(ut\), can be transformed into a set of sine and cosine waves such as:

\[y_t=\eta^y+\sum_{j=1}^N[a^y_j\cos(\omega_j)+b^y_j\sin(\omega_j)\]

\[x_t=\eta^x+\sum_{j=1}^N[a^y_j\cos(\omega_j)+b^y_j\sin(\omega_j)]\]

\[ \beta_t=\eta^\beta+\sum_{j=1}^N[a^\beta_j\cos(\omega_j)+b^\beta_j\sin(\omega_j)]\]

Pre-multiplying (6) by \(Z\):

\[ \dot y=\dot x\dot\beta+\dot u \]

where \(\dot y = Zy\),\(\dot x = Zx\), \(\dot \beta = Z\beta\) y \(\dot u = Zu\)

The system (8) can be rewritten as (see appendix):

\[ \dot y=Zx_tI_nZ^T\dot \beta + ZI_nZ^T\dot u\]

If we call \(\dot e = ZI_nZ ^ T \dot u\), It can be found the \(\dot \beta\) that minimize the sum of squared errors \(E_T = Z ^ T \dot e\).

Once you have found the solution to this optimization, the series would be transformed into the time domain for the system (8).

In the function , \(y\) is the dependent variable, \(x\) is the independent variables,and \(significance\) the significance for the Durbin test.

The algorithm calculation is performed in phases:

  1. Gets the cross-periodogram to \(x\) and \(y\).

Let \(x\) a vector n x 1, in frequency domain \(\hat x= Wx\)

Let \(y\) a vector n x 1, in frequency domain \(\hat y= Wy\)

\(p_j\) denotes the ordinate of the cross-periodogram to \(\hat x\) and \(\hat y\) at frequency \(\lambda_j=2\pi j/n\), and \(\hat x_j\) the j-th element to \(\hat x\) and \(\hat y_j\) the j-th element to \(\hat y\), then

\[ \left\lbrace \begin{array}{ll} p_j=\hat x_{2j}\hat y_{2j}+\hat x_{2j+1}\hat y_{2j+1} & \forall j = 1,...\frac{n-1}{2}\\ p_j=\hat x_{2j}\hat y_{2j}& \forall j = \frac{n}{2}-1 \end{array} \right . \]

\[p_0=\hat x_{1}\hat y_{1}\]

  1. Order the co - spectrum by the absolute value of \(p_j\) and make a index.

  2. Calculate the matrix \(Wx_tI_nW^T\), the matrix rows are ordered by index.

  3. Calculate \(\dot e=WI_nW^T\dot u\), add a vector by constant term, \((1,0,...0)^n\), then calculate the model by constant term and the de two first regressors to ordered matrix \(Wx_tI_nW^T\), cthen calculate the model by the constant and the de fourt first regressors, then for six, to complete the \(n\) regressors to ordered matrix.

  4. Testing for serial correlation all model to \(\alpha=0.1;0.05;0.025;0.01;0.005\).

  5. Select the lowest degree of freedom models with random term uncorrelated. If any is uncorrelated returns the OLS.

rdf <- function (y,x,significance) {
  # Author: Francisco Parra Rodríguez
  # http://rpubs.com/PacoParra/24432
  # Leemos datos en forma matriz
  a <- matrix(y, nrow=1)
  b <- matrix(x, nrow=1)
  n <- length(a)
  # calculamos el cros espectro mediante la funcion cperiodograma
  cperiodograma <- function(y,x) {
# Author: Francisco Parra Rodríguez
# http://econometria.wordpress.com/2013/08/21/estimation-of-time-varying-regression-coefficients/ 
cfx <- gdf(y)
n <- length(y)
cfy <- gdf(x)
if (n%%2==0) {
m1x <- c(0)
m2x <- c()
for(i in 1:n){
if(i%%2==0) m1x <-c(m1x,cfx[i]) else m2x <-c(m2x,cfx[i])}
m2x <- c(m2x,0)
m1y <- c(0)
m2y <- c()
for(i in 1:n){
if(i%%2==0) m1y <-c(m1y,cfy[i]) else m2y <-c(m2y,cfy[i])}
m2y <-c(m2y,0) 
frecuencia <- seq(0:(n/2)) 
frecuencia <- frecuencia-1
omega <- pi*frecuencia/(n/2)
periodos <- n/frecuencia
densidad <- (m1x*m1y+m2x*m2y)/(4*pi)
tabla <- data.frame(omega,frecuencia, periodos,densidad)
tabla$densidad[(n/2+1)] <- 4*tabla$densidad[(n/2+1)]
data.frame(tabla[2:(n/2+1),])}
else {m1x <- c(0)
m2x <- c()
for(i in 1:(n-1)){
if(i%%2==0) m1x <-c(m1x,cfx[i]) else m2x <-c(m2x,cfx[i])}
m2x <-c(m2x,cfx[n])
m1y <- c(0)
m2y <- c()  
for(i in 1:(n-1)){
if(i%%2==0) m1y <-c(m1y,cfy[i]) else m2y <-c(m2y,cfy[i])}
m2y <-c(m2y,cfy[n])
frecuencia <- seq(0:((n-1)/2)) 
frecuencia <- frecuencia-1
omega <- pi*frecuencia/(n/2)
periodos <- n/frecuencia
densidad <- (m1x*m1y+m2x*m2y)/(4*pi)
tabla <- data.frame(omega,frecuencia, periodos,densidad)
data.frame(tabla[2:((n+1)/2),])}
}
  cper <- cperiodograma(a,b)
# Ordenamos de mayor a menor las densidades absolutas del periodograma, utilizando la funcion "sort.data.frame" function, Kevin Wright. Package taRifx
  S1 <- data.frame(f1=cper$frecuencia,p=abs(cper$densidad))
  S <- S1[order(-S1$p),] 
  id <- seq(2,n)
  m1 <- cbind(S$f1*2,evens(id))
  if (n%%2==0) {m2 <- cbind(S$f1[1:(n/2-1)]*2+1,odds(id))} else 
   {m2 <- cbind(S$f1*2+1,odds(id))}
  m <- rbind(m1,m2)
  colnames(m) <- c("f1","id")
  M <- sort.data.frame (m,formula=~id)
  M <- rbind(c(1,1),M)
  # Obtenemos la funcion auxiliar (cdf) del predictor y se ordena segun el indice de las mayores densidades absolutas del co-espectro.
  cx <- cdf(b)
  id <- seq(1,n)
  S1 <- data.frame(cx,c=id)
  S2 <- merge(M,S1,by.x="id",by.y="c")
  S3 <- sort.data.frame (S2,formula=~f1)
  m <- n+2
  X1 <- S3[,3:m]
  X1 <- rbind(C=c(1,rep(0,(n-1))),S3[,3:m])
  # Se realizan las regresiones en el dominio de la frecuencia utilizando un modelo con constante, pendiente y los arm?nicos correspondientes a las frecuencias mas altas de la densidad del coespectro. Se realiza un test de durbin para el residuo y se seleccionan aquellas que son significativas. 
  par <- evens(id)
  i <- 1
  D <- 1
  resultado <- cbind(i,D)
  for (i in par) {
  X <- as.matrix(X1[1:i,])
  cy <- gdf(a)
  B1 <- solve(X%*%t(X))%*%(X%*%cy)
  Y <- t(X)%*%B1 
  F <- gdt(Y)
  res <- (t(a) - F)
  T <- td(res,significance)
  L <- as.numeric(c(T$min<T$s2,T$s2<T$max))
  LT <- sum(L)
  if (n%%2==0) {D=LT-n} else {D=LT-(n-1)} 
  resultado1 <- cbind(i,D)
  resultado <- rbind(resultado,resultado1)
  resultado}
resultado2 <-data.frame(resultado)
criterio <- resultado2[which(resultado2$D==0),]
sol <- as.numeric(is.na(criterio$i[1]))
if (sol==1) {"no encuentra convergencia"} else {
 X <- as.matrix(X1[1:criterio$i[1],])
cy <- gdf(a)
  B1 <- solve(X%*%t(X))%*%(X%*%cy)
  Y <- t(X)%*%B1 
  F <- gdt(Y)
  res <- (t(a) - F)
  datos <- data.frame(cbind(t(a),t(b),F,res))
  colnames(datos) <- c("Y","X","F","res")
list(datos=datos,Fregresores=t(X),Tregresores= t(MW(n))%*%t(X),Nregresores=criterio$i[1],Betas=B1)}
       }

Example

Wiit the historical monthly return data from December 1977 through December 1987, can be downloaded from Berndt’s The Practice of Econometrics.

According to the CAPM formula, we will first get the beta of each stock by regressions by OLS; and plot the residuals periodogram to know that asset were correlated across securities. This problem are present in MOBIL, PANAM and GERBER assets.

library(descomponer)
## Loading required package: taRifx
# Durbin test to random CAPM model

capm.res = function(r,market) {
    capm.fit = lm(r~market)                 # fit capm regression
    capm.res =  capm.fit$residuals              # extract residuals
    capm.res
}

for (i in 1:17) {
resids = capm.res(excessReturns.mat[1:120,i],
              market=excessReturns.mat[1:120,"MARKET"])
gtd(resids,1)}

Estimate RBS model to PANAM:

# Estimate CAPM by RBS to PANAM 

PANAM=excessReturns.mat[1:120,12]
MARKET=excessReturns.mat[1:120,"MARKET"]
capm.fit.RBS = rdf(PANAM,MARKET,1)
summary(capm.fit.RBS)
##             Length Class      Mode   
## datos          4   data.frame list   
## Fregresores 2640   -none-     numeric
## Tregresores 2640   -none-     numeric
## Nregresores    1   -none-     numeric
## Betas         22   -none-     numeric
# Durbin test to random CAPM model

gtd(capm.fit.RBS$datos$res,1)

cpgram(capm.fit.RBS$datos$res)

By OLS we can estimate (2), were \(\bar F_{il}\), are the time domain selected regressors to RBS model:

# Estimate CAPM by multifactor model ussing time domain regressors to PANAM.

capm.fit.RBS.2 <- lm(PANAM~0+capm.fit.RBS$Tregresores) 
summary(capm.fit.RBS.2)
## 
## Call:
## lm(formula = PANAM ~ 0 + capm.fit.RBS$Tregresores)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.26277 -0.06629 -0.00611  0.06705  0.38655 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)  
## capm.fit.RBS$TregresoresC   -0.07542    0.14047  -0.537   0.5925  
## capm.fit.RBS$Tregresores1    5.92535    2.40631   2.462   0.0155 *
## capm.fit.RBS$Tregresores72   3.53383    2.50486   1.411   0.1615  
## capm.fit.RBS$Tregresores73   0.30968    2.16642   0.143   0.8866  
## capm.fit.RBS$Tregresores106  1.11055    2.23219   0.498   0.6199  
## capm.fit.RBS$Tregresores107 -1.76979    2.41283  -0.733   0.4650  
## capm.fit.RBS$Tregresores18  -1.09217    2.40383  -0.454   0.6506  
## capm.fit.RBS$Tregresores19   1.14904    2.16845   0.530   0.5974  
## capm.fit.RBS$Tregresores4    0.79788    2.37093   0.337   0.7372  
## capm.fit.RBS$Tregresores5   -1.06856    2.33190  -0.458   0.6478  
## capm.fit.RBS$Tregresores6   -0.27926    2.27368  -0.123   0.9025  
## capm.fit.RBS$Tregresores7    0.54824    2.40305   0.228   0.8200  
## capm.fit.RBS$Tregresores108 -1.12167    2.43094  -0.461   0.6455  
## capm.fit.RBS$Tregresores109 -1.28743    2.46854  -0.522   0.6032  
## capm.fit.RBS$Tregresores116 -0.71097    2.36961  -0.300   0.7648  
## capm.fit.RBS$Tregresores117  0.89728    2.36412   0.380   0.7051  
## capm.fit.RBS$Tregresores12  -2.39999    2.34962  -1.021   0.3096  
## capm.fit.RBS$Tregresores13   1.57655    2.27898   0.692   0.4907  
## capm.fit.RBS$Tregresores56   3.93398    2.31457   1.700   0.0924 .
## capm.fit.RBS$Tregresores57   2.74521    2.16378   1.269   0.2075  
## capm.fit.RBS$Tregresores28  -3.74645    2.45579  -1.526   0.1303  
## capm.fit.RBS$Tregresores29   1.10685    2.32763   0.476   0.6355  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1237 on 98 degrees of freedom
## Multiple R-squared:  0.2776, Adjusted R-squared:  0.1154 
## F-statistic: 1.711 on 22 and 98 DF,  p-value: 0.03908
# Durbin test to random CAPM model

gtd(capm.fit.RBS.2$residuals,1)

cpgram(capm.fit.RBS.2$residuals)

# Estimate CAPM by single-factor model to PANAM.

capm.fit.OLS.2 <- lm(PANAM~MARKET) 
summary(capm.fit.OLS.2)
## 
## Call:
## lm(formula = PANAM ~ MARKET)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.35878 -0.06450 -0.01259  0.06534  0.39242 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.008576   0.011248  -0.762    0.447    
## MARKET       0.734508   0.163739   4.486  1.7e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1225 on 118 degrees of freedom
## Multiple R-squared:  0.1457, Adjusted R-squared:  0.1384 
## F-statistic: 20.12 on 1 and 118 DF,  p-value: 1.697e-05
# Durbin test to random CAPM model

gtd(capm.fit.OLS.2$residuals,1)

cpgram(capm.fit.OLS.2$residuals)

The tendency line in frequency domain is \(\dot LT=\dot \beta_{im} \dot R_m\) and \(\beta_{im}=\frac{LT}{R_m}\), the periodic oscilations into tendency line RBS model are \(R_{s,i}=\sum_{s=1}^S [a_s\cos(\omega_s)+b_j\sin(\omega_s)\).

# Tendency line and periodic oscilations in frequency domain.

LT.f=capm.fit.RBS$Fregresores[,2]*capm.fit.RBS$Betas[2]
R_ms.f=capm.fit.RBS$Fregresores[,3:22]%*%capm.fit.RBS$Betas[3:22]

# plot data and regression line

plot(MARKET,PANAM,
main="CAPM regression for PANAM",
ylab="Excess returns on PANAM",
xlab="Excess returns on MARKET")
lines(MARKET,gdt(LT.f),type="l",col="red")  # plot tendency lines in RBS
lines(MARKET,capm.fit.OLS.2$fitted.values,type="l",col="blue")      # plot regression line
lines(MARKET,gdt(R_ms.f),type="p",col="green") # plot periodic oscilations points
abline(h=0,v=0)             
legend(-0.25, 0.4, legend=c("Estimated slope RBS","Estimated slope OLS","Estimated periodic RBS"),
       lty=c(1,1,1), col=c("red","blue","green"))

# slope in new model

b_im=gdt(LT.f)/MARKET
b_im[1:5]
## [1] 0.5409078 0.5409078 0.5409078 0.5409078 0.5409078
# compute beta in RBS 
capm.betas.RBS = function(r,market) {
  library(descomponer)
    capm.fit.RBS = rdf(r,market,1)                  # fit capm regression rbs
    LT.f=capm.fit.RBS$Fregresores[,2]*capm.fit.RBS$Betas[2]         # tendency lines in RBS
    capm.beta.RBS=gdt(LT.f)/market #Betas en RBS
    capm.beta.RBS[1]
}

# compute average returns over all period
mu.hat3 = colMeans(excessReturns.mat[61:120,-c(18,19)])
mu.hat3
##        MOBIL       TEXACO          IBM          DEC       DATGEN 
##  0.010324667  0.006491333  0.002008000  0.017641333  0.005008000 
##        CONED         PSNH        WEYER        BOISE        MOTOR 
##  0.013541333 -0.022942000  0.002341333  0.011024667  0.010441333 
##        TANDY        PANAN        DELTA       CONTIL       CITGRP 
## -0.006325333 -0.001342000 -0.002308667 -0.012692000  0.004441333 
##       GERBER       GENMIL 
##  0.014591333  0.014141333
# betas all period
betas3 = apply(excessReturns.mat[1:120,-c(18,19)],2,
               FUN=capm.betas,
               market=excessReturns.mat[1:120,"MARKET"])
betas3
##      MOBIL     TEXACO        IBM        DEC     DATGEN      CONED 
## 0.71469504 0.61323025 0.45682077 0.84742336 1.03082157 0.09319394 
##       PSNH      WEYER      BOISE      MOTOR      TANDY      PANAN 
## 0.21348499 0.82066091 0.93588788 0.84814958 1.05000106 0.73450835 
##      DELTA     CONTIL     CITGRP     GERBER     GENMIL 
## 0.48973643 0.73109061 0.66700948 0.62559196 0.27020988
# betas in RBS all period

betas.rbs = apply(excessReturns.mat[1:120,-c(18,19)],2,
              FUN=capm.betas.RBS,
              market=excessReturns.mat[1:120,"MARKET"])
betas.rbs
##      MOBIL     TEXACO        IBM        DEC     DATGEN      CONED 
## 0.62465437 0.61323025 0.45682077 0.84742336 1.03082157 0.09319394 
##       PSNH      WEYER      BOISE      MOTOR      TANDY      PANAN 
## 0.21348499 0.82066091 0.93588788 0.84977073 1.05000106 0.54090784 
##      DELTA     CONTIL     CITGRP     GERBER     GENMIL 
## 0.48973643 0.73109061 0.66700948 0.67155851 0.27020988
# plot average returns against betas
plot(betas.rbs,mu.hat3,main="Ave return vs. beta")

# estimate regression of ave return on beta
sml.fit.rbs = lm(mu.hat3~betas.rbs)
sml.fit.rbs
## 
## Call:
## lm(formula = mu.hat3 ~ betas.rbs)
## 
## Coefficients:
## (Intercept)    betas.rbs  
##    0.001202     0.004213
summary(sml.fit.rbs)
## 
## Call:
## lm(formula = mu.hat3 ~ betas.rbs)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.025044 -0.004823  0.000429  0.006491  0.012869 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.001202   0.006879   0.175    0.864
## betas.rbs   0.004213   0.009893   0.426    0.676
## 
## Residual standard error: 0.01094 on 15 degrees of freedom
## Multiple R-squared:  0.01195,    Adjusted R-squared:  -0.05392 
## F-statistic: 0.1813 on 1 and 15 DF,  p-value: 0.6763
# estimate regression of ave return on beta
sml.fit.3 = lm(mu.hat3~betas3)
sml.fit.3
## 
## Call:
## lm(formula = mu.hat3 ~ betas3)
## 
## Coefficients:
## (Intercept)       betas3  
##    0.001646     0.003447
summary(sml.fit.3)
## 
## Call:
## lm(formula = mu.hat3 ~ betas3)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0253236 -0.0055196  0.0004964  0.0062154  0.0130745 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.001646   0.007022   0.234    0.818
## betas3      0.003447   0.009916   0.348    0.733
## 
## Residual standard error: 0.01096 on 15 degrees of freedom
## Multiple R-squared:  0.007991,   Adjusted R-squared:  -0.05814 
## F-statistic: 0.1208 on 1 and 15 DF,  p-value: 0.733
# intercept should be zero and slope should be excess return on market
mean(excessReturns.mat[1:120,"MARKET"])
## [1] 0.007153083
plot(betas.rbs,mu.hat3,main="TRUE and Estimated SML")
abline(sml.fit.rbs)
abline(sml.fit.3,col="red")
abline(a=0,b=mean(excessReturns.mat[1:120,"MARKET"]),lwd=2, col="orange")
legend(0.2, -0.01, legend=c("Estimated SML RBS","Estimated SML OLS","TRUE SML"),
       lty=c(1,1,1), col=c("black","red","orange"))

Bibliografía

Berndt’s Ernest R. (1991): The Practice of Econometrics .Addison Wesley, 1991, ISBN 0-201-51489-3.

Bollerslev, R., Engle, R. and J. Wooldridge (1988) “A Capital Asset Pricing Model with Time Varying Covariance”, Journal of political economic, 1988,vol 98 nº1: http://public.econ.duke.edu/~boller/Published_Papers/jpe_88.pdf

DURBIN, J., “Tests for Serial Correlation in Regression Analysis based on the Periodogram ofLeast-Squares Residuals,” Biometrika, 56, (No. 1, 1969), 1-15.

Engle, Robert F. (1974), Band Spectrum Regression,International Economic Review 15,1-11.

Friedman, M., 1957. A theory of the consumption function (Princeton University Press, Princeton, NJ).

Friedman, M. and Kuznets, S., 1945. Income from independent professional practice (National Bureau of Economic Research, NY).

Harvey, A.C. (1978), Linear Regression in the Frequency Domain, International Economic Review, 19, 507-512.

Parra F (2015): Seasonal Adjustment by Frequency Analysis. Package R Version 1.2. https://cran.r-project.org/web/packages/descomponer/index.html

Sharpe, W. (1964). “Capital Asset Prices: A Theory of Market Equilibrium Under Conditions of Risk,”, Journal of Finance, 19:425-442.

Sharpe, W.. (1990) : CAPITAL ASSET PRICES WITH AND WITHOUT NEGATIVE HOLDINGS. Nobel Lecture, December 7, 1990: http://www.nobelprize.org/nobel_prizes/economic-sciences/laureates/1990/sharpe-lecture.pdf

Wikipedia: Capital asset pricing model.https://en.wikipedia.org/wiki/Capital_asset_pricing_model

Zivot E. (2008): testCAPM.r : http://faculty.washington.edu/ezivot/econ424/testCAPM.r