{"id":667,"date":"2023-07-29T03:58:36","date_gmt":"2023-07-29T03:58:36","guid":{"rendered":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/"},"modified":"2023-07-29T03:58:36","modified_gmt":"2023-07-29T03:58:36","slug":"test-di-durbin-watson-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/","title":{"rendered":"Come eseguire un test di durbin-watson in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Uno dei <a href=\"https:\/\/statorials.org\/it\/ipotesi-di-regressione-lineare\/\" target=\"_blank\" rel=\"noopener\">presupposti chiave della regressione lineare<\/a> \u00e8 che non vi sia alcuna correlazione tra i residui, ovvero che i residui siano indipendenti.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Un modo per determinare se questa ipotesi \u00e8 soddisfatta \u00e8 eseguire un <a href=\"https:\/\/statorials.org\/it\/test-di-durbin-watson\/\" target=\"_blank\" rel=\"noopener\">test di Durbin-Watson<\/a> , utilizzato per rilevare la presenza di autocorrelazione nei residui di una regressione. Questo test utilizza le seguenti ipotesi:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>H <sub>0<\/sub> (ipotesi nulla):<\/strong> non esiste correlazione tra i residui.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>H <sub>A<\/sub> (ipotesi alternativa):<\/strong> i residui sono autocorrelati.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega come eseguire un test di Durbin-Watson in R.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio: test di Durbin-Watson in R<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Per eseguire un test di Durbin-Watson, dobbiamo prima adattare un modello di regressione lineare. Utilizzeremo il set di dati R integrato <strong>di mtcars<\/strong> e adatteremo un modello di regressione utilizzando <strong>mpg<\/strong> come variabile predittiva e <strong>disp<\/strong> e <strong>wt<\/strong> come variabili esplicative.<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#load mtcars dataset\n<\/span>data(mtcars)\n\n<span style=\"color: #008080;\">#view first six rows of dataset\n<\/span>head(mtcars)\n\n                   mpg cyl disp hp drat wt qsec vs am gear carb\nMazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4\nMazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4\nDatsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1\nHornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1\nHornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2\nValiant 18.1 6 225 105 2.76 3,460 20.22 1 0 3 1\n\n<span style=\"color: #008080;\">#fit regression model\n<\/span>model &lt;- lm(mpg ~ disp+wt, data=mtcars)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Quindi possiamo eseguire un test Durbin-Watson utilizzando la funzione <strong>durbinWatsonTest()<\/strong> dal pacchetto <strong>perch\u00e9<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#load car package\n<\/span>library(car)\n\n<span style=\"color: #008080;\">#perform Durbin-Watson test\n<\/span>durbinWatsonTest(model)\n\nLoading required package: carData\n lag Autocorrelation DW Statistic p-value\n   1 0.341622 1.276569 0.034\n Alternative hypothesis: rho != 0<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Dal risultato, possiamo vedere che la statistica del test \u00e8 <strong>1.276569<\/strong> e il corrispondente valore p \u00e8 <strong>0.034<\/strong> . Poich\u00e9 questo valore p \u00e8 inferiore a 0,05, possiamo rifiutare l&#8217;ipotesi nulla e concludere che i residui di questo modello di regressione sono autocorrelati.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Cosa fare se viene rilevata l&#8217;autocorrelazione<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se rifiuti l&#8217;ipotesi nulla e concludi che nei residui \u00e8 presente l&#8217;autocorrelazione, hai diverse opzioni per correggere questo problema se lo consideri abbastanza serio:<\/span><\/p>\n<ul data-slot-rendered-dynamic=\"true\">\n<li> <span style=\"color: #000000;\">Per una correlazione seriale positiva, prendere in considerazione l&#8217;aggiunta di ritardi della variabile dipendente e\/o indipendente al modello.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Per la correlazione seriale negativa, assicurati che nessuna delle variabili abbia <em>un ritardo eccessivo<\/em> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Per la correlazione stagionale, prendere in considerazione l&#8217;aggiunta di dummy stagionali al modello.<\/span><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Uno dei presupposti chiave della regressione lineare \u00e8 che non vi sia alcuna correlazione tra i residui, ovvero che i residui siano indipendenti. Un modo per determinare se questa ipotesi \u00e8 soddisfatta \u00e8 eseguire un test di Durbin-Watson , utilizzato per rilevare la presenza di autocorrelazione nei residui di una regressione. Questo test utilizza le [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come eseguire un test di Durbin-Watson in R - Statorials<\/title>\n<meta name=\"description\" content=\"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come eseguire un test di Durbin-Watson in R - Statorials\" \/>\n<meta property=\"og:description\" content=\"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-29T03:58:36+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/\",\"url\":\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/\",\"name\":\"Come eseguire un test di Durbin-Watson in R - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-29T03:58:36+00:00\",\"dateModified\":\"2023-07-29T03:58:36+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come eseguire un test di durbin-watson in r\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come eseguire un test di Durbin-Watson in R - Statorials","description":"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come eseguire un test di Durbin-Watson in R - Statorials","og_description":"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.","og_url":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/","og_site_name":"Statorials","article_published_time":"2023-07-29T03:58:36+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/","url":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/","name":"Come eseguire un test di Durbin-Watson in R - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-29T03:58:36+00:00","dateModified":"2023-07-29T03:58:36+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Una semplice spiegazione su come eseguire un test di Durbin-Watson in R e su come interpretare i risultati.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/test-di-durbin-watson-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come eseguire un test di durbin-watson in r"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/667"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=667"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}