dane<- na.omit(Salaries)
str(Salaries)
## 'data.frame': 397 obs. of 6 variables:
## $ rank : Factor w/ 3 levels "AsstProf","AssocProf",..: 3 3 1 3 3 2 3 3 3 3 ...
## $ discipline : Factor w/ 2 levels "A","B": 2 2 2 2 2 2 2 2 2 2 ...
## $ yrs.since.phd: int 19 20 4 45 40 6 30 45 21 18 ...
## $ yrs.service : int 18 16 3 39 41 6 23 45 20 18 ...
## $ sex : Factor w/ 2 levels "Female","Male": 2 2 2 2 2 2 2 2 2 1 ...
## $ salary : int 139750 173200 79750 115000 141500 97000 175000 147765 119250 129000 ...
dane %>%
group_by(sex,discipline,rank) %>%
shapiro_test(salary)
## # A tibble: 12 × 6
## rank discipline sex variable statistic p
## <fct> <fct> <fct> <chr> <dbl> <dbl>
## 1 AsstProf A Female salary 0.870 0.226
## 2 AssocProf A Female salary 0.863 0.269
## 3 Prof A Female salary 0.934 0.549
## 4 AsstProf B Female salary 0.889 0.354
## 5 AssocProf B Female salary 0.635 0.00117
## 6 Prof B Female salary 0.974 0.923
## 7 AsstProf A Male salary 0.941 0.300
## 8 AssocProf A Male salary 0.878 0.0113
## 9 Prof A Male salary 0.952 0.000259
## 10 AsstProf B Male salary 0.941 0.0458
## 11 AssocProf B Male salary 0.967 0.416
## 12 Prof B Male salary 0.978 0.0435
resultinteractions<- aov(salary~ sex*discipline*rank, data=dane)
raportinteractions<-anova(resultinteractions)
report(raportinteractions)
## The ANOVA suggests that:
##
## - The main effect of sex is statistically significant and small (F(1, 385) =
## 13.46, p < .001; Eta2 (partial) = 0.03, 95% CI [0.01, 1.00])
## - The main effect of discipline is statistically significant and small (F(1,
## 385) = 16.96, p < .001; Eta2 (partial) = 0.04, 95% CI [0.02, 1.00])
## - The main effect of rank is statistically significant and large (F(2, 385) =
## 141.34, p < .001; Eta2 (partial) = 0.42, 95% CI [0.36, 1.00])
## - The interaction between sex and discipline is statistically not significant
## and very small (F(1, 385) = 0.77, p = 0.380; Eta2 (partial) = 2.00e-03, 95% CI
## [0.00, 1.00])
## - The interaction between sex and rank is statistically not significant and
## very small (F(2, 385) = 0.28, p = 0.756; Eta2 (partial) = 1.46e-03, 95% CI
## [0.00, 1.00])
## - The interaction between discipline and rank is statistically not significant
## and very small (F(2, 385) = 0.46, p = 0.633; Eta2 (partial) = 2.37e-03, 95% CI
## [0.00, 1.00])
## - The interaction between sex, discipline and rank is statistically not
## significant and very small (F(2, 385) = 0.13, p = 0.880; Eta2 (partial) =
## 6.63e-04, 95% CI [0.00, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.
#anova with interactions and their significance
resultwointeractions <- aov(salary ~ sex+ discipline + rank, data= dane)
raportwointeractions <- anova(resultwointeractions)
report(raportwointeractions)
## The ANOVA suggests that:
##
## - The main effect of sex is statistically significant and small (F(1, 392) =
## 13.62, p < .001; Eta2 (partial) = 0.03, 95% CI [0.01, 1.00])
## - The main effect of discipline is statistically significant and small (F(1,
## 392) = 17.15, p < .001; Eta2 (partial) = 0.04, 95% CI [0.02, 1.00])
## - The main effect of rank is statistically significant and large (F(2, 392) =
## 142.98, p < .001; Eta2 (partial) = 0.42, 95% CI [0.36, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.
#anova without interactions
covariates <- lm(salary ~ sex* yrs.since.phd * yrs.service, data= dane)
report(covariates)
## We fitted a linear model (estimated using OLS) to predict salary with sex,
## yrs.since.phd and yrs.service (formula: salary ~ sex * yrs.since.phd *
## yrs.service). The model explains a statistically significant and substantial
## proportion of variance (R2 = 0.33, F(7, 389) = 26.87, p < .001, adj. R2 =
## 0.31). The model's intercept, corresponding to sex = Female, yrs.since.phd = 0
## and yrs.service = 0, is at 66955.99 (95% CI [45666.11, 88245.87], t(389) =
## 6.18, p < .001). Within this model:
##
## - The effect of sex [Male] is statistically non-significant and positive (beta
## = 4328.42, 95% CI [-18177.17, 26834.02], t(389) = 0.38, p = 0.706; Std. beta =
## 0.35, 95% CI [-0.03, 0.74])
## - The effect of yrs since phd is statistically significant and positive (beta =
## 1855.48, 95% CI [61.49, 3649.47], t(389) = 2.03, p = 0.043; Std. beta = 0.47,
## 95% CI [-0.27, 1.20])
## - The effect of yrs service is statistically non-significant and positive (beta
## = 1274.56, 95% CI [-1389.64, 3938.77], t(389) = 0.94, p = 0.348; Std. beta =
## 0.13, 95% CI [-0.63, 0.89])
## - The effect of sex [Male] × yrs since phd is statistically non-significant and
## positive (beta = 348.94, 95% CI [-1515.52, 2213.39], t(389) = 0.37, p = 0.713;
## Std. beta = -0.02, 95% CI [-0.79, 0.75])
## - The effect of sex [Male] × yrs service is statistically non-significant and
## positive (beta = 421.97, 95% CI [-2340.98, 3184.92], t(389) = 0.30, p = 0.764;
## Std. beta = -0.03, 95% CI [-0.83, 0.76])
## - The effect of yrs since phd × yrs service is statistically non-significant
## and negative (beta = -43.08, 95% CI [-128.48, 42.32], t(389) = -0.99, p =
## 0.322; Std. beta = -0.24, 95% CI [-0.71, 0.23])
## - The effect of (sex [Male] × yrs since phd) × yrs service is statistically
## non-significant and negative (beta = -22.52, 95% CI [-109.28, 64.23], t(389) =
## -0.51, p = 0.610; Std. beta = -0.12, 95% CI [-0.60, 0.36])
##
## Standardized parameters were obtained by fitting the model on a standardized
## version of the dataset. 95% Confidence Intervals (CIs) and p-values were
## computed using a Wald t-distribution approximation.
#we can see that the effect of yrs since phd is statistically significat and positive
# other are non-significant
#linear model to check the covariance
plot(covariates)




daneex3<-
dane %>%
group_by(rank) %>%
summarise(mean.yrs.since.phd = mean(yrs.since.phd),
mean.yrs.service = mean(yrs.service))
anova_yrs_since_phd <- aov(yrs.since.phd ~ rank, data=dane)
report(anova(anova_yrs_since_phd))
## The ANOVA suggests that:
##
## - The main effect of rank is statistically significant and large (F(2, 394) =
## 191.18, p < .001; Eta2 = 0.49, 95% CI [0.44, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.
#the effect of rank is significant and large
anova_yrs_service <- aov(yrs.service ~ rank, data = dane)
report(anova(anova_yrs_service))
## The ANOVA suggests that:
##
## - The main effect of rank is statistically significant and large (F(2, 394) =
## 115.90, p < .001; Eta2 = 0.37, 95% CI [0.31, 1.00])
##
## Effect sizes were labelled following Field's (2013) recommendations.