If v is a sequence of numerical data, how would you do a t test comparing the odd indexed data points and the even indexed ones?
in R
R code:-
v=rnorm(1000,0,1) # sequence of numerical data
index=1:length(v)
df=data.frame(cbind(index,v))
even_indexes = seq(2,length(v),2)
odd_indexes = seq(1,length(v),2)
v_odd=c()
v_even=c()
for(i in 1:length(even_indexes)) v_even[i]=df$v[df$index==even_indexes[i]] # even indexed data
for(i in 1:length(odd_indexes)) v_odd[i]=df$v[df$index==odd_indexes[i]] # odd indexed data
t.test(v_odd,v_even) # two sample t-tests
Output:-
Welch Two Sample t-test
data: v_odd and v_even
t = -0.036282, df = 995.62, p-value = 0.9711
alternative hypothesis: true difference in means is not equal to
0
95 percent confidence interval:
-0.1292540 0.1245612
sample estimates:
mean of x mean of y
-0.02855257 -0.02620618
Get Answers For Free
Most questions answered within 1 hours.