What we should choose for the A/B testing measurement? T test or linear regression? What's the difference and why so simple approach as linear regression reallyWhat we should choose for the A/B testing measurement? T test or linear regression? What's the difference and why so simple approach as linear regression really

How to Build Connections for A/B Testing and Linear Regression: An Essential Guide

Linear regression or T-test. How to choose?

\ We often get caught up in the buzz around fancy machine learning models and deep learning breakthroughs, but let’s not overlook the humble linear regression.

\ ==In a world of LLM and cutting-edge architectures, linear regression quietly plays a crucial role, and it’s time we shine a light on how it can be beneficial even today.==

\ Consider a scenario where an e-commerce company introduces a new banner, and we aim to assess the impact of it on the average session length. To achieve this, an experiment was conducted, and data was gathered for analysis. Let’s analyze the results.

T-test

Let’s employ a familiar tool for this task: the t-test.

The results are pretty promising:

The uplift in the metric is simply the difference between the sample averages of the control and treatment groups. In our case, the estimated uplift is 0.56 minutes, indicating that users, on average, spend 33 seconds longer using our product.

Linear Regression

Now, let’s employ linear regression with the treatment vector (whether the new banner is shown or not) as the independent variable and the average session length as the output variable.

Then we print the summary of our model:

\

\ Notably, the coefficient for the treatment variable aligns with our earlier uplift estimate of 0.56. It is worth noting that R-squared is just 0.008, and we don’t explain too much of the variance with this model.

Coincidence?

Is this a coincidence that the uplift we got from the t-test and the treatment coefficient are the same? Let’s delve into the connection.

\ Let’s think about what the treatment variable reflects. When it equals 1, it indicates the average session length for users who viewed the banner; when it equals 0, it indicates the average session length for users who did not see the banner. It means the treatment variable (or slope in linear regression terms) signifies the change in mean between the control and treatment groups.

What is the null hypothesis for the treatment variable in linear regression?

What is the null hypothesis when we apply the T-test for the experiment? It’s totally the same.

Hence, when computing the t-statistics and p-value for identical hypotheses, our findings remain consistent and identical.

Why do we want to use linear regression?

However, what is the reason behind using linear regression? We do not want to just overcomplicate things.

\ First, let’s think about whether only the treatment is responsible for the change in our primary metric.

\ In reality, this may not be entirely accurate due to the presence of selection bias.

\ Selection bias in A/B testing is a type of error when there is a systematic difference between the groups being compared that is not due to random chance, for example:

\

  • We witness that old users get exposed to a new banner more often than new customers.

    \

Random allocation that we use in AB tests helps us to mitigate it, but it’s hard to eliminate completely.

\ Let’s formulate how to estimate the true effect.

ATE: average treatment effect that we aim to estimate.

\ ATT: average treatment effect of those treated. We can also call it ACE: average causal effect. We actually can calculate it. It is the difference between the sample averages of the control and treatment groups.

\ SB: selection bias that we aim to minimize.

\ How can we minimize it?

\ Linear regression allows us to add covariates/confounding variables. Let’s try it out and add as one of confounding variable the average session length for users before the experiment.

And print the summary of the model:

Our R-squared has skyrocketed! Now, we explain 86% of the variance.

\ Our treatment effect now is 0.47.

Which one to choose?

So, we have two treatment effects: 0.47 and 0.56; which one is correct?

\ In this case, we know for sure the true effect because I have simulated data and the real uplift: 0.5

import numpy as np import pandas as pd from scipy import stats import statsmodels.api as sm np.random.seed(45) n = 500 x = np.random.normal(loc = 10 ,scale = 3, size= 2 * n) y = x + np.random.normal(loc = 2 , scale = 1 ,size = len(x)) # For 50% of users we simulate treatment effect treat = 1 * (np.random.rand(2 * n) <= 0.5) experiment = pd.DataFrame(x, columns=["covariate"]) experiment['metric'] = y experiment['treatment'] = treat experiment['noise'] = np.random.normal(size = len(experiment)) # Add noise and uplift to 'metric' for rows where 'treat' is equal to 1 # The real uplift is 0.5 experiment['metric'] = experiment.apply(lambda row: row['metric'] + 0.5 * row['treatment'] + row['noise'] if row['treatment'] == 1 else row['metric'], axis=1)

That means 0.47 is better in terms of absolute difference and is closer to reflecting the actual uplift.

Conclusion

Using linear regression has the following advantages:

  1. It provides a deeper comprehension of our data and how well the model aligns with the data.
  2. By using covariates, we can mitigate selection bias, resulting in a more accurate estimation of the treatment effect.

\ Can we use linear regression for other tests, like the Welch t-test or the Chi-square test?

\ The simple answer is yes. However, we have to make some adjustments that we are going to discuss in the next articles!

Market Opportunity
B Logo
B Price(B)
$0.24418
$0.24418$0.24418
+8.31%
USD
B (B) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Fed rate decision September 2025

Fed rate decision September 2025

The post Fed rate decision September 2025 appeared on BitcoinEthereumNews.com. WASHINGTON – The Federal Reserve on Wednesday approved a widely anticipated rate cut and signaled that two more are on the way before the end of the year as concerns intensified over the U.S. labor market. In an 11-to-1 vote signaling less dissent than Wall Street had anticipated, the Federal Open Market Committee lowered its benchmark overnight lending rate by a quarter percentage point. The decision puts the overnight funds rate in a range between 4.00%-4.25%. Newly-installed Governor Stephen Miran was the only policymaker voting against the quarter-point move, instead advocating for a half-point cut. Governors Michelle Bowman and Christopher Waller, looked at for possible additional dissents, both voted for the 25-basis point reduction. All were appointed by President Donald Trump, who has badgered the Fed all summer to cut not merely in its traditional quarter-point moves but to lower the fed funds rate quickly and aggressively. In the post-meeting statement, the committee again characterized economic activity as having “moderated” but added language saying that “job gains have slowed” and noted that inflation “has moved up and remains somewhat elevated.” Lower job growth and higher inflation are in conflict with the Fed’s twin goals of stable prices and full employment.  “Uncertainty about the economic outlook remains elevated” the Fed statement said. “The Committee is attentive to the risks to both sides of its dual mandate and judges that downside risks to employment have risen.” Markets showed mixed reaction to the developments, with the Dow Jones Industrial Average up more than 300 points but the S&P 500 and Nasdaq Composite posting losses. Treasury yields were modestly lower. At his post-meeting news conference, Fed Chair Jerome Powell echoed the concerns about the labor market. “The marked slowing in both the supply of and demand for workers is unusual in this less dynamic…
Share
BitcoinEthereumNews2025/09/18 02:44
3 Paradoxes of Altcoin Season in September

3 Paradoxes of Altcoin Season in September

The post 3 Paradoxes of Altcoin Season in September appeared on BitcoinEthereumNews.com. Analyses and data indicate that the crypto market is experiencing its most active altcoin season since early 2025, with many altcoins outperforming Bitcoin. However, behind this excitement lies a paradox. Most retail investors remain uneasy as their portfolios show little to no profit. This article outlines the main reasons behind this situation. Altcoin Market Cap Rises but Dominance Shrinks Sponsored TradingView data shows that the TOTAL3 market cap (excluding BTC and ETH) reached a new high of over $1.1 trillion in September. Yet the share of OTHERS (excluding the top 10) has declined since 2022, now standing at just 8%. OTHERS Dominance And TOTAL3 Capitalization. Source: TradingView. In past cycles, such as 2017 and 2021, TOTAL3 and OTHERS.D rose together. That trend reflected capital flowing not only into large-cap altcoins but also into mid-cap and low-cap ones. The current divergence shows that capital is concentrated in stablecoins and a handful of top-10 altcoins such as SOL, XRP, BNB, DOG, HYPE, and LINK. Smaller altcoins receive far less liquidity, making it hard for their prices to return to levels where investors previously bought. This creates a situation where only a few win while most face losses. Retail investors also tend to diversify across many coins instead of adding size to top altcoins. That explains why many portfolios remain stagnant despite a broader market rally. Sponsored “Position sizing is everything. Many people hold 25–30 tokens at once. A 100x on a token that makes up only 1% of your portfolio won’t meaningfully change your life. It’s better to make a few high-conviction bets than to overdiversify,” analyst The DeFi Investor said. Altcoin Index Surges but Investor Sentiment Remains Cautious The Altcoin Season Index from Blockchain Center now stands at 80 points. This indicates that over 80% of the top 50 altcoins outperformed…
Share
BitcoinEthereumNews2025/09/18 01:43
Bitcoin devs cheer block reconstruction stats, ignore security budget concerns

Bitcoin devs cheer block reconstruction stats, ignore security budget concerns

The post Bitcoin devs cheer block reconstruction stats, ignore security budget concerns appeared on BitcoinEthereumNews.com. This morning, Bitcoin Core developers celebrated improved block reconstruction statistics for node operators while conveniently ignoring the reason for these statistics — the downward trend in fees for Bitcoin’s security budget. Reacting with heart emojis and thumbs up to a green chart showing over 80% “successful compact block reconstructions without any requested transactions,” they conveniently omitted red trend lines of the fees that Bitcoin users pay for mining security which powered those green statistics. Block reconstructions occur when a node requests additional information about transactions within a compact block. Although compact blocks allow nodes to quickly relay valid bundles of transactions across the internet, the more frequently that nodes can reconstruct without extra, cumbersome transaction requests from their peers is a positive trend. Because so many nodes switched over in August to relay transactions bidding 0.1 sat/vB across their mempools, nodes now have to request less transaction data to reconstruct blocks containing sub-1 sat/vB transactions. After nodes switched over in August to accept and relay pending transactions bidding less than 1 sat/vB, disparate mempools became harmonized as most nodes had a better view of which transactions would likely join upcoming blocks. As a result, block reconstruction times improved, as nodes needed less information about these sub-1 sat/vB transactions. In July, several miners admitted that user demand for Bitcoin blockspace had persisted at such a low that they were willing to accept transaction fees of just 0.1 satoshi per virtual byte — 90% lower than their prior 1 sat/vB minimum. With so many blocks partially empty, they succumbed to the temptation to accept at least something — even 1 billionth of one bitcoin (BTC) — rather than $0 to fill up some of the excess blockspace. Read more: Bitcoin’s transaction fees have fallen to a multi-year low Green stats for block reconstruction after transaction fees crash After…
Share
BitcoinEthereumNews2025/09/18 04:07