R : Conducting Oneway Anova on Continuous and Discrete Data

For a few weeks, I've been trying to figure out whether the results I've received from conducting a one-way ANOVA test are correct if so how. (I have parsed data containing null values & Alpha Numeric values)

My Data :

sal = read.csv("/Salaries.csv", header = TRUE)
sal$$Position - Prof AsstProf AssocProf sal$$Salary - ranging from 50,000 to 260,000

library("nortest")

oneway.test(Salary ~ Position,data=sal)

Results :

One-way analysis of means (not assuming equal variances)

data:  Salary and Position
F = 271.44, num df = 2.00, denom df = 177.19, p-value < 2.2e-16

aovSumW <- aov(Salary ~ Position, data=sal)

Results :

> summary(aovSumW)
Df    Sum Sq   Mean Sq F value Pr(>F)
Position      2 1.432e+11 7.162e+10   128.2 <2e-16 ***
Residuals   394 2.201e+11 5.586e+08
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

# Using Factor
aovSum <- aov(Salary ~ as.factor(Position), data=sal)

Results :

aov(formula = Salary ~ as.factor(Position), data = sal)

Terms:
as.factor(Position)    Residuals
Sum of Squares         143231765736 220068876825
Deg. of Freedom                   2          394

Residual standard error: 23633.67
Estimated effects may be unbalanced

summary(aovSum)

Df    Sum Sq   Mean Sq F value Pr(>F)
as.factor(Position)   2 1.432e+11 7.162e+10   128.2 <2e-16 ***
Residuals           394 2.201e+11 5.586e+08
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Followed :

https://rpubs.com/ibecav/308410 - The most suitable resource https://rpubs.com/heruwiryanto/Anova_linear

I'm not really sure whether what I have done is correct statistically correct or if it is an invalid result can someone please tell if I am doing this correctly using R.

1 Answer

Probably need to check the assumption of equal variance between groups and normally distributed errors but the ANOVA looks like a reasonable approach otherwise. You don't need the one making Position a factor (its the same as the first one) or the t-test.

If you need help checking the assumptions, let me know.

• Hi @André.B Please do explain how assumptions work. Also if possible Residuals, F-Value and what QF has to do with them May 21, 2019 at 8:44
• When we fit models they carry with them a number of assumptions. ANOVA's, which are a special case of generalised linear models, assume that the residuals (that is the distance of your observed values from the fitted line) are normally distributed and constant about the line. I lay out how to check these in this post: stats.stackexchange.com/questions/383468/…. F-values is well explained here: statisticshowto.datasciencecentral.com/…. What do you mean by QF? May 21, 2019 at 22:07
• Sorry for all the links - it's hard to answer question in the comments thoroughly. May 21, 2019 at 22:07
• QF - Critical Value. Thank you very much ! May 22, 2019 at 5:34
• The F-statistic is computed from the data and represents how much the variability among the means exceeds that expected due to chance. An F-statistic greater than the critical value is equivalent to a p-value less than alpha and both mean that you reject the null hypothesis. May 22, 2019 at 20:39