How to deal with zeros in data?

Discussions of ARCH, GARCH, and related models
Aixia_Mei
Posts: 29
Joined: Wed Dec 03, 2014 7:16 pm

Re: How to deal with zeros in data?

Unread post by Aixia_Mei »

TomDoan wrote:The following will give you a count of consecutive zeroes in the series x:

set(first=(x==0.0)) zerocount = %if(x==0,zerocount{1}+1,0.0)

Following your construction, I edit my codes, and it works.
Thanks for that.

But one more issue arises in the following codes:

***Setting dummy varibles
set ssmt = t>=2010:03:31
***Setting deterministic trend
set zerocount = %if(r1{1}==0,zerocount{1}+1,0.0)
set nt = zerocount
***
set v = %variance
set u = 0.0
frml et = r1-b0-b1*v-(b2+b3*v+b4*ssmt*v)*r1{1}
frml ot = %exp(a4*ssmt+%log(1+a5*nt))
frml ht = ot*(a0+a1*u{1}**2/ot{1}+a2*v{1}/ot{1}+%if(u{1}<0.0, a3*u{1}**2/ot{1}, 0.0))

For the line frml ot, RATS keeps reporting a mistake as:
## SX22. Expected Type REAL, Got MATRIX[REAL] Instead
>>>>smt+%log(1+a5*nt))<<<<

How can this mistake be solved?

Regards,
Aixia
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to deal with zeros in data?

Unread post by TomDoan »

exp and log are used for the scalar functions. %exp and %log are element-by-element matrix functions.
Aixia_Mei
Posts: 29
Joined: Wed Dec 03, 2014 7:16 pm

Re: How to deal with zeros in data?

Unread post by Aixia_Mei »

Many thanks Tom.

One more question about the supplementary card. My codes are as follows:

***
restrict 1
#3 6
# 1.0-1.0 0.0
restrict 1
#4 7
# 1.0-1.0 0.0
restrict 1
#5 8
# 1.0-1.0 0.0

restrict 3
#3 6
# 1.0-1.0 0.0
#4 7
# 1.0-1.0 0.0
#5 8
# 1.0-1.0 0.0

But RATS reports a mistake as:
## SC3. Expected 3 Entries on Supplementary Card, Got 2

I can't understand where the problem is.

Regards,
Aixia
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to deal with zeros in data?

Unread post by TomDoan »

# 1.0-1.0 0.0

No space between the 1.0 and -1.0.
1003064
Posts: 2
Joined: Mon Jul 22, 2019 3:07 am

Re: How to deal with zeros in data?

Unread post by 1003064 »

Tom,

What is %LNGAMMA in the above code and where can I find more information on this?
Post Reply