Monte Carlo simulation with recserar

I am struggling to get my matrices conformable when calculating a Monte Carlo Simulation using the recserar function. How can I set this up?

1 Answer



0



Below is an example of recserar usage:

new;
n = 10;

//Create multivariate random numbers
sigma = {   1 -0.3, 
         -0.3    1 };
means = { 0, 0 };
err = rndMVn(n, means, sigma);

//Create predictor matrix
//with 3 random predictor columns
//and a column of ones for the intercept
x = ones(n,1)~rndn(n,3);

//Create the intercept and 3 coefficients
b = { 1, 
      2, 
      3, 
      4 };
      
//Simulate linear model
x_sim = x * b + err;

//First values of output 'y'
y0 = { 0 0 };

rho = { 0.5 0.3 };

//Create autoregressive recursive series
y = recserar(x_sim,y0,rho);

Does that help?

aptech

1,773

Your Answer

1 Answer

0

Below is an example of recserar usage:

new;
n = 10;

//Create multivariate random numbers
sigma = {   1 -0.3, 
         -0.3    1 };
means = { 0, 0 };
err = rndMVn(n, means, sigma);

//Create predictor matrix
//with 3 random predictor columns
//and a column of ones for the intercept
x = ones(n,1)~rndn(n,3);

//Create the intercept and 3 coefficients
b = { 1, 
      2, 
      3, 
      4 };
      
//Simulate linear model
x_sim = x * b + err;

//First values of output 'y'
y0 = { 0 0 };

rho = { 0.5 0.3 };

//Create autoregressive recursive series
y = recserar(x_sim,y0,rho);

Does that help?


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.