Package easi February 15, 2013 Type Package Title EASI Demand System Estimation Version 0.2 Date 2012-05-08 Author Stephane Hoareau <sjlhoaro@yahoo.fr>, Guy Lacroix, Mirella Hoareau, Luca Tiberti Maintainer Stephane Hoareau <sjlhoaro@yahoo.fr> Description easi is a package for R enabling the estimation of the Exact Affine Stone Index demand system of Pendakur and Lewbel (2009). However, more than just a transcript, it offers a number of extensions in an unified framework. Firstly, it allows to calculate elasticities (income elasticities, price elasticities and demographic elasticities) and their standard deviations. Secondly, it enables the calculation and the graphical representation of Engel curves and their confidence interval. Thirdly, it provides simulation tools to assess the impact of price changes, income changes and demographic changes on fitted budget shares, elasticities, and their standard deviations. Finally, easi allows the computation of equivalent incomes. License GPL (>= 2.0) Depends systemfit, stats, micecon LazyLoad yes Repository CRAN Date/Publication 2012-07-04 15:16:12 NeedsCompilation no 1
2 concavity R topics documented: concavity.......................................... 2 easi............................................. 3 elastic............................................ 6 engel............................................. 8 equiv.income........................................ 10 hixdata............................................ 12 simulations......................................... 13 Index 16 concavity Concavity of EASI cost function Description This function provide a test of local concavity Usage concavity(object = object) Arguments object an object of type easi which contains all the information about the previous estimates. Here, in particular, the estimates of the easi system. Details A semi-negative definite Hessian matrix is a necessary and sufficient condition to consider that the cost function is concave. The calculation of Hessian matrix and the test of local concavity is performed in the context of the easi package. Value a A string that indicates the result of the test References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008.
easi 3 Examples data(hixdata) #******* Budget shares Matrix ***************** shares_hix=hixdata[,2:10] #******* price Matrix (in logarithms) ********* log.price_hix=hixdata[,11:19] #******* demographic matrix ******************* var.soc_hix=hixdata[,21:25] #******* logarithm of total expenditure ******* #******* (here divised by a price index) ****** log.exp_hix=hixdata[,20] #******* estimation *************************** est <- easi(shares=shares_hix,log.price=log.price_hix, var.soc=var.soc_hix,log.exp=log.exp_hix) #******* test of local concavity ************** concavity(est) easi Exact Affine Stone Index (EASI) Demand System Estimation Description This function estimates the Exact Affine Stone Index (EASI) Demand System of Pendakur and Lewbel (2009). Usage easi(shares = shares, log.price = log.price, var.soc = var.soc, log.exp = log.exp, y.power=false, labels.share=false, labels.soc=false, py.inter=false, zy.inter=false, pz.inter=false, interpz=false) ## S3 method for class easi coef(object,...) ## S3 method for class easi residuals(object,...) ## S3 method for class easi summary(object,...) ## S3 method for class easi predict(object,...) ## S3 method for class easi vcov(object,...)
4 easi Arguments shares the matrix of budget shares. log.price the matrix of log.prices (in logarithms). var.soc the matrix of demographic variables. log.exp the logarithm of total expenditure. y.power the highest power of y (implicit utility). Default is y.power=3. labels.share a string which contains the names of budget shares. For example, labels.share = c ("foods", "non foods", "others") indicates that the respective names of the three shares in the budget system are "foods", "non foods" and "others". labels.soc a string which contains the names of demographic variables. For example, labels.soc = c ("age", "gender", "hsize") indicates that the respective names of the three demographic variables in the budget system are "age", "non foods" and "hsize". py.inter a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the price variables and y (implicit utility). zy.inter a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the demographic variables and y (implicit utility). pz.inter a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between prices and demographic variables. interpz a vector which allows to choose which demographic variables to interact with prices. For example, interpz=c(3) means that prices are interacted with the third demographic variable while interpz = c (1:n) means that prices are interacted with the first n demographic variables. object an object of type easi which contains all informations about the previous estimates. Here, in particular, the estimates of the easi system.... others options. Details The EASI demand system, in the form of budget shares, is given by (for each good j [1 : J]): w j = R r=1 bj ry r + T t=1 gj t z t + T T k=1 t=1 a jktz t ln p k + J k=1 b jk ln p k y + T t=2 hj tz t y + ε j, where w is the matrix of budget shares, R is the hightest power of implicit utility y, T denotes the number of demographic variables, z is the matrix of demographic variables, J is the number of goods and p is the matrix of prices. Implicit utility y is given by:. y = ln x J j=1 w j ln p j + 1/2 J J j=1 k=1 a jktz t ln p j ln p k 1 1 J J 2 j=1 k=1 b jk ln p j ln p k The system is estimated by an iterated linear 3SLS. This estimator is similar to the estimator suggested by Blundell and Robin (1999) for the QUAIDS, except for the treatment of the endogeneity of w j ln p j.
easi 5 Value an object of class c("easi", "systemfit"). A "easi" object has the following elements : summary fitted.w Residuals CoefCov y varlist shares log.price var.soc log.exp y.power neq nsoc py.inter zy.inter pz.inter interpz labels.shares summary of estimation. the matrix of fitted budget shares. the matrix of residuals. the covariance matrix of the estimates. the implicit utility. the list of all variables. the matrix of budget shares. the matrix of prices (in logarithms). the matrix of demographic variables. the logarithm of total expenditure. the highest power of y (implicit utility) in the system. the number of goods (Excluding the last good). the number of demographic variables. a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the price variables and y (implicit utility). a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the demographic variables and y (implicit utility). a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between prices and demographic variables. a vector which allows to choose the demographic variables to interact with prices. For example, interpz=c(3) means that prices are interacted with the third demographic variable, while interpz = c (1:n) means that prices are interacted with the first n demographic variables. a string which contains the names of budget shares. For example, labels.shares = c ("foods", "non foods", "others") indicates that the names of the three shares in the budget system are "foods", "non foods" and "others", respectively. labels.price a string which contains the names of prices. For example, labels.price = c ("pfoods", "pnonfoods", "pothers") indicates that the names of the three log.prices variables in the budget system are: "pfoods", "pnonfoods" and "pothers", respectively. labels.soc interact fit3sls varlist dim_varlist a string which contains the names of the demographic variables. For example, labels.soc = c ("age", "gender", "hsize") indicates that the names of the three demographic variables in the budget system are "age", "non foods" and "hsize", respectively. a logical variable which is fixed to TRUE if at least one of the variables in either zy.inter, py.inter or pz.inter is fixed to TRUE. object of class systemfit. list of all variables. number of variables.
6 elastic References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008. Examples data(hixdata) #******* Budget shares Matrix ************ shares_hix=hixdata[,2:10] #******* price Matrix (in logarithms) **** log.price_hix=hixdata[,11:19] #******* Demographic matrix ************** var.soc_hix=hixdata[,21:25] #******* logarithm of total expenditure ** #******* (here divised by a price index) * log.exp_hix=hixdata[,20] #******* Estimation... ******************* est <- easi(shares=shares_hix,log.price=log.price_hix, var.soc=var.soc_hix,log.exp=log.exp_hix) #******* Coefficients ******************** coef(est) #******* Summary ************************* summary(est) #******* fitted values ******************* head(predict(est)) #******* Residuals *********************** head(residuals(est)) #******* Covariance Matrix *************** dim(vcov(est)) elastic Elasticities of EASI demand system Description This function calculates price elasticities, demographic elasticities and income elasticities. Usage elastic(object = object, type = c("price", "income", "demographics"), sd = FALSE)
elastic 7 Arguments object type sd an object of type easi which contains all the information about the previous estimates. Here, in particular, the estimates of the easi system. type can take values "price", "demographics" or "income" if one wants to calculate price elasticities, demographics elasticities or income elasticities, respectively. sd (for standard deviations) must be specified as TRUE if one wants to calculate the standard deviations (FALSE otherwise). Details Value The equations for the budget shares elasticities are presented in Pendakur and Lewbel. The elasticities for quantities are derived in the context of the easi package. EP ER EZ EPS EPQ EP_SE ER_SE EZ_SE ELASTPRICE ELASTINCOME ELASTPRICE_SE semi-elasticities of budget shares with respect to prices. semi-elasticities of budget shares with respect to real expenditures. semi-elasticities of budget shares with respect to demographics. matrix of compensated quantity derivatives with respect to unlogged prices. compensated (good-specific) expenditures with respect to prices. standard deviations of semi-elasticities of budget shares with respect to prices. standard deviations of semi-elasticities of budget shares with respect to real expenditures. standard deviations of semi-elasticities of budget shares with respect to demographics. elasticities of quantities with respect to prices. elasticities of quantities with respect to income. standard deviations of Elasticities of quantities with respect to prices. ELASTINCOME_SE standard deviations of Elasticities of quantities with respect to income. References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008. Examples data(hixdata) #******* Budget shares Matrix ***************** shares_hix=hixdata[,2:10] #******* price Matrix (in logarithms) *********
8 engel log.price_hix=hixdata[,11:19] #******* demographic matrix ******************* var.soc_hix=hixdata[,21:25] #******* logarithm of total expenditure ******* #******* (here divised by a price index) ****** log.exp_hix=hixdata[,20] #******* estimation *************************** est <- easi(shares=shares_hix,log.price=log.price_hix, var.soc=var.soc_hix,log.exp=log.exp_hix) #******* price elasticities ******************* #******* without standard deviations ********** ep1 <- elastic(est,type="price",sd=false) #******* price elasticities ******************* #******* with standard deviations ************* ep2 <- elastic(est,type="price",sd=true) #******* demographic elasticities ************* #******* without standard deviations ********** ed <- elastic(est,type="demographics",sd=false) #******* Elasticities income ****************** #******* without standard deviations ********** ei <- elastic(est,type="income",sd=false) engel Engel curves of EASI demand system Description Usage The engel function uses estimates of the easi function in order to calculate and draw the Engel curves. engel(object = object, file = file, sd = FALSE, limy = FALSE) Arguments object file sd an object of type easi which contains all the information about the previous estimation. Here, in particular, the estimates of the easi system. filename with which Engel Curves ("file.pdf") are to be stored. For example, if one specifies "file=myfile1", in the parent directory, the file "Myfile1.pdf" - which contains Engel curves - is generated. sd (for standard deviations) must be specified as TRUE if we want calculate the standard deviations (FALSE otherwise).
engel 9 limy the limits of the Y-axis of the graphical representations of Engel curves. For example, limy=c(0,0.5,0.2,0.5,0,1) means that the first Engel curve will be represented on a graph whose limits on the Y-axis are [0;0.5], the second Engel curve will be represented on a graph whose limits on the Y-axis are [0.2;0.5], and so on. By default, all Y-axis limits are [0;third quartile of observed budget shares]. It is also a good way to evaluate the goodness of fit. Details The equations of the Engel curves are presented in Pendakur and LewbeL. Value The matrix of fitted budget shares. References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008. Examples data(hixdata) #******* Budget shares Matrix ***************** shares_hix=hixdata[,2:10] #******* price Matrix (in logarithms) ********* log.price_hix=hixdata[,11:19] #******* demographic matrix ******************* var.soc_hix=hixdata[,21:25] #******* logarithm of total expenditure ******* #******* (here divised by a price index) ****** log.exp_hix=hixdata[,20] #******* estimation *************************** est <- easi(shares=shares_hix,log.price=log.price_hix, var.soc=var.soc_hix,log.exp=log.exp_hix) #******* engel curves ************************* eng1 <- engel(est,file="graph_engels_curves",sd=false)
10 equiv.income equiv.income Equivalent income of EASI demand system Description The function estimates the equivalent income under the EASI system. Two periods are considered : the reference period (before changes in prices and/or total expenditures) and the current period (after changes in prices and/or total expenditures). The function calculates the equivalent income, namely the necessary income in the reference period (with reference prices) in order to have the same implicit utility in the current period (with current prices and current total expenditures). Usage equiv.income(object = object, log.exp_ref = log.exp_ref, log.exp_cur = log.exp_cur, log.price_ref = log.price_ref, log.price_cur = log.price_cur) Arguments object log.exp_ref log.exp_cur log.price_ref log.price_cur an object of type easi which contains all the information about the previous estimation. Here, in particular, the estimates of the easi system. the logarithm of the total expenditures of the reference period. the logarithm of the total expenditures of the current period. the logarithm of the prices of the reference period. the logarithm of the prices of the current period. Details Equivalent income is derived specially in the context of easi package. Value equiv_income Equivalent Income. References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008.
equiv.income 11 Examples # We propose to simulate a "hybrid model" to # illustrate how to use the function: # This model is composed of five budget shares whose means are # respectively equal to 0.25, 0.15, 0.20, 0.30 and 0.10. w1 <- rnorm(3000,mean=0.25,sd=0.05) w2 <- rnorm(3000,mean=0.15,sd=0.05) w3 <- rnorm(3000,mean=0.20,sd=0.05) w4 <- rnorm(3000,mean=0.30,sd=0.05) w5 <- 1-w1-w2-w3-w4 shares_sim=data.frame(w1,w2,w3,w4,w5) # We simulate five price vectors, whose means are respectively # equal to 25, 15, 20, 30 and 10: p1 <- log(rnorm(3000,mean=25,sd=3)) p2 <- log(rnorm(3000,mean=15,sd=2)) p3 <- log(rnorm(3000,mean=20,sd=3)) p4 <- log(rnorm(3000,mean=30,sd=4)) p5 <- log(rnorm(3000,mean=10,sd=1)) log.price_sim=data.frame(p1,p2,p3,p4,p5) # We simulate four demographics variable : V1, V3, V4 who # are dummy variables, and V2 who take its values in N+ V1 <- abs(round(rnorm(3000,mean=0.7,sd=0.2))) V2 <- abs(round(rnorm(3000,mean=2,sd=1)))+1 V3 <- abs(round(rnorm(3000,mean=0.7,sd=0.2))) V4 <- abs(round(rnorm(3000,mean=0.7,sd=0.2))) var.soc_sim=data.frame(v1,v2,v3,v4) # Finally, we simulate a vector of total expenditure # whose the average is 1200. log.exp_sim <- log(rnorm(3000,mean=1200,sd=200)) # Estimation est <- easi(shares=shares_sim,log.price=log.price_sim, var.soc=var.soc_sim,log.exp=log.exp_sim) ## changes in prices and total expenditure: # log.price_sim are multiplied by 1.4 between reference and current period # log.exp_sim are multiplied by 1.05 between reference and current period log.price_sim2 <- log(exp(log.price_sim)*1.4) log.exp_sim2 <- log(exp(log.exp_sim)*1.05) ## Calculation of equivalent income equiv <- equiv.income(est,log.exp_ref=log.exp_sim,log.exp_cur=log.exp_sim2,
12 hixdata log.price_ref=log.price_sim,log.price_cur=log.price_sim2) hixdata Hixdata Description Usage Format Data consist of 4,847 observations of rental-tenure single-member canadian households that had positive expenditures on rent, recreation, and transportation (For details see Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. data(hixdata) A data frame with 4847 observations on the following 26 variables. obs number of observations. sfoodh the budget share of food at home. sfoodr the budget share of other foods. srent the budget share of rent. soper the budget share of household operations. sfurn the budget share of household furnishing and equipment. scloth the budget share of clothing. stranop the budget share of transportation operations. srecr the budget share of recreation. spers the budget share of personal care pfoodh the logarithm of the price of food at home. pfoodr the logarithm of the price of other foods. prent the logarithm of the price of rent. poper the logarithm of the price of household operations. pfurn the logarithm of the price of household furnishing and equipment. pcloth the logarithm of the price of clothing. ptranop the logarithm of the price of transportation operations. precr the logarithm of the price of recreations. ppers the logarithm of the price of personal care. log_y the logarithm of total expenditure. age the person s age minus 40.
simulations 13 Source hsex the sex dummy equal to one for men. carown a dummy equal to one if real gasoline expenditures (at 1986 gasoline prices) are less than 50 dollars. time a time variable equal to the calendar year minus 1986. tran a social assistance dummy equal to one if government transfers are greater than 10 percent of gross income. wgt weighting variable. Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009 References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009 Examples data(hixdata) ## maybe str(hixdata) ; plot(hixdata)... simulations Simulation tools in the context of the EASI demand system Description Usage The simulations function uses estimates of the easi function in order to simulate the new fitted budget shares and the new elasticities after changes in prices, demographics and total expenditure. simulations(object = object, log.price_new = log.price_new, var.soc_new = var.soc_new, log.exp_new = log.exp_new) Arguments object log.price_new var.soc_new log.exp_new an object of type easi which contains all the information about the previous estimation. Here, in particular, the estimates of the easi system. the new price matrix (in logarithms). the new demographic variables matrix. the new total expenditures (in logarithms). Details Simulation schemes are derived in the context of the easi package.
14 simulations Value summary fitted.w CoefCov y shares log.price var.soc log.exp y.power neq nsoc py.inter zy.inter pz.inter interpz labels.shares labels.price labels.soc interact fit3sls varlist dim_varlist Summary of estimation. Matrix of fitted budget shares. Covariance matrix of estimates. Implicit utility. the matrix of budget shares. the matrix of prices (in logarithms). the matrix of demographic variables. the logarithm of total expenditures. the highest power of y (implicit utility) in the system. The number of goods (Excluding the last good). The number of demographic variables. a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the price variables and y (implicit utility). a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the demographic variables and y (implicit utility). a logical variable which is fixed to TRUE (FALSE otherwise) if the user wants to enable the interaction between the prices and the demographic variables. a vector which allows to choose the demographic variables to interact with the price. For example, interpz=c(3) means that price are interacted with the third demographic variable while interpz = c (1:n) means that prices are interacted with the first n demographic variables. a string which contains the names of budget shares. For example, labels.shares = c ("foods", "non foods", "others") indicates that the names of the three shares in the budget system are "foods", "non foods" and "others", respectively. a string which contains the names of log.prices. For example, labels.price = c ("pfoods", "pnonfoods", "pothers") indicates that the names of the three prices variables in the budget system are: "pfoods", "pnonfoods" and "pothers", respectively. a string which contains the names of demographic variables. For example, labels.soc = c ("age", "gender", "hsize") indicates that the names of the three demographic variables in the budget system are "age", "non foods" and "hsize", respectively. a logical variable which is fixed to TRUE if at least one of the variables in either zy.inter, py.inter or pz.inter is fixed to TRUE. object of class systemfit. list of all variables. number of variables. References Arthur Lewbel and Krishna Pendakur "Tricks with Hicks : The EASI Demand System" The American Economic Review 99(3), 827-863, 2009. Krishna Pendakur "EASI made Easier", www.sfu.ca/pendakur/easi made Easier.pdf, 2008.
simulations 15 Examples data(hixdata) #******* Budget shares Matrix **************** shares_hix=hixdata[,2:10] #****** price Matrix (in logarithms) ********* log.price_hix=hixdata[,11:19] #****** demographic matrix ******************* var.soc_hix=hixdata[,21:25] #****** logarithm of total expenditure ******* #****** (here divised by a price index) ****** log.exp_hix=hixdata[,20] #****** estimation *************************** est <- easi(shares=shares_hix,log.price=log.price_hix, var.soc=var.soc_hix,log.exp=log.exp_hix) #****** Changes in prices ******************** #****** PRIX.HIX --> PRIX.HIX.SIM1 = 0 ******* log.price_hix.sim1 <- log.price_hix for (i in 1:ncol(log.price_HIX)) log.price_hix.sim1[,i] <- 0 #****** Changes in demographic variables ***** #****** var.soc.hix --> var.soc.hix.sim1 = 0 * var.soc_hix.sim1 <- var.soc_hix for (i in 1:ncol(var.soc_HIX)) var.soc_hix.sim1[,i] <- 0 #******* simulation ************************** sim <- simulations(est,log.price_new=log.price_hix.sim1, var.soc_new=var.soc_hix.sim1,log.exp_new=log.exp_hix) #******* corresponding Engel curves ********** eng2 <- engel(sim,file="essai2",sd=false)
Index Topic EASI concavity, 2 easi, 3 elastic, 6 engel, 8 equiv.income, 10 simulations, 13 Topic Elasticities concavity, 2 elastic, 6 Topic Engel engel, 8 Topic Simulation simulations, 13 Topic datasets hixdata, 12 Topic equiv equiv.income, 10 coef.easi (easi), 3 concavity, 2 easi, 3 elastic, 6 engel, 8 equiv.income, 10 hixdata, 12 predict.easi (easi), 3 residuals.easi (easi), 3 simulations, 13 summary.easi (easi), 3 vcov.easi (easi), 3 16