Suggestion about the exercise 10.6

Forums Questions on specific programs Suggestion about the exercise 10.6

This topic contains 8 replies, has 2 voices, and was last updated by Shengzhi Mao July 21, 2021 at 2:39 am.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1923

    Shengzhi Mao
    User

    Hi Fabian,
    Recently I’m reading your answer and codes to exercise 10.6, which is based on Sommer (JME, 2016) “Fertility choice in a life cycle model with idiosyncratic uninsurable earnings risk”. I find that this exercise is quite interesting and important for us to deal with discrete and continuous choices simultaneously.
    After learning the codes in your book, I read Sommer’s paper, which contained a popular method for calibrating all the parameters, i.e., the simulated method of moments. This SMM is very useful and powerful, and I really wanna learn this method. However, there are no codes about Sommer (JME,2016) posted online, and it’s hard to find any books teaching this method clearly with well-explained codes. So would you please share some materials now and add this SMM part to your book in the future edition? Do appreciate it!

    Best regards,
    Shengzhi Mao

    #1929

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    point well taken. This certainly is a useful addition to our book, and I put it on the list for a future edition. In the meanwhile, you might want to take a look at the codes to our paper “Bargaining over Babies: Theory, Evidence and Policy Implications”. There we use a simulated method of moment approach to calibrate parameters (although we no not calculate standard errors). But this model most importantly contains a solution routine called simulated_annealing that you can use to solve those parameter problems. The method uses stochastic simulation to overcome the problem of having multiple local optima in the RSS function.

    Take a look, I hope this helps.

    Thanks for the great suggestion,
    Fabian

    #1934

    Shengzhi Mao
    User

    Dear Fabian,

    Thank you for accepting my advice and also for sharing the paper “Bargaining over Babies: Theory, Evidence and Policy Implications”. Recently, I’ve read the paper and learned the simulated annealing method with online materials, which is quite interesting and useful.
    Now I’m trying to run the Fortran codes of your paper. However, I got some problems with the toolbox.f90 file, which failed at line 3655 ( function log_gamma(x_in) ) with
    Error: ‘log_gamma’ declared at (1) may shadow the intrinsic of the same name. In order to call the intrinsic, explicit INTRINSIC declarations may be required. [-Werror=intrinsic-shadow].

    I checked the internet while did not find useful solutions.
    Another problem comes from policy_analysis.f90, which fails at line 336 (middle = (left+right)/2d0) with
    Error: ‘left’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    policy_analysis.f90:336:0: Error: ‘right’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

    as well as line 345 (if(fmiddle <= tfr_increase .and. fright >= tfr_increase)then) with
    Error: ‘fright’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

    Hope you can give some hints for dealing with the errors. Thank you so much!

    Best regards,
    Shengzhi Mao

    #1936

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    this is strange. Did you try running it through the provided make file? Or did you run it through geany? Running it through geany might get you into some trouble, because you are running the toolbox twice, i.e. the toolbox included into your installation and the toolbox that comes with AER code. Try using it without the toolbox.f90 file.

    With regards to the policy_analysis.f90, you can add the code lines

    
        right = left
        fright = fleft
    

    directly after line 287, where fleft is computed. This should solve the error message, but has no impact on the results anyway.

    Best,
    Fabian

    #1937

    Shengzhi Mao
    User

    Dear Fabian,

    As you said, without running the toolbox.f90, and add the two code lines in policy_analysis.f90, I can compile all the codes in Geany now. However, I still get many errors when I build the fertdec.f90, which reports:

    Undefined symbols for architecture x86_64:
      "___estimation_MOD_do_estimation", referenced from:
          _main in fertdec.o
      "___estimation_MOD_setup_estimation", referenced from:
          _main in fertdec.o
      "___globals_MOD_alpha", referenced from:
          _main in fertdec.o
      "___globals_MOD_beta", referenced from:
          _main in fertdec.o
      "___globals_MOD_dist_hc", referenced from:
          _basic_setup.3457 in fertdec.o
         _main in fertdec.o
      ld: symbol(s) not found for architecture x86_64
      collect2: error: ld returned 1 exit status

    I just list some typical errors, and I guess they are due to some common problems. I’m running the codes on MacOS Sierra, version 10.12.4 with Geany version 1.37.1.

    Best regards,
    Shengzhi

    #1938

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    this is because you should actually run the codes through the makefile. This would make your life much easier.

    If you want to run the codes directly through geany, you would have to proceed in the following steps:

    1. Take all the .f90 codes from the folder src and copy them into the base folder of the replication directory (one folder up).
    2. Now open fertdec.f90 and include all respective .f90 files that contain modules. I suggest to use the following order

      include "globals.f90"
      include "output.f90"
      include "wage_distribution.f90"
      include "model.f90"
      include "simulated_annealing.f90"
      include "policy_analysis.f90"
      include "estimation.f90"

      Include these statements right before the program FertDec statement.

    This should allow you to run the entire code from geany. Let me know if it worked.

    Best,
    Fabian

    #1939

    Shengzhi Mao
    User

    Dear Fabian,

    Thank you very much. As you said, now I get way much fewer problems, but still have two errors:

    Undefined symbols for architecture x86_64:
      "_omp_get_max_threads_", referenced from:
          ___simulated_annealing_MOD_sa_minsearch in fertdec.o
      "_omp_set_num_threads_", referenced from:
          ___simulated_annealing_MOD_sa_minsearch in fertdec.o
          ___estimation_MOD_do_estimation in fertdec.o
    ld: symbol(s) not found for architecture x86_64
    collect2: error: ld returned 1 exit status

    I tried to rearrange the order of “include ‘simulated_annealing.f90′”, but still failed. After solving this problem, I guess it will be working.

    Best,
    Shengzhi

    #1940

    Fabian Kindermann
    Moderator

    Dear Shengzhi,

    it seems you are missing the -fopenmp compiler option. Maybe it would be a good idea to download and install the lates Fortran installation kit from our website. Then all settings should be set to get this going.

    Best,
    Fabian

    #1941

    Shengzhi Mao
    User

    Dear Fabian,

    Thank you for your patience and guidance. It works perfectly now. I will work hard to learn the codes and this COOL method. Do appreciate it!

    Best,
    Shengzhi

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.