Contesto Aziendale

Azienda: Neonatal Health Solutions
Obiettivo: Creare un modello statistico in grado di prevedere con precisione il peso dei neonati alla nascita, basandosi su variabili cliniche raccolte da tre ospedali.
Il progetto mira a migliorare la gestione delle gravidanze ad alto rischio, ottimizzare le risorse ospedaliere e garantire migliori risultati per la salute neonatale.
Il progetto si inserisce all’interno di un contesto di crescente attenzione verso la prevenzione delle complicazioni neonatali.
La possibilità di prevedere il peso alla nascita dei neonati rappresenta un’opportunità fondamentale per migliorare la pianificazione clinica e ridurre i rischi associati a nascite problematiche, come parti prematuri o neonati con basso peso.
Di seguito, i principali benefici che questo progetto porterà all’azienda e al settore sanitario:
1. Miglioramento delle previsioni cliniche: ◦ Il peso del neonato è un indicatore chiave della sua salute. Avere un modello predittivo accurato consente al personale medico di intervenire tempestivamente in caso di anomalie, riducendo le complicazioni perinatali come le difficoltà respiratorie o l’ipoglicemia.
2. Ottimizzazione delle risorse ospedaliere: ◦ Sapere in anticipo quali neonati potrebbero avere bisogno di cure intensive aiuta a organizzare le risorse umane e tecnologiche degli ospedali in modo efficiente. Questo si traduce in una riduzione dei costi operativi e una migliore pianificazione dell’utilizzo delle unità di terapia intensiva neonatale (TIN).
3. Prevenzione e identificazione dei fattori di rischio: ◦ Il modello potrà evidenziare i fattori che maggiormente influenzano negativamente il peso del neonato (come il fumo materno, gravidanze multiple o età avanzata della madre). Queste informazioni sono preziose per la prevenzione e la gestione personalizzata delle gravidanze, permettendo interventi proattivi in caso di rischio elevato.
4. Valutazione delle pratiche ospedaliere: ◦ Attraverso un’analisi comparativa tra i tre ospedali coinvolti, l’azienda potrà identificare eventuali differenze nei risultati clinici, come una maggiore incidenza di parti cesarei in una determinata struttura. Ciò consente di monitorare la qualità delle pratiche e armonizzare i protocolli tra i diversi centri ospedalieri, migliorando la coerenza delle cure.
5. Supporto alla pianificazione strategica: ◦ L’analisi dei dati e le previsioni possono essere utilizzate per prendere decisioni informate non solo a livello clinico ma anche strategico. L’azienda potrà sfruttare queste informazioni per implementare nuove politiche di salute pubblica, garantendo un impatto positivo sui tassi di mortalità e morbilità neonatale.

Dettagli del Progetto

1. Raccolta dei Dati e Struttura del Dataset

Per costruire il modello predittivo, abbiamo raccolto dati su 2500 neonati provenienti da tre ospedali. Le variabili raccolte includono:
Età della madre: Misura dell’età in anni.
Numero di gravidanze: Quante gravidanze ha avuto la madre.
Fumo materno: Un indicatore binario (0=non fumatrice, 1=fumatrice).
Durata della gravidanza: Numero di settimane di gestazione.
Peso del neonato: Peso alla nascita in grammi.
Lunghezza e diametro del cranio: Lunghezza del neonato e diametro craniale, misurabili anche durante la gravidanza tramite ecografie.
Tipo di parto: Naturale o cesareo.
Ospedale di nascita: Ospedale 1, 2 o 3.
Sesso del neonato: Maschio (M) o femmina (F).
L’obiettivo principale è identificare quali di queste variabili sono più predittive del peso alla nascita, con un focus particolare sull’impatto del fumo materno e delle settimane di gestazione, che potrebbero indicare nascite premature.

2. Analisi e Modellizzazione

Analisi Preliminare

Nella prima fase, esploreremo le variabili attraverso un’analisi descrittiva per comprenderne la distribuzione e identificare eventuali outlier o anomalie.
Inoltre si saggeranno le seguenti ipotesi con i test adatti:
1. In alcuni ospedali si fanno più parti cesarei.
2. La media del peso e della lunghezza di questo campione di neonati sono significativamente uguali a quelle della popolazione
3. Le misure antropometriche sono significativamente diverse tra i due sessi.

Creazione del Modello di Regressione

Verrà sviluppato un modello di regressione lineare multipla che includa tutte le variabili rilevanti.
In questo modo, potremo quantificare l’impatto di ciascuna variabile indipendente sul peso del neonato ed eventuali interazioni.
Ad esempio, ci aspettiamo che una maggiore durata della gestazione aumenterebbe in media il peso del neonato.

Selezione del Modello Ottimale

Attraverso tecniche di selezione del modello, come la minimizzazione del criterio di informazione di Akaike (AIC) o di Bayes (BIC), selezioneremo il modello più parsimonioso, eliminando le variabili non significative. Verranno considerati anche modelli con interazioni tra le variabili e possibili effetti non lineari.

Analisi della Qualità del Modello

Una volta ottenuto il modello finale, valuteremo la sua capacità predittiva utilizzando metriche come R² e il Root Mean Squared Error (RMSE). Un’attenzione particolare sarà rivolta all’analisi dei residui e alla presenza di valori influenti, che potrebbero distorcere le previsioni, indagando su di essi.

3. Previsioni e Risultati

Una volta validato il modello, lo useremo per fare previsioni pratiche. Ad esempio, potremo stimare il peso di una neonata considerando una madre alla terza gravidanza che partorirà alla 39esima settimana.

4. Visualizzazioni

Infine, utilizzeremo grafici e rappresentazioni visive per comunicare i risultati del modello e mostrare le relazioni più significative tra le variabili. Ad esempio, potremmo visualizzare l’impatto del numero di settimane di gestazione e del fumo sul peso previsto.

Conclusioni

Il progetto di previsione del peso neonatale è un’iniziativa fondamentale per Neonatal Health Solutions.
Attraverso l’uso di dati clinici dettagliati e strumenti di analisi statistica avanzati, possiamo contribuire a migliorare la qualità della cura prenatale, ridurre i rischi per i neonati e ottimizzare l’efficienza delle risorse ospedaliere.
Questo progetto rappresenta un punto di svolta per l’azienda, consentendo non solo un miglioramento della pratica clinica ma anche l’implementazione di politiche sanitarie più informate e proattive.


## 'data.frame':    2500 obs. of  10 variables:
##  $ Anni.madre  : int  26 21 34 28 20 32 26 25 22 23 ...
##  $ N.gravidanze: int  0 2 3 1 0 0 1 0 1 0 ...
##  $ Fumatrici   : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ Gestazione  : int  42 39 38 41 38 40 39 40 40 41 ...
##  $ Peso        : int  3380 3150 3640 3690 3700 3200 3100 3580 3670 3700 ...
##  $ Lunghezza   : int  490 490 500 515 480 495 480 510 500 510 ...
##  $ Cranio      : int  325 345 375 365 335 340 345 349 335 362 ...
##  $ Tipo.parto  : chr  "Nat" "Nat" "Nat" "Nat" ...
##  $ Ospedale    : chr  "osp3" "osp1" "osp2" "osp2" ...
##  $ Sesso       : chr  "M" "F" "M" "M" ...

Statistical Description of the Data

##    Anni.madre     N.gravidanze       Gestazione         Peso     
##  Min.   : 0.00   Min.   : 0.0000   Min.   :25.00   Min.   : 830  
##  1st Qu.:25.00   1st Qu.: 0.0000   1st Qu.:38.00   1st Qu.:2990  
##  Median :28.00   Median : 1.0000   Median :39.00   Median :3300  
##  Mean   :28.16   Mean   : 0.9812   Mean   :38.98   Mean   :3284  
##  3rd Qu.:32.00   3rd Qu.: 1.0000   3rd Qu.:40.00   3rd Qu.:3620  
##  Max.   :46.00   Max.   :12.0000   Max.   :43.00   Max.   :4930  
##    Lunghezza         Cranio   
##  Min.   :310.0   Min.   :235  
##  1st Qu.:480.0   1st Qu.:330  
##  Median :500.0   Median :340  
##  Mean   :494.7   Mean   :340  
##  3rd Qu.:510.0   3rd Qu.:350  
##  Max.   :565.0   Max.   :390

Standard Deviation of the Considered Variables

##   Anni.madre N.gravidanze   Gestazione         Peso    Lunghezza       Cranio 
##     5.273578     1.280587     1.868639   525.038744    26.318644    16.425330

Coefficient of Variation of the Considered Variables

##   Anni.madre N.gravidanze   Gestazione         Peso    Lunghezza       Cranio 
##    18.724536   130.512310     4.793792    15.987388     5.320208     4.830565

Skewness of the Considered Variables

##   Anni.madre N.gravidanze   Gestazione         Peso    Lunghezza       Cranio 
##    0.0428115    2.5142541   -2.0653133   -0.6470308   -1.5146991   -0.7850527

Kurtosis of the Considered Variables

##   Anni.madre N.gravidanze   Gestazione         Peso    Lunghezza       Cranio 
##    0.3804165   10.9894064    8.2581496    2.0315318    6.4871739    2.9462063

In order to analyze these statistical variables, it is necessary to develop the relative frequency distributions.
Wrapping up all these information, it shall be possible to infer some considerations about the under examination sample.

##     ni     fi   Ni     Fi
## 0    1 0.0004    1 0.0004
## 1    1 0.0004    2 0.0008
## 13   1 0.0004    3 0.0012
## 14   2 0.0008    5 0.0020
## 15   6 0.0024   11 0.0044
## 16  13 0.0052   24 0.0096
## 17  18 0.0072   42 0.0168
## 18  24 0.0096   66 0.0264
## 19  45 0.0180  111 0.0444
## 20  66 0.0264  177 0.0708
## 21  74 0.0296  251 0.1004
## 22 100 0.0400  351 0.1404
## 23 115 0.0460  466 0.1864
## 24 131 0.0524  597 0.2388
## 25 180 0.0720  777 0.3108
## 26 184 0.0736  961 0.3844
## 27 197 0.0788 1158 0.4632
## 28 172 0.0688 1330 0.5320
## 29 174 0.0696 1504 0.6016
## 30 200 0.0800 1704 0.6816
## 31 147 0.0588 1851 0.7404
## 32 159 0.0636 2010 0.8040
## 33 110 0.0440 2120 0.8480
## 34  96 0.0384 2216 0.8864
## 35  66 0.0264 2282 0.9128
## 36  64 0.0256 2346 0.9384
## 37  41 0.0164 2387 0.9548
## 38  38 0.0152 2425 0.9700
## 39  27 0.0108 2452 0.9808
## 40  19 0.0076 2471 0.9884
## 41  13 0.0052 2484 0.9936
## 42   8 0.0032 2492 0.9968
## 43   2 0.0008 2494 0.9976
## 44   4 0.0016 2498 0.9992
## 45   1 0.0004 2499 0.9996
## 46   1 0.0004 2500 1.0000


The mothers’age variable is described by a mean value of 28.16, a standard deviation of 5.27 and, consequently, a coefficient of variation equal to 18.72. Skewness and kurtosis are equal to, respectively, 0.04 and 0.38. It’s easy to notice that this data-set is showing two impossible values (giving birth at 0 and 1 years old is not possible). these data should be eliminated from the analysis.

##      ni     fi   Ni     Fi
## 0  1096 0.4384 1096 0.4384
## 1   818 0.3272 1914 0.7656
## 2   340 0.1360 2254 0.9016
## 3   150 0.0600 2404 0.9616
## 4    48 0.0192 2452 0.9808
## 5    21 0.0084 2473 0.9892
## 6    11 0.0044 2484 0.9936
## 7     1 0.0004 2485 0.9940
## 8     8 0.0032 2493 0.9972
## 9     2 0.0008 2495 0.9980
## 10    3 0.0012 2498 0.9992
## 11    1 0.0004 2499 0.9996
## 12    1 0.0004 2500 1.0000


The pregnancies number variable is described by a mean value of 0.98, a standard deviation of 1.28 and, consequently, a coefficient of variation equal to 130.51. Skewness and kurtosis are equal to, respectively, 2.51 and 10.99.

##     ni     fi   Ni     Fi
## 25   1 0.0004    1 0.0004
## 26   1 0.0004    2 0.0008
## 27   2 0.0008    4 0.0016
## 28   4 0.0016    8 0.0032
## 29   3 0.0012   11 0.0044
## 30   5 0.0020   16 0.0064
## 31   8 0.0032   24 0.0096
## 32   9 0.0036   33 0.0132
## 33  18 0.0072   51 0.0204
## 34  16 0.0064   67 0.0268
## 35  33 0.0132  100 0.0400
## 36  62 0.0248  162 0.0648
## 37 192 0.0768  354 0.1416
## 38 437 0.1748  791 0.3164
## 39 581 0.2324 1372 0.5488
## 40 741 0.2964 2113 0.8452
## 41 329 0.1316 2442 0.9768
## 42  56 0.0224 2498 0.9992
## 43   2 0.0008 2500 1.0000


The gestation weeks number variable is described by a mean value of 38.98, a standard deviation of 1.87 and, consequently, a coefficient of variation equal to 4.79. Skewness and kurtosis are equal to, respectively, -2.06 and 8.26.

##            ni     fi   Ni     Fi
## 3300 3400 203 0.0812  203 0.0812
## 3100 3200 212 0.0848  415 0.1660
## 3600 3700 147 0.0588  562 0.2248
## 3000 3100 188 0.0752  750 0.3000
## 3500 3600 189 0.0756  939 0.3756
## 3400 3500 172 0.0688 1111 0.4444
## 2900 3000 161 0.0644 1272 0.5088
## 2300 2400  20 0.0080 1292 0.5168
## 3700 3800 131 0.0524 1423 0.5692
## 2700 2800  94 0.0376 1517 0.6068
## 3200 3300 241 0.0964 1758 0.7032
## 2600 2700  63 0.0252 1821 0.7284
## 2800 2900 144 0.0576 1965 0.7860
## 4100 4200  43 0.0172 2008 0.8032
## 3900 4000  85 0.0340 2093 0.8372
## 3800 3900 110 0.0440 2203 0.8812
## 4300 4400  20 0.0080 2223 0.8892
## 4200 4300  26 0.0104 2249 0.8996
## 2400 2500  35 0.0140 2284 0.9136
## 1300 1400   3 0.0012 2287 0.9148
## 2500 2600  48 0.0192 2335 0.9340
## 2100 2200   8 0.0032 2343 0.9372
## 4600 4700   5 0.0020 2348 0.9392
## 2200 2300  18 0.0072 2366 0.9464
## 4400 4500   9 0.0036 2375 0.9500
## 4000 4100  49 0.0196 2424 0.9696
## 2000 2100  13 0.0052 2437 0.9748
## 1400 1500   5 0.0020 2442 0.9768
## 1800 1900   4 0.0016 2446 0.9784
## 1500 1600   4 0.0016 2450 0.9800
## 1200 1300   5 0.0020 2455 0.9820
## 1700 1800   9 0.0036 2464 0.9856
## 4500 4600   7 0.0028 2471 0.9884
## 1900 2000   9 0.0036 2480 0.9920
## 1100 1200   5 0.0020 2485 0.9940
## 800 900     2 0.0008 2487 0.9948
## 1600 1700   3 0.0012 2490 0.9960
## 4800 4900   2 0.0008 2492 0.9968
## 900 1000    4 0.0016 2496 0.9984
## 4700 4800   3 0.0012 2499 0.9996
## 4900 5000   1 0.0004 2500 1.0000


The weight variable is described by a mean value of 3284 g, a standard deviation of 525.04 g and, consequently, a coefficient of variation equal to 15.99. Skewness and kurtosis are equal to, respectively, -0.65 and 2.03.

##          ni     fi   Ni     Fi
## 480 490 392 0.1568  392 0.1568
## 490 500 551 0.2204  943 0.3772
## 510 520 268 0.1072 1211 0.4844
## 470 480 262 0.1048 1473 0.5892
## 500 510 392 0.1568 1865 0.7460
## 450 460 104 0.0416 1969 0.7876
## 460 470 158 0.0632 2127 0.8508
## 520 530 147 0.0588 2274 0.9096
## 440 450  58 0.0232 2332 0.9328
## 540 550  35 0.0140 2367 0.9468
## 530 540  56 0.0224 2423 0.9692
## 380 390   6 0.0024 2429 0.9716
## 390 400   4 0.0016 2433 0.9732
## 430 440  15 0.0060 2448 0.9792
## 400 410  11 0.0044 2459 0.9836
## 410 420   8 0.0032 2467 0.9868
## 350 360   4 0.0016 2471 0.9884
## 420 430  11 0.0044 2482 0.9928
## 550 560   5 0.0020 2487 0.9948
## 370 380   3 0.0012 2490 0.9960
## 300 310   1 0.0004 2491 0.9964
## 360 370   3 0.0012 2494 0.9976
## 310 320   2 0.0008 2496 0.9984
## 330 340   1 0.0004 2497 0.9988
## 320 330   1 0.0004 2498 0.9992
## 560 570   1 0.0004 2499 0.9996
## 340 350   1 0.0004 2500 1.0000


The length variable is described by a mean value of 494.7 mm, a standard deviation of 26.32 mm and, consequently, a coefficient of variation equal to 5.32. Skewness and kurtosis are equal to, respectively, -1.51 and 6.49.

##          ni     fi   Ni     Fi
## 320 330 399 0.1596  399 0.1596
## 340 350 624 0.2496 1023 0.4092
## 370 380  33 0.0132 1056 0.4224
## 360 370 141 0.0564 1197 0.4788
## 330 340 658 0.2632 1855 0.7420
## 290 300  25 0.0100 1880 0.7520
## 310 320 143 0.0572 2023 0.8092
## 350 360 382 0.1528 2405 0.9620
## 380 390  11 0.0044 2416 0.9664
## 300 310  58 0.0232 2474 0.9896
## 280 290   6 0.0024 2480 0.9920
## 270 280  12 0.0048 2492 0.9968
## 250 260   2 0.0008 2494 0.9976
## 260 270   4 0.0016 2498 0.9992
## 230 240   1 0.0004 2499 0.9996
## 240 250   1 0.0004 2500 1.0000


The skull circumference variable is described by a mean value of 340 mm, a standard deviation of 16.43 and, consequently, a coefficient of variation equal to 4.83. Skewness and kurtosis are equal to, respectively, -0.79 and 2.95.

The variable smoker is characterized by a frequency distribution given by:

## Fumatrici
##    0    1 
## 2396  104

And a Gini index equal to:

## [1] 0.1594778

The considered sample is characterized by a larger group of non smoker mothers, having a Gini index indicating an almost homogeneous group of observations..
The variable type of birth is characterized by a frequency distribution given by:

## Tipo.parto
##  Ces  Nat 
##  728 1772

And a Gini index equal to:

## [1] 0.8256102

It is possible to notice a predominant component of natural births, even though Gini index is indicating a considerable heterogeneity and therefore the presence of a certain number of caesarean operations. From an epidemiological point of view, a cesarean section rate close to 29% is a realistic figure and in line with Western hospitalization rates. This indicates that the sample includes a main physiological component, but also a significant share of pregnancies at risk or with complications that required cesarean section
The variable Hospital is characterized by a frequency distribution given by:

## Ospedale
## osp1 osp2 osp3 
##  816  849  835

And a Gini index equal to:

## [1] 0.9998683

This variable is almost absolutely heterogeneous, having a high Gini index. This indicates that the data-set is not affected by geographic or structural selection bias: the data were collected in a fair and balanced manner across the three healthcare facilities, providing a solid basis for any future comparative analyses between hospitals.


From the comparative analysis of the anthropometric characteristics of newborns divided by gender, clear biological patterns emerge:
- Newborn Weight: The median of males (M) is visibly higher than that of females (F). The entire body distribution (the box) of males is also shifted upward.
- Newborn Length and Skull Diameter: Consistent with weight, both the median length and the median skull diameter, confirm that male newborns tend to be biologically larger and heavier at birth than females.
- Gestation Weeks: Unlike physical measurements, gestation length has an identical median (about 39 weeks) and a nearly overlapping distribution between males and females. This suggests that the gender of the newborn does not influence the length of the gestation period, which remains regulated by purely biological factors of the mother and standard fetal development.

A key and systematic detail in all boxplots is the presence of a strong negative (downward) skewness, characterized by numerous outliers (the single lower black dots):
- Premature Births: In the Gestation Weeks graph, there are many cases of premature births that fall below 35 weeks, reaching even borderline cases of 25 weeks.
- Clinical Correlation of Outliers: The presence of newborns with exceptionally low weight (under 2000g, up to less than 1000g), short lengths (under 400 mm), and small cranial diameters (under 280 mm) is the direct clinical consequence of the premature births. Infants born significantly prematurely did not complete their intrauterine growth, ranking as outliers in all anthropometric metrics.
- Absence of higher macro-abnormalities: On the contrary, there are almost no higher outliers (e.g., gestations beyond 42 weeks or weights exceeding 4800 g). This suggests that the medical protocol of the three hospitals tends to induce labor or schedule cesarean sections before the physiological safety window is exceeded.


Hypothesis A: some hospitals perform more cesarean surgery than others.

In order to test this affirmation, we’ll consider the following system of hypotheses: \[\left\{ \begin{array}{l} \text{H0: each hospital performs in average the same amount of caserean surgeries.}\\ \text{H1: at least one hospital performs in average a different amount of cesarean surgeries.} \end{array} \right.\]

##         Tipo.parto
## Ospedale       Ces       Nat
##     osp1 0.2965686 0.7034314
##     osp2 0.2991755 0.7008245
##     osp3 0.2778443 0.7221557
## 
##  Pearson's Chi-squared test
## 
## data:  tab
## X-squared = 1.0972, df = 2, p-value = 0.5778

Pearson’s Chi-squared test doesn’t allow to affirm a statistically significant association between hospital and type of birth. Moreover, it is shown a percentage of cesarean birth in the hospitals equals to 29.6%, 29.9% and 27.8% respectively. Then, the hypothesis H0 is acceptable and there is no substantial difference in the number of cesarean surgeries.

Hypothesis B: the average weight and length of this sample are significantly equal to the values of the referred population.

In order to test this affirmation, we’ll consider the following system of hypotheses: \[\left\{ \begin{array}{l} \text{H0: the average weight and length of this sample are significantly equal to the values of the referred population.}\\ \text{H1: at least one between average weight and length of this sample differs significantly from the values of the referred population.} \end{array} \right.\] In a more compact form and simplifying the analysis, it is possible to consider singularly the two variables, describing two sets of hypotheses: \[\left\{ \begin{array}{l} \text{H}_0: \mu_{weight} = 3300\\ \text{H}_1: \mu_{weight} \neq 3300 \end{array} \right.\]

\[\left\{ \begin{array}{l} \text{H}_0: \mu_{length} = 500\\ \text{H}_1: \mu_{length} \neq 500 \end{array} \right.\]

## 
##  One Sample t-test
## 
## data:  Peso
## t = -1.516, df = 2499, p-value = 0.1296
## alternative hypothesis: true mean is not equal to 3300
## 95 percent confidence interval:
##  3263.490 3304.672
## sample estimates:
## mean of x 
##  3284.081
## 
##  One Sample t-test
## 
## data:  Lunghezza
## t = -10.084, df = 2499, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 500
## 95 percent confidence interval:
##  493.6598 495.7242
## sample estimates:
## mean of x 
##   494.692

Considering the obtained confidence intervals and the p-values for both the variables, it has shown that the null hypothesis is rejected and it is concluded that the average profile of the newborns in the sample differs significantly from that of the population. The standard T test performed singularly on the variables shows that the length of the newborns differs significantly from the average value of the population.

Hypothesis C: Anthropometric measures are significantly different between the genders.

In this scenario, the considered variables are weight, length and skull diameter, each of them related to the gender of the newborn. The set of hypotheses that shall be analyzed for each variable is: \[\left\{ \begin{array}{l} \text{H}_0: \mu_{M} = \mu_{F}\\ \text{H}_1: \mu_{M} \neq \mu_{F} \end{array} \right.\] T test for two independent groups could be the suitable statistical test in order to evaluate the current hypothesis, only though the conditions of normality and homogeneity of the variances of the considered variables are satisfied.
Variable Weight:

## 
##  Shapiro-Wilk normality test
## 
## data:  Peso[Sesso == "M"]
## W = 0.96647, p-value = 2.321e-16
## 
##  Shapiro-Wilk normality test
## 
## data:  Peso[Sesso == "F"]
## W = 0.96285, p-value < 2.2e-16
## 
##  F test to compare two variances
## 
## data:  Peso by Sesso
## F = 1.136, num df = 1255, denom df = 1243, p-value = 0.02436
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  1.016653 1.269284
## sample estimates:
## ratio of variances 
##           1.135984

Variable Length:

## 
##  Shapiro-Wilk normality test
## 
## data:  Lunghezza[Sesso == "M"]
## W = 0.92028, p-value < 2.2e-16
## 
##  Shapiro-Wilk normality test
## 
## data:  Lunghezza[Sesso == "F"]
## W = 0.89953, p-value < 2.2e-16
## 
##  F test to compare two variances
## 
## data:  Lunghezza by Sesso
## F = 1.312, num df = 1255, denom df = 1243, p-value = 1.673e-06
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  1.174205 1.465987
## sample estimates:
## ratio of variances 
##           1.312029

Variable Skull Diameter:

shapiro.test(Cranio[Sesso=="M"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Cranio[Sesso == "M"]
## W = 0.97046, p-value = 3.006e-15
shapiro.test(Cranio[Sesso=="F"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Cranio[Sesso == "F"]
## W = 0.95543, p-value < 2.2e-16
var.test(Cranio~Sesso,data=dataset)
## 
##  F test to compare two variances
## 
## data:  Cranio by Sesso
## F = 1.1301, num df = 1255, denom df = 1243, p-value = 0.03073
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  1.011431 1.262764
## sample estimates:
## ratio of variances 
##           1.130149

As shown in the results of the performed tests of normality and homogeneity of the variables, T-test could head to incorrect valuations of the hypotheses. A solution could be the Wilcoxon-Mann-Whitney non parametric test, that offers the following results:

## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  Peso by Sesso
## W = 538640, p-value < 2.2e-16
## alternative hypothesis: true location shift is not equal to 0
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  Lunghezza by Sesso
## W = 594454, p-value < 2.2e-16
## alternative hypothesis: true location shift is not equal to 0
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  Cranio by Sesso
## W = 641638, p-value = 9.633e-15
## alternative hypothesis: true location shift is not equal to 0

For each variable, the related p-value is significantly below the usual level of 0.05. Consequently, it is possible to reject the null hypothesis and the anthropometric measures are significantly different between the genders.


Regression Model Creation and Selection

The variable weight isn’t described by a normal distribution. Anyway, proceeding with the development of the model, the distribution of the residuals shall be checked out. In fact it is more relevant than the normality of weight.
On purpose of developing a linear regression model comprehensive of the whole set of variables, the matrix of correlation with the relative graphic representation shall be shown.

The first attempt of multiple linear regression model is described by the following features:

## 
## Call:
## lm(formula = Peso ~ ., data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1124.40  -181.66   -14.42   160.91  2611.89 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -6738.4762   141.3087 -47.686  < 2e-16 ***
## Anni.madre        0.8921     1.1323   0.788   0.4308    
## N.gravidanze     11.2665     4.6608   2.417   0.0157 *  
## Fumatrici       -30.1631    27.5386  -1.095   0.2735    
## Gestazione       32.5696     3.8187   8.529  < 2e-16 ***
## Lunghezza        10.2945     0.3007  34.236  < 2e-16 ***
## Cranio           10.4707     0.4260  24.578  < 2e-16 ***
## Tipo.partoNat    29.5254    12.0844   2.443   0.0146 *  
## Ospedaleosp2    -11.2095    13.4379  -0.834   0.4043    
## Ospedaleosp3     28.0958    13.4957   2.082   0.0375 *  
## SessoM           77.5409    11.1776   6.937 5.08e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 273.9 on 2489 degrees of freedom
## Multiple R-squared:  0.7289, Adjusted R-squared:  0.7278 
## F-statistic: 669.2 on 10 and 2489 DF,  p-value: < 2.2e-16

An adjusted R-squared of 0.7278 for the first model provides a substantial explained variability. Moreover, the considered model and the features detected for each variable allows to suppose the substantial effect of the variables Gestation, Length, Skull Diameter and Gender on the Weight of the newborn. These considerations shall be checked out in the next section through the automatic procedure step-wise.

## Start:  AIC=28139.32
## Peso ~ Anni.madre + N.gravidanze + Fumatrici + Gestazione + Lunghezza + 
##     Cranio + Tipo.parto + Ospedale + Sesso
## 
##                Df Sum of Sq       RSS   AIC
## - Anni.madre    1     46578 186809099 28132
## - Fumatrici     1     90019 186852540 28133
## - Ospedale      2    685979 187448501 28133
## - N.gravidanze  1    438452 187200974 28137
## - Tipo.parto    1    447929 187210450 28138
## <none>                      186762521 28139
## - Sesso         1   3611021 190373542 28179
## - Gestazione    1   5458403 192220925 28204
## - Cranio        1  45326172 232088693 28675
## - Lunghezza     1  87951062 274713583 29096
## 
## Step:  AIC=28132.12
## Peso ~ N.gravidanze + Fumatrici + Gestazione + Lunghezza + Cranio + 
##     Tipo.parto + Ospedale + Sesso
## 
##                Df Sum of Sq       RSS   AIC
## - Fumatrici     1     90897 186899996 28126
## - Ospedale      2    692738 187501837 28126
## - Tipo.parto    1    448222 187257321 28130
## <none>                      186809099 28132
## - N.gravidanze  1    633756 187442855 28133
## + Anni.madre    1     46578 186762521 28139
## - Sesso         1   3618736 190427835 28172
## - Gestazione    1   5412879 192221978 28196
## - Cranio        1  45588236 232397335 28670
## - Lunghezza     1  87950050 274759149 29089
## 
## Step:  AIC=28125.51
## Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Tipo.parto + 
##     Ospedale + Sesso
## 
##                Df Sum of Sq       RSS   AIC
## - Ospedale      2    701680 187601677 28119
## - Tipo.parto    1    440684 187340680 28124
## <none>                      186899996 28126
## - N.gravidanze  1    610840 187510837 28126
## + Fumatrici     1     90897 186809099 28132
## + Anni.madre    1     47456 186852540 28133
## - Sesso         1   3602797 190502794 28165
## - Gestazione    1   5346781 192246777 28188
## - Cranio        1  45632149 232532146 28664
## - Lunghezza     1  88355030 275255027 29086
## 
## Step:  AIC=28119.23
## Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Tipo.parto + 
##     Sesso
## 
##                Df Sum of Sq       RSS   AIC
## - Tipo.parto    1    463870 188065546 28118
## <none>                      187601677 28119
## - N.gravidanze  1    651066 188252743 28120
## + Ospedale      2    701680 186899996 28126
## + Fumatrici     1     99840 187501837 28126
## + Anni.madre    1     54392 187547285 28126
## - Sesso         1   3649259 191250936 28160
## - Gestazione    1   5444109 193045786 28183
## - Cranio        1  45758101 233359778 28657
## - Lunghezza     1  88054432 275656108 29074
## 
## Step:  AIC=28117.58
## Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
## 
##                Df Sum of Sq       RSS   AIC
## <none>                      188065546 28118
## - N.gravidanze  1    623141 188688687 28118
## + Tipo.parto    1    463870 187601677 28119
## + Ospedale      2    724866 187340680 28124
## + Fumatrici     1     91892 187973654 28124
## + Anni.madre    1     54816 188010731 28125
## - Sesso         1   3655292 191720838 28158
## - Gestazione    1   5464853 193530399 28181
## - Cranio        1  46108583 234174130 28658
## - Lunghezza     1  87632762 275698308 29066
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1149.44  -180.81   -15.58   163.64  2639.72 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -6681.1445   135.7229 -49.226  < 2e-16 ***
## N.gravidanze    12.4750     4.3396   2.875  0.00408 ** 
## Gestazione      32.3321     3.7980   8.513  < 2e-16 ***
## Lunghezza       10.2486     0.3006  34.090  < 2e-16 ***
## Cranio          10.5402     0.4262  24.728  < 2e-16 ***
## SessoM          77.9927    11.2021   6.962 4.26e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 274.6 on 2494 degrees of freedom
## Multiple R-squared:  0.727,  Adjusted R-squared:  0.7265 
## F-statistic:  1328 on 5 and 2494 DF,  p-value: < 2.2e-16

This procedure has led to a model based on the variables Number of Pregnancies, Gestation Weeks, Length, Skull Diameter and Gender. The adjusted R-squared of 0.7265 for the latter model is comparable to the value of the former, equal to 0.7278. However, the latter model is based on a fewer number of variables and, therefore, preferable.
It is possible to compare the models using the following selection methods:
- AIC:

##                 df      AIC
## model_updated    7 35179.33
## model_completed 12 35171.95
  • BIC:
##                 df      BIC
## model_updated    7 35220.10
## model_completed 12 35241.84


The assessment of the model requires the analysis of the residuals, as follows:

The graphical representations seem to show that the average value of the residuals is approximately 0, the normality of the residuals is satisfied except for extreme values.
In order to analyze the residuals properly, the cmean(residuals(model_updated))orrect tests shall be performed:

Average Value of the residuals:

## [1] 3.025824e-15
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(model_updated)
## W = 0.97408, p-value < 2.2e-16
## 
##  studentized Breusch-Pagan test
## 
## data:  model_updated
## BP = 90.253, df = 5, p-value < 2.2e-16
## 
##  Durbin-Watson test
## 
## data:  model_updated
## DW = 1.9535, p-value = 0.1224
## alternative hypothesis: true autocorrelation is greater than 0


VIF test:

## N.gravidanze   Gestazione    Lunghezza       Cranio        Sesso 
##     1.023475     1.669189     2.074689     1.624465     1.040054


The mean of the residuals is 0. The Shapiro-Wilk test rejects normality, but this is mainly due to the extreme values, corresponding to premature births and newborns with abnormal physical characteristics. The independence of the residuals is satisfied, but there are problems with homoscedasticity. The analysis of the leverage and outliers values and the Cook distance show critical issues with observation 1551. This may be due to a data collection error, so it will be eliminated from the data-set.

##          13          15          34          67          89          96 
## 0.005630918 0.007050422 0.006744143 0.005891590 0.012816470 0.005351586 
##         101         106         131         134         151         155 
## 0.007526751 0.014479871 0.007229339 0.007552819 0.010883937 0.007207682 
##         161         189         190         204         205         206 
## 0.020335483 0.004893297 0.005366557 0.014490604 0.005351634 0.009476652 
##         220         294         305         310         312         315 
## 0.007393997 0.005912765 0.005442061 0.028812123 0.013169272 0.005385800 
##         378         440         442         445         486         492 
## 0.015934061 0.005404736 0.007723662 0.007509382 0.005164446 0.008274018 
##         497         516         582         587         592         614 
## 0.005166306 0.013079851 0.011665555 0.008412325 0.006384116 0.005299262 
##         638         656         657         684         697         702 
## 0.006688287 0.005927777 0.005322685 0.008818987 0.005863826 0.005202259 
##         729         748         750         757         765         805 
## 0.005023115 0.008565543 0.006942097 0.008145491 0.006070298 0.014356657 
##         828         893         895         913         928         946 
## 0.007179817 0.005075205 0.005295896 0.005571144 0.022742332 0.006909044 
##         947         956         985        1008        1014        1049 
## 0.008409465 0.007784123 0.007039416 0.005343037 0.008470133 0.004956169 
##        1067        1091        1106        1130        1166        1181 
## 0.008465430 0.008933360 0.005967317 0.031728597 0.005513559 0.005677676 
##        1188        1200        1219        1238        1248        1273 
## 0.006477203 0.005492370 0.030694311 0.005908078 0.014622914 0.007085831 
##        1291        1293        1311        1321        1325        1356 
## 0.006117497 0.006073639 0.009625908 0.009293111 0.004857169 0.005303442 
##        1357        1385        1395        1400        1402        1411 
## 0.006965051 0.012636943 0.005126697 0.005925069 0.004811441 0.008048184 
##        1420        1428        1429        1450        1505        1551 
## 0.005155654 0.008192811 0.021757172 0.015104831 0.013330439 0.048769569 
##        1553        1556        1573        1593        1606        1610 
## 0.008504889 0.005919673 0.005047204 0.005623758 0.005001812 0.008722184 
##        1617        1619        1628        1686        1693        1701 
## 0.004866796 0.015067498 0.005069731 0.009349313 0.005077858 0.010842957 
##        1712        1718        1727        1735        1780        1781 
## 0.006992084 0.006958857 0.013300523 0.004884846 0.025538678 0.016832361 
##        1809        1827        1868        1892        1962        1967 
## 0.008707504 0.006065698 0.005205637 0.005332812 0.005540442 0.005337356 
##        1977        2037        2040        2046        2086        2089 
## 0.006927281 0.004889127 0.011494872 0.005471670 0.013193090 0.006293550 
##        2098        2114        2115        2120        2140        2146 
## 0.005094455 0.013316875 0.011772090 0.018659995 0.006244232 0.005802168 
##        2148        2149        2157        2175        2200        2215 
## 0.007926839 0.013583436 0.005907225 0.032527273 0.011670024 0.004892265 
##        2216        2220        2221        2224        2225        2244 
## 0.008117864 0.005414040 0.021628717 0.005838076 0.005591261 0.006929217 
##        2257        2307        2317        2318        2337        2359 
## 0.006170254 0.013965608 0.007673614 0.004831118 0.005230450 0.010067364 
##        2408        2422        2436        2437        2452        2458 
## 0.009696691 0.021532808 0.004986522 0.023943328 0.023838489 0.008506087 
##        2471        2478 
## 0.020903740 0.005775173



OutliersTest:

##       rstudent unadjusted p-value Bonferroni p
## 1551 10.051908         2.4906e-23   6.2265e-20
## 155   5.027798         5.3138e-07   1.3285e-03
## 1306  4.827238         1.4681e-06   3.6702e-03



The Bayesian Information Criterion for the regression models selection aims to favor models characterized by a smaller number of parameters, simplifying the model at the cost of a small loss of information. Using this criterion and the residual analysis, the latter model is preferable and it will be the base line for the research and analysis of non linear effects.
In the next section, the interaction between pairs of variables will be analyzed and, particularly, the next two selected models:

## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1165.74  -179.59   -12.74   162.89  1410.88 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -6683.4142   133.0802 -50.221  < 2e-16 ***
## N.gravidanze    13.1652     4.2557   3.094    0.002 ** 
## Gestazione      29.5891     3.7340   7.924 3.43e-15 ***
## Lunghezza       10.8927     0.3017  36.109  < 2e-16 ***
## Cranio           9.9187     0.4225  23.476  < 2e-16 ***
## SessoM          78.1348    10.9840   7.114 1.47e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 269.3 on 2493 degrees of freedom
## Multiple R-squared:  0.7372, Adjusted R-squared:  0.7367 
## F-statistic:  1399 on 5 and 2493 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso + Gestazione:Cranio, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1153.07  -179.27   -11.91   164.98  1457.57 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        203.85870 1084.26164   0.188  0.85088    
## N.gravidanze        13.88876    4.22350   3.288  0.00102 ** 
## Gestazione        -154.13058   28.94575  -5.325 1.10e-07 ***
## Lunghezza           11.14280    0.30182  36.919  < 2e-16 ***
## Cranio             -11.72645    3.40811  -3.441  0.00059 ***
## SessoM              71.83674   10.94135   6.566 6.28e-11 ***
## Gestazione:Cranio    0.56621    0.08848   6.400 1.85e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 267.1 on 2492 degrees of freedom
## Multiple R-squared:  0.7414, Adjusted R-squared:  0.7408 
## F-statistic:  1191 on 6 and 2492 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso + Lunghezza:Cranio, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1169.52  -178.70   -12.43   164.69  1444.37 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       1.604e+02  1.009e+03   0.159 0.873652    
## N.gravidanze      1.391e+01  4.219e+00   3.298 0.000987 ***
## Gestazione        3.735e+01  3.870e+00   9.650  < 2e-16 ***
## Lunghezza        -3.831e+00  2.172e+00  -1.764 0.077876 .  
## Cranio           -1.161e+01  3.174e+00  -3.659 0.000258 ***
## SessoM            7.153e+01  1.093e+01   6.546 7.16e-11 ***
## Lunghezza:Cranio  4.429e-02  6.472e-03   6.844 9.67e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.8 on 2492 degrees of freedom
## Multiple R-squared:  0.742,  Adjusted R-squared:  0.7414 
## F-statistic:  1195 on 6 and 2492 DF,  p-value: < 2.2e-16
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso + 
##     Gestazione:Cranio
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2492 177817769                                  
## 2   2493 180740178 -1  -2922409 40.956 1.854e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso + 
##     Lunghezza:Cranio
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2492 177405812                                  
## 2   2493 180740178 -1  -3334367 46.837 9.674e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


BIC Selection Method:

##                 df      BIC
## model_completed 12 35130.78
## model_updated    7 35107.74
## model1           8 35074.83
## model2           8 35069.03


In the next section, squared effects will be analyzed:

model_squared1 <- update(model_updated, ~ .+I(Gestazione^2)+I(Lunghezza^2)+I(Cranio^2))
summary(model_squared1)
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso + I(Gestazione^2) + I(Lunghezza^2) + I(Cranio^2), data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1180.39  -180.05   -14.07   159.99  1325.41 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -8.515e+02  1.152e+03  -0.739 0.460008    
## N.gravidanze     1.426e+01  4.212e+00   3.387 0.000718 ***
## Gestazione       2.571e+02  6.929e+01   3.711 0.000211 ***
## Lunghezza       -1.315e+01  5.055e+00  -2.602 0.009320 ** 
## Cranio          -1.688e+01  9.897e+00  -1.705 0.088307 .  
## SessoM           7.295e+01  1.091e+01   6.688 2.77e-11 ***
## I(Gestazione^2) -2.866e+00  9.067e-01  -3.161 0.001589 ** 
## I(Lunghezza^2)   2.472e-02  5.144e-03   4.805 1.64e-06 ***
## I(Cranio^2)      3.974e-02  1.457e-02   2.727 0.006427 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.2 on 2490 degrees of freedom
## Multiple R-squared:  0.7434, Adjusted R-squared:  0.7425 
## F-statistic: 901.5 on 8 and 2490 DF,  p-value: < 2.2e-16
model_squared2 <- update(model_updated, ~ .+I(Gestazione^2)+I(Lunghezza^2))
summary(model_squared2)
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso + I(Gestazione^2) + I(Lunghezza^2), data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1187.72  -180.63   -13.61   164.12  1320.11 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -2.811e+03  9.019e+02  -3.117 0.001848 ** 
## N.gravidanze     1.440e+01  4.217e+00   3.414 0.000651 ***
## Gestazione       2.004e+02  6.617e+01   3.028 0.002489 ** 
## Lunghezza       -1.928e+01  4.535e+00  -4.252 2.20e-05 ***
## Cranio           1.009e+01  4.202e-01  24.023  < 2e-16 ***
## SessoM           7.340e+01  1.092e+01   6.721 2.22e-11 ***
## I(Gestazione^2) -2.135e+00  8.673e-01  -2.462 0.013890 *  
## I(Lunghezza^2)   3.093e-02  4.618e-03   6.697 2.62e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.6 on 2491 degrees of freedom
## Multiple R-squared:  0.7426, Adjusted R-squared:  0.7419 
## F-statistic:  1027 on 7 and 2491 DF,  p-value: < 2.2e-16
model_squared3 <- update(model_updated, ~ .+I(Lunghezza^2))
summary(model_squared3)
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + 
##     Sesso + I(Lunghezza^2), data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1176.79  -178.89   -12.52   164.19  1327.44 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -1.607e+03  7.586e+02  -2.119 0.034207 *  
## N.gravidanze    1.420e+01  4.220e+00   3.364 0.000781 ***
## Gestazione      3.773e+01  3.890e+00   9.700  < 2e-16 ***
## Lunghezza      -1.172e+01  3.342e+00  -3.508 0.000459 ***
## Cranio          1.015e+01  4.201e-01  24.157  < 2e-16 ***
## SessoM          7.222e+01  1.092e+01   6.614 4.57e-11 ***
## I(Lunghezza^2)  2.330e-02  3.430e-03   6.795 1.35e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.8 on 2492 degrees of freedom
## Multiple R-squared:  0.742,  Adjusted R-squared:  0.7413 
## F-statistic:  1194 on 6 and 2492 DF,  p-value: < 2.2e-16
anova(model_squared1,model_updated)
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso + 
##     I(Gestazione^2) + I(Lunghezza^2) + I(Cranio^2)
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2490 176494079                                  
## 2   2493 180740178 -3  -4246099 19.968 8.682e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(model_squared2,model_updated)
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso + 
##     I(Gestazione^2) + I(Lunghezza^2)
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F   Pr(>F)    
## 1   2491 177021363                                 
## 2   2493 180740178 -2  -3718815 26.165 5.68e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(model_squared3,model_updated)
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso + 
##     I(Lunghezza^2)
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2492 177452060                                  
## 2   2493 180740178 -1  -3288119 46.176 1.348e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


BIC Selection Method:

##                df      BIC
## model_squared1 10 35071.81
## model_squared2  9 35071.44
## model_squared3  8 35069.69
## model_updated   7 35107.74


Combining the information obtained from the analysis of the various models related to the interactions between variables and the quadratic effects, some definitive models will be proposed and analyzed.

## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + 
##     I(Lunghezza^2) + Lunghezza:Cranio, data = dataset)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1174.0  -178.5   -11.8   163.5  1377.1 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      -4.879e+02  7.599e+02  -0.642 0.520884    
## N.gravidanze      1.411e+01  4.218e+00   3.346 0.000831 ***
## Gestazione        3.801e+01  3.886e+00   9.783  < 2e-16 ***
## Lunghezza        -9.350e+00  3.329e+00  -2.809 0.005011 ** 
## SessoM            7.155e+01  1.091e+01   6.556 6.72e-11 ***
## I(Lunghezza^2)    1.377e-02  3.418e-03   4.027 5.82e-05 ***
## Lunghezza:Cranio  2.070e-02  8.537e-04  24.245  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.7 on 2492 degrees of freedom
## Multiple R-squared:  0.7423, Adjusted R-squared:  0.7417 
## F-statistic:  1197 on 6 and 2492 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + 
##     I(Gestazione^2) + I(Lunghezza^2) + Lunghezza:Cranio, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1186.40  -178.71   -13.79   163.75  1318.32 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      -1.857e+03  9.032e+02  -2.056 0.039918 *  
## N.gravidanze      1.432e+01  4.213e+00   3.400 0.000684 ***
## Gestazione        2.223e+02  6.606e+01   3.365 0.000778 ***
## Lunghezza        -1.794e+01  4.527e+00  -3.962 7.64e-05 ***
## SessoM            7.286e+01  1.091e+01   6.679 2.96e-11 ***
## I(Gestazione^2)  -2.419e+00  8.658e-01  -2.794 0.005244 ** 
## I(Lunghezza^2)    2.246e-02  4.618e-03   4.863 1.23e-06 ***
## Lunghezza:Cranio  2.061e-02  8.531e-04  24.157  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266.3 on 2491 degrees of freedom
## Multiple R-squared:  0.7431, Adjusted R-squared:  0.7424 
## F-statistic:  1029 on 7 and 2491 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + 
##     I(Gestazione^2) + I(Lunghezza^2) + Gestazione:Cranio, data = dataset)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1183.07  -181.38   -12.68   164.74  1315.26 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -1.769e+03  9.024e+02  -1.960 0.050100 .  
## N.gravidanze       1.442e+01  4.207e+00   3.427 0.000620 ***
## Gestazione         1.846e+02  6.606e+01   2.794 0.005252 ** 
## Lunghezza         -1.534e+01  4.518e+00  -3.396 0.000695 ***
## SessoM             7.280e+01  1.090e+01   6.682 2.91e-11 ***
## I(Gestazione^2)   -3.085e+00  8.642e-01  -3.569 0.000364 ***
## I(Lunghezza^2)     2.690e-02  4.607e-03   5.839 5.95e-09 ***
## Gestazione:Cranio  2.634e-01  1.084e-02  24.307  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 266 on 2491 degrees of freedom
## Multiple R-squared:  0.7437, Adjusted R-squared:  0.743 
## F-statistic:  1033 on 7 and 2491 DF,  p-value: < 2.2e-16
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + I(Lunghezza^2) + 
##     Lunghezza:Cranio
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2492 177205699                                  
## 2   2493 180740178 -1  -3534480 49.705 2.305e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + I(Gestazione^2) + 
##     I(Lunghezza^2) + Lunghezza:Cranio
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2491 176652058                                  
## 2   2493 180740178 -2  -4088121 28.824 4.214e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Analysis of Variance Table
## 
## Model 1: Peso ~ N.gravidanze + Gestazione + Lunghezza + Sesso + I(Gestazione^2) + 
##     I(Lunghezza^2) + Gestazione:Cranio
## Model 2: Peso ~ N.gravidanze + Gestazione + Lunghezza + Cranio + Sesso
##   Res.Df       RSS Df Sum of Sq      F    Pr(>F)    
## 1   2491 176234018                                  
## 2   2493 180740178 -2  -4506160 31.846 2.204e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


BIC Selection Method:

##                 df      BIC
## model_completed 12 35130.78
## model1           8 35074.83
## model2           8 35069.03
## model_squared1  10 35071.81
## model_squared2   9 35071.44
## model_squared3   8 35069.69
## model_optimal1   8 35066.21
## model_optimal2   9 35066.22
## model_optimal3   9 35060.30
## model_updated    7 35107.74


AIC Selection Method:

##                 df      AIC
## model_completed 12 35060.90
## model1           8 35028.24
## model2           8 35022.45
## model_squared1  10 35013.57
## model_squared2   9 35019.02
## model_squared3   8 35023.10
## model_optimal1   8 35019.63
## model_optimal2   9 35013.81
## model_optimal3   9 35007.88
## model_updated    7 35066.98


The value of BIC method, the adjusted R-squared, the RSE and the significance of the regressors suggest to choose the Model_Optimal 3, based on the variables Number of Pregnancies, Gestation Weeks, Length, Gender, square Gestation weeks, square Length and the interaction between Gestation and Skull Diameter. The AIC method suggests the same choice.

Residual Analysis


Test on the Residuals:

## [1] -5.44255e-15
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(model_optimal3)
## W = 0.99004, p-value = 3.692e-12
## 
##  studentized Breusch-Pagan test
## 
## data:  model_optimal3
## BP = 12.744, df = 7, p-value = 0.0786
## 
##  Durbin-Watson test
## 
## data:  model_optimal3
## DW = 1.954, p-value = 0.125
## alternative hypothesis: true autocorrelation is greater than 0


Leverage:

##          15          34          36          61          67          89 
## 0.009217556 0.007072619 0.007750389 0.007258620 0.009219682 0.012861826 
##         101         106         119         131         134         151 
## 0.020841255 0.023966130 0.006630263 0.007660805 0.007746642 0.012064542 
##         155         161         204         206         220         304 
## 0.015410273 0.023286854 0.014728272 0.013690093 0.008586739 0.010768317 
##         305         310         312         317         322         328 
## 0.008647797 0.089347283 0.046966660 0.007365411 0.006651253 0.007892711 
##         378         383         442         445         471         486 
## 0.062634450 0.007996679 0.008248747 0.008813195 0.010765751 0.007734879 
##         492         513         516         582         587         592 
## 0.025188603 0.006438497 0.013445055 0.012439613 0.023095804 0.012628402 
##         629         638         666         684         702         706 
## 0.007348826 0.006854756 0.009295664 0.009258344 0.008559252 0.006450901 
##         729         748         750         757         765         805 
## 0.010128111 0.016767855 0.014581749 0.008243313 0.008407510 0.036092806 
##         828         895         928         946         947         949 
## 0.007206700 0.007548147 0.135475686 0.008143249 0.014071937 0.006555167 
##         956         958         964         985         988         991 
## 0.010223005 0.006940094 0.008201226 0.008788036 0.007086213 0.007971271 
##        1014        1067        1091        1130        1188        1219 
## 0.035324324 0.016272783 0.009269083 0.036436029 0.009984601 0.030758760 
##        1222        1238        1248        1267        1273        1275 
## 0.006417583 0.007735465 0.026666340 0.006508264 0.013926381 0.008026026 
##        1283        1291        1311        1321        1323        1357 
## 0.007874914 0.006524212 0.009655575 0.009697146 0.009039267 0.014408171 
##        1385        1400        1411        1428        1429        1450 
## 0.043408332 0.009285459 0.008215317 0.037373365 0.039826400 0.015375525 
##        1505        1513        1553        1556        1573        1593 
## 0.013362758 0.010220782 0.008759626 0.006844490 0.006885186 0.008207740 
##        1610        1619        1628        1634        1639        1686 
## 0.014120951 0.079223260 0.010671824 0.008432814 0.008202322 0.020379750 
##        1701        1712        1718        1727        1780        1781 
## 0.021644645 0.007448235 0.009098523 0.013477920 0.130252482 0.017138223 
##        1809        1893        1920        1977        2016        2040 
## 0.010177435 0.006716610 0.007889417 0.009548541 0.006930662 0.023132814 
##        2086        2087        2089        2114        2115        2120 
## 0.013228317 0.008407025 0.010123838 0.046284483 0.026196017 0.070893140 
##        2140        2148        2149        2157        2175        2200 
## 0.007264059 0.008136580 0.022488744 0.006444987 0.060839031 0.025672673 
##        2216        2221        2244        2257        2307        2317 
## 0.020997713 0.021652488 0.006980277 0.013076293 0.026407662 0.008165337 
##        2359        2391        2408        2422        2437        2452 
## 0.010739079 0.012821750 0.013769331 0.021572049 0.101080177 0.093526575 
##        2458        2471        2478 
## 0.019715823 0.021254752 0.012381264


Outliers:

##       rstudent unadjusted p-value Bonferroni p
## 1306  4.973830         7.0115e-07    0.0017522
## 155   4.948915         7.9613e-07    0.0019895
## 1399 -4.470978         8.1352e-06    0.0203300
## 1694  4.372693         1.2777e-05    0.0319290


The mean of the residuals is almost equal to 0. The Shapiro-Wilk test rejects normality, but this is mainly due to the extreme values, corresponding to premature births and newborns with abnormal physical characteristics and anticipated births. The independence of the residuals is satisfied, and homoscedasticity too. The analysis of the leverage and outliers values and the Cook distance do not show critical issues. The selected model will be appropriate for performing predictions in most common situations.

Prediction and Graphics

Example of weight prediction for a male-child under these conditions: mother with three previous pregnancies, 39 weeks of gestation, length of 530 mm and skull diameter of 330 mm.
The estimated weight is:

##        1 
## 3666.444

Another case about a female-child under the following conditions: no previous pregnancy for the mother, 37 weeks of gestation, length of 500 mm and skull diameter of 300 mm.
The estimated weight is:

##        1 
## 2813.123
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

Conclusion

The selected model for the interpretation of the data and performing previsions is Model Optimal 3, based on the variables Number of Pregnancies, Gestation Weeks, Length, Gender, square Gestation weeks, square Length and the interaction between Gestation and Skull Diameter. This model and the related main variables could suggest that the Age of the Mother, the Smoking Condition, the kind of Birth (natural or cesarean) and the Hospital are statistically insignificant on the Weight of the newborn.
The analysis of the forecasts and residual diagnostic plots confirms the goodness of fit of the model. Possible critical issues are the non-total normality of the residuals (as discussed in the previous section), the presence of outlier and leverage values (altering the determination of the coefficients) and the omission of variables related to the condition of the mother (for example maternal nutrition, gestational pathologies, maternal body mass index…).
By analyzing these issues and integrating the model accordingly, also considering generalized linear models or non-linear transformations, it will be possible to better manage the deviation from normality of the residuals and reduce the unexplained variance.