Code: Select all
'This program generates some data, y and a bunch of Xs (put in a group called XS), then calculates the standardized coefficients of a regression of Y on Xs. These coefficients are put in a vector called sbetas
'To use this on a real workfile, not generated data, delete between GENERATE SOME DATA and PERFORM REGRESSION. You can change the name of the series and the name of the group containing the other series here:
%seriesname = "Y"
%groupname = "XS"
'GENERATE SOME DATA
rndseed 1
create u 100
group {%groupname}
for !i=1 to 10
%name="x" + @str(!i)
series {%name} =nrnd
{%groupname}.add {%name}
next
series {%seriesname}=nrnd
'PERFORM REGRESSION
equation eq1.ls {%seriesname} {%groupname}
!count={%groupname}.@count
vector(!count) sbetas
!stdevY = @stdev({%seriesname})
for !i=1 to !count
%name={%groupname}.@seriesname(!i)
!stdevX=@stdev({%name})
sbetas(!i)=eq1.@coefs(!i) * ( !stdevX/ !stdevY )
next