【问题标题】:is there lm(.~x,data)? how can i run many y in lm formula [duplicate]有 lm(.~x,data) 吗?我如何在 lm 公式中运行许多 y [重复]
【发布时间】:2017-06-18 06:48:53
【问题描述】:

我知道lm(y~. , data) 但我想知道相反的方向

如果我想把多个 y 放到 lm 函数中,我应该怎么做?用于?循环?

我想要的结果是获得 Y 的每个 p 值和 beta 值。只有一个 X。

【问题讨论】:

    标签: r for-loop lm


    【解决方案1】:

    lm 支持公式的 LHS 上的矩阵:

    f <- as.formula(sprintf("cbind(%s) ~ Species", 
                             paste(names(iris)[names(iris) != "Species"], collapse = ", ")))
    #cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species
    summary(lm(f, data = iris))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 2020-03-04
      • 2015-11-20
      • 2013-07-01
      • 2018-08-14
      • 1970-01-01
      • 2022-09-29
      相关资源
      最近更新 更多