<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>regressione multipla &#8211; paologironi blog</title>
	<atom:link href="https://www.gironi.it/blog/en/tag/regressione-multipla/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.gironi.it/blog</link>
	<description>Scattered notes on (retro) computing, data analysis, statistics, SEO, and things that change</description>
	<lastBuildDate>Wed, 22 Jul 2026 10:24:35 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Multiple Regression Analysis, Explained Simply</title>
		<link>https://www.gironi.it/blog/en/multiple-regression-analysis-explained-simply/</link>
					<comments>https://www.gironi.it/blog/en/multiple-regression-analysis-explained-simply/#respond</comments>
		
		<dc:creator><![CDATA[paolo]]></dc:creator>
		<pubDate>Thu, 22 Jul 2021 14:55:00 +0000</pubDate>
				<category><![CDATA[statistics]]></category>
		<category><![CDATA[regressione multipla]]></category>
		<guid isPermaLink="false">https://www.gironi.it/blog/?p=3311</guid>

					<description><![CDATA[Does content length help ranking? Do backlinks bring traffic? Do faster pages convert better?Taken one at a time, these questions almost always get the same lazy answer: &#8220;yes, a bit&#8221;. The trouble is that in the real world factors never arrive one at a time. Long pages also tend to attract more links; pages with &#8230; <a href="https://www.gironi.it/blog/en/multiple-regression-analysis-explained-simply/" class="more-link">Continue reading<span class="screen-reader-text"> "Multiple Regression Analysis, Explained Simply"</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Does content length help ranking? Do backlinks bring traffic? Do faster pages convert better?<br>Taken one at a time, these questions almost always get the same lazy answer: &#8220;yes, a bit&#8221;. The trouble is that in the real world factors never arrive one at a time. Long pages also tend to attract more links; pages with more links are often the most carefully made, and maybe the slowest too. Everything moves together, and the question that really matters is a different one: *<em>which of these factors weighs on traffic </em>net of<em> the others?</em>*</p>



<p class="wp-block-paragraph">We saw, talking about <a href="https://www.gironi.it/blog/en/correlation/">correlation</a>, that we can measure how much two variables move together; and with <a href="https://www.gironi.it/blog/en/correlation-and-regression-analysis-linear-regression/">simple linear regression</a> that we can use one to predict the other.<br>But one correlation at a time is blind to the tangle: it risks handing the same medal to a factor and to its companion, without being able to tell them apart. It is the doorway to a trap we already know, <a href="https://www.gironi.it/blog/en/simpsons-paradox-in-seo-when-aggregate-data-can-lie/">Simpson&#8217;s paradox</a>: an association that flips sign or vanishes as soon as we account for a third variable. Multiple regression is the tool that tackles precisely this head-on — many causes together, each measured while holding the others fixed.</p>



<span id="more-3311"></span>



<p class="wp-block-paragraph"><strong>What we will cover</strong>:</p>



<ul class="wp-block-list"><li><a href="#why-multiple">Why one correlation at a time is not enough</a></li><li><a href="#equation">The equation: many causes, one effect</a></li><li><a href="#example">An example: what drives a page&#8217;s traffic</a></li><li><a href="#coefficients">Reading the coefficients: who really matters</a></li><li><a href="#validity">How valid is the model?</a></li><li><a href="#try-it">Try it yourself</a></li><li><a href="#further-reading">Further reading</a></li></ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="why-multiple">Why one correlation at a time is not enough</h2>



<p class="wp-block-paragraph">Suppose we measure, on our own site, the correlation between content length and the traffic pages receive. We will almost certainly find it positive: longer pages get more traffic.<br>The temptation, at that point, is every hurried consultant&#8217;s shortcut: &#8220;I&#8217;ll write longer and traffic will rise&#8221;. But that correlation, on its own, does not tell us <em>why</em> long pages do better. Do they do better because they are long, or because — being long and well made — they have collected more <em>backlinks</em> over the years, and it is the links that bring the traffic?</p>



<p class="wp-block-paragraph">These are two completely different stories, with two opposite action plans, and the correlation between traffic and length blends them into a single number. To separate them we need to be able to ask: <em>holding backlinks fixed</em>, does length still matter?<br>That is exactly the question multiple regression can answer. <strong>Multiple regression does not measure whether a factor is associated with the outcome, but how much it contributes once all the others are held fixed</strong>: it is the difference between looking at the world one variable at a time and looking at it as a whole.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="equation">The equation: many causes, one effect</h2>



<p class="wp-block-paragraph">The shape of the equation is the natural expansion of the simple-regression one: instead of a single predictor we put in several, each with its own coefficient. We want to explain a <em>response</em> variable (unique) from a set of <em>predictor</em> variables:</p>



\( y = b + a_1 x_1 + a_2 x_2 + \dots + a_k x_k \\ \)



<p class="wp-block-paragraph">where \( y \) is the variable we want to explain (traffic), \( x_1, x_2, \dots, x_k \) are the predictors (length, backlinks, speed), \( a_1, a_2, \dots, a_k \) are the <strong>regression coefficients</strong> and \( b \) is the intercept.<br>The heart of it all is the meaning of each \( a_i \): it is how much \( y \) changes when \( x_i \) increases by one unit <strong>and all the other variables stay constant</strong>. That &#8220;stay constant&#8221; is the magic — and the responsibility — of the method: it is there that the separation of effects happens, the very effects that stay tangled to the naked eye.</p>



<p class="wp-block-paragraph">In other terms: multiple regression simultaneously estimates the contribution of each factor, cleansed of that of all the others in the model. The best way to grasp it is to watch it dismantle a case built on purpose to fool us.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="example">An example: what drives a page&#8217;s traffic</h2>



<p class="wp-block-paragraph">Let me build in R an example table with sixty pages of a site. For each one I have the monthly traffic, the number of words, the <em>backlinks</em> received and the load time in seconds. In reality these data come from Search Console, a <em>crawler</em> and a link tool; here, being an example, I simulate them — but with a precise mechanism in mind, which will be our testing ground:</p>



<pre class="wp-block-code"><code>set.seed(42)
n &lt;- 60
words   &lt;- round(rnorm(n, 1200, 380)); words[words &lt; 350] &lt;- 350
speed   &lt;- round(pmax(0.6, rnorm(n, 2.6, 0.8)), 2)
# longer content attracts more backlinks: here is the tangle
backlinks &lt;- round(pmax(0, 0.018 * words + rnorm(n, 0, 6)))
# traffic is driven BY backlinks and speed, NOT by words
traffic &lt;- round(38 * backlinks - 260 * speed + 900 + rnorm(n, 0, 220))
traffic[traffic &lt; 0] &lt;- 0

pages &lt;- data.frame(traffic, words, backlinks, speed)</code></pre>



<p class="wp-block-paragraph">I built the data so that traffic really depends only on backlinks and speed, while length has no direct effect at all. But I also tied length to backlinks — long pages attract more of them — just as happens in reality. How tied are they?</p>



<pre class="wp-block-code"><code>cor(pages$words, pages$backlinks)
# [1] 0.81</code></pre>



<p class="wp-block-paragraph">A strong bond: <strong>0.81</strong>. Let us now see what happens if, naively, we study traffic looking only at length, with a simple regression:</p>



<pre class="wp-block-code"><code>coef(summary(lm(traffic ~ words, data = pages)))
#              Estimate Std. Error t value  Pr(&gt;|t|)
# (Intercept) 241.1577   137.9404   1.748 0.0857...
# words         0.6128     0.1088   5.635 0.0000...</code></pre>



<p class="wp-block-paragraph">The verdict looks overwhelming: every hundred extra words are worth some sixty extra sessions, with a tiny <em>p-value</em> (below 0.001). Length &#8220;matters&#8221;, and matters a lot.<br>If we stopped here, we would go and write an editorial directive — <em>make all content longer</em> — on a basis that is about to turn out a mirage. Let us add the other two factors to the model and see what remains of length:</p>



<pre class="wp-block-code"><code>model &lt;- lm(traffic ~ words + backlinks + speed, data = pages)
coef(summary(model))
#              Estimate Std. Error t value Pr(&gt;|t|)
# (Intercept) 1100.797   120.119    9.164  0.0000
# words          0.107     0.102    1.041  0.3025
# backlinks     29.444     4.804    6.129  0.0000
# speed       -322.943    34.515   -9.357  0.0000</code></pre>



<p class="wp-block-paragraph">Here is the reversal. The length coefficient has collapsed from 0.613 to <strong>0.107</strong>, and its <em>p-value</em> has jumped to <strong>0.30</strong>: no longer distinguishable from zero.<br>Length, <em>holding backlinks and speed fixed</em>, brings almost nothing. What in the simple regression looked like its merit was in fact a reflection of the backlinks: long pages get more traffic not because they are long, but because — being long — they attract more links, and it is the links that do the work.</p>



<div class="wp-block-group has-background" style="background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem"><div class="wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained">

<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1020" height="690" src="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-confondente-en.png" alt="Traffic against number of words, with points coloured by backlink level. The red line is the simple regression: slope +0.61, length &quot;seems&quot; to drive traffic. The dashed green line is the effect of length holding backlinks and speed fixed: almost flat. The points with many backlinks (dark blue) cluster in the top right — they are the ones creating the apparent slope." class="wp-image-4399" srcset="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-confondente-en.png 1020w, https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-confondente-en-300x203.png 300w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /><figcaption class="wp-element-caption">Traffic against number of words, with points coloured by backlink level. The red line is the simple regression: slope +0.61, length &quot;seems&quot; to drive traffic. The dashed green line is the effect of length holding backlinks and speed fixed: almost flat. The points with many backlinks (dark blue) cluster in the top right — they are the ones creating the apparent slope.</figcaption></figure>

</div></div>



<p class="wp-block-paragraph"><strong>This is the deep meaning of multiple regression: it tells the factor that acts from the one that merely tags along.</strong> A task no correlation taken singly could ever perform.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="coefficients">Reading the coefficients: who really matters</h2>



<p class="wp-block-paragraph">From the full model we get three coefficients, but comparing them as they are would be a mistake: they have different units. The words coefficient (0.107) is per <em>word</em>, the backlinks one (29.4) is per <em>link</em>, the speed one (−323) is per <em>second</em>. Saying that speed &#8220;matters more&#8221; because its number is bigger makes no sense: a second and a word are not the same thing.</p>



<p class="wp-block-paragraph">To compare them we must put them on the same scale. The standard way is to standardize all the variables — express them in standard deviations — and rerun the regression: the resulting coefficients, called <strong>standardized coefficients</strong> (or <em>betas</em>), tell how many standard deviations traffic changes for one extra standard deviation of each factor. Now they are comparable. I compute them in R by standardizing the data with <code>scale</code>:</p>



<pre class="wp-block-code"><code>z &lt;- as.data.frame(scale(pages))
round(coef(lm(traffic ~ words + backlinks + speed, data = z))[-1], 3)
#    words backlinks    speed
#    0.104     0.610   -0.552</code></pre>



<p class="wp-block-paragraph">The picture becomes readable at a glance: <strong>backlinks</strong> are the engine (+0.61), <strong>speed</strong> a powerful drag (−0.55: the slower a page, the less traffic it gathers), and <strong>words</strong> a trifle (+0.10) that, as we already know, is not even distinguishable from chance.<br>A coefficient on its own, though, is not enough to trust: around every estimate there is a margin of uncertainty. If a coefficient&#8217;s confidence interval includes zero, that factor might well have no effect at all — which is precisely the situation of length.</p>



<div class="wp-block-group has-background" style="background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem"><div class="wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained">

<figure class="wp-block-image size-large"><img decoding="async" width="990" height="600" src="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-coefficienti-en.png" alt="Coefficient plot: each factor with its standardized coefficient and 95% confidence interval. Backlinks (+0.61) and speed (−0.55) sit clearly on one side of the zero line; words (+0.10) crosses it — an effect indistinguishable from chance. The length of the interval also tells the precision of the estimate." class="wp-image-4400" srcset="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-coefficienti-en.png 990w, https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-coefficienti-en-300x182.png 300w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /><figcaption class="wp-element-caption">Coefficient plot: each factor with its standardized coefficient and 95% confidence interval. Backlinks (+0.61) and speed (−0.55) sit clearly on one side of the zero line; words (+0.10) crosses it — an effect indistinguishable from chance. The length of the interval also tells the precision of the estimate.</figcaption></figure>

</div></div>



<div class="wp-block-group has-background" style="background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1.5rem;padding-left:1.5rem"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<p>A word of warning: in our example words and backlinks were correlated at <strong>81%</strong>, and this is no harmless detail. When two predictors are too much alike, the model struggles to separate their effects, and the coefficients become unstable and imprecise — this is <strong>multicollinearity</strong>, one of the pitfalls we will tackle when talking about <a href="https://www.gironi.it/blog/en/multicollinearity-heteroscedasticity-autocorrelation-three-difficult-sounding-concepts-explained-simply/">model diagnostics</a>. Here it played in our favour, helping unmask the fake effect of length; but in general <strong>a non-significant coefficient does not prove a factor is irrelevant: it may only tell us that, given these tightly tangled predictors, we cannot isolate its contribution.</strong></p>
</div></div>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="validity">How valid is the model?</h2>



<p class="wp-block-paragraph">Knowing which factors matter is half the job; the other half is asking how well, overall, the model reconstructs reality. The reference measure is the <strong>coefficient of determination</strong> \( R^2 \): the share of traffic variability the model manages to explain, from 0 (nothing) to 1 (everything). I read it from the summary:</p>



<pre class="wp-block-code"><code>summary(model)$r.squared      # 0.805
summary(model)$adj.r.squared  # 0.795</code></pre>



<p class="wp-block-paragraph">An \( R^2 \) of <strong>0.805</strong> says our three factors together explain 80.5% of the traffic variability across pages — the rest is noise, or factors we did not include.<br>Beside it appears the <em>adjusted</em> \( R^2 \) (0.795), a slightly lower value: it penalizes the addition of useless variables, and should be looked at instead of the raw \( R^2 \) when comparing models with a different number of predictors. It guards against a trap: adding variables <em>always</em> raises the raw \( R^2 \), even when those variables add nothing real.</p>



<p class="wp-block-paragraph">The most honest way to judge a model, though, is to watch it at work: put the traffic it <em>predicts</em> against the <em>observed</em> one, page by page. The closer the points hug the diagonal, the better the model captures reality.</p>



<div class="wp-block-group has-background" style="background-color:#f5f7f9;margin-top:2.5rem;margin-bottom:2.5rem;padding-top:1.5rem;padding-right:1.5rem;padding-bottom:1rem;padding-left:1.5rem"><div class="wp-block-group__inner-container is-layout-constrained wp-container-core-group-is-layout-eed7543b wp-block-group-is-layout-constrained">

<figure class="wp-block-image size-large"><img decoding="async" width="930" height="750" src="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-osservati-predetti-en.png" alt="Observed traffic against traffic predicted by the three-variable model. The points cluster around the diagonal (perfect prediction); the vertical grey segments are the gaps between observed and predicted. The model explains 80.5% of the variability." class="wp-image-4401" srcset="https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-osservati-predetti-en.png 930w, https://www.gironi.it/blog/wp-content/uploads/2026/07/regressione-multipla-osservati-predetti-en-300x242.png 300w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /><figcaption class="wp-element-caption">Observed traffic against traffic predicted by the three-variable model. The points cluster around the diagonal (perfect prediction); the vertical grey segments are the gaps between observed and predicted. The model explains 80.5% of the variability.</figcaption></figure>

</div></div>



<p class="wp-block-paragraph">A high \( R^2 \), it must be said, is not an automatic promotion: behind it lies a list of <strong>requirements</strong> the model takes for granted — that the relationships be linear, that the residuals behave well, that the predictors not be redundant (the multicollinearity of a moment ago). When these assumptions break, the coefficients stay numbers, but they stop being reliable. That is the territory of diagnostics, and it deserves a discussion of its own.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading" id="try-it">Try it yourself</h2>



<p class="wp-block-paragraph">The best way to fix the mechanism is to get your hands on it. Taking the code above, there are three interesting directions to explore:</p>



<ol class="wp-block-list"><li>Drop backlinks from the model — <code>lm(traffic ~ words + speed)</code> — and watch what happens to the words coefficient: it grows large and &#8220;significant&#8221; again. It is the counter-proof that the fake effect lives only as long as the confounder stays out of the model.</li><li>Add a completely <strong>made-up, random</strong> variable (<code>pages\( noise &lt;- rnorm(60)</code>) and put it back into the model: watch the raw \)R^2\( rise by a hair and the adjusted \)R^2$ hold still or fall. That is the practical meaning of the adjustment.</li><li>Change the generating mechanism: make traffic depend <em>also</em> on words (add a <code>+ 0.3 <em> words</code> to the <code>traffic</code> formula) and check that now, in the full model, the length coefficient survives. It serves to </em>feel* the difference between a real effect and a merely apparent one.</li></ol>



<p class="wp-block-paragraph">A hint: the structure never changes — you fit the model, read the coefficients <em>holding the others fixed</em>, check the \( R^2 \) and the observed-predicted cloud. It is by playing with the variables in and out of the model that you grasp how much of what we call a &#8220;ranking factor&#8221; is cause and how much, simply, company.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph">So far our response variable has been a number that flows without jumps — traffic, which can be 300 sessions or 1,520. But very many SEO questions do not have this shape: a page <em>converts or does not convert</em>, a user <em>returns or does not return</em>, a keyword <em>breaks into the first page or stays out</em>. The answer is a yes or a no, and then a line predicting continuous numbers is no longer enough: we would need a model that predicts a <em>probability</em>, forced to stay between 0 and 1. That is the job of <a href="https://www.gironi.it/blog/en/logistic-regression-predicting-the-outcome-of-an-event/">logistic regression</a>, the next step of our path.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading" id="further-reading">Further reading</h3>



<p class="wp-block-paragraph">If you want to go deeper into multiple regression, the interpretation of coefficients <em>holding the others fixed</em> and the reading of \( R^2 \) — the very backbone of what we built here — <em><a href="https://www.amazon.it/dp/1461471370?tag=consulenzeinf-21" rel="nofollow sponsored noopener" target="_blank">An Introduction to Statistical Learning</a></em> by James, Witten, Hastie and Tibshirani is the book I recommend: it builds the linear-model framework with care, always starting from applied problems, and its hands-on R labs let you reproduce every step — including the traps of correlated predictors.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.gironi.it/blog/en/multiple-regression-analysis-explained-simply/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
