### Aptech Systems, Inc. Worldwide Headquarters

Address:

Aptech Systems, Inc.

2350 East Germann Road, Suite #21

Chandler, AZ 85286Phone: 360.886.7100

FAX: 360.886.8922**Ready to Get Started?**### Request Quote & Product Information

### Industry Solutions

### Products

### Resources

### Support

### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

### What’s New in GAUSS 17

### Want to find out more?

### Have a Specific Question?

### Q&A: Register and Login

### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!

### Where to Buy

Available across the globe, you can have access to GAUSS no matter where you are.

### Recent Tags

applications character vectors CML CMLMT Constrained Optimization datasets dates dlibrary dllcall econometrics Editor error error codes error handling errors Excel file i/o GAUSS Engine GAUSS Light graphics GUI hotkeys installation license licensing linux loading data loop loops matrix manipulation Maximum Likelihood Maxlik MaxLikMT Memory multidimensional array optimization Optmum output panel data PQG graphics procs random numbers strings structures threading### Recent Questions

### Features

### Time Series 2.0 MT

### Industry Solutions

### Find out more now

### Time Series MT 2.1

### Find out more now

### Find out more now

# Resources

# loading data and creating independent and dependent variable

Hey guys,

I am new in Gauss but i am willing to learn it. There is a code below about a cointegration model's data's uploading. I could not understand what should i input in the second part.

load data[7000,4]=C:\Users\user\Desktop\gauss\coin\returns.txt;

datap=data[? , ?]~data[?,?]~data[?,?];

I think sceond line about the definition of dependent and indepenedent variables. Btw I have one dependent and 3 independent variable. Do you have any idea

Best

B&D

## 2 Answers

The second line is arranging the columns in some manner to create a new matrix that I am guessing will be the independent variable. To understand the second line you posted and know how to use it, you need to know how to index matrices in GAUSS and also about matrix concatenation.

The main things to know are that the tilde operator `~` performs horizontal concatenation. While we are at it, we may as well mention that the pipe operator `|` performs vertical concatenation. For example:

```
//Create some data to play with
A = { 1, 2, 3, 4 };
B = { 7, 8, 9, 10 };
C = { 13, 17, 19, 23 };
```

will create two column vectors:

1 7 13 A = 2 B = 8 C = 17 3 9 19 4 10 23

We can create a new matrix `X` which contains the contents of all three matrices above with the tilde operator, like this:

```
//Horizontal concatenation of three column vectors
X = A~B~C;
```

Now in addition to the vectors `A`, `B` and `C`, we will have this matrix `X` below:

1 7 13 X = 2 8 17 3 9 19 4 10 23

Now let's introduce indexing. GAUSS uses square brackets `[ ]` to indicate an indexing operation. The square brackets will contain a comma separated list of indices. Since we are dealing with matrices here (not N-dimensional arrays) we will have only two indices--one for the rows and the second for the columns. For example:

```
//Extract one element
Z = X[2, 3];
```

will assign `Z` to equal 17. You can use the colon operator to indicate a range. So if we wanted to assign `Z` to equal the second, third and fourth elements from the third column of `X`, we would use this command:

Z = X[2:4, 3];

and `Z` would now equal:

17 Z = 19 23

The final operator that you need to know to use indexing is the dot operator `'.'`. A dot inside the indexing brackets means "all" rows or columns. For example, to set `Z` to equal the second column of `X` could be done like this:

Z = X[.,2];

We could set `Z` equal to the third row of `X` like this:

Z = X[3,.];

Finally, it is very common to load a matrix with multiple variables in which the first column is the dependent variable and all subsequent columns are independent variables. Continuing to use the three column `X` from above, we might do something like this:

//Create 'indvar' from first column of 'X' indvar = X[.,1]; //Create 'depvar' from 2nd and 3rd columns of 'X' depvar = X[.,2:3];

Play around with this and post any further questions that come up.

Thank you very much for all the information

## Your Answer

## 2 Answers

The second line is arranging the columns in some manner to create a new matrix that I am guessing will be the independent variable. To understand the second line you posted and know how to use it, you need to know how to index matrices in GAUSS and also about matrix concatenation.

The main things to know are that the tilde operator `~` performs horizontal concatenation. While we are at it, we may as well mention that the pipe operator `|` performs vertical concatenation. For example:

```
//Create some data to play with
A = { 1, 2, 3, 4 };
B = { 7, 8, 9, 10 };
C = { 13, 17, 19, 23 };
```

will create two column vectors:

1 7 13 A = 2 B = 8 C = 17 3 9 19 4 10 23

We can create a new matrix `X` which contains the contents of all three matrices above with the tilde operator, like this:

```
//Horizontal concatenation of three column vectors
X = A~B~C;
```

Now in addition to the vectors `A`, `B` and `C`, we will have this matrix `X` below:

1 7 13 X = 2 8 17 3 9 19 4 10 23

Now let's introduce indexing. GAUSS uses square brackets `[ ]` to indicate an indexing operation. The square brackets will contain a comma separated list of indices. Since we are dealing with matrices here (not N-dimensional arrays) we will have only two indices--one for the rows and the second for the columns. For example:

```
//Extract one element
Z = X[2, 3];
```

will assign `Z` to equal 17. You can use the colon operator to indicate a range. So if we wanted to assign `Z` to equal the second, third and fourth elements from the third column of `X`, we would use this command:

Z = X[2:4, 3];

and `Z` would now equal:

17 Z = 19 23

The final operator that you need to know to use indexing is the dot operator `'.'`. A dot inside the indexing brackets means "all" rows or columns. For example, to set `Z` to equal the second column of `X` could be done like this:

Z = X[.,2];

We could set `Z` equal to the third row of `X` like this:

Z = X[3,.];

Finally, it is very common to load a matrix with multiple variables in which the first column is the dependent variable and all subsequent columns are independent variables. Continuing to use the three column `X` from above, we might do something like this:

//Create 'indvar' from first column of 'X' indvar = X[.,1]; //Create 'depvar' from 2nd and 3rd columns of 'X' depvar = X[.,2:3];

Play around with this and post any further questions that come up.

Thank you very much for all the information