In: Statistics and Probability
Controlling for a variable in statistical analysis is the attempt to reduce the effect of confounding variables in an observational study or experiment. It means that when looking at the effect of one variable, the effects of all other variable predictors are taken into account, either by making the other variables take on a fixed value (in an experiment) or by including them in a regression to separate their effects from those of the explanatory variable of interest (in an observational study).
Now, neither did you describe the type of dependent variable nor independent variable we are dealing with here so, I am going describe the procedure of controlling a variable in two separate contexts.
1. Experiments
Experiments attempt to assess the effect of manipulating one or more independent variables on one or more dependent variables. To ensure the measured effect is not influenced by external factors, other variables must be held constant. These variables that are made to remain constant during an experiment are referred to as the control variables.
In controlled experiments of medical treatment options on humans, researchers randomly assign individuals to a treatment group or control group. This is done to reduce the confounding effect of irrelevant variables that are not being studied, such as the placebo effect.
2. Observational Study
Observational studies are used when controlled experiments may be unethical or impractical.
In an observational study, researchers have no control over the values of the independent variables, they must control for variables using statistics.
Any observed association between the independent variable and the dependent variable could be due to outside, spurious factors rather than indicating a true link between them. This can be problematic even in a true random sample. By controlling for the extraneous variables, the researcher can come closer to understanding the true effect of the independent variable on the dependent variable.
In this context the extraneous variables can be controlled for by using multiple regression. The regression uses as independent variables not only the one or ones whose effects on the dependent variable are being studied, but also any potential confounding variables, thus avoiding omitted variable bias.