# Logistic regression, computation of the linear model used in given paper, how to apply to a different data set

I'm referring to this paper :

Model building strategy for logistic regression: purposeful selection http://dx.doi.org/10.21037/atm.2016.02.15

Data is created at the start and I'm unsure about the $$z$$ term that's used.

Here's the code from the start:

    # variables
age    <- abs(round(rnorm(n=n1, mean = 67, sd =14)))
lac    <- abs(round(rnorm(n=n1, mean = 5 , sd = 3),1))
gender <- factor(rbinom(n=n1, size=1, prob=0.6), labels = c("male","female"))
wbc    <- abs(round(rnorm(n=n1, mean=10, sd=3),1))
hb     <- abs(round(rnorm(n=n1, mean=120,sd=40)))

# linear model?
z      <- 0.1 * age - 0.02 * hb + lac - 10

# probability estimate for each entry
pr     <- 1 / (1 + exp(-z))

# outcome
mort   <- factor(rbinom(n1, 1, pr), labels = c("alive","die"))
data   <- data.frame(age, gender, lac, wbc, hb,mort)


There the probabilities are computed based on the $$z$$ that's given before.

How have those coefficient values been solved for though?

If

$$z = \beta_0 + \beta_1 \text{Age} + \beta_2 \text{hb} + \beta_3 \text{lac}$$

Then my question is why

\begin{align} \beta_0 &= -10 \\ \beta_1 &= 0.1 \\ \beta_2 &= 0.02 \\ \beta_3 &= 1 \end{align}

I'm unsure how I would apply this process to my own data, given that $$z$$ doesn't seem to have an explanation within the paper.

• But the last term isn't a product? I assumed the coefficient of lac was one and that the -10 was the intercept. – baxx Dec 21 '18 at 17:25
• doh! @baxx, you are right! I misread that last term as being multiplied by 10. I'll modify my answer and delete my previous comment accordingly! Thanks for the catch! I guess this underscores the importance of readable code, which the author certainly didn't present. – StatsStudent Dec 21 '18 at 17:38

In the paper, $$z$$ and the coefficients on the other variables related to it are created purposefully by the author -- not estimated/fit by some model. The point of the paper is to demonstrate a variable selection procedure and to do that, the author has created a known or "true" underlying relationship between z and the variables, ag, hb, and lac (and a baseline mean or intercept). So the author purposefully created the relationship:
$$z=-0.1Age-0.02HB+1LAC-10$$
The author could have chosen any relationship between $$z$$ and these variables. Once this true relationship is known, the author then proceeds to use the known relationship to demonstrate the effectiveness of the variable selection procedure. He can evaluate the effectiveness of the selection procedure only by comparing it against a known model.
In reality, you wouldn't know $$z$$ or its relationship to the independent variables. You'd have a dataset consisting of an outcome response (like mort), and then some independent variables ag, hb, and lac. You'd then carry out the steps of purposeful selection to determine the relationship between mort and ag, hb, and lac. So, to carry out this process in your own analysis, you'd essentially be starting from the point where the data already exists. The author has simply generated data for demonstration purposes here.