FAQ#

Installation#

  • How do I install the package?

    You can install the package following the Installation Guide.

    As a quick reference, you can install the package using pip:

    pip install mcf
    

Usage#

  • Where can I find the results of the ModifiedCausalForest class?

    The results are stored in a dictionary returned by the predict() method of the ModifiedCausalForest class. This dictionary contains various estimated treatment effects, their corresponding standard errors and related objects, all of which can be inspected in your variable explorer.

    Here is a brief demonstration on how to retrieve these results:

    # Train the Modified Causal Forest:
    my_mcf.train(df)
    # Assign the output of the predict method to a variable:
    results = my_mcf.predict(df)
    # The 'results' dictionary contains the estimated treatment effects, standard errors and others:
    print(results.keys())
    

    For more examples you can check out the Getting Started or the User Guide.

    Moreover, when using the train(), predict(), analyse() methods, and the McfOptPolReport class, a folder called “out” is generated in your specified output path. If no output path is specified, all files will be saved where the Anaconda distribution is installed. You can learn more about working directories and output paths at w3schools.

    The “out” folder contains a PDF with crucial information regarding the estimation of the ModifiedCausalForest. For more comprehensive insights, we recommend reviewing the Full example with all parameters used.

  • Where can I find the results of the OptimalPolicy class?

    The results are stored mainly in two diccionaries which you can access once you have used the evaluate() and allocate() and solve() methods. Additionally, you can access further results stored in your instance of the OptimalPolicy class where you can access multiple dictionaries containing additional results.

    For more examples you can check out the Getting Started or the User Guide.

    As with the ModifiedCausalForest class, further results are also stored in the “out” folder either as PDF, txt or csv files.

  • How can I determine which data points were excluded during common support checks and access the corresponding dataframe?

    We recommend you check the Common Support section. Additonally, you can check which data points were excluded in the common support section of the PDF file which is automatically generated.

  • How do I access the dataframe representing the final sample that passed common support criteria?

    You can access the final sample that passed the common support criteria from the results dictionary returned by the predict() method of the ModifiedCausalForest class. The dataframe is stored under the key “iate_data_df”.

    # Access the dataframe from the results dictionary
    final_sample_df = results["iate_data_df"]
    print(final_sample_df)
    
  • Do I include the heterogeneity variable in the covariates?

    Yes, you must include the heterogeneity variable that you are interested in with the rest of your covariates.

  • What’s the difference between ordered and unordered variables?

    Ordered variables are numerical variables that have a natural order, such as age or income. To increase the speed of the mcf algorithm, specify binary variables also as ordered ones. Unordered variables, also known as categorical variables, are variables that don’t have a natural order, such as occupation or nationality.

Troubleshooting#

  • I’m getting an error when I try to install the package. What should I do?

    Make sure you have the latest version of pip installed. If the problem persists, please use the issue tracker.

  • I’m getting an error with Ray. What should I do?

    If you’re getting an error with Ray, try resetting the kernel before every training. This can often solve issues related to Ray. If the problem persists, please use the issue tracker.

  • The package has been installed successfully, but I’m getting an error when I try to import it. What should I do?

    This could be due to a conflict with other packages or an issue with your Python environment. Try creating a new virtual environment and installing the package there. If the problem persists, please open an issue on the GitHub repository.

  • I’m getting unexpected results when I use the package. What should I do?

    Make sure you’re using the package as intended. Check the documentation and examples to see if you’re using the functions and classes correctly. If you believe the results are incorrect, please open an issue on the GitHub repository.

  • The package is running slower than I expected. What can I do to improve performance?

    Performance can depend on many factors, including the size of your data and your hardware. Check the documentation for tips on improving performance, specially the Computational section.

  • I’m having trouble understanding how to use a certain feature of the package. Where can I find help?

    The documentation is the best place to start. It provides a detailed explanation of all features and how to use them. If you’re still having trouble, consider opening an issue on the GitHub repository.

  • I am getting an error during the Common Support Analysis, what can I do?

    Are you sure the variables specified under ‘var_x_name_unord’ are discrete unordered ones? You might have provided a continuous ordered variable, but a discrete unordered one is expected. This raises a ValueError of the form:

    ValueError: Found array with 0 sample(s) (shape=(0, 1001)) while a minimum of 1 is required by RandomForestClassifier.