Dr. Baranyai László

 

R: csoportok összehasonlítása

júl 26, 20:11, |

 

Az adatsoron belüli csoportok összehasonlításának legegyszerűbb módszere a grafikus ábrázolás boxplot vagy errorbar segítségével. Amikor lehet, az előbbit részesítem előnyben, mert a csoportokon belüli eloszlásról is ad információt. Az utóbbi (errorbar) a középértékek konfidencia intervallumát mutatja be. Mindkettőnek megvannak a maga előnyei.

Boxplot példa 3 csoportra

A fenti grafikon R-projectben készült a beépített iris adattábla felhasználásával:

boxplot(Sepal.Length ~ Species,data=iris)

Az ábráról ugyan leolvasható a medián és a negyedelők (kvartilisek) értéke, de ez csak szemléltetésként fogadható el, nem ad pontos számszerű eredményt. Az idevágó statisztikai próbák az átlag és szórás adatokból (LSD = least significant difference), esetleg a 95%-os konfidencia intervallum (MRT = multiple range test) alapján hoznak döntést. Ezeket az értékeket külön kiegészítő csomag telepítése nélkül is kiszámíthatjuk:

range.test <- function(myData,myLevels)
{
 ul <- sort(unique(myLevels))
 Name <- ul
 Mean <- rep(0,length(ul))
 SD <- Mean
 CI95.min <- Mean
 CI95.max <- Mean
 for (i in 1:length(ul)) {
  tmp <- myData[ myLevels == ul[i] ]
  Mean[i] <- mean(tmp)
  SD[i] <- sd(tmp)
  CI95.min[i] <- t.test(tmp)$conf.int[1]
  CI95.max[i] <- t.test(tmp)$conf.int[2]
 }
 return( data.frame(Name,Mean,SD,CI95.min,CI95.max) )
}

A fenti függvény kiszámítja a kiválasztott adatsor csoportjainak említett paramétereit. Az átlag és szórás egyértelmű, a középérték konfidencia intervallumát pedig az egymintás t-próba segítségével határozza meg. Használata a következő:

> range.test(iris$Sepal.Length,iris$Species)
        Name  Mean        SD CI95.min CI95.max
1     setosa 5.006 0.3524897 4.905824 5.106176
2 versicolor 5.936 0.5161711 5.789306 6.082694
3  virginica 6.588 0.6358796 6.407285 6.768715

A szokásos páronkénti összehasonlítást nem végzi el, a konfidencia intervallumok átlapolódásából mi magunk állapíthatjuk meg a szignifikáns eltéréseket. A függvény kiegészíthető ellenőrző funkciókkal is, pl. a két paraméter vektor hosszának összehasonlítása.

Mindenkinek jó munkát!

 

Ehhez a cikkhez nem fűzhető megjegyzés!

Hazai időjárás

Magyarország domborzati hőtérképe Felhőkép

 

Hirdetések

 

Linux for open minds.

 

Legfrissebb cikkek

 

EurekAlert! - Agriculture

  • Study shows electron-beam irradiation reduces virus-related health risk in lettuce, spinach
    (Texas A&M AgriLife Communications) The recent study by scientists from the National Center for Electron Beam Research (Texas A&M University) and other entities has quantified the theoretical health-risk reduction from virus-related food-borne illness through the use of electron-beam irradiation.
  • Satellite tracking reveals sea turtle feeding hotspots
    (United States Geological Survey) Satellite tracking of threatened loggerhead sea turtles has revealed two previously unknown feeding "hotspots" in the Gulf of Mexico that are providing important habitat for at least three separate populations of the turtles.
  • Consumers willing to buy sustainable US cotton, MU researchers find
    (University of Missouri-Columbia) Researchers from the University of Missouri have found that United States consumers are more willing to buy clothing made from sustainably grown US cotton than apparel produced using conventional practices in an unknown location.
  • A new species of bamboo-feeding plant lice found in Costa Rica
    (Pensoft Publishers) Several periods of field work during 2008 have led to the discovery of a new species of bamboo-feeding plant lice in Costa Rica's high-altitude region Cerro de la Muerte. The discovery was made thanks to molecular data analysis of mitochondrial DNA. The collected records have also increased the overall knowledge of plant lice (one of the most dangerous agricultural pests worldwide) from the region with more that 20 percent. The study was published in the open-access journal ZooKeys.
  • Established journal Evolutionary Applications to publish under open-access model
    (Wiley-Blackwell) Wiley-Blackwell, the scientific, technical, medical and scholarly publishing business of John Wiley & Sons Inc., today announced that Evolutionary Applications has joined the Wiley Open Access publishing program. All newly published articles in the journal will be open access and free to view, download and share for non-commercial use.

EurekAlert!