Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use SAS or SAS Studio If x and x' are distributed as two independent standard normal variables and y=rho*x+sqrt(1-rho)*x, then x and y have a

Use SAS or SAS Studio
image text in transcribed
If x and x' are distributed as two independent standard normal variables and y=rho*x+sqrt(1-rho)*x, then x and y have a standard bivariate normal distribution with correlation=rho. From this standard bivariate distribution, you can scale x any y to have any mean and standard deviation by simply multiplying by the standard deviation and adding the mean. The result remains bivariate with a correlation between x and y of rho. Create a macro named binorm that creates a data set with the random variables x and y generated from a bivariate normal distribution. Give binorm the keyword parameters mux, muy, stdx, stdy, rho and seed that allow you to set the means, standard deviations, correlation between x and y and the seed for the random number generator. Have these parameters default to generate x and y from two independent (i.e. rho=0) standard normal distributions with a seed based on the computers internal clock. Add the parameters n and sims that allow you to specify how many observations to generate. You will generate n observations for each of sims simulations. Have n and sims default to 100 and 1 respectively. Add a parameter named outdata that allows you to define the name of the data set created. outdata should default to binorm. The final data set will have n*sims observations with the variables simnum, x and y only, simnum will be 1 for the first n records, 2 for the next n records and so on. Add a final parameter to the macro named plot that defaults to N. When plot is set to Y, have the macro generate a simple scatter plot of y vs. x. Make the plot parameter insensitive to case and any additional letters after the first letter so that a plot will be generated if and only if the plot parameter value that starts with y or Y. Put a main title on the figure saying "Plot of y vs. x" and a second title that would say "n=10000, X-N(0,1), Y-N(0, 1), corr(x, y)=0" for the default settings, but would report the actual settings if they were different from the default. Note that in the title N(0, 1) means normal with a mean of O and variance of 1 which is the standard normal distribution, so 0 and 1 may change depending on the settings of the parameters. Define any new macro variables created in the macro as local to the macro. Make sure no extra spaces appear in the title. When the plot=Y, have the macro generate a separate plot for each simulation. The simulation number should appear automatically as the third title on the plot. Run a simulation of n=100,000 and use PROC CORR to validate that the generated estimates are close to your parameter settings. Try for a couple settings. Try running this macro with default settings except turn the plot option on and run for correlations 0, 0.2, 0.5 and 0.9 respectively. Next try running five simulations of sample size 50 with plots for correlations and 0.2. With a sample size of 50 can you tell the difference between a correlation of O and 0.2? If x and x' are distributed as two independent standard normal variables and y=rho*x+sqrt(1-rho)*x, then x and y have a standard bivariate normal distribution with correlation=rho. From this standard bivariate distribution, you can scale x any y to have any mean and standard deviation by simply multiplying by the standard deviation and adding the mean. The result remains bivariate with a correlation between x and y of rho. Create a macro named binorm that creates a data set with the random variables x and y generated from a bivariate normal distribution. Give binorm the keyword parameters mux, muy, stdx, stdy, rho and seed that allow you to set the means, standard deviations, correlation between x and y and the seed for the random number generator. Have these parameters default to generate x and y from two independent (i.e. rho=0) standard normal distributions with a seed based on the computers internal clock. Add the parameters n and sims that allow you to specify how many observations to generate. You will generate n observations for each of sims simulations. Have n and sims default to 100 and 1 respectively. Add a parameter named outdata that allows you to define the name of the data set created. outdata should default to binorm. The final data set will have n*sims observations with the variables simnum, x and y only, simnum will be 1 for the first n records, 2 for the next n records and so on. Add a final parameter to the macro named plot that defaults to N. When plot is set to Y, have the macro generate a simple scatter plot of y vs. x. Make the plot parameter insensitive to case and any additional letters after the first letter so that a plot will be generated if and only if the plot parameter value that starts with y or Y. Put a main title on the figure saying "Plot of y vs. x" and a second title that would say "n=10000, X-N(0,1), Y-N(0, 1), corr(x, y)=0" for the default settings, but would report the actual settings if they were different from the default. Note that in the title N(0, 1) means normal with a mean of O and variance of 1 which is the standard normal distribution, so 0 and 1 may change depending on the settings of the parameters. Define any new macro variables created in the macro as local to the macro. Make sure no extra spaces appear in the title. When the plot=Y, have the macro generate a separate plot for each simulation. The simulation number should appear automatically as the third title on the plot. Run a simulation of n=100,000 and use PROC CORR to validate that the generated estimates are close to your parameter settings. Try for a couple settings. Try running this macro with default settings except turn the plot option on and run for correlations 0, 0.2, 0.5 and 0.9 respectively. Next try running five simulations of sample size 50 with plots for correlations and 0.2. With a sample size of 50 can you tell the difference between a correlation of O and 0.2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Geography Of Finance

Authors: Gordon L. Clark, Darius Wójcik

1st Edition

0199213364, 978-0199213368

More Books

Students also viewed these Finance questions

Question

3. What should a contract of employment contain?

Answered: 1 week ago

Question

1. What does the term employment relationship mean?

Answered: 1 week ago