anova

Using R to calculate between- by within-subj ANOVA interaction contrasts using car or lme

不问归期 提交于 2019-12-12 03:37:25
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . Psychology student here. As part of my thesis I have some data from an experiment with two between-subjects IVs, classification and condition , and a within-subjects IV, trial_type . The data are of the form: test = data.frame( ID=rep(c(1,2,3,4,5,6), each=3), condition=rep(c('comp', 'seq', 'comp_text'), each=3, times=2), classification=rep(c('rule', 'exemplar'), each=3, length

Setting Contrasts for ANOVA in R

自作多情 提交于 2019-12-11 08:46:46
问题 I've been attempting to perform an ANOVA in R recently on the attached data frame. My question revolves around the setting of contrasts. My design is a 3x5 within-subjects design. There are 3 visual conditions under 'Circle1' and 5 audio under 'Beep1'. Does anyone have any idea how I should set the contrasts? This is something I'm unfamiliar with as I'm making the transition from point and click stats in SPSS to coded in R. Thanks for your time Data file: 回答1: Reiterating my answer from

Checking Type III ANOVA results [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-11 06:29:05
问题 This question already has answers here : How to use formula in R to exclude main effect but retain interaction (3 answers) Why do I get NA coefficients and how does `lm` drop reference level for interaction (1 answer) Closed 2 years ago . Setting aside the debate about Type III ANOVA and the Principle of Marginality and all that... I've set up two models whose sum of squares should be different (and Type III ANOVA would test that difference). Here's the code: library(car) library(openintro)

ANOVA on multiple responses, by multiple groups NOT part of formula

蓝咒 提交于 2019-12-11 03:40:26
问题 I'm struggling to figure out how to do some ANOVA testing for a collection of responses in multiple environments & sample types. I have a big dataframe, and I want to run these ANOVAs separately by these grouping factors, but they shouldn't be included in the formula. Maybe I'm missing an obvious way to do this, but so far I've just been subsetting the data is tedious to do.. In SAS, this would be similar to a BY statement within the PROC statement.. it is quite easy to do in SAS. Here is an

How to convert Afex or car ANOVA models to lmer? Observed variables

有些话、适合烂在心里 提交于 2019-12-10 18:24:33
问题 In the afex package we can find this example of ANOVA analysis: data(obk.long, package = "afex") # estimate mixed ANOVA on the full design: # can be written in any of these ways: aov_car(value ~ treatment * gender + Error(id/(phase*hour)), data = obk.long, observed = "gender") aov_4(value ~ treatment * gender + (phase*hour|id), data = obk.long, observed = "gender") aov_ez("id", "value", obk.long, between = c("treatment", "gender"), within = c("phase", "hour"), observed = "gender") My question

Tukey-Test Grouping and plotting in SciPy

我与影子孤独终老i 提交于 2019-12-10 12:25:35
问题 I'm trying to plot results from a Tukey test, but I am struggling with putting data into groups based on a P-Value. This is the equivalent in R which I am trying to replicate. I have been using the SciPy one-way ANOVA tests and the Tukey test statsmodel but can't get these groups done in the same way. Any help is greatly appreciated I've also just found this another example in R of what I want to do in python 回答1: I have been struggling to do the same thing. I found a paper that tells you how

Automatically use LRT to assess significance of entire factor variable

别说谁变了你拦得住时间么 提交于 2019-12-10 09:43:15
问题 R's output for a multivariable regression model including one or more factor variable does not automatically include a likelihood ratio test (LRT) of the significance of the entire factor variable in the model. For example: fake = data.frame( x1=rnorm(100), x2=sample(LETTERS[1:4], size=100, replace=TRUE), y=rnorm(100) ) head(fake) x1 x2 y 1 0.6152511 A 0.7682467 2 -0.8215727 A -0.5389245 3 -1.3287208 A -0.1797851 4 0.5837217 D 0.9509888 5 -0.2828024 C -0.9829126 6 0.3971358 B -0.4895091 m =

Perform an ANOVA for each individual level of a factor in R

与世无争的帅哥 提交于 2019-12-09 07:20:23
问题 I am looking for a short and efficient method to run individual ANOVA analysis on each level of a factor. What I currently have, I think, is redundant and clutters the work space. Let's say I have the following: Letter Number Question A 1 1 A 2 1 A 3 1 B 1 1 B 2 1 B 3 1 C 1 1 C 2 1 C 3 1 I could run the following code to split the data frame into subsets A, B, and C: > list2env(split(data, data$Letter), globalenv()) > ANOVA.A <- aov(Question~Number, data=A) > ANOVA.B <- aov(Question~Number,

Looping many one-sided ANOVA in R

喜夏-厌秋 提交于 2019-12-08 13:08:31
I would like to run 100 ANOVA for different numeric vectors. My numeric vectors are (ruy, fjr, akf....) from my data.frame aa=aov(data.frame$ruy~data.frame$Group) anova(aa) ab=aov(data.frame$fjr~data.frame$Group) anova(ab) ac=aov(data.frame$akf~data.frame$Group) anova(ac) ..... ..... My looping skills are poor so please be nice. Since aov is based on lm you can cbind dependent variables on the LHS, which results in seperate models being run: formula <- as.formula(paste0("cbind(", paste(names(iris)[-5], collapse = ","), ") ~ Species")) fit <- aov(formula, data=iris) summary(fit) # Response

R: remove multiple rows based on missing values in fewer rows

梦想与她 提交于 2019-12-08 09:41:42
问题 I have an R data frame with data from multiple subjects, each tested several times. To perform statistics on the set, there is a factor for subject ("id") and a row for each observation (given by factor "session"). I.e. print(allData) id session measure 1 1 7.6 2 1 4.5 3 1 5.5 1 2 7.1 2 2 NA 3 2 4.9 In the above example, is there a simple way to remove all rows with id==2, given that the "measure" column contains NA in one of the rows where id==2? More generally, since I actually have a lot