1

I was told to do a coefplot in R to visualise my data better.

Therefore i first did a chi square test. and after i put my data into a table it looked like this:

                    1  2  3  5  6
 5_min_blank        11 21 18 19  8
 Boldstyle           6  7 14 10  2
 Boldstyle_pause     9 22 19  8  0
 Breaststroke        7 16 10  5  4
 Breaststroke_pause  9 13 10  8  3
 Diving             14 20 10 10  4

1-6 are categories and "bold style" etc. are different sounds.

i than did a test:

    fit.swim<-chisq.test(X2,simulate.p.value = TRUE, B = 10000)

and got this result:

Pearson's Chi-squared test with simulated p-value (based on 10000 replicates)

data:  X2
X-squared = 87.794, df = NA, p-value = 0.09479

Now i would like to do a coefplot with my data but i only get this error:

  coefplot(fit.swim)  
Error: $ operator is invalid for atomic vectors  

Any ideas how to draw a nice plot?

Thank you very much for the help!

All the best

Marie

Jessi
  • 25
  • 1
  • 4
  • Not sure what you are trying to achieve... `coefplot` is designed to plot coefficients of `lm`, `glm`, `rxGlm`, `rxLinMod` and `rxLogit`, but not for `chisq.test`. What are you trying to plot ? – AshOfFire May 03 '18 at 13:11
  • As has been pointed out, `chisq.test` is a test, not a model, so it doesn't have coefficients that could be used by `coefplot`. Maybe you can describe more clearly what it is you want to plot (the residuals from the test?) – camille May 03 '18 at 14:09

1 Answers1

0

I think that the reason you are getting that error is because coefplot requires a fitted model as input in the form of an lm, glm or rxLinMod obj.

In your case you have carried out a goodness of fit test that essentially compares the observed sample distribution with the expected probability distribution. There isn't a fitted model to plot the coefficients from.

haffamoto
  • 66
  • 1
  • 9
  • thank you, than i misunderstood the idea in the beginning. The problem is i can't do a glm because i always get an error. i already asked it here but so far it was unfortunately not very helpful... see here: https://stackoverflow.com/questions/50043467/error-glm-na-nan-inf- in-y?noredirect=1#comment87103093_50043467 – Jessi May 04 '18 at 08:40