计算均值,在SPSS中删除案例...多次 [英] Compute variable mean with case removed in SPSS...many times

查看:254
本文介绍了计算均值,在SPSS中删除案例...多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这是一个简单的问题,但我无法为其创建SPSS语法。

I hope this is an easy question but I'm having trouble creating SPSS syntax for it.

我有一个数据集与单个变量和约200例。我需要计算该变量的平均值,但我需要计算平均值200次,这样计算一次每次除去的情况。因此,平均值需要计算200次,删除每个案例一次(然后替换它),并计算该案例缺失的平均值。换句话说,第一次计算平均值应该排除第一种情况(因此分析了情况2到200)。第二次计算平均值应该排除第二种情况,但包括第一种情况(因此分析情况1和3到200)。等等。

I have a dataset with a single variable and about 200 cases. I need to compute the mean of that variable, but I need to compute the mean 200 times such that it is computed once with each case removed. So the mean needs to be computed 200 times, removing each case once (and then replacing it) and calculating the mean with that case missing. In other words, the first time I compute the mean it should exclude the first case (so cases 2 through 200 are analyzed). The second time I compute the mean it should exclude the second case but include the first case (so cases 1 and 3 through 200 are analyzed). And so on.

理想情况下,我想做的是创建一个新的SPSS数据集,这样新数据集中唯一的变量包含这200个平均值。我相信最好的方法是通过聚合函数。

Ideally what I would like to do is create a new SPSS dataset, such that the only variable in this new dataset contains these 200 means. I believe the best way to do this is through the aggregate function.

我遇到的麻烦是如何删除每个案例,计算平均值,替换案例,再次计算平均值,删除另一个案例,依此类推。我可以做一个过滤器,但我想自动化,而不是每次复制/过去或更改语法。我在想某种重复的过滤器,但我不是很熟悉重复和循环命令(但工作...)。

What I am having trouble with is how to remove each case, compute the mean, replace the case, compute the mean again with another case removed, and so on. I could do this with a filter, but I would like to automate it rather than having to copy/past or change the syntax each time. I am thinking some kind of repeating filter, but I am not very familiar with repeat and loop commands (but working on it...).

任何有关如何创建此类过滤器的最佳方式的洞察力或帮助将非常感激。

Any insight or help about the best way to create a filter like this would be much appreciated

推荐答案

我在我的评论中是正确的,你可以征收使用 REGRESSION 过程中的删除统计信息,循环通过数据集。

I was correct in my comment that you can levy the use of the deletion statistics available in the REGRESSION procedure to get the info you need without having to loop through the dataset yourself.

您必须做的是计算您自己的常数值1,并强制 REGRESSION SPSS不允许您指定一个空回归方程)来预测您感兴趣的变量。然后使回归过程保存删除残差。这些删除残差与原始变量之间的差异是删除的观察结果。

What you have to do is calculate your own constant value of 1 and force the REGRESSION through the origin (as SPSS does not let you specify an empty regression equation) predicting your variable of interest. Then have the regression procedure save the deletion residuals. The difference between these deletion residuals and your original variable are the jackknifed means with that observation deleted.

简单来说,这段代码将提供信息 - 只需替换 X 与您感兴趣的变量。

So in a nutshell this code would provide that info - just replace X with your variable of interest.

COMPUTE Const = 1.
REGRESSION
  /ORIGIN 
  /DEPENDENT X
  /METHOD=ENTER Const
  /SAVE DRESID (MeanResid).
COMPUTE JackknifeMeanX = X - MeanResid.

完整示例(假数据和通过汇总检查)如下:

Full example (with fake data and checking via aggregate) is below:

INPUT PROGRAM.
LOOP Id = 1 TO 10.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
DATASET NAME Sim.
COMPUTE X = RV.NORMAL(10,5).
COMPUTE Const = 1.
FORMATS Id Const (F2.0).
EXECUTE.

*Using deletion residuals in linear regression to calculate Jackknifed mean.
*Here I calculate my own intercept and force through origin.
REGRESSION
  /ORIGIN 
  /DEPENDENT X
  /METHOD=ENTER Const
  /SAVE DRESID (MeanResid).
COMPUTE JackknifeMeanX = X - MeanResid.

*Checking to make sure this agrees with data.
VECTOR XMis(10).
LOOP #i = 1 TO 10.
  IF $casenum <>#i XMis(#i) = X.
END LOOP.
AGGREGATE OUTFILE = * OVERWRITE=YES MODE=ADDVARIABLES
  /BREAK
  /XMis1 TO XMis10=MEAN(Xmis1 TO XMis10).

这篇关于计算均值,在SPSS中删除案例...多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆