Page 1 of 1

GENERATING RANDOM NORMAL DRAWS

Posted: Sun Dec 10, 2023 6:57 am
by ndzama
Dear Eviews team

'==========================='
'CALCUTLATING FORECAST ERROR, ITS VARIANCE, and generating RANDOM DRAWS
'==============================
genr error_CA_{%h}Y_{%c}_AR = CA_{%c} - CA_{%c}_0_AR 'actual-forecast = error
scalar errorvariance_CA_{%h}Y_{%c}_AR=@var( error_CA_{%h}Y_{%c}_AR) 'Forecast error variance
scalar num_draws_AR = 1000 'Set the number of random draws you want to generate random draws from the normal distribution
series draws_errorvariance_CA_{%h}Y_{%c}_AR=@rnorm(num_draws, 0, @sqrt(errorvariance_CA_{%h}Y_{%c}_AR)) ' generate random draws from
the normal distribution //

ON THE LAST LINE OF THIS CODE I KEEP GETTING A SYNTAX ERROR. I cannot figure out why. Please advice.

Kind Regards,
Florence

Re: GENERATING RANDOM NORMAL DRAWS

Posted: Sun Dec 10, 2023 7:05 pm
by EViews Gareth
Without the rest of the code and/or workfile impossible to say. But you probably need to have had defined num_draws

Re: GENERATING RANDOM NORMAL DRAWS

Posted: Mon Dec 11, 2023 11:23 am
by EViews Matt
Quick follow up... EViews' @rnorm function is parameterless since it returns draws from the standard normal distribution. You can adjust your genr statement accordingly, e.g.,

Code: Select all

series draws_errorvariance_CA_{%h}Y_{%c}_AR = @rnorm * @sqrt(errorvariance_CA_{%h}Y_{%c}_AR)

Re: GENERATING RANDOM NORMAL DRAWS

Posted: Wed Dec 20, 2023 8:25 am
by ndzama
Quick follow up... EViews' @rnorm function is parameterless since it returns draws from the standard normal distribution. You can adjust your genr statement accordingly, e.g.,

Code: Select all

series draws_errorvariance_CA_{%h}Y_{%c}_AR = @rnorm * @sqrt(errorvariance_CA_{%h}Y_{%c}_AR)

Thank you for the responses.
The problem with @rnorm syntax does not allow multiple random draws, e.g 1000

@rmvnorm works well for a VAR model. I can generate 1000 random draws.
matrix draw_var_{%c}=@rmvnorm(covs_{%c}, 1000) 'random draws from the normal distribution

How can I draw these 1000 draws using a simple AR model? I have tried @rnorm and @nrnd

Re: GENERATING RANDOM NORMAL DRAWS

Posted: Fri Dec 22, 2023 8:54 am
by ndzama
Greetings,

Problem solved. After the @rnorm code you suggested, I simply created a new page with 1000 random observations, then wala!


Again thank you for your help. Much appreciated.