# Generating financial data

I am trying to generate monthly stock data using a one-factor model:

$$R_{a,t} = \alpha + BR_{b,t}+\epsilon_{t}$$

The description says:

$R_{a,t}$ is the excess asset returns vector, $\alpha$ is the mispricing coefficients vector, $B$ is the factor loadings matrix, $R_{b,t}$ is the vector of excess returns on the factor portfolios, $R_{b}-N(\mu_{b},\sigma_{b})$, and $\epsilon_{t}$ is the vector of noise, $\epsilon - N(0,\sum_{e})$, which is independent with respect to the factor portfolios.

For our simulations, we assume that the risk-free rate follows a normal distribution, with an annual average of 2% and a standard deviation of 2%. We assume that there is only one factor (K=1), whose annual excess return has an annual average of 8% and a standard deviation of 16%. The mispricing $\alpha$ is set to zero and the factor loadings, B, are evenly spread between 0.5 and 1.5. Finally, the variance-covariance matrix of noise, $\sum_{\epsilon}$, is assumed to be diagonal, with elements drawn from a uniform distribution with support [0.10,0.30], so that the cross-sectional average annual idiosyncratic volatility is 20%.

Using the information provided here I try to generate the data:

alpha <- 0 #mispricing index is set to 0

R <- rnorm(100,mean=8/12,sd=16/sqrt(12)) #factor with annual excess return of 8% and standard deviation of 16%

epsilon <- rnorm(100, mean=0,sd=runif(10,min=0.1,max=0.30)) #error term with mean 0 and standard deviation drawn from a uniform distribtion


Then I generate the data:

data <- alpha + B*R + epsilon


My question is: is this the correct way to do it or am I missing something?

• By definition a diagonal matrix has zero entries in non-diagonal positions. In your case the diagonal elements are picked randomly between 0.1 and 0.3. – noob2 Jan 12 '16 at 14:30
• I would like to know whether I understand the process correctly. The text does not explain what the subscripts 'a' and 'b' stand for. – user3742038 Jan 15 '16 at 11:19
• R_a are returns for actual securities (stocks?), while R_b are returns on factors generate or drive the returns on the stocks. In your case however, there is only one factor. So superficially (i.e. without compiling it or testing it) your code seems right. – noob2 Jan 15 '16 at 18:20