# A Synthetic Demonstration of Logistic Regression with a Three-Level Group Variable

## Introduction

This manuscript demonstrates a research software workflow using synthetic data. It is an educational example, not a clinical study. The workflow covers data generation, model fitting, and reporting of a binary outcome with group and covariate predictors. The aim is to show how a logistic regression model can be executed and described reproducibly.

We focus on a simple scenario: 600 simulated independent observations, a binary outcome, three groups, and a continuous covariate. The logistic model is specified as y ~ group + z. This synthetic example is intended to illustrate software mechanics. It does not evaluate any real treatment, intervention, or patient population. The letters A, B, and C denote simulated categories and do not identify any real exposure.

The workflow includes the following components: generating synthetic data with a fixed random seed, fitting a generalized linear model with a logit link, and reporting odds ratios with confidence intervals and p-values. The model assumptions are described, and the scope is limited to this synthetic dataset. No clinical validity, superiority, or publication readiness is implied.

The software used for model fitting is R's glm function, documented in the R Core Team reference [1].  No analyses beyond those specified were performed.

This introduction describes the synthetic nature and limited scope of the demonstration. The methods section details the data generation and model fitting. The results section reports the exact numerical outputs. The discussion interprets the workflow and its limitations.

## Methods

This methods section describes a synthetic demonstration. No real data or patients were involved. The data were generated using R [1]. The random seed was fixed at 230924. We simulated 600 independent observations. Group assignment used sample(c('A','B','C'), 600, TRUE). The covariate x was drawn from a uniform(0,10) distribution. The covariate z was drawn from a standard normal distribution. The binary outcome y was generated as Bernoulli with probability plogis(-0.6 + 0.1*x + 0.5*(group=='B') - 0.4*(group=='C') + 0.2*z).

The analysis model was a logistic regression fitted with glm using the formula y ~ group + z. The logit link was used. The model estimated an intercept, two group contrasts (B vs A, C vs A), and a coefficient for z. The covariate x was not included in the model. This means the fitted model is not the same as the data-generating model, which included x. This is an intentional demonstration of a misspecified model relative to the synthetic truth.

Exposure and covariate coefficients are exponentiated to give odds ratios; the intercept remains on the log-odds scale. An odds ratio is a ratio of odds, not a risk ratio. The 95% confidence intervals use the normal Wald approximation on the coefficient scale, followed by exponentiation for odds ratios. No missing data were present. All 600 records were analyzed. No exclusions were applied. The analyzed unit is the individual record. Observations were independent, without clustering or repeated measurements.

The primary effect of interest is the contrast between group B and group A. The secondary contrasts are group C versus group A and the coefficient for z. The intercept is also reported. All estimates are accompanied by 95% confidence intervals and p-values. No model fit statistics, power calculations, or additional analyses were performed. The only diagnostics reported is that the fixed analysis recipe completed successfully. The synthetic data and model are not intended for inference about any real population.

## Results

This results section presents numerical outputs from a synthetic demonstration. All values are from the supplied metrics. No clinical interpretation is warranted.

The analysis input contained 600 records. No records were missing. No records were excluded. The analyzed sample size was 600. The outcome y had mean 0.45, standard deviation 0.49791, and median 0. The variable group had 3 categories. The covariate z had mean -0.023632, standard deviation 0.95872, and median -0.082315.

Table 1 contains the two group contrasts; Table 2 reports all model coefficients. The intercept on the log-odds scale was -0.3338 (95% CI -0.6100 to -0.0576; p=0.017854). It describes modeled baseline log-odds, rather than a group comparison. The group B versus group A odds ratio was 1.7574 (95% CI 1.1800 to 2.6172; p=0.005528). The group C versus group A odds ratio was 0.8722 (95% CI 0.5864 to 1.2973; p=0.499730). The coefficient for z had an odds ratio of 1.1484 (95% CI 0.9677 to 1.3630; p=0.113254).

These odds ratios are interpreted as multiplicative changes in the odds of the outcome, not as risks. For group B versus A, the odds of the outcome are estimated to be 1.76 times the odds for group A, holding z constant. For group C versus A, the odds are estimated to be 0.87 times the odds for group A, holding z constant. For a one-unit increase in z, the odds are estimated to be 1.15 times as large, holding group constant. The confidence interval for the group B contrast excludes 1, while the intervals for group C and z include 1.

Table 2 includes the intercept and all fitted coefficients. Table 3 summarizes analysis variables and missingness, with zero missing records. Table 4 describes the analysis flow: 600 received and 600 analyzed, with zero excluded. Table 5 reports baseline and group descriptions, as summarized above. The model fitting diagnostic indicates that the fixed analysis recipe completed successfully. No further diagnostics are available.

The numerical results exactly match the supplied metrics. No uncertainty beyond the reported confidence intervals is presented. These estimates apply only to this synthetic dataset.

## Discussion

This discussion interprets a synthetic demonstration only. It does not imply clinical validity, patient involvement, or real interventions. The findings are specific to the simulated data and the misspecified model. No causal or clinical conclusions can be drawn.

The workflow demonstrated that a logistic regression model can be fitted and reported in a reproducible manner. The model included group and z but omitted x, which was part of the data-generating process. This omission illustrates how model assumptions affect estimates. The exposure and covariate effects are odds ratios, whereas the intercept is on the log-odds scale. The group B contrast was larger than the group C contrast in this synthetic sample. However, these are properties of the simulation, not of any real exposure.

Several assumptions underlie the fitted model. Observations are assumed independent. The logit link is assumed correct. The relationship between z and the log-odds is assumed linear. No interactions were included. The model omits x. In this simulation x was generated independently of group and z; its omission does not establish confounding. Because odds ratios are non-collapsible, coefficients from this reduced model need not equal conditional coefficients in the generating model. This is a deliberate feature of the demonstration. The synthetic data generation used simple random sampling without clustering, so no random effects were needed. 

The analysis had no missing data and no exclusions. This is a feature of the simulation. In real research, missingness and exclusions would require careful handling and reporting. The reported confidence intervals and p-values are based on the fitted model and should not be interpreted as evidence for any real effect. The p-value for group B is less than 0.05, but this is a synthetic result. The p-values for group C and z are greater than 0.05.

The scope of this demonstration is limited to software mechanics. No novelty is claimed. No power calculation was performed. No model fit statistics are reported. The only diagnostic is that the analysis completed. The numerical results are exact and are not intended to be generalized. The synthetic example does not evaluate any treatment, policy, or biological mechanism.

Future users of this workflow should verify all assumptions, inspect data quality, and consider sensitivity analyses. They should not use this demonstration as a template for clinical research without appropriate validation. The letters A, B, and C are arbitrary labels. The outcome y is simulated. The covariates x and z are simulated. No real data were used.

This synthetic demonstration shows how a logistic regression model can be fitted and reported using R's glm [1]. It highlights the importance of model specification and the difference between odds and risk. It does not provide evidence for any real-world effect. No clinical or publication readiness is implied. The workflow is reproducible with the fixed seed and supplied code.

## References

[1] R Core Team. glm: Fitting Generalized Linear Models. R Documentation.


## Figure legends

Figure 1. Odds ratios from logistic regression. Points show estimates; horizontal lines indicate 95% confidence intervals. The analysis included 600 observations. Intervals use the Wald normal approximation.

> AI 生成内容，请人工核对。请按期刊要求披露 AI 使用。

<!-- AIGC {"AIGC":{"Label":"1","ContentProducer":"Clin2Sci","ProduceID":"clin2sci:6b163b9c-8ee9-4f11-8871-267c7419ad4c","ReservedCode1":"","ContentPropagator":"Clin2Sci","PropagateID":"clin2sci:6b163b9c-8ee9-4f11-8871-267c7419ad4c","ReservedCode2":""}} -->
