What shape should data be in to perform a linear fit with GLM?

for constructing the data frame you can

  1. push! a NamedTuple in a loop, so you work with named tuples instead Vectors in input.
  2. Make a Matrix via mapreduce(permutedims, vcat, input) and construct a DataFrame from that matrix via DataFrame(mat, :auto).

For using lm you can

  1. Use lm(y, X) instead of @formula
  2. Construct a formula programmatically in the method described here.
2 Likes