{"id":1277,"date":"2023-07-27T01:17:19","date_gmt":"2023-07-27T01:17:19","guid":{"rendered":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/"},"modified":"2023-07-27T01:17:19","modified_gmt":"2023-07-27T01:17:19","slug":"goldfeld-durante-il-test-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/","title":{"rendered":"Come eseguire il test goldfeld-quandt in r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Il <strong>test di Goldfeld-Quandt<\/strong> viene utilizzato per determinare se <a href=\"https:\/\/statorials.org\/it\/regressione-dell'eteroschedasticita\/\" target=\"_blank\" rel=\"noopener\">l&#8217;eteroschedasticit\u00e0<\/a> \u00e8 presente in un modello di regressione.<\/span><\/p>\n<p> <span style=\"color: #000000;\">L&#8217;eteroschedasticit\u00e0 si riferisce alla dispersione non uniforme dei <a href=\"https:\/\/statorials.org\/it\/residuo\/\" target=\"_blank\" rel=\"noopener\">residui<\/a> a diversi livelli di una <a href=\"https:\/\/statorials.org\/it\/variabili-risposte-esplicative\/\" target=\"_blank\" rel=\"noopener\">variabile di risposta<\/a> in un modello di regressione.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se \u00e8 presente l&#8217;eteroschedasticit\u00e0, ci\u00f2 viola uno dei <a href=\"https:\/\/statorials.org\/it\/ipotesi-di-regressione-lineare\/\" target=\"_blank\" rel=\"noopener\">presupposti chiave della regressione lineare<\/a> secondo cui i residui sono equamente dispersi a ciascun livello della variabile di risposta.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial fornisce un esempio passo passo di come eseguire il test Goldfeld-Quandt in R per determinare se l&#8217;eteroschedasticit\u00e0 \u00e8 presente o meno in un determinato modello di regressione.<\/span><\/p>\n<h3> <strong>Passaggio 1: creare un modello di regressione<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Innanzitutto, creeremo un <a href=\"https:\/\/statorials.org\/it\/regressione-lineare-multipla-r\/\" target=\"_blank\" rel=\"noopener\">modello di regressione lineare multipla<\/a> utilizzando il set di dati <strong>mtcars<\/strong> integrato in R:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#fit a regression model<\/span>\nmodel &lt;- lm(mpg~disp+hp, data=mtcars)\n\n<span style=\"color: #008080;\">#view model summary\n<\/span>summary(model)\n\nCoefficients:\n             Estimate Std. Error t value Pr(&gt;|t|)    \n(Intercept) 30.735904 1.331566 23.083 &lt; 2nd-16 ***\navailable -0.030346 0.007405 -4.098 0.000306 ***\nhp -0.024840 0.013385 -1.856 0.073679 .  \n---\nSignificant. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\n\nResidual standard error: 3.127 on 29 degrees of freedom\nMultiple R-squared: 0.7482, Adjusted R-squared: 0.7309 \nF-statistic: 43.09 on 2 and 29 DF, p-value: 2.062e-09\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Passaggio 2: eseguire il test Goldfeld-Quandt<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Successivamente, utilizzeremo la funzione <b>gqtest()<\/b> del pacchetto <strong>lmtest<\/strong> per eseguire il test Goldfeld-Quandt per determinare se \u00e8 presente l&#8217;eteroschedasticit\u00e0.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questa funzione utilizza la seguente sintassi:<\/span><\/p>\n<p> <strong><span style=\"color: #000000;\">gqtest(modello, ordine.per, dati, frazione)<\/span><\/strong><\/p>\n<p> <span style=\"color: #000000;\">Oro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>modello:<\/strong> il modello di regressione lineare creato dal comando lm().<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>order.by:<\/strong> le variabili predittive del modello.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>dati:<\/strong> il nome del set di dati.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>frazione*:<\/strong> numero di osservazioni centrali da rimuovere dal set di dati.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">*Il test Goldfeld-Quandt funziona rimuovendo un numero di osservazioni situate al centro del set di dati e quindi testando per vedere se la distribuzione dei residui \u00e8 diversa dai due set di dati risultanti che si trovano su entrambi i lati dei set di dati. osservazioni centrali.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In genere, scegliamo di rimuovere circa il 20% delle osservazioni totali. In questo caso, mtcars ha 32 osservazioni in totale, quindi possiamo scegliere di rimuovere le 7 osservazioni centrali:<\/span><\/p>\n<pre style=\"background-color: #e5e5e5; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#load lmtest library<\/span>\nlibrary(lmtest)\n\n<span style=\"color: #008080;\">#perform the Goldfeld Quandt test<\/span>\ngqtest(model, order.by = ~disp+hp, data = mtcars, fraction = 7)\n\n\tGoldfeld-Quandt test\n\ndata: model\nGQ = 1.0316, df1 = 10, df2 = 9, p-value = 0.486\nalternative hypothesis: variance increases from segment 1 to 2\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ecco come interpretare il risultato:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">La statistica del test \u00e8 <b>1.0316<\/b> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">Il valore p corrispondente \u00e8 <strong>0,486<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Il test di Goldfeld-Quandt utilizza le seguenti ipotesi nulle e alternative:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>Nullo (H <sub>0<\/sub> )<\/strong> : \u00e8 presente l&#8217;omoschedasticit\u00e0.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Alternativa ( <sub>HA<\/sub> ):<\/strong> \u00e8 presente eteroschedasticit\u00e0.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Poich\u00e9 il valore p non \u00e8 inferiore a 0,05, non riusciamo a rifiutare l&#8217;ipotesi nulla. Non abbiamo prove sufficienti per affermare che l\u2019eteroschedasticit\u00e0 sia presente nel modello di regressione.<\/span><\/p>\n<h3> <strong>Cosa fare dopo<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Se non si riesce a rifiutare l&#8217;ipotesi nulla del test di Goldfeld-Quandt, l&#8217;eteroschedasticit\u00e0 non \u00e8 presente e si pu\u00f2 procedere a interpretare il risultato della regressione originale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tuttavia, se si rifiuta l\u2019ipotesi nulla, significa che nei dati \u00e8 presente l\u2019eteroschedasticit\u00e0. In questo caso, gli errori standard visualizzati nella tabella di output della regressione potrebbero essere inaffidabili.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esistono diversi modi comuni per risolvere questo problema, tra cui:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>1. Trasformare la variabile di risposta.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Puoi provare a eseguire una trasformazione sulla variabile di risposta, ad esempio prendendo <a href=\"https:\/\/statorials.org\/it\/trasformare-i-dati-in-r\/\" target=\"_blank\" rel=\"noopener\">il logaritmo, la radice quadrata o la radice cubica<\/a> della variabile di risposta. In generale, ci\u00f2 pu\u00f2 far scomparire l\u2019eteroschedasticit\u00e0.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>2. Utilizzare la regressione ponderata.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">La regressione ponderata assegna un peso a ciascun punto dati in base alla varianza del relativo valore adattato. In sostanza, ci\u00f2 attribuisce pesi bassi ai punti dati che presentano varianze pi\u00f9 elevate, riducendo i loro quadrati residui.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Quando vengono utilizzati i pesi appropriati, la regressione ponderata pu\u00f2 eliminare il problema dell&#8217;eteroschedasticit\u00e0.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/regressione-lineare-multipla-r\/\" target=\"_blank\" rel=\"noopener\">Come eseguire la regressione lineare multipla in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/prova-bianca-in-r\/\" target=\"_blank\" rel=\"noopener\">Come eseguire il test di White in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/breusch-prova-pagana-r\/\" target=\"_blank\" rel=\"noopener\">Come eseguire un test di Breusch-Pagan in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Il test di Goldfeld-Quandt viene utilizzato per determinare se l&#8217;eteroschedasticit\u00e0 \u00e8 presente in un modello di regressione. L&#8217;eteroschedasticit\u00e0 si riferisce alla dispersione non uniforme dei residui a diversi livelli di una variabile di risposta in un modello di regressione. Se \u00e8 presente l&#8217;eteroschedasticit\u00e0, ci\u00f2 viola uno dei presupposti chiave della regressione lineare secondo cui i [&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 il test Goldfeld-Quandt in R<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#039;eteroschedasticit\u00e0, con un esempio.\" \/>\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\/goldfeld-durante-il-test-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come eseguire il test Goldfeld-Quandt in R\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#039;eteroschedasticit\u00e0, con un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T01:17:19+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=\"3 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/\",\"url\":\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/\",\"name\":\"Come eseguire il test Goldfeld-Quandt in R\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-27T01:17:19+00:00\",\"dateModified\":\"2023-07-27T01:17:19+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#39;eteroschedasticit\u00e0, con un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come eseguire il test goldfeld-quandt 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 il test Goldfeld-Quandt in R","description":"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#39;eteroschedasticit\u00e0, con un esempio.","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\/goldfeld-durante-il-test-in-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come eseguire il test Goldfeld-Quandt in R","og_description":"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#39;eteroschedasticit\u00e0, con un esempio.","og_url":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-27T01:17:19+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"3 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/","url":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/","name":"Come eseguire il test Goldfeld-Quandt in R","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-27T01:17:19+00:00","dateModified":"2023-07-27T01:17:19+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come eseguire il test Goldfeld-Quandt in R per l&#39;eteroschedasticit\u00e0, con un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/goldfeld-durante-il-test-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come eseguire il test goldfeld-quandt 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\/1277"}],"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=1277"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1277\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}