Git Product home page Git Product logo

Comments (9)

murao164jp avatar murao164jp commented on June 16, 2024 1

from bimets.

andrea-luciani avatar andrea-luciani commented on June 16, 2024

Hi murao164jp.

I hope that you solved all your issues. I will tag this thread as "solved".

Have a good day.

from bimets.

murao164jp avatar murao164jp commented on June 16, 2024

from bimets.

andrea-luciani avatar andrea-luciani commented on June 16, 2024

Hi murao164jp.

Thank you for your suggestion.

We are currently working on a bimets version 4 that will allow users to estimate and simulate rational expectations / forward-looking models.

This task is the most significant change since the bimets package went out years ago.

After bimets version 4 is made available to users, we will try to insert max likelihood estimation methods in the bimets ESTIMATE procedure.

Anyway, please consider that you can insert custom estimation coefficients in a bimets model bypassing the ESTIMATE procedure; i mean that at the moment you can estimate your equation (outside bimets) using standard R code (e.g. stats4::mle) and then insert your custom coefficients into the model, e.g.:

mymodel$behaviorals$myendogenous$coefficients <- mycustomMLEcoefficients

Have a good day.

from bimets.

murao164jp avatar murao164jp commented on June 16, 2024

Regarding TSEXTEND() function, we have the following property or problem.

TSEXTEND() function generates hypothetical values for, say Scenario 1. TSEXTEND() function does not change the previous values even if we set new conditions for Scenario 2. If we run the whole R script, again, then TSEXTEND() function changes the previous values to the new values for Scenario 2.

This property requires us to make more than two bimets-type models if we have more than one scenario. This kind of information is not shown in the current manual of bimets. The next version of the bimets manual would provide the information of how to deal with this property or problem. If so, please ignore the following my suggestion.

The bimets manual provides some illustrative examples, including the out-sample forecast (p.25) and the stochastic forecast (p.175). However, these examples are based on one scenario, not more than one scenario.

Suppose that we have two scenarios: Scenario 1 (base projection) and Scenario 2 (plus G projection). We use the same estimated model and the same observed data set. We use two different sets of hypothetical values for Scenario 1 and Scenario 2. The model is called “model_text” and the observed data set is called “data_bimets”, which means “the usual-type data set for bimets”.

For this setup, the syntax or algorithm for related functions is written as follows.


Scenario 1

x <- LOAD_MODEL(modelText = model_text)
x <- LOAD_MODEL_DATA(x, data_bimets)
x <- ESTIMATE(x, ---)
The use of TSEXTEND() function.
x <- SIMULATE(x, ---)

Scenario 2

y <- LOAD_MODEL(modelText = model_text)
y <- LOAD_MODEL_DATA(y, data_bimets)
y <- ESTIMATE(y, ---)
The use of TSEXTEND() function.
y <- SIMULATE(y, ---)


Notice that we estimate the same model twice with the same observed data set. It is “strange” in a sense.

Normally we use the same estimated model with two different sets of hypothetical values and get the two sets of simulation values for Scenario 1 and Scenario 2. This approach does not work due to the above property of TSEXTEND() function.

In short, it is important to provide this kind of information in the bimets manual.

Attached are my R script with the above syntax and its output picture. You can get the details of the syntax. If you get syntax better than the above syntax, then I would like to know it.

Thank you for your attention to my suggestion.

sim_use_TSEXTEND_shock_G.pdf
sim_use_TSEXTEND_shock_G

from bimets.

andrea-luciani avatar andrea-luciani commented on June 16, 2024

hi @murao164jp

I am unsure I understand your problem with the TSEXTEND function, but I try to give you some hints.

The first time you use the TSEXTEND function, you update the G, MrP and TAX time series values inside the bimodel$modelData list up to 2024-4 using your custom factor:

(i)

bimodel$modelData <- within(bimodel$modelData,{
G = TSEXTEND(G, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
MrP = TSEXTEND(MrP, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
TAX = TSEXTEND(TAX, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
})

The second time you call the TSEXTEND function it does not change anything because the input time serie (in bold here below) has already been extended up to the 2024-4 period during the previous TSEXTEND call (i):

(ii)

bimodel$modelData <- within(bimodel$modelData,{
G = TSEXTEND(G, UPTO = c(2024,4), EXTMODE = 'MYRATE', FACTOR = 1.03)
MrP = TSEXTEND(MrP, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
TAX = TSEXTEND(TAX, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
})

The TSEXTEND simply does not change anything if the input times series already has defined values up to the 2024-4 period. Take a look at reference manual pag. 196 https://cran.r-project.org/web/packages/bimets/bimets.pdf

Independently from bimets and any modeling aspect (this is R base behaviour), the standard R command within in (i) and (ii) takes as input (and updates) the objects that are defined inside the input bimodel$modelData list, while it does not change the G, MrP and TAX in the GlobalEnv.
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/with

G and bimodel$modelData$G are two distinct time series in R workspace. Using the within command you always read and update the second one.

If you want to perform a new TSEXTEND in G, MrP, TAX without reloading the whole model and dataset, you have to extend an unchanged base time series, I mean something like (typos apart...):

G_base <- G
MrP_base <- MrP
TAX_base <- TAX
...
bimodel=LOAD_MODEL(...)
bimodel=LOAD_MODEL_DATA(...)
bimodel=ESTIMATE(...)
...
bimodel$modelData <- within(bimodel$modelData,{
G = TSEXTEND(G_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
MrP = TSEXTEND(MrP_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
TAX = TSEXTEND(TAX_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.005)
})

...
bimodel=SIMULATE(...)
...

G = TSEXTEND(G_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.003)
MrP = TSEXTEND(MrP_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.003)
TAX = TSEXTEND(TAX_base, UPTO = c(2024, 4), EXTMODE = "MYRATE", FACTOR = 1.003)
})

...
bimodel=SIMULATE(...)
...

from bimets.

murao164jp avatar murao164jp commented on June 16, 2024

Thank you for your useful information, again.

Since we know the property of TSEXTEND() function, we know which method works or not. We know the following method works all right, resulting different simulation values for Scenario 1 and Scenario 2.


Scenario 1

x <- LOAD_MODEL(modelText = model_text)
x <- LOAD_MODEL_DATA(x, data_bimets)
x <- ESTIMATE(x, ---)

Copy x to y for Scenario 2 before TSEXTEND call

y <- x
The use of TSEXTEND() function for Scenario 1
x <- SIMULATE(x, ---)
The use of TSEXTEND() function for Scenario 2
y <- SIMULATE(y, ---)

We know that the following method does not work well, resulting the same simulation values for Scenario 1 and Scenario 2.


Scenario 1

x <- LOAD_MODEL(modelText = model_text)
x <- LOAD_MODEL_DATA(x, data_bimets)
x <- ESTIMATE(x, ---)
The use of TSEXTEND() function for Scenario 1
x <- SIMULATE(x, ---)

Copy x to y for Scenario 2 after TSEXTEND call

y <- x
The use of TSEXTEND() function for Scenario 2
y <- SIMULATE(y, ---)

Using the wrong method, the user would have a hard time to solve the problem if the user does not know the property of TSEXTEND() function. The user notices that something is wrong since the outcomes of Scenario 1 and Scenario 2 are the same. However, no error messages are present. Consequently, the user would have a hard time to solve the problem.

I thought that many users would adapt the wrong method since I used it for my first use of TSEXTEND() function. If you believe that no users would adapt the wrong method, then you do not need to change the bimets manual.

If you think that some users would adapt the wrong method, then you need to modify the bimets manual. It is important that the bimets manual provides the following information.

(1) The second call of TSEXTEND() function does not change the previous values with the new values. Because the inputs time series has already been extended up to the time period specified during the previous TSEXTEND call.

(2) The bimets manual provides the information for dealing with this problem so that the user can get different simulation results for Scenario 1 and Scenario 2. There are a few correct methods for the task. I have shown two correct methods, and you have shown one correct method. You can choose the simple and efficient method among the three methods. Then you provide an example to get different simulation values for Scenario 1 and Scenario 2, using TSEXTEND() function.

Besides the problem under consideration, the bimets manual does not show an example of more than one scenario. In this sense, it is nice to show an example of more than one scenario, using Kleain Model I.

Thank you for your attention to my using concern.

from bimets.

andrea-luciani avatar andrea-luciani commented on June 16, 2024

@murao164jp

Yes, I think that the simplest way to address multiple scenarios analysis is the way you suggested in your last post:

model1 <- LOAD_MODEL(modelText = model_text)
model1 <- LOAD_MODEL_DATA(model1, data_bimets)
model1 <- ESTIMATE(model1, ---)

#create multiple models
model2 <- model1
model3 <- model1
model4 <- model1
...

#change exogenous paths on model2
model2$modelData <- within(model2$modelData,{
exog1 = TSEXTEND(exog1 , ...)
exog2 = TSEXTEND(exog2 , ...)
...
})

#simulate model2
model2 <- SIMULATE(model2,...)


#change exogenous paths on model3
model3$modelData <- within(model3$modelData,{
exog1 = TSEXTEND(exog1 , ...)
exog2 = TSEXTEND(exog2 , ...)
...
})

#simulate model3
model3 <- SIMULATE(model3,...)

#compare simulated endogneous results in model2 vs model3
#e.g. with TABIT or other commands....
TABIT(model2$simulation$endog1,model3$simulation$endog1)

We will insert a similar example in bimets reference manual.
Have a good day.

from bimets.

murao164jp avatar murao164jp commented on June 16, 2024

from bimets.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.