我正在从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个区域。