R中的Eta / Eta平方例程 [英] Eta/Eta-squared routines in R

查看:326
本文介绍了R中的Eta / Eta平方例程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了在应用GLM系列技术之前使用的线性图形估计法(注视散点图法)外,还有几种方法可以通过算术方式进行此估计(即不使用图形)。

Apart from graphical estimation of linearity (gaze-at-scatterplot method), which is utilized before applying some technique from GLM family, there are several ways to do this estimation arithmetically (i.e. without graphs).

现在,我将集中讨论Fisher的 eta平方-相关比:算术上,它等于Pearson的 r 的平方(系数)。确定值: r 2 ),如果两个变量之间的关系是线性的。因此,您可以比较 eta r 的值,并评估关系的类型(线性或非线性)。它提供了有关因变量由线性变量解释(线性或非线性)的方差百分比的信息。因此,可以在不满足线性假设的情况下应用它。

Right now, I'll focus on Fisher's eta-squared - correlation ratio: arithmetically, it's equal to squared Pearson's r (coef. of determination: r2) if relationship between two variables is linear. Hence, you can compare values of eta and r and make an assessment about type of relation (linear or not). It provides an information about percent of variance in the dependent variable explained (linearly or not) by the independent variable. Therefore, you can apply it when linearity assumptions are not met.

简单地说:R中是否存在eta / eta平方的例程?

Simply stated: is there a routine for eta/eta-squared in R?

推荐答案

我还是很震惊,我必须承认...没有简单,直接的方法可以计算η。或 R 中的η 2 ...因此,我根据维基百科页面

I'm still quite stunned, I must admit... there's no easy and straightforward way for calculating η or η2 in R... So I wrote a function according to Wikipedia page. Here goes:

eta <- function(x, squared = FALSE, ...) {
    stopifnot(is.list(x))
    ## unlist
    y <- unlist(x)
    ## group mean
    mg <- rapply(x, mean, ...)
    ## group size
    ng <- rapply(x, length, ...)
    ## total mean
    mtot <- mean(y, ...)
    ## SSb
    ssb <- sum(ng * (mg - mtot) ^ 2)
    ## SSt
    sst <- sum((y - mtot) ^ 2)
    # get eta-squared
    if (squared) {
      res <- ssb/sst
    # get eta
    } else {
      res <- sqrt(ssb/sst)
    }
    return(res)
}

所以这产生了另一个问题,我将在不久后发布...您将使用什么来检查线性?但是,我无法计算p值,因此,如果有人知道该怎么做...请让我知道!

So this yields another question, which I'm about to post shortly... what do you use to check linearity? However, I can't calculate p-values, so if anyone knows how to do it... please, let me know!

这篇关于R中的Eta / Eta平方例程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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