# Association analysis covariate

**URL:** <https://discuss.hail.is/t/association-analysis-covariate/462>\
**Category:** Hail Query & hailctl\
**Created:** [April 12, 2018, 6:44pm UTC](https://discuss.hail.is/t/association-analysis-covariate/462 "2018-04-12T18:44:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trptyrphe](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/trptyrphe/32/263_2.png) [@trptyrphe](https://discuss.hail.is/u/trptyrphe)\
**Post date:** [April 12, 2018, 6:44pm UTC](https://discuss.hail.is/t/association-analysis-covariate/462/1 "2018-04-12T18:44:12Z")

</div>

Hi, I have got covariate such as RACE that’s basically string/categorical, I know hail currently doesn’t support this type, so what’s the syntax to convert that column in my samples\_table from string to numeric? Thanks.

---

<div class="post-metadata">

**Author:** ![jbloom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jbloom/32/109_2.png) [@jbloom](https://discuss.hail.is/u/jbloom)\
**Post date:** [April 13, 2018, 3:02pm UTC](https://discuss.hail.is/t/association-analysis-covariate/462/2 "2018-04-13T15:02:36Z")

</div>

Suppose the matrix table `mt` has a column field `RACE` of type `String` that can take three values: `"EUR"`, `"ASN"`, `"AFR"`. Since Hail internally adds an intercept covariate (which takes the value `1` for every sample), you’ll only want to add two covariates to account for `RACE`. Were you to add three covariates, the design matrix would be singular.

The simplest approach is a [dummy encoding](https://www.cscu.cornell.edu/news/statnews/stnews72.pdf) that encodes each category as a Boolean field. You could add these column fields to `mt` with [annotate\_cols](https://hail.is/docs/devel/hail.MatrixTable.html?highlight=annotate_cols#hail.MatrixTable.annotate_cols) if you’ll reuse them elsewhere in your analyses. But if you only want to use them in a regression, you might as well just create them on the fly. In 0.2 syntax, this looks like:

```auto
mt = hl.linear_regression(y = ..., x = ..., covariates = [mt.RACE == 'EUR', mt.RACE == 'ASN'])

```
