✏️ Esercizi#
from scipy.stats import norm
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
Intel MKL WARNING: Support of Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) enabled only processors has been deprecated. Intel oneAPI Math Kernel Library 2025.0 will require Intel(R) Advanced Vector Extensions (Intel(R) AVX) instructions.
In questo esercizio verrà presentato un problema relativo al modello di regressione lineare bivariata.
Si consideri il seguente output relativo ad un modello di regressione che è stato adattato usando PyMC:
variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
1 alpha 474. 474. 21.1 20.4 439. 508. 1.00 12093. 9976.
2 beta 0.309 0.315 0.145 0.139 0.0640 0.536 1.00 11148. 9048.
3 sigma 117. 115. 17.6 16.1 92.4 149. 1.00 10085. 9068.
Supponiamo che il modello ipotizzi una distribuzione gaussiana di possibili valori \(y\) centrati su \(\hat{y}\). Si consideri una tale distribuzione in corrispondenza di \(x_i\) pari a 1.5; si trovi il valore \(y_i \mid x_i\) che lascia sotto di sé una probabilità pari a 0.2. Prima di eseguire l’analisi di regressione, si standardizzino i dati.
Soluzione#
# Given parameters
b0 = 474
b1 = 0.309
sigma = 117
x_i = 1.5
# Calculating the mean of the distribution
mean = b0 + b1 * x_i
print(mean)
474.4635
# Finding the quantile of order 0.2 for the distribution
quantile_0_2 = norm.ppf(0.2, loc=mean, scale=sigma)
print("The quantile of order 0.2 for the distribution is:", quantile_0_2)
The quantile of order 0.2 for the distribution is: 375.99381567196906