First, is it appropriate to assume that the trials are independent of each other? Let's assume that.
Hopefully the predictors label, label2, label3
do not have too many categories. If a categorical variable has $n$ possible values, then the model will have to estimate $n-1$ different parameters. If each has relatively few categories, that is fine, but if there are a large number of categories you may want to think whether they can be grouped together in some way to make the analysis more intuitive.
You have said that impedance
is a ratio value. It may turn out that you don't get the best fit using impedance
as a linear coefficient because its true relationship to the fit is non-linear. You might try fitting one model with impedance
and one with log(impedance)
, and see which one has a better fit overall.
Luckily, your response variable is binary-valued, and you want to estimate the probability of a state change. You should try a binomial logistic regression, so that you are estimating $ln\left(\frac{p}{1-p}\right)$ rather than $p$ directly (this is called "logit" function). If you used the glm
package in R
, you would input the model approximately like this:
fitted.model <- glm(did_state_change ~ impedance + label1 + label2 + label3, family = binomial(link="logit"), data = yourDataFrame)
If there is reason to believe that the variance will not be uniform across trials, you can choose quasibinomial
as the family rather than binomial
.
Consider looking at some example problems in a textbook on the topic, e.g. Gelman and Hill (2007)
Let's say that you are also interested in finding a cutoff point for impedence
, above which the probability of a state change, for given values of label_i
, exceeds a certain value $x$. When you fit a basic binary logistic regression, you will get parameters specifying an intercept $\alpha$ and $\beta_i$ (coefficients of the predictors). Supposing that we do a dumbed down model, where only impedence
is used as a predictor (call it $I$), then the model will return parameters $\alpha$ and $\beta_1$ for an equation having the form:
$$ln\left(\frac{p}{1-p}\right) = \alpha + \beta_1I$$
If $\beta_1$ is positive, then $p$ will increase with increasing $I$. In that case, you can plug in your cutoff point, $x$, and solve for $I$, getting:
$$I(p=x) = \frac{1}{\beta_1}\left\{ln\left(\frac{x}{1-x}\right) - \alpha\right\}$$
You can simplify some of this by programming a little logit function in R:
logit <- function(x){log(x/(1-x))}
Then if you type in logit(x)
it will return $ln\left(\frac{x}{1-x}\right)$.