# How to test goodness of fit between two dataframes in R?

I know goodness-of-fit can be used to check the goodness between one dataset and a distribution type. I wonder if it is possible to get the goodness for two dataframe in R?

e <- c(1,1,1,1,3,3)
f <- c(2,2,2,2,4,5)
g <- goodfit(e,f, method="MinChisq")
Error in match.arg(type) : 'arg' must be NULL or a character vector

-

You need to provide a two column data frame to the function. In your example it will be

...
two_column_data <- cbind(e,f)
g <- goodfit(two_column_data, method = "MinChisq")
summary(g)

Goodness-of-fit test for poisson distribution

X^2 df  P(> X^2)
Pearson 3.772097  4 0.4377268
Warning message:
In summary.goodfit(g) : Chi-squared approximation may be incorrect

-

You might also look into R package qualV and function generalME. It provides various comparisons between observed and predicted values of the model. The package is described in Journal of Statistical Software.

The function generalME will work with two vectors, no need to combine them into one data.frame.

-