{"id":727,"date":"2025-07-31T11:43:17","date_gmt":"2025-07-31T11:43:17","guid":{"rendered":"https:\/\/agustincastro.es\/?p=727"},"modified":"2026-02-05T13:37:59","modified_gmt":"2026-02-05T13:37:59","slug":"comparacion-de-ventas-mensuales-entre-cinco-antibioticos-un-caso-practico-con-anova","status":"publish","type":"post","link":"https:\/\/agustincastro.es\/index.php\/2025\/07\/31\/comparacion-de-ventas-mensuales-entre-cinco-antibioticos-un-caso-practico-con-anova\/","title":{"rendered":"\ud83d\udcca Comparaci\u00f3n de ventas de cinco antibi\u00f3ticos: un caso pr\u00e1ctico con ANOVA"},"content":{"rendered":"\n<p>En este an\u00e1lisis presentamos un caso pr\u00e1ctico utilizando <strong>ANOVA unifactorial<\/strong> para comparar las ventas de distintos antibi\u00f3ticos a lo largo de un a\u00f1o. Aunque el enfoque es simulado, reproduce una situaci\u00f3n muy real en el \u00e1mbito comercial y farmac\u00e9utico: detectar diferencias en el rendimiento de distintos productos (en este caso, antibi\u00f3ticos) en t\u00e9rminos de ventas.<\/p>\n\n\n\n<p>Esta pr\u00e1ctica tiene menos detalle en el desarrollo que otras que he publicado en el blog, por lo que puedes consultar las entradas anteriores para buscar explicaciones extensas de los pasos realizados etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\uddea Contexto del ejercicio<\/h3>\n\n\n\n<p>Una empresa farmac\u00e9utica desea analizar las <strong>ventas mensuales<\/strong> de cinco antibi\u00f3ticos durante 12 meses, con el objetivo de determinar si hay diferencias estad\u00edsticamente significativas entre sus promedios de venta. Los antibi\u00f3ticos incluidos en el an\u00e1lisis son:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>AmoxiClear<\/strong><\/li>\n\n\n\n<li><strong>CiproFast<\/strong><\/li>\n\n\n\n<li><strong>DoxiPlus<\/strong><\/li>\n\n\n\n<li><strong>ErythroMax<\/strong><\/li>\n\n\n\n<li><strong>LevoStrong<\/strong><\/li>\n<\/ul>\n\n\n\n<p>No se introduce variaci\u00f3n estacional: el mes del a\u00f1o solo act\u00faa como repetici\u00f3n, no como factor explicativo. *** todos los nombres son inventados para la pr\u00e1ctica. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"561\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28-1024x561.png\" alt=\"\" class=\"wp-image-728 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28-1024x561.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28-300x164.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28-768x421.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28-1536x842.png 1536w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-28.png 1970w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/561;\" \/><\/figure>\n\n\n\n<p>La tabla con los datos (data frame) quedar\u00eda de la siguiente forma. Tendr\u00edamos un valor de venta mensual para cada antibi\u00f3tico. En esta imagen solo vemos los datos de uno de ellos, AmoxiClear. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"772\" height=\"894\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-29.png\" alt=\"\" class=\"wp-image-729 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-29.png 772w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-29-259x300.png 259w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-29-768x889.png 768w\" data-sizes=\"(max-width: 772px) 100vw, 772px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 772px; --smush-placeholder-aspect-ratio: 772\/894;\" \/><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d Metodolog\u00eda<\/h3>\n\n\n\n<p>Se utiliz\u00f3 un <strong>ANOVA de un factor (one-way ANOVA)<\/strong> para comparar las medias de ventas de los cinco antibi\u00f3ticos. Al detectarse diferencias significativas (p &lt; 0.05), se aplic\u00f3 una prueba <strong>post-hoc de Tukey<\/strong> para identificar qu\u00e9 pares de antibi\u00f3ticos difieren entre s\u00ed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"406\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-31-1024x406.png\" alt=\"\" class=\"wp-image-732 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-31-1024x406.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-31-300x119.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-31-768x304.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-31.png 1126w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/406;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"453\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-32-1024x453.png\" alt=\"\" class=\"wp-image-733 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-32-1024x453.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-32-300x133.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-32-768x340.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-32.png 1346w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/453;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"433\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-34-1024x433.png\" alt=\"\" class=\"wp-image-735 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-34-1024x433.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-34-300x127.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-34-768x325.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-34.png 1144w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/433;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"756\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-33-1024x756.png\" alt=\"\" class=\"wp-image-734 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-33-1024x756.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-33-300x221.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-33-768x567.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-33.png 1412w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/756;\" \/><\/figure>\n\n\n\n<p>De las <strong>10 comparaciones posibles<\/strong> entre antibi\u00f3ticos, <strong>8 resultaron estad\u00edsticamente significativas<\/strong> (p &lt; 0.05). Este \u00faltimo punto es clave: <strong>algunas diferencias aparentes no resultan significativas<\/strong> <strong>estad\u00edsticamente<\/strong>, lo cual destaca la importancia de aplicar pruebas adecuadas y no fiarse solo del aspecto visual o intuitivo. As\u00ed, no son diferencias estad\u00edsticamente significativas las ventas de CiproFast &#8211; AmoxiClear, ni las de LevoStrong &#8211; DoxyPlus (p > 0.05) &#8211; Ver tabla de resultados del test Tukey (arriba) y comparar con la representaci\u00f3n de boxplot (m\u00e1s abajo). En esta pr\u00e1ctica no se est\u00e1n teniendo en cuenta factores importantes como pueden, por ejemplo, la influencia de <strong><em>outliers <\/em><\/strong>en el caso de las ventas de LevoStrong. Ser\u00eda interesante analizar esto con mayor detalle.  <\/p>\n\n\n\n<p>En la tabla se muestran las 8 que si resultaron significativas:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"210\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-35-1024x210.png\" alt=\"\" class=\"wp-image-736 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-35-1024x210.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-35-300x62.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-35-768x158.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-35.png 1529w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/210;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"559\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1-1024x559.jpg\" alt=\"\" class=\"wp-image-737 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1-1024x559.jpg 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1-300x164.jpg 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1-768x419.jpg 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1-1536x838.jpg 1536w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/ventas_antibioticos-1.jpg 1980w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/559;\" \/><\/figure>\n\n\n\n<p>Este ser\u00eda el c\u00f3digo para el visual.- <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"724\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30-1024x724.png\" alt=\"\" class=\"wp-image-731 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30-1024x724.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30-300x212.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30-768x543.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30-1536x1085.png 1536w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-30.png 1582w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/724;\" \/><\/figure>\n\n\n\n<p>Por \u00faltimo, comprobamos los supuestos de normalidad y homocedasticidad, que son correctos y, por tanto, validan los resultados del ANOVA realizado. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"504\" data-src=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36-1024x504.png\" alt=\"\" class=\"wp-image-738 lazyload\" data-srcset=\"https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36-1024x504.png 1024w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36-300x148.png 300w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36-768x378.png 768w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36-1536x755.png 1536w, https:\/\/agustincastro.es\/wp-content\/uploads\/2025\/07\/image-36.png 1818w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/504;\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>En este an\u00e1lisis presentamos un caso pr\u00e1ctico utilizando ANOVA unifactorial para comparar las ventas de distintos antibi\u00f3ticos a lo largo de un a\u00f1o. Aunque el enfoque es simulado, reproduce una situaci\u00f3n muy real en el \u00e1mbito comercial y farmac\u00e9utico: detectar diferencias en el rendimiento de distintos productos (en este caso, antibi\u00f3ticos) en t\u00e9rminos de ventas. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":739,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,7,5],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-portfolio","category-r","category-tecnica-y-practica"],"_links":{"self":[{"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":5,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":745,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/posts\/727\/revisions\/745"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/media\/739"}],"wp:attachment":[{"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agustincastro.es\/index.php\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}