R Chi Squared Post Hoc Test
up vote
1
down vote
favorite
I'm new to R (and statistics in general) so apologies in advance for what's probably a very remedial question, but I'd appreciate any help!
I'm trying to assess if there's a statistical advantage to starting a motor race in a given lane over another.
The sample sizes I have are small and not necessarily normally distributed so I'm opting to use a chi sq test to check for a significant difference between the expected vs observed wins.
#create lanes var
lane_num <- c(1:10)
#num wins per lane
num_wins <- c(8, 7, 10, 7, 6, 3, 6, 4, 1, 0)
#create df
df <- as.data.frame(cbind(lane_num, num_wins))
#convert lanes_num factor
df$lane_num <- as.factor(df$lane_num)
#check str
str(df)
#run chisq
chi_res <- chisq.test(df$num_wins)
#check results
chi_res
#check for sig diff between lanes
chisq.post.hoc(df) #this is where i'm having issues
The result of the chisq.test gives the following results suggesting a significant difference between expected v observed;
Chi-squared test for given probabilities
data: df$num_wins
X-squared = 17.231, df = 9, p-value = 0.04522
Where I'm struggling is when it comes to running a post-hoc test between lanes to see exactly which ones are significantly more advantageous to start from.
Simply running:
chisq.post.hoc(df)
returns the following error;
Error in test(tbl[prs[, i], ], ...) :
all entries of 'x' must be nonnegative and finite
As I say, I'm new to R and stats so the documentation provided regarding chisq.post.hoc doesn't make a lot of sense to me - plus it seems the package is no longer supported so i had to download an archived version. I've tried various things but all produce errors. For example;
chisq.post.hoc(df$num_wins, control = "bonferroni")
> Error in 1:nrow(tbl) : argument of length 0
I'd really appreciate a steer on this or any advise regarding an alternative post-hoc test I could use along with how the data needs to be structured before running etc.
Thanks in advance!
r chi-squared posthoc
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
favorite
I'm new to R (and statistics in general) so apologies in advance for what's probably a very remedial question, but I'd appreciate any help!
I'm trying to assess if there's a statistical advantage to starting a motor race in a given lane over another.
The sample sizes I have are small and not necessarily normally distributed so I'm opting to use a chi sq test to check for a significant difference between the expected vs observed wins.
#create lanes var
lane_num <- c(1:10)
#num wins per lane
num_wins <- c(8, 7, 10, 7, 6, 3, 6, 4, 1, 0)
#create df
df <- as.data.frame(cbind(lane_num, num_wins))
#convert lanes_num factor
df$lane_num <- as.factor(df$lane_num)
#check str
str(df)
#run chisq
chi_res <- chisq.test(df$num_wins)
#check results
chi_res
#check for sig diff between lanes
chisq.post.hoc(df) #this is where i'm having issues
The result of the chisq.test gives the following results suggesting a significant difference between expected v observed;
Chi-squared test for given probabilities
data: df$num_wins
X-squared = 17.231, df = 9, p-value = 0.04522
Where I'm struggling is when it comes to running a post-hoc test between lanes to see exactly which ones are significantly more advantageous to start from.
Simply running:
chisq.post.hoc(df)
returns the following error;
Error in test(tbl[prs[, i], ], ...) :
all entries of 'x' must be nonnegative and finite
As I say, I'm new to R and stats so the documentation provided regarding chisq.post.hoc doesn't make a lot of sense to me - plus it seems the package is no longer supported so i had to download an archived version. I've tried various things but all produce errors. For example;
chisq.post.hoc(df$num_wins, control = "bonferroni")
> Error in 1:nrow(tbl) : argument of length 0
I'd really appreciate a steer on this or any advise regarding an alternative post-hoc test I could use along with how the data needs to be structured before running etc.
Thanks in advance!
r chi-squared posthoc
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm new to R (and statistics in general) so apologies in advance for what's probably a very remedial question, but I'd appreciate any help!
I'm trying to assess if there's a statistical advantage to starting a motor race in a given lane over another.
The sample sizes I have are small and not necessarily normally distributed so I'm opting to use a chi sq test to check for a significant difference between the expected vs observed wins.
#create lanes var
lane_num <- c(1:10)
#num wins per lane
num_wins <- c(8, 7, 10, 7, 6, 3, 6, 4, 1, 0)
#create df
df <- as.data.frame(cbind(lane_num, num_wins))
#convert lanes_num factor
df$lane_num <- as.factor(df$lane_num)
#check str
str(df)
#run chisq
chi_res <- chisq.test(df$num_wins)
#check results
chi_res
#check for sig diff between lanes
chisq.post.hoc(df) #this is where i'm having issues
The result of the chisq.test gives the following results suggesting a significant difference between expected v observed;
Chi-squared test for given probabilities
data: df$num_wins
X-squared = 17.231, df = 9, p-value = 0.04522
Where I'm struggling is when it comes to running a post-hoc test between lanes to see exactly which ones are significantly more advantageous to start from.
Simply running:
chisq.post.hoc(df)
returns the following error;
Error in test(tbl[prs[, i], ], ...) :
all entries of 'x' must be nonnegative and finite
As I say, I'm new to R and stats so the documentation provided regarding chisq.post.hoc doesn't make a lot of sense to me - plus it seems the package is no longer supported so i had to download an archived version. I've tried various things but all produce errors. For example;
chisq.post.hoc(df$num_wins, control = "bonferroni")
> Error in 1:nrow(tbl) : argument of length 0
I'd really appreciate a steer on this or any advise regarding an alternative post-hoc test I could use along with how the data needs to be structured before running etc.
Thanks in advance!
r chi-squared posthoc
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm new to R (and statistics in general) so apologies in advance for what's probably a very remedial question, but I'd appreciate any help!
I'm trying to assess if there's a statistical advantage to starting a motor race in a given lane over another.
The sample sizes I have are small and not necessarily normally distributed so I'm opting to use a chi sq test to check for a significant difference between the expected vs observed wins.
#create lanes var
lane_num <- c(1:10)
#num wins per lane
num_wins <- c(8, 7, 10, 7, 6, 3, 6, 4, 1, 0)
#create df
df <- as.data.frame(cbind(lane_num, num_wins))
#convert lanes_num factor
df$lane_num <- as.factor(df$lane_num)
#check str
str(df)
#run chisq
chi_res <- chisq.test(df$num_wins)
#check results
chi_res
#check for sig diff between lanes
chisq.post.hoc(df) #this is where i'm having issues
The result of the chisq.test gives the following results suggesting a significant difference between expected v observed;
Chi-squared test for given probabilities
data: df$num_wins
X-squared = 17.231, df = 9, p-value = 0.04522
Where I'm struggling is when it comes to running a post-hoc test between lanes to see exactly which ones are significantly more advantageous to start from.
Simply running:
chisq.post.hoc(df)
returns the following error;
Error in test(tbl[prs[, i], ], ...) :
all entries of 'x' must be nonnegative and finite
As I say, I'm new to R and stats so the documentation provided regarding chisq.post.hoc doesn't make a lot of sense to me - plus it seems the package is no longer supported so i had to download an archived version. I've tried various things but all produce errors. For example;
chisq.post.hoc(df$num_wins, control = "bonferroni")
> Error in 1:nrow(tbl) : argument of length 0
I'd really appreciate a steer on this or any advise regarding an alternative post-hoc test I could use along with how the data needs to be structured before running etc.
Thanks in advance!
r chi-squared posthoc
r chi-squared posthoc
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 10 at 14:17
eod1984
61
61
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
eod1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
eod1984 is a new contributor. Be nice, and check out our Code of Conduct.
eod1984 is a new contributor. Be nice, and check out our Code of Conduct.
eod1984 is a new contributor. Be nice, and check out our Code of Conduct.
eod1984 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239839%2fr-chi-squared-post-hoc-test%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown