Am 13.07.2010 17:32, schrieb Allin Cottrell:
> On Tue, 13 Jul 2010, Artur T. wrote:
>
>
>> Thank you very much for your responses and ideas. This was exactly what
>> I was looking for!! ;-)
>>
> Good.
>
>
>> I've got only one problem - maybe it is a bug or so. I modified the
>> function like this:
>> ------
>> function series paasche_index (list P, int base)
>> matrix MP = {P}
>> matrix Num = sumr(MP)
>> matrix Den = sumr(MP[base,])
>> series ret = 100 * (Num ./ Den)
>> return ret
>> end function
>> -----
>>
>> I've got obs. from 1947:1 to 2010:2 and before running the function for
>> a variable I restrict the sample by "smpl --no-missing x". For some
>> reason I obtain an error for some variables saying:
>> "? smpl --no-missing q
>> Full data range: 1947:1 - 2010:2 (n = 254)
>> Current sample: 1952:1 - 2008:4 (n = 228)
>>
>> ? series q_indx = paasche_index(q, 2005:1)
>> Index value 233 is out of bounds
>>
> "2005:1" translates into an offset from the absolute start of the
> data, namely 233 if the data start in 1947:1. But if you
> sub-sample the data then convert to a matrix, row 233 will not
> correspond to 2005:1 any more, and may be out of bounds.
> I don't think this is a bug, it's just something you have to keep
> in mind when converting between series and matrices.
>
> What you'd have to do is
>
> smpl --no-missing q
> scalar base = 2005:1 - $t1 + 1
> series q_indx = paasche_index(q, base)
>
Ah, I understand I think. Thanks for the alternative way ;-)
> Allin Cottrell
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>
Artur