cesModel: Fitting CES models

Description Usage Arguments Value Note Examples

View source: R/cesModel.R

Description

This function fits a CES model with 2 or 3 factors of production. In principle, the CES model can handle up to 4 factors of production, but this is not supported by cesModel() at this time.

Usage

1
2
3
4
5
6
cesModel(formula, data, response, x1 = NULL, x2 = NULL, x3 = NULL,
  x4 = NULL, time = NULL, nest = 1:3, prevModel = NULL,
  algorithms = c("PORT", "L-BFGS-B"), multErr = TRUE, rho = c(9, 2,
  1, 0.43, 0.25, 0.1, -0.1, -0.5, -0.75, -0.9, -0.99), rho1 = c(9, 2, 1,
  0.43, 0.25, 0.1, -0.1, -0.5, -0.75, -0.9, -0.99), digits = 6,
  save.data = TRUE, constrained = TRUE, fitBoundaries = TRUE, ...)

Arguments

formula

a formula of the form response ~ a + b + c + d + time. c and d are optional. The use of d had not yet been implemented.

data

a data frame, in which to evaluate the formula.

response

instead of specifying a formula, expressions for the components can be specified individually.

x1

instead of specifying a formula, expressions for the components can be specified individually as character strings.

x2

instead of specifying a formula, expressions for the components can be specified individually as character strings.

x3

instead of specifying a formula, expressions for the components can be specified individually as character strings.

x4

instead of specifying a formula, expressions for the components can be specified individually as character strings. Currently only 2 or 3 factors of production are supported. This is a placeholder for potential expansion of the package.

time

instead of specifying a formula, expressions for the components can be specified individually as character strings.

nest

a permutation (a,b,c,d) of the integers 1 through 4. For models with 3 factors, the nesting is (xa + xb) + xc. For 4 factors, the nesting is (xa + xb) + (xc + xd)

prevModel

a model used to start a gradient search. prevModel will be used as a starting point for a gradient search after both (a) grid search in rho and rho1 and (b) a gradient search starting from the best grid search are complete. #' Use NULL (the default value) if you want to skip the gradient search from a previous model.

multErr

logical, tells whether errors are to be assessed in a multiplicative manner

rho, rho1

creates a grid upon which gradient searches in all other (free) parameters will be made. (I.e., when rho and/or rho1 are specified, the algorithm performs gradient searches in the scale parameter, lambda, delta, and delta1 (if 3 factors of production are given) with rho and rho1 fixed.) Note that the default arguments for both rho and rho1 include the value 0.25. 0.25 is also the starting value for both rho and rho1 used by cesEst for gradient searches when rho and rho1 are unspecified. Thus, if you accept the default arguments, there is no need to do an additional cesEst gradient search with rho and rho1 unspecified. (rho = 0.25 corresponds to sigma = 0.8.) After the grid search, a gradient search is performed in which all parameters are free (including rho and rho1), starting from the best grid search point.

digits

the number of sse digits that is to be considered significant when comparing one fit against another.

save.data

a logical indicating whether data is to be saved with the model. Be sure to set TRUE if resampling is needed later. Default is TRUE.

constrained

a logical indicating whether the parameters should be constrained in the fitting process. Default is TRUE.

fitBoundaries

a logical indicating whether fits should be performed along boundaries. Default is TRUE.

Value

a cesEst model with additional information attached as attributes.

Note

For now the components in f (or the arguments response, x1, x2, x3, x4, and time) must correspond to variables in data and may not be other kinds of expressions.

For now, this function works for only 2 or 3 factors of production. Setting the value of x4 or using f of the form y ~ a + b + c + d + time will not work.

Examples

1
2
3
4
5
6
7
8
if (require("EconData") & require("dplyr")) {
  cesModel(iGDP ~ iK + iL + iQp + iYear, data = filter(Calvin, Country=="US"), nest = c(1,2,3))
  cesModel(iGDP ~ iK + iL + iQp + iYear, data = filter(Calvin, Country=="US"), nest = c(2,3,1))
  cesModel(iGDP ~ iK + iL + iQp + iYear, data = filter(Calvin, Country=="US"), nest = c(3,1,2))
  cesModel(iGDP ~ iK + iL + iQp + iYear, data = filter(Calvin, Country=="ZM"), nest = c(3,1,2))
  cesModel(response="iGDP", x1="iK", x2="iL", x3="iQp", time="iYear",
           data = filter(Calvin, Country=="ZM"), nest = c(3,1,2))
}

EconModels/MacroGrowth documentation built on Dec. 17, 2019, 10:41 p.m.