R 中的 Eta/Eta 平方例程

发布于 2024-09-05 01:12:11 字数 347 浏览 3 评论 0原文

除了在应用 GLM 系列的某些技术之前使用的线性度图形估计(凝视散点图方法)之外,还有多种方法可以通过算术进行此估计(即无需图形)。

现在,我将重点关注 Fisher 的 eta 平方 - 相关比:从算术上讲,它等于 Pearson 的平方 r(决定系数:r2)如果两个变量之间的关系是线性的。因此,您可以比较 etar 的值并对关系类型(线性或非线性)进行评估。它提供有关由自变量解释(线性或非线性)的因变量方差百分比的信息。因此,您可以在不满足线性假设时应用它。

简单地说:R 中有 eta/eta-squared 的例程吗?

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).

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞梦里开花 2024-09-12 01:12:11

我仍然很震惊,我必须承认...在R中没有简单直接的方法来计算 η 或 η2...所以我根据到维基百科页面。这里是:

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 值,所以如果有人知道该怎么做...请告诉我!

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)
}

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!

画离情绘悲伤 2024-09-12 01:12:11

阅读此问题并尝试答案中的功能后,我发现这是
库“sjstats”
包含一个 Eta 平方函数。
也许这对未来的寻求者有帮助。

After reading this Question, and trying the function in the answer, I just found this the
library "sjstats".
There is an Eta-Squared-function included.
Maybe it is helpful for future seekers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文