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

z.test returning NA's #25

Closed
gdunster opened this issue Aug 7, 2017 · 4 comments
Closed

z.test returning NA's #25

gdunster opened this issue Aug 7, 2017 · 4 comments

Comments

@gdunster
Copy link

gdunster commented Aug 7, 2017

Hello,

I am using the z.test function from the BSDA package in an attempt to analyze some data and I keep getting an output of "NA". There are no errors when I run the test, but all of my outputs ( z=, p-value =, etc) simply say NA. Below is the code I have written to run the analysis, hopefully you can provide some insight.

Dat1 <- Dat[Dat$Year == 1,]
Dat2 <- Dat[Dat$Year == 2,]

sd16 <- sd(Dat1$ColumnA, na.rm = T)
sd17 <- sd(Dat2$ColumnA, na.rm = T)

z.test(x = Dat1$ColumnA, sigma.x = sd16, y = Dat2$ColumnA, sigma.y = sd17)

@alanarnholt
Copy link
Owner

The function does not automatically remove NA values. I do not have your data but I suspect you have NA values in one or both of Dat1$ColumnA and Dat2$ColumnA. Try

`
Dat1 <- Dat[Dat$Year == 1,]
Dat2 <- Dat[Dat$Year == 2,]

sd16 <- sd(Dat1$ColumnA, na.rm = T)
sd17 <- sd(Dat2$ColumnA, na.rm = T)

z.test(x = na.omit(Dat1$ColumnA), sigma.x = sd16, y = na.omit(Dat2$ColumnA), sigma.y = sd17)
`
let me know if that solves your problem. I will try to write some code in the future to do this automatically.

@alanarnholt
Copy link
Owner

Thanks for bringing this to my attention. I just updated the code to remove the NAs as I claimed in the documentation. Please use the development version 1.2.1 for the latest fix. I will update BSDA on CRAN in a month or so. Let me know if the code in 1.2.1 solves your issue.

@gdunster
Copy link
Author

gdunster commented Aug 7, 2017

It worked perfectly! Thank you so much for your help!

@alanarnholt
Copy link
Owner

Issue closed

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

2 participants