Hi All.
I have a group of more than 100variables and I'd like to normalize the members (x(:,i)mean/std) and then create a new group. Is it a way to do that?
Thanks in advance.Veni
normalize a group of variables
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12540
 Joined: Tue Sep 16, 2008 5:38 pm
Re: normalize a group of variables
Something like:
Code: Select all
group mynewgroup
for !i=1 to mygroup.@count
%sn = mygroup.@seriesname(!i)
series {%sn}_norm = ({%sn}@mean({%sn}))/@stdev({%sn})
mynewgroup.add {%sn}
next
Follow us on Twitter @IHSEViews
Re: normalize a group of variables
Thanks a lot Gareth!
Construct a series from a series
Hi All
I have the following simple thing to do; given two series, namely phase and x, I'd like to construct four new series subject to some constraints fulfilled for the first one. That is if phase(i)=1, create a new series ret1, where ret1(i)=x(i), if phase(i)=2, then ret2(i)=x(i) etc.
Doing this
for !i=2 to @rows(x)1
if phase(!i)=1 then
!count1=!count1+1
ret1{!count1}=x{!i}
'I exclude the other options
endif
I've got an error that !count1 is not defined in !count1=!count1+1
and doing this
!count1=0
scalar phase1=0
for !i=2 to @rows(x)1
if phase(!i)=1 then
!count1=!count1+1
phase1=phase1+1
series ret1(!count1)=x(!i)
endif
next
I'm getting the series ret1 which has the same size as the original one (although the goal is to have as many rows as the count1).
Can you provide some advice? Many thanks in advance!
I have the following simple thing to do; given two series, namely phase and x, I'd like to construct four new series subject to some constraints fulfilled for the first one. That is if phase(i)=1, create a new series ret1, where ret1(i)=x(i), if phase(i)=2, then ret2(i)=x(i) etc.
Doing this
for !i=2 to @rows(x)1
if phase(!i)=1 then
!count1=!count1+1
ret1{!count1}=x{!i}
'I exclude the other options
endif
I've got an error that !count1 is not defined in !count1=!count1+1
and doing this
!count1=0
scalar phase1=0
for !i=2 to @rows(x)1
if phase(!i)=1 then
!count1=!count1+1
phase1=phase1+1
series ret1(!count1)=x(!i)
endif
next
I'm getting the series ret1 which has the same size as the original one (although the goal is to have as many rows as the count1).
Can you provide some advice? Many thanks in advance!

 Posts: 202
 Joined: Tue Jul 17, 2012 9:47 am
Re: normalize a group of variables
Bit late in seeing this, but the the MacroTrans addin was built for this (at least  the first post) type of purpose in a dated workfile context.

 EViews Developer
 Posts: 430
 Joined: Thu Apr 25, 2013 7:48 pm
Re: normalize a group of variables
Hello,
EViews can do the heavy lifting of matching and iterating through all the rows for you...
Since you want the four new result structures to contain only as many rows as are copied from series x, those structures need to vector objects instead of series objects. Series objects always contain as many rows (observations) as their enclosing workfile page, but vector objects can have any number of rows. Using the "smpl" command followed by an assignment/copy command is an easy way to get EViews to find and copy only the rows of data you want. I've wrapped that in a loop going through all your phase numbers, assuming they're always consecutive integers. You could add or remove phases without modifying the above code.
EViews can do the heavy lifting of matching and iterating through all the rows for you...
Code: Select all
for !i = @min(phase) to @max(phase)
smpl if phase = !i
vector ret{!i} = x
next
smpl @all
Since you want the four new result structures to contain only as many rows as are copied from series x, those structures need to vector objects instead of series objects. Series objects always contain as many rows (observations) as their enclosing workfile page, but vector objects can have any number of rows. Using the "smpl" command followed by an assignment/copy command is an easy way to get EViews to find and copy only the rows of data you want. I've wrapped that in a loop going through all your phase numbers, assuming they're always consecutive integers. You could add or remove phases without modifying the above code.
Re: normalize a group of variables
Matt, thank you so much for replying so quickly and for the code. Can you suggest some reading? Unfortunately, I'm matlab user.

 EViews Developer
 Posts: 430
 Joined: Thu Apr 25, 2013 7:48 pm
Re: normalize a group of variables
You're welcome.
Reading specifically regarding EViews programming? Here are some ideas:
Reading specifically regarding EViews programming? Here are some ideas:
Re: normalize a group of variables
Thank you so much!
Who is online
Users browsing this forum: No registered users and 10 guests