Environmental awareness is of increasing concern for society and leads heavy pressure to adopt challenging political decisions, in such diverse economic sectors as oil industries, automotive industries and electric utilities. Undoubtedly, all this goes beyond the environmental scope, entails reallocating significant financial resources and moving employment from one economic sector to another, with its corresponding impact on social welfare. Some examples of this transformation are the replacement of polluting coal and fuel generation plants by renewable energy sources (RES), the replacement of internal combustion engine vehicles by electric vehicles, new skilled occupations in energy efficiency improvements related to buildings, among others.In developed countries, electricity is increasingly important for small end-consumers as their consumption per capita is several-folder higher than developing countries2. Consequently, the final price of electricity is a sensitive issue that is often at the heart of political debate due to its potential effects on consumer price indexes and on the most vulnerable consumers. Lastly, many countries consider electricity as an essential good and have specific rules aimed to protect these vulnerable consumers.This thesis focus on grid-related costs linked to RES. The replacement of conventional generation technologies by RES is one of the most important challenges for electricity systems in the last few decades because RES might be located far from actual conventional capacity and their production profile is very different, with the consequent impact on grid use, need and other costs. In this regard, grid-related costs also affect the performance of the power sector and impact on social welfare as they are recovered through the final price of electricity paid by consumers and firms. These costs can be classified in several groups despite all them being fairly interlinked in one way or another. In the analysis presented in this dissertation, attention is centered on electricity losses, grid-congestions and grid-investments.First, electricity losses correspond to wasted energy through the grids and paid by consumers in the final electricity price. Clearly, these losses affect social welfare and the efficiency of the power sector. To provide some context, in Spain energy losses represented about 1,600Me in 2017 (Ministry of Industry, 2018; REE, 2018).Second, grid-congestion costs4 include compensations to generators facing partial or total curtailments resulting from temporary grid constraints or grid bottlenecks. These compensations are shared among all consumers as part of the wholesale price of electricity in a country. For reference, in Spain these compensations represented about 390Me in 2017, which accounts for 2.6% of the annual wholesale price of electricity (REE, 2020). Moreover, this grid constraint means curtailing the production from a generation plant, and also means wasting decarbonized energy when RES are involved. It is important to highlight that these costs will hardly ever be zero as there are unforeseen events, not all situations are predictable, and the network cannot be endlessly reinforced. In this regard, only the most repeated events are those solved by reinforcing or building a new grid. Part of the empirical analyses presented in this PhD dissertation is based on gravity models, this thesis represents another contribution because these models have not been applied to the analysis of electricity flows within a country. The few existing studies using gravity models in the context of electricity flows are limited to the flows between countries, not within a country as is the case here (Antweiler, 2016; Batalla-Bejerano et al., 2019)