maybe this has come up before, but if so then I don't remember the answer:
I just noticed that I can stick together horizontally (as in 'x ~ y') a
100x2 matrix and a 1x100 row vector. However, the result was that the
first element of the row vector was repeated 100 times and formed the
third column of the output.
So effectively I got:
x ~ (y .* ones(rows(x), 1))
What was intended instead was:
x ~ y'
where I simply forgot the transpose.
Try it for yourselves:
matrix x = ones(10,2)
matrix y = seq(0,9)
matrix out1 = x ~ y' # intended
matrix out2 = x ~ y # what I got
I guess this comes from gretl *trying* to broadcast the vector y to
match the dimensions of x, but I would not really call the result
broadcasting. Or is there a rationale for this behavior?
Show replies by date