Hi Valeri and everyone,
Firstly I'm using the the output from my whole data set (i.e. "mydata") using the R code solution posted earlier by FJCC.
As explained earlier, the next step for me is:
I would like to test if the mean ranking in Stats1 is uniform i.e. is there actually a difference in the respondents' ranking in Stats1?
The expected mean ranking score (i.e. ImptExpectedMeanRanking vector) for each of model, location, education, fee, and income was calculated as follows:
Expected Mean Ranking Score = ((264/5)*1 +(264/5)*2 +(264/5)*3 +(264/5)*4 +(264/5)*5))/264 = 2.6
As the expected mean ranking is uniform then there is no difference in the expected respondents’ ranking score so the expected mean ranking score is the same for all the variables and is equal to 2.6 (i.e. ImptExpectedMeanRanking
vector where the expected mean ranking score for each of model, location, education, fee, and income = 2.6)
H0: Mean rank(model) = Mean rank (location) = Mean rank(education) = Mean rank(fee) = Mean rank(income) = expected uniform mean ranking score = 2.6
i.e.there is no difference in the respondents’ ranks i.e. the mean ranking is uniform.
H1: Any of Mean rank(model), Mean rank (location), Mean rank(education), Mean rank(fee), Mean rank(income) is different from each other i.e. there is a difference in the respondents’ ranks i.e. the mean ranking is not uniform.
In the reprex you can see how I set up and then ran a chi squared test to test this BUT IT DID NOT WORK!!
The output from the chi squared test is as follows (as you will also see towards the end in the reprex):
Error in chisq.test(ImptMeanRanking, ExpectedImptMeanRanking) :
'x' and 'y' must have at least 2 levels
library("tidyverse")
library("reprex")
#Calculate means
Columns1 <- mydata %>% select(model:income)
Col1_tall <- Columns1 %>% gather(key = Feature, value = Rank, model:income)
Stats1 <- Col1_tall %>% group_by(Feature) %>% summarize(Avg = mean(Rank))
Stats1
#> # A tibble: 5 x 2
#> Feature Avg
#> <chr> <dbl>
#> 1 education 2.647727
#> 2 fee 3.481061
#> 3 income 3.037879
#> 4 location 2.852273
#> 5 model 2.981061
#Now I would like to test if the mean ranking in Stats1 is uniform
#i.e. is there a difference in the respondents' ranking in Stats1?
#H0: Mean rank(model) = Mean rank (location) = Mean rank(education) = Mean rank(fee) = Mean rank(income) = expected uniform mean ranking = 2.6
#i.e.there is no difference in the respondents ranks i.e. the mean ranking is uniform.
#H1: Any of Mean rank(model), Mean rank (location), Mean rank(education), Mean rank(fee), Mean rank(income) is different from each other
#i.e. there is a difference in the respondents㤼㸲 ranks i.e. the mean ranking is not uniform.
#I set and ran a chi squared test to test this as follows BUT IT DID NOT WORK!!
ModelMeanRank <- round(mean(mydata$model), digits = 6)
LocationMeanRank <- round(mean(mydata$location), digits = 6)
EducationMeanRank <- round(mean(mydata$education), digits = 6)
FeeMeanRank <- round(mean(mydata$fee), digits = 6)
IncomeMeanRank <- round(mean(mydata$income), digits = 6)
ModelMeanRank
[1] 2.981061
LocationMeanRank
[1] 2.852273
EducationMeanRank
[1] 2.647727
FeeMeanRank
[1] 3.481061
IncomeMeanRank
[1] 3.037879
ImptMeanRanking <- c(ModelMeanRank, LocationMeanRank, EducationMeanRank, FeeMeanRank, IncomeMeanRank)
#ImptExpectedMeanRanking for each of model, location, education, fee, and income was calculated
#as follows: ImptExpectedMeanRanking = ((264/5)*1 +(264/5)*2 +(264/5)*3 +(264/5)*4 +(264/5)*5))/264 = 2.6
ExpectedImptMeanRanking <- c(2.6, 2.6, 2.6, 2.6, 2.6)
#I then ran the chi squared test to test if the observed ranking score (i.e.ImptMeanRanking) was
#statistically different from the expected uniform ranking score i.e. if there is no difference in the respondents ranking scores (i.e.ExpectedImptMeanRanking) )
chisq.test(ImptMeanRanking, ExpectedImptMeanRanking)
Error in chisq.test(ImptMeanRanking, ExpectedImptMeanRanking) :
'x' and 'y' must have at least 2 levels
I am really doing something incorrect here and I don't know how to fix it.
Any help or suggestions from anyone about the appropriate statistical tool and correct R code is gratefully appreciated.
Many thanks.