资源描述
序列的操作
2.创建数组(group)
多个序列组合而成,以便对组中的所有变量同时执行某项操作。数组和各个序列之间是一种链接关系,修改序列的数据、更改序列名、删除序列等操作,都会在数组中产生相应的变化。
1)创建完文件后,使用data建立数据组变量;若有word表格数据或excel数据,直接粘贴;或者用Import 从其它已有文件中直接导入数据。
data x y,…
可以同时建立几个变量序列,变量值按列排列,同时在表单上出现新建的组及序列,且可以随时在组中添加新的序列。利用组的优点:一旦某个序列的数据发生变化,会在组中和变量中同时更新;数组窗口可以直接关闭,因为工作文件中已保留了有关变量的数据。
2)通过已有序列建立一个需要的组:group mygroup x y
可以在组中直接加入滞后变量 group mygroup y x(0 to -1)
3.创建标量:常数值
scalar val = 10 show val 则在左下角显示该标量的值
6.向量
列向量对象 vector、行向量对象 rowvector、系数向量对象 coeff
vector vect:定义了一个一维且取值为0 的列向量
vector(n) vect:定义一个n维且取值为0的列向量
vect.fill 1, 3, 5, 7, 9 :定义了分量的值
vector(n) vect=100:定义一个n维且取值为100的列向量
行向量对象 rowvector、系数向量对象 coeff 类似
4.创建变量序列
series x
series y
data x y
series z = x + y
series fit = Eq1.@coef(1) + Eq1.@coef(2) * x
利用两个回归系数构造了拟合值序列
4)排序:在workfile窗口,执行主菜单上的procs/sort series,可选择升序或降序:Sort x:则y随之移动,即不破坏对应关系。
sort(d) x:按降序排序,注意所有的其它变量值都会随之相应移动。
5.生成变量序列
genr 变量名 = 表达式
genr xx = x^2 genr yy = val * y
genr zz = x*y (对应分量相乘) genr zz = log(x*y) (各分量求对数)
genr lnx = log(x) genr x1 = 1/x
genr Dx = D(x) genr value = 3(注意与标量的区别)
genr hx = x*(x>=3)(同维新序列,小于3的值变为0,其余数值不变)
1)表达式表示方式:可以含有>,<,<>,=,<=,>=,and,or。
2)简单函数:
D(X):X的一阶差分
D(X,n):X的n阶差分
LOG(X):自然对数
DLOG(X) :自然对数增量LOG(X)-LOG(X(-1))
EXP(X) :指数函数
ABS(X) :绝对值
SQR(X) :平方根函数
RND:生成0、1间的随机数
NRND:生成标准正态分布随机数。
1. 一般函数
@abs(x) @log(x) @exp(x) @inv(x) @sqrt(x)=sqr(x)
分别表示 |x| lnx ex 1/x
@pch(x)=(x-x(-1))/x(-1) @seas(n) (seasonal dummy) @obs(X)(观察值个数N) @mean(X) @max(X) @min(X) @sum(X) @var(X)(分母n) @cor(X,Y) @cov(X,Y) @stdev(x)(分母n-1) @sumsq(x)(平方和) @sin(x) @cos(x) @tan(x) d(x)=x-x(-1) dlog(x)=log(x)-log(x(-1))
3)描述统计函数:eviews中有一类以@打头的特殊函数,用以计算序列的描述统计量,或者用以计算常用的回归估计量。大多数@函数的返回值是一个常数。
@SUM(X):序列X的和
@MEAN(X): 序列X的平均数
@VAR(X): 序列X的方差
@SUMSQ(X): 序列X的平方和
@OBS(X): 序列X的有效观察值个数
@COV(X,Y): 序列X和序列Y的协方差
@COR(X,Y): 序列X和序列Y的相关系数
@CROSS(X,Y): 序列X,Y的点积 genr val=@cross(x,y)
当X为一个数时,下列统计函数返回一个数值;当X为一个序列时,下列统计函数返回的也是一个序列。
@PCH(X): X的增长率(X-X(-1))/ X(-1)
@INV(X): X的倒数1/X
@LOGIT(X): 逻辑斯特函数
@FLOOR(X): 转换为不大于X的最大整数
@CEILING(X): 转换为不小于X的最小整数
@DNORM(X): 标准正态分布密度函数
@CNORM(X): 累计正态分布密度函数
@TDIST(X,n): 自由度为n,取值大于X的t统计量的概率
@FDST(X,n,m): 自由度为(n,m)取值大于X的F分布的概率@CHISQ(X,n): 自由度为n,不小于x的分布的概率
7)Jarque-Bera统计量: ,用于检验变量是否服从正态分布。在变量服从正态分布的原假设下,JB统计量服从自由度为2的卡方分布。如果JB统计量大于卡方分布的临界值,或对应概率值较小,则拒绝该变量服从正态分布的假设(where S is the skewness, K is the kurtosis, and k represents the number of estimated coefficients used to create the series)
Basic Mathematical Functions
The following functions perform basic mathematical operations. When applied to a series, they return a value for every observation in the current sample. When applied to a matrix object, they return a value for every element of the matrix object. The functions will return NA values for observations where the input values are NAs, or where the input values are not valid. For example, the square-root function @sqrt, will return NAs for all observations less than zero.
Note: @iff, @inv, and @recode do not work with matrix objects.
Name
Function
Examples/Description
@abs(x), abs(x)
absolute value
@abs(-3)=3.
@ceiling(x)
smallest integer not less than
@ceiling(2.34)=3, @ceiling(4)=4.
@exp(x), exp(x)
exponential,
@exp(1)=2.71813.
@fact(x)
factorial,
@fact(3)=6, @fact(0)=1.
@factlog(x)
natural logarithm of the factorial,
@factlog(3)=1.79176, @factlog(0)=0.
@floor(x)
largest integer not greater than
@floor(1.23)=1, @floor(-3.1)=-4.
@iff(s,x,y)
recode by condition
returns if condition is true; otherwise returns . Note this is the same as @recode.
@inv(x)
reciprocal,
inv(2)=0.5 (For series only; you should use @einv to obtain the element inverse of a matrix).
@mod(x,y)
floating point remainder
returns the remainder of with the same sign as. If the result is 0.
@log(x), log(x)
natural logarithm,
@log(2)=0.693..., log(@exp(1))=1.
@log10(x)
base-10 logarithm,
@log10(100)=2.
@logx(x,b)
base-b logarithm,
@logx(256,2)=8.
@nan(x,y)
recode NAs in X to Y
returns if, and if.
@recode(s,x,y)
recode by condition
Returns if condition is true; otherwise returns .
@round(x)
round to the nearest integer
@round(-97.5)=-98, @round(3.5)=4.
@sqrt(x), sqr(x)
square root
@sqrt(9)=3.
Time Series Functions
The following functions facilitate working with time series data. Note that NAs will be returned for observations for which lagged values are not available. For example, d(x) returns a missing value for the first observation in the workfile, since the lagged value is not available.
Name
Function
Description
d(x)
first difference
where is the lag operator.
d(x,n)
n-th order difference
.
d(x,n,s)
n-th order difference with a seasonal difference at
.
dlog(x)
first difference of the logarithm
.
dlog(x,n)
n-th order difference of the logarithm
.
dlog(x,n,s)
n-th order difference of the logarithm with a seasonal difference at
.
@pc(x)
one-period percentage change (in percent)
equals @pch(x)*100
@pch(x)
one-period percentage change (in decimal)
.
@pca(x)
one-period percentage change-annualized (in percent)
equals @pcha(x)*100
@pcha(x)
one-period percentage change-annualized (in decimal)
where is the lag associated with one-year () for quarterly data, etc.).
@pcy(x)
one-year percentage change (in percent)
equals @pchy(x)*100
@pchy(x)
one-year percentage change (in decimal)
, where is the lag associated with one-year () for annual data, etc.).
展开阅读全文