Question

If v is a sequence of numerical data, how would you do a t test comparing...

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

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How do you developers numerical data
How do you developers numerical data
How do you convert categorical data to numerical data in R? My categorical explanatory variable is...
How do you convert categorical data to numerical data in R? My categorical explanatory variable is gender and my numerical is height. I want to make a boxplot for the relationship between them. When I go to make a boxplot using this: aces$genderF <-factor(aces$gender,labels=c("male","female")) boxplot(aces$height_cm-aces$genderF) I get an error.
What statistical analysis type would you use for the following data (2 sampled unpaired t test,...
What statistical analysis type would you use for the following data (2 sampled unpaired t test, 1 sample z test, logistic regression, etc). Do an analysis of the multitasking activity from the ClassData sheet: comparing the time to type or write abcd…z and 123…26 to the time for 1a2b3c…26z.
When completing a hypothesis test you are comparing the two population means. How do you write...
When completing a hypothesis test you are comparing the two population means. How do you write the null hypothesis? Explain how to determine, in detail, which distribution to use. Assume both distributions are normal or both n's are at least 30. When completing a hypothesis test you are comparing the two population proportions. How do you write the null hypothesis? In order to complete hypothesis test for two population proportions, what requirements need to be met?
Question: How would you scan for outliers in your dataset? What would you do with data...
Question: How would you scan for outliers in your dataset? What would you do with data points that are considered outliers?
Which hypothesis test do we use when comparing more than two samples of normal data? Select...
Which hypothesis test do we use when comparing more than two samples of normal data? Select one: a. 1 sample t test b. HOV c. Regression d. ANOVA
Discuss how you would respond and how you would explain the purpose of the t test...
Discuss how you would respond and how you would explain the purpose of the t test and significance in this case.
If you were going to do the t-test instead of the nonparametric test, would you use...
If you were going to do the t-test instead of the nonparametric test, would you use the results from the test assuming “unequal variance” or “equal variance”, and explain why.
In python 3, how would you do the following? 1. conditional to check if choice is...
In python 3, how would you do the following? 1. conditional to check if choice is 7. if choice is 7, print out "lucky". if not, print "unlucky" 2. You're provided with a random number in a variable called num. Use a conditional to check if the number is odd. If num is odd, print "odd". If not, print "even" (use modulus % to figure out if number is odd)
how do you decide whether to use an independent groups t test or a correlated t...
how do you decide whether to use an independent groups t test or a correlated t test ?