CESKalman: Function for estimating a CES production function with the...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/CESKalman.R

Description

The function applies the CESKalman_Estimation function to estimate the elasticity of substitution in a CES production function using the Kalman filter. CESKalman is more robust than the CESKalman_Estimation as it loops over different values of the signal-to-noise ratio, the number of lags, and initial parameter values. The combination that maximizes the likelihood given the model is well specified based on the bgtest from lmtest package and the Normalized Innovations Squared is chosen.

Usage

1
2
3
CESKalman(data,grid.param_init=c(-9,-1,5),max_nlags=2,grid.lambda,
                grid.alpha_init=c(-0.9,-0.1,0.3),grid.sigma_init=c(0,1.5,0.5),
                cVal_NIS=0.10,cVal_Auto=0.10,print_results=TRUE,lambda_est_freely=TRUE)

Arguments

data

A matrix or ts matrix with the data series (see details)

grid.param_init

A string of length 3. First and second argument are the, respectively, lower and upper bound of the grid of the initial variance of the error term used in the dlmMLE function. Third is the step size

max_nlags

Maximum number of lags used. One of 0,1,2

grid.lambda

A string of length 3. First and second argument are the, respectively, lower and upper bound of the grid of the inverse of the signal-to-noise ratio. Third is the step size. If set to NA, no grid is used

grid.alpha_init

A string of length 3. First and second argument are the lower and upper bound of initial values for the adjustment parameter, α, to loop over. Third is the step size

grid.sigma_init

A string of length 3. First and second argument are the lower and upper bound of initial values for the long run elasticity of substitution, σ, to loop over. Third is the step size

cVal_NIS

Critical value to be used to construct the confidence bands of the NIS test

cVal_Auto

Critical value to be used in the Breusch Godfrey test for autocorrelation

print_results

Do you want the function to print results while estimating?

lambda_est_freely

Should lambda also be estimated freely?

Details

This function calls the function CESKalman_Estimation multiple times as it loops over a grid of values of the signal-to-noise ratio, number of lags chosen to prevent autocorrelation and different combinations of initial parameter values of sigma and alpha. The optimal signal-to-noise ratio and initial parameter values are chosen to maximize the likelihood, conditional on the model being well specified based on a Breusch Godfrey test for autocorrelation and a Normialized Innovations Squared test for filter misspecification.

The estimated function is the Error-Correction model from Kronborg et al (2019): Δ s_{t}=α(s_{t-1}-(1-σ)p_{t-1}-μ_{t-1})+∑_{i=0}^{nlags}κ_{i}Δ p_{t-i}+∑_{i=1}^{nlags}γ_{i}Δ s_{t-i}+ε_t. s_t is the relative budget shares in logs (expenditure on factor 1 relative to factor 2), p_t is the relative prices in logs and μ_t=(σ-1)log(Γ_t) where Γ_t is the relative augmenting technical change. The process of μ_t, the state variable, is an I(2) process: Δ μ_t=Δ μ_{t-1}+η_t.

data should be a matrix or ts matrix containing the data series and the dimension Tx4. First and second column is the price of the first and second factor, respectively. Third and forth is the quantity of factor 1 and factor 2, respectively.

The function loops over a grid of different signal-to-noise ratios in the range specified in grid.lambda. In addition, it is possible to also estimate this parameter freely by setting lambda_est_freely=TRUE. In this case, the preferred value from the grid search is compared to the free estimation and the one that maximizes likelihood given the estimation being well specified is chosen.

If sigma is estimated to be negative it is restricted to zero, but we still allow for short run fluctuations of prices to influence the budget shares.

Potential convergence errors of dlmMLE can most often be resolved by increasing the range of grid.param_init, e.g. to grid.param_init=c(-9,-1,1). Note that the variances are specified such that Σ^ε=exp(param[1]) and Σ^η=exp(param[2]) if lambda is freely estimated. Else, only exp(param[1]) is used and λΣ^η=Σ^ε. When lambda is freely estimated the grid.param_init is still only over values of exp(param[1]), i.e. the observation variance. But for any observation variance we try five different values of lambda in the interval 10-1000 as initial value of exp(param[2]).

Value

Returns a list of class CESKalman from the preferred call of function CESKalman_Estimation (highest likelihood and well specified). See CESKalman_Estimation for description. In addition, the data series applied is returned.

Author(s)

Christian Sandholm Kastrup <CST@dreamgruppen.dk> , Anders Farver Kronborg <ANK@dreamgruppen.dk> and Peter Philip Stephensen <psp@dreamgruppen.dk>

References

Kronborg et al (2019) and Kastrup et al (2021)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## First, data is loaded with the Load_Data function (or any other data set)
data = Load_Data(Country="USA",tstart=1970,tend=2017)

data = cbind(data[,"q"],data[,"w"],data[,"K"],data[,"L"])

## We can then estimate with four different approaches that all depends on the value of lambda.

# 1. Grid combined with free estimation (our preffered method)
Kalman = CESKalman(data=data,grid.lambda=c(10,500,20), lambda_est_freely=TRUE)

# 2. Grid only
Kalman = CESKalman(data=data,grid.lambda=c(10,500,20), lambda_est_freely=FALSE)

# 3. Free estimation only
Kalman = CESKalman(data=data,grid.lambda=NA, lambda_est_freely=TRUE)

# 4. A fixed value of lambda, e.g. lambda=100
Kalman = CESKalman(data=data,grid.lambda=c(100,100,100), lambda_est_freely=FALSE) ## Only argument [1] used

## Output is displayed with e.g. the plot function:
plot(Kalman)

sigma=Kalman$sigma # This is the elasticity
alpha=Kalman$alpha # This is the adjustment parameter
Gamma=Kalman$Gamma # This is the relative log augmenting technologies

CKastrup/CESKalman documentation built on Jan. 26, 2022, 9:09 a.m.