Recent reviews in sociology, public health, and urban planning suggest small-scale geographic variations in urban environments are associated with an individual's health, behavior, and well-being. However, estimation of these ‘neighborhood effects' are complicated. One complicating factor is residential sorting: Individual characteristics such as race, age, and socioeconomic status are associated with behavior and health and these same individual-level factors are often geographically clustered within neighborhoods. This residential sorting leads to a correlation between individual and environmental determinants of behavior and health and poses problems for statistical inference. A second complicating factor is uncertainty about the geographic dimensions of a person's neighborhood. We explore these two potential confounders through a simulation experiment that generates synthetic cityscapes and synthetic behaviors for geolocated individuals. The simulation is used to develop a model of how residential sorting, urban structure, and the geographic definition of an individual's neighborhood affect our understanding of the association between the urban environment and behavior. We find that residential sorting does not systematically affect the magnitude of neighborhood effect estimates, however, the misrepresentation of the geographic dimensions of an individual's neighborhood leads to systematic bias in estimates of neighborhood effects. Unlike previous research on the modifiable areal unit problem we find a systematic relationship between the definition of geographic units of analysis and the magnitude of regression coefficients.