如何通过另一个变量加权我的变量? [英] How can I weight my variables by another variable?

查看:66
本文介绍了如何通过另一个变量加权我的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SPSS 中,我可以通过使用weights_by"来选择一个我想用于加权其他变量的变量.

In SPSS I can choose a variable which I want to use for weighting other variables just by using "weights_by".

为了我的学习,我现在必须使用 Rstudio.当我执行上述操作并在 R 中打开它时,它们的权重将消失.那么我如何在 R 中做到这一点?

For my studies I have to use Rstudio now. When I do the above thing and open it in R, they weights will disappear. How can I do this in R then?

类似于:

"weights(pspwhgt)" (without"") is not working for me... 

我完全是初学者.我有我的可变性别,我想用我的另一个变量 pspwhgt 加权.如果不是数学或编程方面的天才,我怎么能做到这一点?

I'm on a totally beginner level. I have my variable gender and I want to weight it by my other variable pspwhgt. How can I do this without being a genius in math or programming?

推荐答案

与 SPSS 不同,R 中的权重应用于操作级别而不是全局.因此,如何指定和使用权重取决于您要执行的操作.许多 R 函数都有一个 weights 参数(例如 lm() 等).您可能还需要 weighted.mean()

Unlike SPSS, weights in R are applied at the operation level rather than globally. So, how you specify and use weights depends on what operation you want to perform. Many R functions have a weights argument (such as lm(), etc.). You may also want weighted.mean(), etc.

这篇关于如何通过另一个变量加权我的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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