You are here

Group Exercise: Another T-test

Formulate a causal model and then identify a categorical independent variable and a numeric dependent variable. Compute the T-test and interpret the results. Paste your R code below your interpretation.

Comments

> t.test(V162111[V161241==1],V162111[V161241==2])

Welch Two Sample t-test

data: V162111[V161241 == 1] and V162111[V161241 == 2]
t = -3.2341, df = 3582.6, p-value = 0.001231
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-12.96005 -3.17709
sample estimates:
mean of x mean of y
59.50796 67.57653

Reject the null hypothesis

> t.test(V162111[V161241==1], mu=50)

One Sample t-test

data: V162111[V161241 == 1]
t = 4.699, df = 2324, p-value = 2.767e-06
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
55.54008 63.47584
sample estimates:
mean of x
59.50796

I am 95% confident that the mean favorability towards transgender people fall between 55.5 and 63.4 degrees

> t.test(V162111[V161241==2], mu=50)

One Sample t-test

data: V162111[V161241 == 2]
t = 12.043, df = 1260, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
64.71323 70.43982
sample estimates:
mean of x
67.57653
I am 95% confident the mean favorability towards transgender people fall between 64.7 and 70.4 degrees

> library(gmodels)
> library(psych)
> ANES2016<-read.csv("http://www.shortell.nyc/online/files/anes_timeseries_2016.csv")
> attach(ANES2016)
> t.test(V162099[V161309==1],V162099[V161309==2])

Welch Two Sample t-test

data: V162099[V161309 == 1] and V162099[V161309 == 2]
t = 1.2943, df = 806.17, p-value = 0.1959
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.8454448 4.1186018
sample estimates:
mean of x mean of y
75.21351 73.57694

There is no evidence that the mean of favorability towards Pope Francis is different between Latinos and non-Latinos.

> t.test(V162098[V161302==1],V162098[V161302==2])

Welch Two Sample t-test

data: V162098[V161302 == 1] and V162098[V161302 == 2]
t = 8.2674, df = 2029.9, p-value = 2.443e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
9.21305 14.94323
sample estimates:
mean of x mean of y
70.00407 57.92593

> t.test(V161093,mu=50)

One Sample t-test

data: V161093
t = -1.5473, df = 4234, p-value = 0.1219
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
48.25003 50.20616
sample estimates:
mean of x
49.2281
> t.test(V161093[V161002==1],V161093[V161002==2])

Welch Two Sample t-test

data: V161093[V161002 == 1] and V161093[V161002 == 2]
t = -1.0992, df = 1161.7, p-value = 0.2719
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-5.494746 1.548753
sample estimates:
mean of x mean of y
48.37814 50.35113

> t.test(V162105[class==0],V162105[class==1])

Welch Two Sample t-test

data: V162105[class == 0] and V162105[class == 1]
t = 1.2762, df = 1079.5, p-value = 0.2021
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.866090 8.810312
sample estimates:
mean of x mean of y
57.98493 54.51282

We accept the null hypothesis

There is no evidence of difference that the mean of favorability towards rich people is different between lower class and upper class.

> t.test(V161095,mu=50)

One Sample t-test

data: V161095
t = -3.928, df = 4200, p-value = 8.703e-05
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
47.27012 49.08789
sample estimates:
mean of x
48.179

> t.test(V161095[V161081==1],V161095[V161081==2])

Welch Two Sample t-test

data: V161095[V161081 == 1] and V161095[V161081 == 2]
t = 37.981, df = 2472.5, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
29.77436 33.01614
sample estimates:
mean of x mean of y
71.36975 39.97450
I reject the null hypothesis. I am 95% confident that the mean favorability towards the democratic party who believe we are on the right track and those who dont is between 57.98 and 54.13