# Overview

The `modelplot` function, within the `modelsummary` package, constructs coefficient plots from regression output - i.e. visualization of model estimates and confidence intervals. In this building block, we will provide two examples of coefficients plots that are frequently used:

• A focal regression coefficient across multiple models
• Multiple regression coefficients within a single model

We will be using the models from the paper “Doing well by doing good? Green office buildings”. These models regress the logarithm of rent per square foot in commercial office buildings on a dummy variable representing a green rating (1 if rated as green) and other building characteristics. Please refer to the `modelsummary` building block for more information about the paper.

## The `modelsummary` table

Below you see the five regression models for which results are displayed in Table 1 of Eiccholtz et al. (2010). For a detailed overview and understanding of these regressions, please refer to the `modelsummary` building block. ## Plotting a Focal Coefficient Across Multiple Models

Let’s create a coefficient plot of the “Green Rating” variable, which measures the impact of a green rating on the rent of the building. The Green rating variable is binary, taking the value 1 if the building has a certified green rating and takes the value of zero otherwise. We will plot the regression coefficient and it’s confidence interval across a different regression specifications.

We will include the regression models 1, 3, and 4 in the models list, as these include the Green rating variable. The order of the models in `models2` will determine the order of the variable rows in the plot.

We can customize the variable names displayed in the coefficient plot using the `coef_map` argument. In the vector `cm`, we assign a new name to the original term name. Only variables included in `coef_map` will be shown in the plot. ### Changing the confidence level

By default, the confidence level is set to 95%. We can change this by specifying the desired level using the `conf_level` argument.

### Further customization of the plot

Further customization of the plot can be done using `ggplot2` functions. In the next code block, the following changes are made:

• Changing the font type to Times New Roman
• Modifying the color of the lines
• Adjusting the order of the legend

Within the `scale_color_manual()` functions, we specify the colors of the lines and control the order of the regressions in the legend. To do this, we need to define two vectors: `color_map` for the colors of the lines, and `legend_order` for the order of the regressions in the legend. Tip

Before specifying Times New Roman as the font type in our plot, we need to import this font into R. You can use the following code to import the font:

For Windows users:

``````library(extrafont)

font_import()
``````

For IOS users:

``````library(extrafont)

font_import(prompt = FALSE)
``````

Note that running `font_import()` may take a few minutes to complete.

### Changing the labels

We can modify the labels of the plot using the `labs()` argument. We omit the x-axis label and add a title, subtitle, and caption. Also, the title of the legend is changed by specyfying it as a character string and assigning it to the `color` parameter within `labs()`.

Furthermore, we can change the position of the text elements within `theme()`. Specifically, we adjust the position of the title and subtitle to be centered by setting `hjust = 0.5`. Similarly, the caption is placed on the left side by setting `hjust = 0`. This plot visualises the relationship between the presence of a green rating and the rent of the building. For the different regression models, the magnitude and the statistical significance of the green rating is unchanged. Thus, the plot reveals that the rent in a green-rated building is significantly higher by 2.8 to 3.5 percent compared to building without a green rating.

## Multiple Coefficients Within a Single Model

We can also use a a coefficient plot to visualize more than one regression coefficient from a single model Let’s showcase the coefficients of the each of the building age variables in regression 3 to demonstrate this. This plot allows us to visualize the effects of different building age categories on the the log of rental prices.

We can construct this plot as follows: ### Further customizations

Similar to the first example, we can customize the plot further with `ggplot2` functions. We add a theme, change the font type and adjust the labels and captions. This plot clearly demonstrates that newer buildings command a significant premium compared to older ones, indicating a positive relationship between building age and rent in these models. Summary

The `modelplot` function from the `modelsummary` package offers a useful tool for creating clear and informative coefficients plots in `R`. In this building block, two examples are provided. The first example demonstrates how to visualize a single coefficient across multiple models. The second example showcases how to visualize multiple coefficients within a single model.