[問題] 複迴歸的固定變數
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
新手(沒寫過程式,R 是我的第一次)
[問題敘述]:
想請問各位大神...
我想要做一個複迴歸。
例如:
依變數是g
自變數有三個類別變數:t81、t82和t83
固定變數是性別(sex)和類組(group)
資料檔為ALL
然後我google到的code是:
lm(g~ factor(t81)+factor(t82)+ factor(t83), data= ALL,
index=c("sex","group"), method="within", effect="twoways")
結果出現錯誤訊息
Warning messages:
1: In lm(g ~ factor(t81) + factor(t82) + factor(t83), data = ALL,
index = c("sex", : method = 'within' is not supported. Using 'qr'
2: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
extra arguments ‘index’, ‘effect’ will be disregarded
想請問的是:
1. 固定變數的code真的是這樣打嗎?
(非常抱歉我的統計能力很弱...QQ然後找了好幾天一直都沒有解法...)
2. 請問錯誤訊息是什麼意思呢?
先謝謝各位大神!
[環境敘述]:
RGui(64-bit)
Windows10
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.85.215.211
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1519651015.A.E52.html
→
02/26 21:56,
7年前
, 1F
02/26 21:56, 1F
非常謝謝c大!
我下載了lfe之後,這樣寫code:
felm(ALL$g ~ factor(ALL$t81)+ factor(ALL$t82)+ factor(ALL$t83)+ G(ALL$sex)+
G(ALL$group))
好像就可以出現結果了!
但還出現了一則警告訊息:
1: The G() syntax is deprecated, please use multipart formulas instead
2: In chol.default(mat, pivot = TRUE, tol = tol) :
the matrix is either rank-deficient or indefinite
我自己解讀的意思是他建議不要使用G( )的語法,可是我不懂為什麼?
也不懂是什麼情況下可以使用、什麼情況下不能使用...
可以再問問大家嗎?謝謝!
※ 編輯: tmpuauee (219.85.215.211), 02/26/2018 22:37:54
→
02/27 00:27,
7年前
, 2F
02/27 00:27, 2F
→
02/27 00:48,
7年前
, 3F
02/27 00:48, 3F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章
54
117