# One sided formula & ModelMatrix

**URL:** <https://discourse.julialang.org/t/one-sided-formula-modelmatrix/5102>\
**Category:** Data\
**Tags:** question, data\
**Created:** [July 28, 2017, 3:10am UTC](https://discourse.julialang.org/t/one-sided-formula-modelmatrix/5102 "2017-07-28T03:10:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![clinton](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clinton](https://discourse.julialang.org/u/clinton)\
**Post date:** [July 28, 2017, 3:10am UTC](https://discourse.julialang.org/t/one-sided-formula-modelmatrix/5102/1 "2017-07-28T03:10:25Z")

</div>

I’m trying to write some 2SLS code, and ran into the following scenarios:

I have a one-sided formula and a DataFrame. Is there a simple way to get the model matrix given that formula? The @formula macro throws an error without a LHS.

Similarly, if the formula is two sided, can I get a vector for the dependent variable? The ModelMatrix(ModelFrame(@formula(…), df)).m strategy doesn’t supply the dependent variable. Getting this vector is non-trivial since the validity of dependent variable data points is affected by the presence of NAs on both sides of the formula.
