This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
howtos:workwithdata:project_into_history [2009/10/14 21:31] shona.weldon |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Project Data Back Into History ====== | ||
- | Often you have a variable, say a demand, for which you have measured data over some historical period up to your simulation period. You may need to project that demand back into history. | ||
- | |||
- | The best way is to get a ratio of that measured value to some driver like population over the known period. Assuming you have the driver back into "pre-history", you can then project the ratio back in several ways as described below | ||
- | |||
- | ===== Linear Trend ===== | ||
- | The simplest way is to linear trend it back into history and then multiply it against the known driver in "pre-history". For example getting families in from 1910 to 1977 when we know families and population over historic time th. | ||
- | |||
- | <code> | ||
- | local ratioFamPerPer[cr,th] = familiesTot[cr,th] / CTotPop[cr,th] | ||
- | local ratioFamPerPerPH[cr,t19101977] = lintrend (ratioFamPerPer[cr,th]; time=1910) | ||
- | familiesPH[cr,t19101977] = extract (CEEFpop[cr,t18511990]; time:1910..1977) * ratioFamPerPerPH[cr,t19101977] | ||
- | </code> | ||
- | |||
- | The main danger here is that your linear trend variable, ratioFamPerPerPH[cr,t19101977], goes negative | ||
- | |||
- | ===== Ratio with linint ===== | ||
- | A safer way is to create an extra variable which is the ratio of the first year of pre-history to the first year of history and then linear interpret between these 2 points for the historic period. | ||
- | |||
- | <code> | ||
- | local ratioFamPerPer[cr,th] = familiesTot[cr,th] / CTotPop[cr,th] | ||
- | local ratioFamPerPerPHx[cr,t19101977] = changeseq (copyshape (ratioFamPerPer[cr,th]); dim=time, start=1910) | ||
- | ratioFamPerPerPHx[cr,t19101977] = insert (ratioFamPerPer[cr,th]; time->time:1978) | ||
- | ratioFamPerPerPHx[cr,t19101977] = insert (extract (ratioFamPerPer[cr,th]; time:1978, shrink=on) * \ | ||
- | ratioFamPerPer1910to1978[cr]; time:1910) | ||
- | |||
- | local ratioFamPerPerPH[cr,t19101977] = extract (linint (ratioFamPerPerPHx[cr,t19101977]); time:+0..1977) | ||
- | |||
- | familiesPH[cr,t19101977] = extract (CEEFpop[cr,t18511990]; time:1910..1977) * ratioFamPerPerPH[cr,t19101977] | ||
- | </code> | ||
- | |||
- | The main problem with this approach is that it is very flat over pre-history time | ||
- | |||
- | ===== log and exponential lintrend===== | ||
- | Another way to use lintrend and avoid the negatives it to use logarithm and exponential | ||
- | |||
- | <code> | ||
- | local ratioFamPerPer[cr,th] = familiesTot[cr,th] / CTotPop[cr,th] | ||
- | local ratioFamPerPerPH[cr,t19101977] = exp (max (lintrend (loge (ratioFamPerPer[cr,th]); time=1910), 0)) | ||
- | familiesPH[cr,t19101977] = extract (CEEFpop[cr,t18511990]; time:1910..1977) * ratioFamPerPerPH[cr,t19101977] | ||
- | </code> | ||