[英]lm() linear model - attributes
所以我對lm()命令有些困惑。 我嘗試了lm(x~y, mydata)
和lm(y~x, mydata)
,得到了不同的輸出。 那么,哪個變量用作x以及哪個變量用作y? 很抱歉提出這樣的菜鳥問題,但我不確定,我找不到任何能解釋該命令參數的信息!
答案可以在該功能的幫助頁面上找到。 在“ Details
部分中,我們有:
A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response.
還有更多的細節(也與從lm
幫助頁formula
在細節部分進行。 formula
,我們有:
The ~ operator is basic in the formation of such models. An expression of the form y ~ model is interpreted as a specification that the response y is modelled by a linear predictor specified symbolically by model.
綜上所述,您可以用符號術語定義模型,其中LHS是您的響應變量,而RHS是您的預測變量。 您得到不同的答案,因為在一個模型中, y
是您的響應變量,而另一個是x
。
如果您不知道,可以使用?
訪問幾乎所有功能的幫助頁面?
在命令行上,即?lm
或?formula
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.