[R] ANOVA and contrasts
Dears members of R list, I would like that a more experienced R user help me to complete this analysis: r = gl(3, 8, label = c('r1', 'r2', 'r3')) e = rep(gl(2, 4, label = c('e1', 'e2')), 3) y = c(26.2, 26.0, 25.0, 25.4, 24.8, 24.6, 26.7, 25.2, 25.7, 26.3, 25.1, 26.4, 19.6, 21.1, 19.0, 18.6, 22.8, 19.4, 18.8, 19.2, 19.8, 21.4, 22.8, 21.3) df = data.frame(r, e, y) attach(df) par(mfrow=c(2,1)) interaction.plot(r, e, y, col = 'blue', ylab = 'y', xlab = 'r') interaction.plot(e, r, y, col = 'blue', ylab = 'y', xlab = 'r') av1 = aov(y ~ r*e) av2 = aov(y ~ r/e) efR_E = summary(av2, split = list('r:e' = list('e1 vs e2/r1' = 1, 'e1 vs e2/r2' = 2, 'e1 vs e2/r3' = 3))) av3 = aov(y ~ e/r) efE_R = summary(av3, split = list('e:r' = list('r/e1' = c(1,3), 'r/e2' = c(2,4 # --Begin the problem- # # I woud like to compare r/e1 (SS = 87.122 with 2 GL) like this: # r1 vs (r2,r3 ) / e1 # r2 vs r3 / e1 # And compare r/e2 (SS = 69.500 with 2 GL) like this: # r1 vs (r2,r3 ) / e2 # r2 vs r3 / r1 / e2 # # --End the problem mds = model.tables(av1, ty = 'means') detach(df) cat('\nData:'); cat('\n') print(df) cat('\nMeans:'); cat('\n') print(mds) cat('\nANOVA:'); cat('\n') print(summary(av1)); cat('\n') cat('\nANOVA - E effect in R levels:'); cat('\n') print(efR_E); cat('\n') cat('\nANOVA - R effect in E levels:'); cat('\n') print(efE_R); cat('\n') Best regards, Saudações, José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Aid on two-way ANOVA with contrasts
Dears members of R list, It would like that a more experienced statician in R helped me to complete the analysis to follow: r = gl(3, 8, label = c('r1', 'r2', 'r3')) e = rep(gl(2, 4, label = c('e1', 'e2')), 3) y = c(26.2, 26.0, 25.0, 25.4, 24.8, 24.6, 26.7, 25.2, 25.7, 26.3, 25.1, 26.4, 19.6, 21.1, 19.0, 18.6, 22.8, 19.4, 18.8, 19.2, 19.8, 21.4, 22.8, 21.3) df = data.frame(r, e, y) attach(df) par(mfrow=c(2,1)) interaction.plot(r, e, y, col = 'blue', ylab = 'y', xlab = 'r') interaction.plot(e, r, y, col = 'blue', ylab = 'y', xlab = 'r') av1 = aov(y ~ r*e) av2 = aov(y ~ r/e) efR_E = summary(av2, split = list('r:e' = list('e1 vs e2/r1' = 1, 'e1 vs e2/r2' = 2, 'e1 vs e2/r3' = 3))) av3 = aov(y ~ e/r) efE_R = summary(av3, split = list('e:r' = list('r/e1' = c(1,3), 'r/e2' = c(2,4 mds = model.tables(av1, ty = 'means') detach(df) cat('\nData:'); cat('\n') print(df) cat('\nMeans:'); cat('\n') print(mds) cat('\nANOVA:'); cat('\n') print(summary(av1)); cat('\n') cat('\nANOVA - E effect in R levels:'); cat('\n') print(efR_E); cat('\n') cat('\nANOVA - R effect in E levels:'); cat('\n') print(efE_R); cat('\n') #I would like to get as resulted (efE_R) like this: # ANOVA - R effect (contrasts) in E levels: #Df Sum SqMean Sq F value Pr(>F) # e 1 19.082 # e:r(4) (156.622) #e:r: r/e1 (2) (87.122) # r1 vs (r2,r3)/e1 1 ?... # r2 vs r3/e11 ? #e:r: r/e2 (2) (69.500) # r1 vs (r2,r3)/e1 1 ?... # r2 vs r3/e2 1 ?... # Residuals 18 23.090 1.283 #Through manual calculations I got: # ANOVA - R effect in E levels: #Df Sum SqMean Sq F valuePr(>F) # e 1 19.082 # e:r(4) (156.622) #e:r: r/e1 (2) (87.122) # r1 vs (r2,r3)/e 1 19.26 # r2 vs r3/e11 67.86 #e:r: r/e2 (2) (69.500) # r1 vs (r2,r3)/e 1 63.38 # r2 vs r3/e21 6.12 # Residuals18 23.090 1.283 Best regards, José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R: Help (two-way analysis of variance with contrasts)
Dears members of R list, It would like that a more experienced statician in R helped me to complete the analysis to follow: r = gl(3, 8, label = c('r1', 'r2', 'r3')) e = rep(gl(2, 4, label = c('e1', 'e2')), 3) y = c(26.2, 26.0, 25.0, 25.4, 24.8, 24.6, 26.7, 25.2, 25.7, 26.3, 25.1, 26.4, 19.6, 21.1, 19.0, 18.6, 22.8, 19.4, 18.8, 19.2, 19.8, 21.4, 22.8, 21.3) df = data.frame(r, e, y) attach(df) par(mfrow=c(2,1)) interaction.plot(r, e, y, col = 'blue', ylab = 'y', xlab = 'r') interaction.plot(e, r, y, col = 'blue', ylab = 'y', xlab = 'r') av1 = aov(y ~ r*e) av2 = aov(y ~ r/e) efR_E = summary(av2, split = list('r:e' = list('e1 vs e2/r1' = 1, 'e1 vs e2/r2' = 2, 'e1 vs e2/r3' = 3))) av3 = aov(y ~ e/r) efE_R = summary(av3, split = list('e:r' = list('r/e1' = c(1,3), 'r/e2' = c(2,4 mds = model.tables(av1, ty = 'means') detach(df) cat('\nData:'); cat('\n') print(df) cat('\nMeans:'); cat('\n') print(mds) cat('\nANOVA:'); cat('\n') print(summary(av1)); cat('\n') cat('\nANOVA - E effect in R levels:'); cat('\n') print(efR_E); cat('\n') cat('\nANOVA - R effect in E levels:'); cat('\n') print(efE_R); cat('\n') #I would like to get as resulted (efE_R) like this: # ANOVA - R effect (contrasts) in E levels: #Df Sum SqMean Sq F value Pr(>F) # e 1 19.082 # e:r (4) (156.622) #e:r: r/e1 (2)(87.122) # r1 vs (r2,r3)/e1 1 ? ? ?? # r2 vs r3/e11 ? ? ?? #e:r: r/e2 (2) (69.500) # r1 vs (r2,r3)/e1 1 ? ? ?? # r2 vs r3/e2 1 ? ? ?? # Residuals 18 23.090 1.283 #Through manual calculations I got: # ANOVA - R effect in E levels: # Df Sum SqMean Sq F valuePr(>F) # e 1 19.082 # e:r (4) (156.622) #e:r: r/e1 (2)(87.122) # r1 vs (r2,r3)/e 1 19.26 # r2 vs r3/e11 67.86 #e:r: r/e2 (2)(69.500) # r1 vs (r2,r3)/e 1 63.38 # r2 vs r3/e216.12 # Residuals18 23.090 1.283 Best regards, José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Exclude selected values for columns in frames
Dear list, I'm needing submit values (V1 = 8,6,4,3,1,2,9) (Id = 2:8) of a data.frame (DF), like below Id V1 V2 ... 101 ... 2810 ... 362 ... 444 ... 537 ... 618 ... 726 ... 897 ... 961 ... 10 54 ... to selection (>=2 and <8) for remanescents like below: Id V1 V2 ... 1 .1 ... 2 .10 ... 362 ... 444 ... 537 ... 6 . 8 ... 726 ... 8 . 7 ... 961 ... 10 54 ... or Id V1 V2 ... 1 . . ... 2 . . ... 362 ... 444 ... 537 ... 6 . . ... 726 ... 8 . 7 ... 96 . ... 10 54 ... How to do this betther with R? Is there a command to compare all to same time? I would be very thankful. Yours sincerly Att. José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help to compare...
Dear list, I'm needing submit values (V1 = 8,6,4,3,1,2,9) (Id = 2:8) of a data.frame (DF), like below Id V1 V2 ... 101 ... 2810 ... 362 ... 444 ... 537 ... 618 ... 726 ... 897 ... 961 ... 10 54 ... to selection (>=2 and <8) for remanescents like below: Id V1 V2 ... 101 ... 2. 10 ... 362 ... 444 ... 537 ... 6. 8 ... 726 ... 8. 7 ... 961 ... 10 54 ... how to do that betther with R? Is there a command to compare all to same time? I would be very thankful. Yours sincerly José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Frequency table
Hi, See if this generic function I made can help you. data <- c(65, 70, 85, 65, 65, 65, 62, 55, 82, 59, 55, 66, 74, 55, 65, 56, 80, 73, 45, 64, 75, 58, 60, 56, 60, 65, 53, 63, 72, 80, 90, 95, 55, 70, 79, 62, 57, 65, 60, 47, 61, 53, 80, 75, 72, 87, 52, 72, 80, 85, 75, 70, 84, 60, 72, 70, 76, 70, 79, 72, 69, 80, 62, 74, 54, 58, 58, 69, 81, 84) # begin options of table--- min <-40 max <- 100 h <- 10 #-- end options of table--- # begin declaration of variables--- Fi <- numeric(); FacA <- numeric(); FacP <- numeric(); FrA <- numeric(); FrP<- numeric() # end declaration of variables- #- begin function-- Createtable <- function() { Fi <<- table(cut(data, br = seq(min, max, h), right = FALSE)) K <- length(names(Fi)) n <- length(data) for(i in 1:K) { FrA[i] = Fi[i] / n } for(i in 1:K) { FrP[i] = (Fi[i] / n) * 100 } for(i in 1:K) { FacA[i] = sum(Fi[1:i]) } for(i in 1:K) { FacP[i] = (sum(Fi[1:i]) / n) * 100 } table <- data.frame(Fi, FrA, FrP, FacA, FacP) } #- end function-- tab <- Createtable() print("Complete table:") print(tab) José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE: Frequency table (JCFaria)
Hi, Same time ago I made this generic function for frequency table. I think that it can help you. data <- c(65, 70, 85, 65, 65, 65, 62, 55, 82, 59, 55, 66, 74, 55, 65, 56, 80, 73, 45, 64, 75, 58, 60, 56, 60, 65, 53, 63, 72, 80, 90, 95, 55, 70, 79, 62, 57, 65, 60, 47, 61, 53, 80, 75, 72, 87, 52, 72, 80, 85, 75, 70, 84, 60, 72, 70, 76, 70, 79, 72, 69, 80, 62, 74, 54, 58, 58, 69, 81, 84) # begin options of table--- min <- 40 max <- 100 h <- 10 #-- end options of table--- # begin declaration of variables--- Fi <- numeric() FacA <- numeric(); FacP <- numeric() FrA <- numeric(); FrP <- numeric() # end declaration of variables- #- begin function-- Createtable <- function() { Fi <<- table(cut(data, br = seq(min, max, h), right = FALSE)) K <- length(names(Fi)) for(i in 1:K) { FrA[i] = Fi[i] / 70 } for(i in 1:K) { FrP[i] = (Fi[i] / 70) * 100 } for(i in 1:K) { FacA[i] = sum(Fi[1:i]) } for(i in 1:K) { FacP[i] = (sum(Fi[1:i]) / 70) * 100 } table <- data.frame(Fi, FrA, FrP, FacA, FacP) } #- end function-- tab <- Createtable() print("Complete table:") print(tab) José Cláudio Faria UESC/DCET Brasil 73-634.2779 [EMAIL PROTECTED] [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html