Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement Cramer's test in Java? - Cramer - 'ArrayStoreException' #152

Closed
betrw opened this issue Nov 7, 2018 · 4 comments
Closed

Comments

@betrw
Copy link

betrw commented Nov 7, 2018

Submitting the parameters to the method:

Cramer c = new Cramer();
c.cramerTest1(CR1, CR2);
pi.CremerTValue = ?

fails with the error 'ArrayStoreException' at the second line after passing the parameters.

I tried:

List<List>CR1 = new ArrayList<List>();
List<List>CR2 = new ArrayList<List>();

CR1.add(First);
CR2.add(Second);

--or--

List<List>CR1 = Arrays.asList(First);
List<List>CR2 = Arrays.asList(Second);

Both declarations failed.

First and Second are both of the type ArrayList with a size of 177 items.
CR1 and CR2 have one item that contain 177 values.

How can I implement the two sample Cramer-Mises T test?

@betrw
Copy link
Author

betrw commented Nov 8, 2018

I guess the two samples Cramer test is the Anderson-Darling-Test?

@abifet abifet assigned abifet and unassigned abifet Jan 16, 2019
@abifet
Copy link
Collaborator

abifet commented Jan 16, 2019

@pmgj: can you help on this? Thanks!

@pmgj
Copy link
Contributor

pmgj commented Jan 16, 2019

Hi,

This cramer test works comparing the attribute values of a List of Instance elements. An example that can read values from ARFF files is:

    List<Instance> x = Cramer.fileToInstances("test1-x.arff");
    List<Instance> y = Cramer.fileToInstances("test1-y.arff");
    Cramer c = new Cramer();
    Cramer.CramerTest ct = c.cramerTest(x, y);
    System.out.println("p Value.: " + ct.pValue);
    System.out.println("Critical value: " + ct.critValue);
    System.out.println("Statistic: " + ct.statistic);

The CramerTest is only used inside the class. I probably had to make it private. This Java implementation was based on the Cramer test source code available in the R statistic tool.

@betrw
Copy link
Author

betrw commented Jan 17, 2019

Thanks a lot.

@abifet abifet closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants