On Tue, 13 Jul 2010, Artur T. wrote: > Hi gretl community, > > is there a simple way to generate a index series of a variable, e.g. > Lapeyres (year x =100) or Paasche?? > At the moment I use a spreadsheet to construct it easily but this > requires the ex- and import of the series of interest every time...
Something like this? <script> function series laspeyres(list Prices, list Quantities, scalar base) genr time scalar ndx = time[base] qbase = {Quantities}[ndx,]' series ret = lincomb(Prices, qbase) return ret*100/ret[base] end function function series paasche(list Prices, list Quantities, scalar base) genr time scalar ndx = time[base] pbase = {Prices}[ndx,]' series ret = sumr({Quantities} .* {Prices}) return ret*100/lincomb(Quantities, pbase) end function # --- example with fake data ---------------------------------------- nulldata 40 setobs 4 2000:1 price1 = uniform() price2 = uniform() price3 = uniform() q1 = uniform() q2 = uniform() q3 = uniform() list P = price1 price2 price3 list Q = q1 q2 q3 series LPI = laspeyres(P, Q, 2002:1) series PPI = paasche(P, Q, 2002:1) series FPI = sqrt(LPI*PPI) </script> Riccardo (Jack) Lucchetti Dipartimento di Economia Università Politecnica delle Marche r.lucchetti(a)univpm.it http://www.econ.univpm.it/lucchetti