Hatena::ブログ(Diary)

BOD

2011-12-16

[][]水準ごとに回帰をかける 17:07

以下を参照。

http://stackoverflow.com/questions/7523427/ddply-with-lm-function

一旦回帰の結果をリストに入れて、coefやらanovaで目的のものを引き出すという感じ。

res <- dlply(iris, .(Species), lm, formula = Sepal.Length~Sepal.Width)
coefs <- ldply(res, coef)

ちなみにうっかりdlply(data = iris, .....)とすると以下のようなエラーが出るので注意

"as.quoted" をクラス "function" のオブジェクトに適用できるようなメソッドがありません