Dr. Baranyai László

 

R: csoportok összehasonlítása

4 nappal ezelőtt, |

 

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!

 

« régebbi

Hazai időjárás

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

 

Hirdetések

Linux for open minds.

 

Aktuális írások

Legfrissebb cikkek

 

Hozzászólások

 

RSS feed   Atom feed

 

ScienceDaily Newsfeed

  • Researchers find new translocation; weak spots in DNA lead to genetic disease
    Pediatric researchers continue to discover recurrent translocations -- places in which two chromosomes exchange pieces of themselves, and can lead to genetic disease and disability. Originating in locations where DNA strands are prone to bending and breaking, this translocation between chromosomes 8 and 22 strengthens the possibility that unstable spots in the genome may reflect a general mechanism lurking in the structure of DNA.
  • Plant compound resveratrol shown to suppresses inflammation, free radicals in humans
    Resveratrol, a popular plant extract shown to prolong life in yeast and lower animals due to its anti-inflammatory and antioxidant properties, appears also to suppress inflammation in humans, based on results from the first prospective human trial of the extract.
  • Unexpected viral 'fossils' found in vertebrate genomes
    Over millions of years, retroviruses, which insert their genetic material into the host genome as part of their replication, have left behind bits of their genetic material in vertebrate genomes. In a recent study, a team of researchers found that human and other vertebrate genomes also contain many ancient sequences from Ebola/Marburgviruses and Bornaviruses -- two deadly virus families.
  • Snake venom studies yield insights for development of therapies for heart disease and cancer
    Researchers seeking to learn more about stroke by studying how the body responds to toxins in snake venom are this week releasing new findings that they hope will aid in the development of therapies for heart disease and, surprisingly, cancer.
  • How not to blow up a molecule
    Can single-shot imaging with femtosecond x-ray pulses from powerful new free electron lasers really work, or will the beam damage the sample too quickly? Pulse length is the key. A new study reveals that "frustrated absorption" explains why ultrashort pulses, even if their peak power is greater, do less damage to molecules than longer pulses.

ScienceDaily.com