以下を使用して作成されたplmオブジェクトがあります。
require(plm)
plm1 <- plm(Sepal.Length ~ Petal.Length + Petal.Width, data = iris, index = "Species")
pseries オブジェクトをマトリックスや data.frame のような使用可能なものに操作することはできないようです。
> data.frame(resid(plm1))
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class '"pseries"' into a data.frame
次のようなものがあればいいのですが:
> df1 <- data.frame(time = rep(1:10,15), Species = iris$Species, resid1 = runif(150))
> head(df1)
time Species resid1
1 1 setosa 0.7038776
2 2 setosa 0.2164597
3 3 setosa 0.1988884
4 4 setosa 0.9311872
5 5 setosa 0.7087211
6 6 setosa 0.9914357
ddply または aggregate を使用して、各種の rsquared を見つけることができます。
助言がありますか?