Introduction to GAUSS: Generating Data From a Linear Model

Introduction

Simulated data can be very useful for testing models, function, and program files. In this tutorial we will be use GAUSS random number generators and matrix operations to simulate linear data:

$$y_i = \beta_0 + \beta_{1} + \epsilon_i$$

For this exercise, let's work from the GAUSS command line.

GAUSS Command Page.

The Command Page in GAUSS provides a large Program Input/Output Window for entering interactive commands in GAUSS and seeing the printed output.

Cleaning up the workspace

Our first step is to clean up the workspace and screen. A clean workspace helps to ensure that previously used data matrices don't interfere with our current work.

First, place your cursor in the program input/output window. To clear out any previously assigned variables from the workspace, enter:

new;

Next, to clear any previously printed output from the screen enter:

cls;

You should now see these two commands in your Command History Window under the italicized heading, Today.

GAUSS interactive commands.

Randomly generating data

Now that we have a clean workspace we will generate our x data using the GAUSS rndn function. The GAUSS function rndn generates normally distributed numbers. You can change the variance (standard deviation) by multiplying the standard normal numbers by the desired variance.

Place your cursor at the GAUSS command-line again and enter:

x = rndn(500, 1);

Confirm that the matrix was created by entering:

print x;

The print keyword will print the output directly to the Program Input/Output Window.

From the GAUSS command-line, enter:

err = 5 * rndn(500, 1);

Simulating the y data

Now to finish generating our data we need to specify the parameters of the model and generate the dependent data according to the model specified above: $$ \beta_0 = 2.0\\ \beta_1 = 3.5\\ y_i = 2 + 3.5x_i + \epsilon_i $$

Create a new 1x1 matrix b_0 set equal to 2 by entering the following statement on the command line:

b_0 = 2;

Create a new 1 x 1 matrix b_1 set equal to 3.5 by entering the following statement on the command line:

b_1 = 3.5;

Create the matrix y using the previously created b_0, b_1, x, and err by entering the following statement on the command line:

y = b_0 + b_1*x + err;

Creating a program file

All the steps above were performed in the command window. However, it is easy to use the Command History Window to copy these actions into a program file. This program file can be saved and used later to run this code again.

Send command history to a program file.

Figure 3: Sending multiple commands to a new program file.

Use the mouse to select the commands that you wish to copy to a program file. You may click-and-drag, or hold down the SHIFT button or the CTRL button to and select the desired files with your mouse.

Once you have selected the files, hold your mouse over the files and right-click to bring up a context menu. From the context menu, select Send to File.

Conclusion

Congratulations! In this tutorial you have learned how to:

  • Clear the screen and workspace.
  • Generate random data.
  • Use matrix operations to simulate data.
  • Create a program file using the command line history

Continue to Viewing Data in GAUSS

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

REQUEST A FREE QUOTE

Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap