In Julia, I'd like to calculate a GLM with family Binomial()
and LogitLink()
. My data are three linear arays: xvalues
, number of hits
, and number of misses
. I would like to explain the binomially distributed hits and misses by their positions on the x axis. I have multiple samples with the same x coordinates (because the data originally stems from a 2D array that was flattened).
In R, I have to supply hits and misses in a two-column-matrix. Something like the following works:
glm1 <- glm(cbind(hits, misses)~xvalues, family=binomial)
But in the GLM formula in Julia, I cannot specify arbitrary arrays. Rather, I have to specify columns from a dataframe and dataframe columns cannot be 2D it seems. So I've put my data into a dataframe:
data = DataFrame(xvals = xvals, hits = hits, misses = misses)
and tried things that don't work (like this):
glm1 = glm(hcat(hits, misses) ~ xvals, data, family = Binomial, link = LogitLink())
An example with data can be downloaded here.
Any advice? Cheers, Hannes