Upload data- dbload not working- all values NaN

199 views
Skip to first unread message

SS

unread,
Jul 27, 2012, 5:48:57 AM7/27/12
to iris-t...@googlegroups.com
I am very new to Matlab and am trying to upload data using IRIS for a DSGE model, but the dbload command isn't working.

It's a time series database(quarterly) with 14 variables for 160 time periods- saved in a CSV (comma delimited) file.
The command I'm using is: d=dbload('filename.csv')

But Matlab is not reading the data. When I check for the structure 'd' in the workspace- it has 14 fields within it- one for each variable. However, when I open the the fields, all values are displayed as NaN. Why do you think this is?

I also tried tweaking the command: d = dbload(’filename.csv’, ’freq’,4,’dateFormat’,’YYYY-MM-01’)
But this also didnt work- same problem.

In fact I tried uploading a dataset from one of the tutorials: Jaromir's Tutorials- Simple SPBC model. I tried uploading the 'Simple_SPBC_quarterly.csv' dataset using:
Raw4 = dbload(’Simple_SPBC_quarterly.csv’, ...
’freq’,4,’dateFormat’,’YYYY-MM-01’);


But this didnt work either. I can't figure out what I'm doing incorrectly. Please help!

Thanks in advance!

Jaromir Benes

unread,
Jul 27, 2012, 6:48:38 AM7/27/12
to iris-t...@googlegroups.com

Jaromir Benes

unread,
Jul 27, 2012, 6:53:16 AM7/27/12
to iris-t...@googlegroups.com
Hi,

the database loads all right. The only thing you need to know is that you cannot open IRIS time series objects in the workspace variables editor -- which is actually what you're trying to do.

To view the contents of a time series, just type its name in the command window, e.g.

>> d.XXX

where d is a database and XXX is the name of a time series in that database. You can also view the observations within a specified range only, e.g.

>> d.XXX(qq(2010,1):qq(2012,4))

etc. To manipulate/change existing tseries objects, use again commands (in the command window or in your m-files), do not try to use the variables editor. For instance

>> d.XXX(qq(2010,1):qq(2012,4)) = 0;

There's also one or two tutorials on time series and database management available from the iris web site. Might be useful for you to go through them, too.

And of course, let me know should you have any further questions.

Best,
Jaromir


On Friday, July 27, 2012 11:48:57 AM UTC+2, SS wrote:

SS

unread,
Jul 27, 2012, 7:08:28 AM7/27/12
to iris-t...@googlegroups.com
Thank you, very much.
I was getting worried the data isn't loading.

Best.

bogmunds

unread,
Sep 19, 2012, 2:46:44 PM9/19/12
to iris-t...@googlegroups.com
I am also having a problem loading data. I can load the example csv files fine, but when I read the ones that I have created, the database loads blank (the variable names are read, but there are no values). Is there a compatability problem with Excel 2010?

Thanks.

Jaromir Benes

unread,
Sep 19, 2012, 2:50:52 PM9/19/12
to iris-t...@googlegroups.com
I guess this is most likely because of the date format you use, or because the dates are not correctly saved in the CSV file (this happens quite often).

Can you please post one the CSVs you've created? (use the "Attach a file" button here).

I'll be then able to fix the problem, and explain what exactly went wrong.

Jaromir

bogmunds

unread,
Sep 19, 2012, 3:01:36 PM9/19/12
to iris-t...@googlegroups.com
Thanks. File is attached.
nk_data.csv

Jaromir Benes

unread,
Sep 19, 2012, 3:23:27 PM9/19/12
to iris-t...@googlegroups.com
This will do the job:

    d = dbload('nk_data.csv','dateformat=','01/MM/YYYY','freq=',4)

First, you need to specify the date format in which your dates appear. The default IRIS date formats are 1999M12 for monthly dates, 1999Q1 for quarter dates, etc. If your date format is different, you have to use the 'dateformat=' option to tell IRIS what it is.

Second, because you have quarterly data but they are labeled using months (like 01/07/1995 for the third quarter 1995) you also have to specify that the dates are. indeed, quarterly. Otherwise, IRIS will interpret them as monthly data, with only every third observation available (just go and run the command without the 'freq=' option, and you'll see what happens).

J.

bogmunds

unread,
Sep 19, 2012, 3:26:46 PM9/19/12
to iris-t...@googlegroups.com
That did it. Thank you so much for the time. Really appreciate it. 

Jaromir Benes

unread,
Sep 19, 2012, 3:35:09 PM9/19/12
to iris-t...@googlegroups.com
No worries.
Reply all
Reply to author
Forward
0 new messages