This thesis develops novel methods for econometric analysis of time series data, and applies these methods in the context of demand-side management in California's electricity markets. The first method is an optimization framework for simulating the behavior of electricity consumers with realistic dynamic consumption models under various dynamic electricity tariffs. This allows to generate new insights into the effect of intertemporal substitution on individual and social surplus under various existing and hypothetical pricing schemes, including Real-Time pricing, Time-of-Use pricing, Critical Peak Pricing, and Critical Peak Rebates. By introducing the concept of a baseline-taking equilibrium, it is possible to quantify the welfare implications of the manipulation of Demand Response (DR) baselines. A second contribution of this thesis is the formulation of the optimal contract design problem a DR aggregator faces when employing inter-temporal flexibility of commercial buildings' HVAC-related power consumption in order to participate in the regulation capacity spot market. The associated bilevel optimization problem can be cast as a mixed-integer optimization problem that can be solved efficiently. The third contribution of this thesis is a novel methodology for causal inference on time series data based on ideas from Machine Learning. This two-stage approach allows to evaluate conditional individual treatment effects in experimental and non-experimental settings with repeated treatment exposure. The setup is very general and agnostic to the specific regression models used. Besides establishing core theoretical results, this thesis presents associated multi-stage bootstrapping techniques, which allow to perform statistical inference even under computationally challenging prediction models. Based on the developed inference methodology, the empirical contribution of this thesis is to study the effect of receiving DR notifications on energy consumption of residential electricity customers in California, including causal estimates of individual and average treatment effects. These results inform the design of a large-scale randomized controlled trial of much broader scope, which is currently being implemented in collaboration with a DR provider in California and involves more than 10,000 customers over a 14 month duration.