I intend to use metaprogramming to perform multiple regression on several columns, but an error occurs.
My script:
sql(sqlColAlias(makeUnifiedCall(toArray, makeUnifiedCall(ols, (sqlCol(`rr), sqlCol(t.columnNames()[12:16]), false, 0))), `param), from=t.nullFill(0.0), groupBy=sqlCol(`month`symbol)).eval()
Error message:
::evaluate(sql(sqlColAlias(makeUnifiedCall(toArray, makeUnifiedCall(ols, (sqlCol("rr"), sqlCol(::columnNames(t)[12 : 16]), 0, 0))), "param"), ::nullFill(t, 0), , sqlCol(["month","tsymbol"]))) => The dimension of dependent doesn't match the dimension of independent factors.
Then I change my script as follows, which runs normally.
sql(sqlColAlias(makeUnifiedCall(rowSum, sqlCol(t.columnNames()[12:16])), `newCol), t.nullFill(0.0)).eval()
In metaprogramming, it is necessary to combine multiple columns into a matrix, instead of a tuple; otherwise, the script may not be parsed normally. Here is an example script: