0

I am looking at the relationship between Facebook usage and Political engagement. Political engagement is measured from 0-7 and Facebook usage is measured as "User" or "Non_User." How do I conduct a chisquared with this data? ... if this is the appropriate statistical method to use in the first place.

df$Political_engagement[df$V162174a=="0. Zero days"] <- 0
df$Political_engagement[df$V162174a=="1. One day"] <- 1
df$Political_engagement[df$V162174a=="2. Two days"] <- 2
df$Political_engagement[df$V162174a=="3. Three days"] <- 3
df$Political_engagement[df$V162174a=="4. Four days"] <- 4
df$Political_engagement[df$V162174a=="5. Five days"] <- 5
df$Political_engagement[df$V162174a=="6. Six days"] <- 6
df$Political_engagement[df$V162174a=="7. Seven days"] <- 7

df$Facebook_usage[df$V162370=="1. Yes have a Facebook account I have used in the past month"] <- "User"
df$Facebook_usage[df$V162370=="2. Have a Facebook account but have not used it in past month"] <- "Non_user"
df$Facebook_usage[df$V162370=="3. No, do not have a Facebook account"] <- "Non_user"

df$User <- "User"
df$Non_user <- "Non_user"

table(df$Facebook_usage, df$Political_engagement)

chisq.test(df$User, df$Political_engagement, correct=FALSE)

Error in chisq.test(df$User, df$Political_engagement, correct = FALSE):
  'x' and 'y' must have at least 2 levels
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • What's the output of the `table`? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. But asking about appropriate uses of statistical methods is off topic for Stack Overflow. If you needs stats advice, you should seek help at [stats.se] instead. – MrFlick Jun 07 '19 at 20:08
  • But it also seems that you set everyone to a user with `df$User <- "User"`. You can't test for differences when every one of your rows has the same value for a given variable. Did you mean to use `df$Facebook_usage` in the `chisq.test` like you did in table rather than `df$User`? – MrFlick Jun 07 '19 at 20:10
  • I would like to see the different p values for the 'User' group and 'Non_user' group, that's why I didn't do df$Facebook_usage in the chisq.test –  Jun 07 '19 at 20:12
  • But you don't have a variable that tells whether or not someone is a user. you've hard coded the same value for `User` all rows in your data.frame. It's the `Facebook_usage` variable that you should be using for testing. – MrFlick Jun 07 '19 at 20:13
  • How would I make a variable that tells whether or not someone is a user? I though I did this with: `df$Facebook_usage[df$V162370=="1. Yes have a Facebook account I have used in the past month"] <- "User" df$Facebook_usage[df$V162370=="2. Have a Facebook account but have not used it in past month"] <- "Non_user" df$Facebook_usage[df$V162370=="3. No, do not have a Facebook account"] <- "Non_user"` –  Jun 07 '19 at 20:17
  • You did and you called it "Facebook_usage". Now you need to use that in your test! Use `chisq.test(df$Facebook_usage, df$Political_engagement, correct=FALSE)` – MrFlick Jun 07 '19 at 20:18
  • So with the result; X-squared = 11.503, df = 7, p-value = 0.1181... this is for just the 'User' group? *Edit* oh nevermind, I think I understand now, thank you! –  Jun 07 '19 at 20:20

1 Answers1

0

It is hard to answer this question without reproducible code but a good approach is to consider using your table(df$Facebook_usage, df$Political_engagement) in the chisq.test. Consider: testtab<-table(df$Facebook_usage, df$Political_engagement) and then chisq.test(testtab)

crich
  • 99
  • 3
  • 8