I am trying to use Levene's test (of package car), but I do not understand quite well how to use it. '?levene.test' does not unfortunately provide any example. My data are in a data frame and correspond to 1 factor plus response. Could someone please give me an example about how to use the command levene.test(y, group) Thanks in advance, marta -- View this message in context: http://r.789695.n4.nabble.com/levene-test-tp2288452p2288452.html Sent from the R help mailing list archive at Nabble.com.
On Wed, 2010-07-14 at 01:37 -0700, martanair wrote:> I am trying to use Levene's test (of package car), but I do > not understand quite well how to use it. '?levene.test' does > not unfortunately provide any example. My data are in a data > frame and correspond to 1 factor plus response. Could > someone please give me an example about how to use the command > > levene.test(y, group) > > Thanks in advance, > > martaHi Marta, levene.test is deprecated functions in car package as say the help of command (?levene.test). Instead this use leveneTest (?levene.test again)If you type ?leveneTest you get examples -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil
On Wed, 2010-07-14 at 01:37 -0700, martanair wrote:> I am trying to use Levene's test (of package car), but I do > not understand quite well how to use it. '?levene.test' does > not unfortunately provide any example.Err, yes it does, several examples in fact.> My data are in a data > frame and correspond to 1 factor plus response. Could > someone please give me an example about how to use the command > > levene.test(y, group) > > Thanks in advance, > > martaHere is an example where data aren't in a data.frame. require(car) ## dummy data with know different variances set.seed(123) Y <- c(rnorm(20, sd = 6), rnorm(20, sd = 1)) G <- gl(2, 20, labels = paste("Group", 1:2, sep = "")) ## Y is the thing we measured on our two groups, ## G is the group indicator ## levene test of different variances levene.test(y = Y, group = G) ## Gives: Levene's Test for Homogeneity of Variance Df F value Pr(>F) group 1 21.033 4.792e-05 *** 38 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 If Y and G were in a data frame, then the easiest way to run it is: ## put data above in to a data frame dat <- data.frame(Y = Y, G = G) head(dat) str(dat) ## ok so G is a factor within data frame ## run levene's test with(dat, leven.test(y = Y, group = G)) ?leven.test even shows you this usage! ## or if you like $ levene.test(dat$Y, dat$G) Just replace dat Y and G with the relevant objects and components of the data frame holding your data. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
I am trying to use Levene's test (of package car), but I do not understand quite well how to use it. '?levene.test' does not unfortunately provide any example. My data are in a data frame and correspond to 1 factor plus response. Could someone please give me an example about how to use the command levene.test(y, group) Thanks in advance, marta filedati=read.table("filedati.txt",header=TRUE) filedati modello=aov(filedati$y ~ filedati$fertilizzante) anova(modello) str(filedati$fertilizzante) filedati$fertilizzante=factor(filedati$fertilizzante) filedati$fertilizzante library(car) levene.test(filedati$y , filedati$fertilizzante) filedati fertilizzante x y 1 55 502 1 60 532 1 48 525 1 44 444 1 63 527 1 60 531 1 50 478 1 56 530 1 54 547 2 100 619 2 75 425 2 52 400 2 62 418 2 68 449 2 86 525 2 57 470 2 82 506 2 72 507 2 88 495 2 55 393 2 67 515 2 45 382 2 103 570 2 103 611 2 84 473 -- View this message in context: http://r.789695.n4.nabble.com/levene-test-tp2288632p2288632.html Sent from the R help mailing list archive at Nabble.com.