楼主: ssfbear
13457 8

[问答] 请问如何用spss直接执行whites test? [推广有奖]

  • 0关注
  • 0粉丝

高中生

15%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
258 点
帖子
44
精华
0
在线时间
1 小时
注册时间
2007-12-10
最后登录
2014-5-5

楼主
ssfbear 发表于 2008-8-22 07:24:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

我想对 y=a+b*x1+c*x2+D*x3的回归方程进行white's test, 可以直接用spss得到结果吗? 怎么操作啊?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:whites White test SPSS PSS SPSS test whites

沙发
birdnick 发表于 2008-8-22 16:30:00
。。。这个应该不可以,记得以前上课的时候,老师讲过的》。。。

[此贴子已经被作者于2008-8-22 16:29:55编辑过]

藤椅
birdnick 发表于 2008-8-22 16:33:00

太牛了,找到一个人写得 宏文件,spss的

[em01]

**********************************************************************
White's test with SPSS:
======================

* First of all, read "Heterocedasticity: testing and correcting in SPSS", by Gwilym Pryce
    http://pages.infinit.net/rlevesqu/spss.htm#Heteroscedasticity
    This macro is based on his paper.
*   SPSS Code by Marta Garcia-Granero 2002/04/04.

* Steps:

* Create several new variables:
  * The square of the unstandardized residuals.
  * The square of every predictor variable in the model you want to test.
  * The cross-product of all the predictors.

* Run a regression model to predict the squared residuals with
the predictors, their squares and cross-products.

* Multiply the model R-square (unadjusted) by the sample size (n*R-square).
* This is the White's statistic. Its significance is tested by comparing
it with the critical value of the Chi-square distribution with "p" degrees
of freedom, where "p" is the total number of regressors in the last
regression model (original+squares+cross-products).


* IMPORTANT:
* If any of the original predictors is binary (dummy variable), then its square
will be identical to the original, and they will correlate perfectly.
* In this case, the regression model will drop one of them (the original or its square),
and "p" has to be decreased in 1 unit for each binary predictor in the model.

* WHITE'S TEST MACRO *

* The MACRO needs 5 arguments:
*   a) the number of predictors,
*   b) the number of cross-products that will be created:
" predictors*(predictors-1)/2"
*      [I could not find other way of making VECTOR to accept the number],
*   c) "P" (predictors+squares+cross-products), corrected for binary predictors,
*   d) the name of the dependent variable and
*   e) the list of predictors in the form 'first predictor TO last predictor'
*      (ordered and consecutive in the database).

* MACRO definition.

DEFINE whitest(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)
              /!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)
              /!POSITIONAL !CMDEND).

* >>>> 1st regression model to get the residuals <<<< *.
REGRESSION
  /STATISTICS R ANOVA
  /DEPENDENT !4
  /METHOD=ENTER !5
  /SCATTERPLOT=(*ZRESID,*ZPRED)
  /SAVE RESID(residual) .

* >>>> New variables <<<< *.
* New dependent variable.
COMPUTE sq_res=residual**2.
* Getting rid of superfluous variables (dependent and residuals).
SAVE OUTFILE='c:\windows\temp\tempdat_.sav'
   /keep=sq_res !5.
GET FILE='c:\windows\temp\tempdat_.sav'.
EXECUTE.
* Vectors for all new predictor variables.
VECTOR v=!5 /sq(!1) /cp(!2).
* Squares of all predictors.
LOOP #i=1 to !1.
COMPUTE sq(#i)=v(#i)**2.
END LOOP.
* Cross-products of all predictors.
* Modification of a routine by Ray Levesque.
COMPUTE #idx=1.
LOOP #cnt1=1 TO !1-1.
LOOP #cnt2=#cnt1+1 TO !1.
COMPUTE cp(#idx)=v(#cnt1)*v(#cnt2).
COMPUTE #idx=#idx+1.
END LOOP.
END LOOP.
EXECUTE.

* >>>> White's test <<<< *.
* Regression of sq_res on all predictors.
REGRESSION /VARIABLES=ALL
  /STATISTICS R
  /DEPENDENT sq_res
  /METHOD= ENTER
  /SAVE RESID(residual) .
* Final report.
* Routine by Gwilym Pryce (slightly modified).
matrix.
compute p=!3.
get sq_res /variables=sq_res.
get residual /variables=residual.
compute sq_res2=residual&**2.
compute n=nrow(sq_res).
compute rss=msum(sq_res2).
compute ii_1=make(n,n,1).
compute i=ident(n).
compute m0=i-((1/n)*ii_1).
compute tss=transpos(sq_res)*m0*sq_res.
compute regss=tss-rss.
print regss
/format="f8.4"
/title="Regression SS".
print rss
/format="f8.4"
/title="Residual SS".
print tss
/format="f8.4"
/title="Total SS".
compute r_sq=1-(rss/tss).
print r_sq
/format="f8.4"
/title="R-squared".
print n
/format="f4.0"
/title="Sample size (N)".
print p
/format="f4.0"
/title="Number of predictors (P)".
compute wh_test=n*r_sq.
print wh_test
/format="f8.3"
/title="White's General Test for Heteroscedasticity"
+ " (CHI-SQUARE df=P)".
compute sig=1-chicdf(wh_test,p).
print sig
/format="f8.4"
/title="Significance level of Chi-square df=P (H0:"
+ "homoscedasticity)".
end matrix.

!ENDDEFINE.

* Sample data Nr. 1: continuous predictors *.
INPUT PROGRAM.
- VECTOR x(5).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 5.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.
* x1 is the dependent and x2 TO x5 the predictors.
rename variables x1=y.
execute.
* MACRO call: there are 4 predictors, therefore, 6 cross-products and 14
regressors.
whitest 4 6 14 y x2 TO x5.

* Sample data Nr. 2: one binary predictor *.
INPUT PROGRAM.
- VECTOR x(5).
- LOOP #I = 1 TO 100.
-  LOOP #J = 1 TO 5.
-   COMPUTE x(#J) = NORMAL(1).
-  END LOOP.
-  END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.
RECODE x2  (Lowest thru 0=0)  (0 thru Highest=1)  .
EXECUTE .

* x1 is the dependent and x2 TO x5 the predictors.
rename variables x1=y.
execute.
* MACRO call: as before, 4 predictors, 6 cross-products but ONLY 13
regressors.
whitest 4 6 13 y x2 TO x5.

* As you can see from the output, X2 is not included in the model.

板凳
ssfbear 发表于 2008-8-22 19:04:00
ls的方法看不懂, 还是谢谢了
那用sas能做white's 测试吗?

报纸
lamfang 发表于 2008-8-22 21:15:00
在spss里面是不能进行white检验的,eviews里面可以。当你回归完了,点击view可以看到里面有这个选项。

地板
birdnick 发表于 2008-8-23 20:51:00

在spss syntax里面应该就可以运行了,具体要研究一下哈

SAS里面应该可以,嘿嘿,不过还没研究哈

7
ssfbear 发表于 2008-8-29 06:34:00
感谢ls各位的回复, 成功在eviews里执行white's test了

8
yanjinjane 发表于 2010-4-18 09:02:38
现在回答这个问题似乎晚了,但是我知道了还是写上去好了。

spss不能直接的进行WHITE test ,但是稍微加上一点自己的计算就好了。
以SPSS 17.0 英文版为例,

Analyze--->Regression--->Linear,选好Dependent 和Independent Varibles, 点击Save , 然后钩选Residuals下的Unstandardized, 然后Continue,点击OK。
这个时候你会发现数据(data view)表格那里出现了一个RES_1, 、这个就是residuals~~
White Test 关键就是将Error Term和 Dependent Varible 组成一个新的Regression :ei^2=r+dYi,
用spss,run the regression of
ei^2=r+dYi (set Error term as indep. V, and Y dep.V), 然后model summary那里的R^2记录下来。
nR^2~ X^2(卡方),n为Number of Observation, R^2 为刚刚算得.
Thus, Reject H0 : Homoscedasticity of errors, if   n R^2 >
X^2(卡方).

9
ccs0531 发表于 2018-11-13 10:38:33
yanjinjane 发表于 2010-4-18 09:02
现在回答这个问题似乎晚了,但是我知道了还是写上去好了。

spss不能直接的进行WHITE test ,但是稍微加上 ...
编码乱了,能给个截图吗?谢谢!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-24 18:44