我正在从 Java 运行这个 R 脚本(我正在使用 Renjin):
getCoefficients <- function(x, y, Regions) {
nbRegions <- length(Regions)
lengthY <- length(y)
colRegions <- NULL
from <- 1
to <- lengthY / nbRegions
for (i in 1:nbRegions) {
region <- Regions[i]
c <- cbind(region, from:to)
colRegions <- rbind(colRegions, c)
}
indexCols <- as.data.frame(colRegions)
x_ <- t(x)
data_ <- cbind(indexCols, y, x_)
dataFrame <- data.frame(data_)
colnames(dataFrame) <- c("region", "date", "y", "a", "b", "c", "d", "e", "f", "r", "o")
print(colnames(dataFrame))
model_RE_S <- try(plm(y ~ x_, data = dataFrame, model = "random", index = c("region", "date"), effect = "twoways"))
summryModel <- summary(model_RE_S)
coeff <- as.numeric(summryModel$coefficients)
#print(summryModel)
return(coeff)
}
我收到以下错误,我不知道如何解决它:
Error : replacement has 3648 rows, data has 456
x 是 456 8 矩阵,y 是 456 1 和 3 个区域。
**更新:另一种选择:** 我摆脱了 Renjin 并改用了Rserve。