[Gretl-devel] omit bug

Sven Schreiber svetosch at gmx.net
Sat May 24 11:00:43 EDT 2008


Am 23.05.2008 22:44, Allin Cottrell schrieb:
> On Fri, 23 May 2008, Sven Schreiber wrote:
> 

>> However, another new problem just appeared...
>>
>> matrix hausmanresult = $hausman
>> pvalue X hausmanresult[1,2]-1 hausmanresult[1,1]
>>
>> -- and this now gives an "invalid argument" error (it didn't in 
>> 1.7.4)...
> 
> Oof, this is to do with a change I introduced at Stefano's 
> behest: not "casting" 1x1 matrix results to scalars automatically.  
> I'll have to think about that some more.

first, one thing I don't understand here: the second term 
(hausmanresult[1,1]) doesn't seem problematic (see the workaround I 
mentioned, where it is unchanged). But that would mean it is treated as 
a scalar, no? Then why does the first term (hausmanresult[1,2]) give 
something different?

secondly, I think there are two different issues involved here:
1) The first one is what data type is returned by a function (built-in 
or user-defined).
2) The second issue is what happens if you pick elements from a matrix, 
as in the above example.

 From my experience with earlier discussions about those issues on the 
numpy (numerical python) mailing list, these issues can and should be 
decided separately.

With respect to the first issue, I have some sympathy with Stefano's 
view that the returned datatype should not depend on the specific matrix 
dimension in particular cases.

As for the second issue, I would say that explicitly indexing a single 
scalar element from a matrix --as in the above example-- should return a 
scalar. However, that would *not* mean that each indexing range which 
refers to a 1x1 submatrix should be returned as a scalar. For example, 
let's say somebody picks the first row of a matrix mymat by using 
mymat[1,] in an expression. In general the first row would not be just a 
single element, and as such mymat[1,] should always be a matrix, even if 
it turns out to be just a 1x1 matrix.


[and now continuing a different topic:]

> 
>> BTW, on various occasions I noticed that arithmetic expressions 
>> cannot always be used in place of simple variables. But 
>> sometimes it does seem to work. Is there some rule when it 
>> should work, or is it sheer luck when it does?
> 
> In general, arbitrary arithmetic should work for arguments to 
> built-in functions (or user-defined functions for that matter),
> while it's not very likely to work for arguments to straight
> "commands".  

In principle I think I understand, but I'm not sure the demarcation 
between commands and functions is very clear in gretl. What would that 
'pvalue' thing be for example?

-sven


More information about the Gretl-devel mailing list