est_param_hetero_aggregate, use debug or debugonce function in RStudio:debug(est_param_hetero_aggregate)
RStudio automatically starts a debug mode when you call the function after running the above command.

In the debug mode, push n to evaluate the current line and move to the next line. Push c to run the remaining lines of the function and q to quit. When you step into a loop, you can press f to finish the loop.
As you debug(function_name), you need to reload the package including the function or undebug(function_name) to stop entering into the debug mode. If you used debugonce(function_name), RStudio does not enter the debug mode from the second function call.
You should always be able to locate the exact step raising the error. If there is no error is found in line n and there is an error in line n + k, then there should be a line between n and n + k that causes the error.
As you detect the exact location of the error or unexpected behavior, then start thinking about the reason for this. If R issues an error message, carefully read the message and search the internet for the solution.
At this point, you can ask ChatGPT about the possible solution. To do so, you will copy the code and the error message and paste it into the chat and ask “I had this error message when I run the following command in R”.
Because ChatGPT often tells a lie, you may not find a relevant solution. Then, search the web resource for the solution. Typically, you will search keywords like “R [keywords from the error message]”.
If you don't find the solution, report the problem to the supervisor. When you do so, make sure to explain how to replicate the error. For this, you will need to report
If you find the reason for the error or unexpected behavior, fix it first in the test files in the tests/ folder. After confirming that the problem is resolved with the test files, you reflect these changes in the files in the main/ folder. Always follow these steps. Otherwise, the test files in the tests/ folder get obsolete and are no longer used for testing the code.
Make sure to check the behavior and test whether the bug is fixed as you edit the code to resolve the problem. Some just edit the code and do not check the behavior. Then, the problem is not resolved with a high probability.
Leave a bug report containing the problem, cause, and solution on the project page.