Tutorial import data and set the fname?

I am a newbie here.

Please, I am trying to run a simple unit root test importing my own txt data (btc.txt). I used the wizard tool to import (it only has 1 column), and then I was trying to set the data using the following steps:

library tsmt;

fname = "btc.txt";

//Load Data

btc = loadd("btc.txt");

p = 0;
l = 3;
{ alpha, tstat_adf, adf_t_crit } = vmadfmt(btc, p, l);
print "tstat_adf"; tstat_adf;

However, I couldn't go through.

Thank you

5 Answers



0



What happened exactly? Did you get an error report?

aptech

1,773


0



The error mesage:

error: file 'btc.txt' of unknown type
[formula_parse.src, line 79]

File saveload.src, line 70, in __loadd
ret = __LoadFormulaCallback(dataset, formula, tmp, tmp, 0, tmp, string_read);
File saveload.src, line 80, in loadd
retp(__loadd(dataset, 0, ...));

 

Thank you!



0



The problem is that loadd does not know what type of file it is. If this file has a header (or variable name) on the first line, then you should change the name to btc.csv and loadd will work.

Alternatively, you could add a file schema to the front of the file name to tell loadd that it is a CSV file, like this:

// Use file schema 'csv://' to tell loadd that
// btc.txt is a CSV file.
btc = loadd("csv://btc.txt");

aptech

1,773


0



Hi, sorry. But it did not work.

new;

fname = "btc.txt";
btc = loadd("csv://BTC.txt");
p = 0;
l = 3;
{ alpha, tstat_adf, adf_t_crit } = vmadfmt(btc, p, l);
print "tstat_adf"; tstat_adf;

Invalid characters in headers: '-' in '-0.133531'

Currently active call:

File formula_parse.src, line 219, in __reader_init
end;
Traceback:

File formula_parse.src, line 172, in __loadFormula
__reader_init(r);
File formula_parse.src, line 87, in __LoadFormulaCallback
retp(__loadFormula(&r, ...));
File saveload.src, line 70, in __loadd
ret = __LoadFormulaCallback(dataset, formula, tmp, tmp, 0, tmp, string_read);
File saveload.src, line 80, in loadd
retp(__loadd(dataset, 0, ...));

Please, follow my txt (header)

-0.133531
0.133531
-0.470004
0.182322
0
0
0
0.154151
-0.154151
0
0
0
0
0
0.154151



0



As I mentioned, loadd is for data files with variable names. Your file does not have variable names at the top. That is why you got the error message:

Invalid characters in headers: '-' in '-0.133531'

You can either add a variable name to the first line of the file, or use csvReadM.

btc = csvReadM("bc.txt");

aptech

1,773

Your Answer

5 Answers

0

What happened exactly? Did you get an error report?

0

The error mesage:

error: file 'btc.txt' of unknown type
[formula_parse.src, line 79]

File saveload.src, line 70, in __loadd
ret = __LoadFormulaCallback(dataset, formula, tmp, tmp, 0, tmp, string_read);
File saveload.src, line 80, in loadd
retp(__loadd(dataset, 0, ...));

 

Thank you!

0

The problem is that loadd does not know what type of file it is. If this file has a header (or variable name) on the first line, then you should change the name to btc.csv and loadd will work.

Alternatively, you could add a file schema to the front of the file name to tell loadd that it is a CSV file, like this:

// Use file schema 'csv://' to tell loadd that
// btc.txt is a CSV file.
btc = loadd("csv://btc.txt");

0

Hi, sorry. But it did not work.

new;

fname = "btc.txt";
btc = loadd("csv://BTC.txt");
p = 0;
l = 3;
{ alpha, tstat_adf, adf_t_crit } = vmadfmt(btc, p, l);
print "tstat_adf"; tstat_adf;

Invalid characters in headers: '-' in '-0.133531'

Currently active call:

File formula_parse.src, line 219, in __reader_init
end;
Traceback:

File formula_parse.src, line 172, in __loadFormula
__reader_init(r);
File formula_parse.src, line 87, in __LoadFormulaCallback
retp(__loadFormula(&r, ...));
File saveload.src, line 70, in __loadd
ret = __LoadFormulaCallback(dataset, formula, tmp, tmp, 0, tmp, string_read);
File saveload.src, line 80, in loadd
retp(__loadd(dataset, 0, ...));

Please, follow my txt (header)

-0.133531
0.133531
-0.470004
0.182322
0
0
0
0.154151
-0.154151
0
0
0
0
0
0.154151

0

As I mentioned, loadd is for data files with variable names. Your file does not have variable names at the top. That is why you got the error message:

Invalid characters in headers: '-' in '-0.133531'

You can either add a variable name to the first line of the file, or use csvReadM.

btc = csvReadM("bc.txt");


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.