Questions tagged [anova]

ANOVA is an acronym for "analysis of variance". It is a widely used statistical technique to analyze the source of variance within a data set.

Overview

Although ANOVA stands for ANalysis Of VAriance, it is about comparing means of data from different groups. It is part of the general linear model which also includes linear regression and ANCOVA. In matrix algebra form, all three are:

Y=XB+e

Where Y is a vector of values for the dependent variable (these must be numeric), X is a matrix of values for the independent variables and e is error.

Tag usage

  • SO questions on ANOVA should be about implementation and programming problems, not about the statistical or theoretical properties of the technique.

  • Consider whether your question might be better suited to CrossValidated, the StackExchange site for statistics, machine learning and data analysis.

In scientific software for statistical computing and graphics, function aov implements ANOVA. Note that function anova does something else. See When should I use aov() and when anova()?

1456 questions
6
votes
3 answers

How can I classify post-hoc test results in R?

I am trying to understand how to work with ANOVAs and post-hoc tests in R. So far, I have used aov() and TukeyHSD() to analyse my data. Example: uni2.anova <- aov(Sum_Uni ~ Micro, data= uni2) uni2.anova Call: aov(formula = Sum_Uni ~ Micro, data =…
Carolin
  • 63
  • 1
  • 4
6
votes
0 answers

Is there python function for comparing two or more Logistic Regression models using anova?

I am trying to implement the Python version of this 'R' code to compare 2 or more Logistic Regression models by finding deviance statistics anova(LogisticModel.1, LogisticModel.2) which gives an output like this There is an statsmodels…
snehil
  • 586
  • 6
  • 12
6
votes
2 answers

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

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 =…
skan
  • 7,423
  • 14
  • 59
  • 96
6
votes
3 answers

substitute in r together with anova

I tried to run anova on different sets of data and didn't quite know how to do it. I goolged and found this to be useful: https://stats.idre.ucla.edu/r/codefragments/looping_strings/ hsb2 <-…
olala
  • 4,146
  • 9
  • 34
  • 44
6
votes
1 answer

How obtain the true residual deviance and degrees of freedom in R of a glm model when a set of parameters gets pasted() as a vector

I'm writing a script (in python, with the R parts in pypeR) such that I need to use a function in R that compares two models with an F-ratio test. The models are like this: Model 1: Response ~ Predictor A + Predictor B + Predictor C.... + Predictor…
Atticus29
  • 4,190
  • 18
  • 47
  • 84
6
votes
1 answer

partition of anova and comparisons (orthogonal single df) in r

I want to do single df orthogonal contrast in anova (fixed or mixed model). Here is just example: require(nlme) data (Alfalfa) Variety: a factor with levels Cossack, Ladak, and Ranger Date : a factor with levels None S1 S20 O7 Block: a…
SHRram
  • 4,127
  • 7
  • 35
  • 53
6
votes
1 answer

contrasts in anova

I understand the contrasts from previous posts and I think I am doing the right thing but it is not giving me what I would expect. x <- c(11.80856, 11.89269, 11.42944, 12.03155, 10.40744, 12.48229, 12.1188, 11.76914, 0, 0, 13.65773,…
statstar
  • 73
  • 1
  • 1
  • 5
6
votes
1 answer

Comparing two linear models with anova() in R

I don't quite understand what the p-value in this output means. I don't mean p-values as such, but in this case. > Model 1: sl ~ le + ky > Model 2: sl ~ le Res.Df RSS Df Sum of Sq F Pr(>F) 1 97 0.51113 …
lisa
  • 640
  • 5
  • 10
  • 26
5
votes
2 answers

lme4 mixed model error

What is wrong with the following model: # simulated data yr = 2; vg = 4, fm = 5, gen = 5 mbb <- data.frame( trait1 = rnorm(200, 15, 4),yr = c(rep (1:2, each = 100)), vg = c(rep(rep(1:4, each =25), 2)), fm = rep(rep(1:5, each = 5), 8), …
jon
  • 11,186
  • 19
  • 80
  • 132
5
votes
2 answers

Posthoc labels on anova boxplot in R

If I have some data and do an ANOVA and post-hoc tests, how do I make a boxplot that adds the post-hoc classification automatically, rather than having to edit the figure outside of R? For example, here are some data to get…
user1006644
  • 51
  • 1
  • 1
  • 2
5
votes
2 answers

How to create a boxplot for multiple dependent variables from the WeightLoss dataset?

I'm trying to make a boxplot from the WeightLoss dataset from the car package. The variables of interest are separated by month, so I made boxplots by month separately, with all the groups (Control, Diet, Diet and Exercise) showing. I only want to…
5
votes
1 answer

How to interpret the summary table for Python OLS Statsmodel?

I have a continuous dependent variable y and a independent categorical variable x named control_grid. x contains two variables: c and g using python package statsmodel I am trying to see if independent variable has significant effect on y variable,…
J.A.Cado
  • 715
  • 5
  • 13
  • 24
5
votes
0 answers

Why using anova_lm in Python shows shapes not aligned?

Based on this question enter link description here, I used statsmodels to implement ANOVA in python. My data is in a Pandas DataFrame and country is a categorical variable. def anova(data): mod = ols('C(country) ~ playerRank+playerGames',…
YNR
  • 867
  • 2
  • 13
  • 28
5
votes
1 answer

How to compare slopes in R

I am performing an ANCOVA so as to test what is the relationship between body size (covariate, logLCC) and different head measures (response variable, logLP) in each sex (cathegorical variable, sexo). I got the slopes for each sex in the lm and I…
Alicia
  • 51
  • 1
  • 8
5
votes
1 answer

What is the "effects" returned by `aov` and `lm`?

I would like to ask the difference between $coefficients and $effects in aov output. Here the f1 factor and the interaction f1 * f2 are significant. I want to interpret the effect of that factor on the response and I thought that the $effects is…
Lefty
  • 368
  • 4
  • 11
1 2
3
96 97