0

I would like to test the null hypothesis that the mean value of y at a specified x is equal to a specific value vs. the alternative that it is not equal to that specific value.

How can I calculate the corresponding T value for the test statistic and p-value in R? Also, how can I calculate the corresponding 95% confidence interval for the mean value of y at that specific value in R?

Here is what I have tried:

TVEXP <- c(28.5, 48.3, 40.2, 34.8, 50.1, 44.0, 27.2, 37.8, 27.2, 46.1, 31.3, 50.1, 31.3, 24.8,42.2, 23.0, 30.1, 36.5, 40.2, 46.1)

VOTE <- c(35.4, 58.2, 46.1, 45.5, 64.8, 52.0, 37.9, 48.2, 41.8, 54.0, 40.8, 61.9, 36.5, 32.7, 53.8, 24.6, 31.2, 42.6, 49.6, 56.6)

voting_data <- data.frame(TVEXP, VOTE)

t.test(voting_data$VOTE, voting_data$TVEXP, mu = 45, alternative = "two.sided", conf.level = 0.95)

I want to test null hypothesis that the mean value of y is 45 when x is 36.99 vs the alternative that it does not equal 45. I expect t.test() to produce T = 0.954 and a p-value of 0.3, but that is not what I got as output.

mebby
  • 25
  • 3
  • 1
    Have you tried using the t.test() function in base R? – Bill O'Brien Jul 15 '21 at 15:40
  • @BillO'Brien, I just looked it up and tried the following code, but it did not produce the expected output: `t.test(voting_data$VOTE, voting_data$TVEXP, mu = 45, alternative = "two.sided", conf.level = 0.95)`. I think I need to specify the specified x value, or I'm just way off course. – mebby Jul 15 '21 at 16:03
  • I can help if you are willing to post a reproducible example... https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Bill O'Brien Jul 15 '21 at 16:05
  • @BillO'Brien, I have updated the post with an example. – mebby Jul 15 '21 at 16:28

0 Answers0