0

I am able to create a linear regression in R using

lmex = lm(overweight$h_egfr_cystc96 ~ overweightlogblood + overweight$sex, data = overweight)

In my data.frame, sex is labeled as 2 for female and 1 for male. I want to make sure that the sign for the slope for my linear regression is correct.

In other words, if female was 0 and male was 1, the sign of the slope of my regression would be opposite than if female was 2 and male was 1. How do I label my categorical variables in the regression, or is there a better solution?

Thanks in advance!

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
goose144
  • 27
  • 6
  • With `help('relevel')` you can make sure the base level is the one you have chosen. – Rui Barradas Jul 02 '20 at 21:35
  • 2
    There is not need to use `$` when you explicitly pass a data.frame to `data` argument, so you can write just `lm(h_egfr_cystc96 ~ logblood + sex, data = overweight)` – Jilber Urbina Jul 02 '20 at 21:35
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. How exactly do you want to "label" the values in the regression? The output for `lm` usually includes the names of the relevant levels for factors (assuming you used factors rather than "magic" numbers). – MrFlick Jul 02 '20 at 21:35

0 Answers0