R, hypothesis testing and Z score In learning of hypothesis testing, I want to see if different gender has the same survival rate.
By using Australian AIDS Survival Data
Here are my hypothesis statements:
Hº: Gender has no significant difference in survival
H1: Female has better chance of survival

I want to calculate the Z score to test the hypothesis. In R:
a.data <- read.csv("https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/MASS/Aids2.csv")
female_data <- subset(a.data, a.data$sex == "F")

#function for z test
z.test2 = function(a, b, n){
  sample_mean = mean(a)
  pop_mean = mean(b)
  c = nrow(n)
  zeta = (sample_mean - pop_mean) / (sd(b) / sqrt(c))
  return(zeta)
}

z.test2(as.numeric(female_data$status), as.numeric(a.data$status), female_data)

The Z score is -0.4645053
As the Z score is between -1.96 and +1.96, the p-value will be larger than 0.05. so I can’t reject the null hypothesis.
Am I doing the right thing in hypothesis testing? If not, where's the problem?
If the null hypothesis is “Female has a better survival rate”, how shall I change the testing process?
Thank you.
 A: I'm assuming that you want to test two null hypotheses: 


*

*H_0a: no association between female and survival 

*H_0b: positive relationship between female and survival.


You should refrain from using H_1 to denote a null hypothesis as this is usually used to refer to a an alternative hypothesis (the alternative is what you want to show, the null is what you want to disprove). 
What you call the population mean is not really the population mean. It is the sample mean of both groups and therefore random. This renders the standard error that you compute incorrect.
One way to get a correct standard error for the difference of the means in the two groups is to run the following regression
data <- read.csv("https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/MASS/Aids2.csv")
data$female <- as.integer(data$sex == "F")
data$alive <- as.integer(data$status == "A")
summary(lm(alive ~ female, data = data))

This will give you a test statistic of 0.472. The absolute value of this is less than 1.96 and you don't reject H_0a. 
Your null hypothesis H_0b can be tested by a one-sided t-test. The test statistic is less than  1.65 (0.95 quantile of standard normal) and you will not reject H_0b.
Please note that you should never test these two hypotheses in this order without adjusting for multiple testing. 
A: Chi-Squared Test of Independence should do for your binomial response:
H0=same proportions of survival for the sexes 
H1=different survival rates for the sexes (indicating gender variable dependence)

chisq.test(table(sex=a.data$sex,status=a.data$status))


   ##   Pearson's Chi-squared test with Yates' continuity correction
   ## 
   ## data:  table(sex = a.data$sex, status = a.data$status)
   ##X-squared = 0.13041, df = 1, p-value = 0.718

The p-value suggests that no significant difference was found and hence you did not find evidence to reject H0, the hypothesis of independence.
