aidsCalc | R Documentation |
Given prices, total expenditure and coefficients this function calculates the demanded quantities and expenditure shares based on the Almost Ideal Demand System.
aidsCalc( priceNames, totExpName, coef, data, priceIndex = "TL", basePrices = NULL, baseShares = NULL, shifterNames = NULL ) ## S3 method for class 'aidsEst' predict( object, newdata = NULL, observedShares = FALSE, ... )
priceNames |
a vector of strings containing the names of the prices. |
totExpName |
a string containing the variable name of total expenditure. |
coef |
a list containing the coefficients alpha, beta, gamma, and (only for the translog price index) alpha0. |
data |
a data frame containing the data. |
priceIndex |
a character string specifying the price index
(see |
basePrices |
a vector specifying the base prices for the Paasche, Laspeyres, and Tornqvist price index. |
baseShares |
a vector specifying the base expenditure shares for the Laspeyres, simplified Laspeyres, and Tornqvist index. |
shifterNames |
a vector of strings containing the names of the demand shifters. |
object |
an object of class |
newdata |
an optional data frame which should contain the variables for the prediction. If omitted, the data frame used for the estimation is used also for the prediction. |
observedShares |
logical. Using observed shares? (see details). |
... |
currently not used. |
The predict
method for objects of class aidsEst
extracts all relevant elements from an object returned by aidsEst
and passes them as arguments to aidsCalc
.
The optional argument observedShares
determines
whether fitted (default) or observed expenditure shares are
used in the price index of the LA-AIDS.
aidsCalc
and
the predict
method for objects of class aidsEst
return a list with following elements:
shares |
a data frame containing the calculated expenditure shares. |
quantities |
a data frame containing the calculated quantites. |
Arne Henningsen
Deaton, A.S. and J. Muellbauer (1980) An Almost Ideal Demand System. American Economic Review, 70, p. 312-326.
aidsEst
, aidsPx
data( Blanciforti86 ) # Data on food consumption are available only for the first 32 years Blanciforti86 <- Blanciforti86[ 1:32, ] priceNames <- c( "pFood1", "pFood2", "pFood3", "pFood4" ) shareNames <- c( "wFood1", "wFood2", "wFood3", "wFood4" ) ## LA-AIDS estResult <- aidsEst( priceNames, shareNames, "xFood", data = Blanciforti86, priceIndex = "S" ) # using observed shares in the Stone index lnp <- aidsPx( "S", priceNames, Blanciforti86, shareNames ) fitted <- aidsCalc( priceNames, "xFood", coef = coef( estResult ), data = Blanciforti86, priceIndex = lnp ) fitted$shares # equal to estResult$wFitted fitted$quant # equal to estResult$qFitted # now the same with the predict method fitted2 <- predict( estResult, observedShares = TRUE ) all.equal( fitted, fitted2 ) # using fitted shares in the Stone index fitted <- aidsCalc( priceNames, "xFood", coef = estResult$coef, data = Blanciforti86, priceIndex = "S" ) # now the same with the predict method fitted2 <- predict( estResult ) all.equal( fitted, fitted2 ) ## AIDS estResult <- aidsEst( priceNames, shareNames, "xFood", data = Blanciforti86, method = "IL" ) fitted <- aidsCalc( priceNames, "xFood", coef = coef( estResult ), data = Blanciforti86 ) fitted$shares # equal to estResult$wFitted fitted$quant # equal to estResult$qFitted fitted2 <- predict( estResult ) all.equal( fitted, fitted2 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.