Page 1 of 1

number of positive obs and runs in series

Posted: Fri Feb 19, 2016 7:53 am
by ch2324
Hi everybody,
how can calculate number of positive obs in the series?
when i use this command message error "syntax error"

Code: Select all

scalar nobsp nobsp=@obs(resid) if resid>0
have you an idea with this case.

Re: number of positive obs in series

Posted: Fri Feb 19, 2016 8:06 am
by startz

Code: Select all

series posSum = @sum(resid>0)

Re: number of positive obs and runs in series

Posted: Fri Feb 19, 2016 8:13 am
by ch2324
thanks Mr startz, another question please, how get the number of positive obs in the scalar? an error message "Scalar sent to function which operates on a matrix." and how can calculate the number of runs in the resid?

Code: Select all

scalar nobsp nobop=@sum(resid>0)

Re: number of positive obs and runs in series

Posted: Fri Feb 19, 2016 8:54 am
by startz
No idea. Sorry.

Re: number of positive obs and runs in series

Posted: Fri Feb 19, 2016 9:29 am
by EViews Gareth
What's the definition of a "run"?

If it is simply any time resid switches from negative to positive or vice versa...

Code: Select all

series posres = resid>0 series runs = @recode(@trend=0, 1, (resid>0 and resid(-1)>0) or (resid<0 and resid(-1)>0)) scalar nobsp = @sum(posres) scalar nobsr = @sum(runs)

Re: number of positive obs and runs in series

Posted: Fri Feb 19, 2016 1:00 pm
by ch2324
a tiny mistake :oops: the correct code is:

Code: Select all

series runs = @recode(@trend=0, 1, (resid>0 and resid(-1)<0) or (resid<0 and resid(-1)>0))
thanks million Mr Gareth & Mr startz for your help :D