t-test and interpreting p values using R Programming

Поділитися
Вставка
  • Опубліковано 22 лип 2024
  • This video explains how to use a t-test and interpret the p value using R programming. If you are doing data analysis or interested in data science, then you'll need to learn how to do statistical analysis. Statistics and statistical inference is easy when you know how. If you're doing any kind of quantitative rsearch, then this is a must.

КОМЕНТАРІ • 138

  • @RProgramming101
    @RProgramming101  11 місяців тому

    Get my FREE cheat sheets for R programming and statistics (including transcripts of these lessons) here: www.learnmore365.com/courses/rprogramming-resource-library

    • @oluderaolumide2003
      @oluderaolumide2003 6 місяців тому

      I will like you to seperate the statistics analysis from business analysis

  • @Shawn-gm4cf
    @Shawn-gm4cf 2 роки тому +23

    I can't say this enough, but please keep making these. I'm hoping I can use your videos to supplement my own stats classes in the future, because they really are great at getting at the meat and potatoes of both the code and theory behind the stats.

  • @KathySolita
    @KathySolita 2 роки тому +2

    Thanks so much for making this. I've been watching dozens of videos, and none of them explain how to extract the values from the t-test for inline coding like here! MVP

  • @ImLeviathan
    @ImLeviathan 3 місяці тому

    as a total newbie in statistics and trying to learn by myself this video has helped a lot. Thanks for coupling up explanations of code and basic concepts in statistics. Very much appreciated!

  • @daniellarkins7743
    @daniellarkins7743 2 роки тому +4

    Great video, I'm just starting with R and your videos have been great. The explanations of the codes you provide is fantastic. Keep up the awesome work.

  • @muhammedhadedy4570
    @muhammedhadedy4570 2 роки тому +2

    Great as usual. I can't wait to see the next video. Thanks for the great work.

  • @thomassauv1893
    @thomassauv1893 2 роки тому +10

    As a PhD candidate, your videos helped a lot. Very efficient. Thanks a lot.¨Please continue with other statiscal tests ;)

  • @michaelmillett1478
    @michaelmillett1478 Рік тому

    I really appreciate you making these videos! They are really helpful!

  • @jd5481
    @jd5481 2 роки тому +1

    Another great one in the bag. Great job!

  • @rupeshingle2681
    @rupeshingle2681 2 роки тому

    Thank you sir for proving this important and beautiful knowledge, I love the way you teach.
    Thank you again

  • @romanvasiura6705
    @romanvasiura6705 Рік тому

    Thank you for this great video!
    It's so fan to look how easy you do it))
    Hopefully I'll find more materials in your other resources!

    • @RProgramming101
      @RProgramming101  Рік тому +1

      Of course, more to come, Roman. Thank you for the amazing feedback!

  • @janinemashny525
    @janinemashny525 Рік тому

    I love how excited he is to talk about R!!

    • @RProgramming101
      @RProgramming101  Рік тому

      So nice of you, Janine. Thank you for your feedback!

  • @jamesleleji6984
    @jamesleleji6984 2 роки тому +1

    Thanks for sharing this Greg. It's incredibly helpful

    • @RProgramming101
      @RProgramming101  2 роки тому +1

      Glad it was helpful!

    • @jamesleleji6984
      @jamesleleji6984 2 роки тому

      @@RProgramming101 Please remember to do a tutorial on difference in differences between a control and experimental group. Thanks

  • @AmitYadav-ee7sz
    @AmitYadav-ee7sz Рік тому

    I hope you will never stop making videos on R........as far as R is in trend.

  • @hernanrosas2995
    @hernanrosas2995 2 роки тому +2

    Learning so much from your videos!

    • @RProgramming101
      @RProgramming101  2 роки тому

      I'm so glad! Thanks for the feedback, Hernan. Much appreciated.

  • @etm9703
    @etm9703 Рік тому

    Great video! Helped me with my R lab homework, thank you!!

  • @javiermonroy4616
    @javiermonroy4616 Рік тому

    Jesus Christ, this channel just keeps getting better and better. Thanks for the content!

  • @LearningAddict
    @LearningAddict 2 роки тому +1

    I really enjoyed your videos. As always. Thx for making this great video explanation.

  • @aaronmombos
    @aaronmombos Рік тому

    This is great! I'm new to R and new to statistics and your channel is very helpful! A question, if using t-tests to determine significance in product price changes, would you use a double sided, single sided test, or paired test? Thank you!

  • @AmitYadav-ee7sz
    @AmitYadav-ee7sz Рік тому

    one of the best R programming teacher.....love you

    • @RProgramming101
      @RProgramming101  Рік тому

      You are too sweet Amit - thanks! More R videos to come of course! ☺

  • @user-gp9vu7mw9r
    @user-gp9vu7mw9r 5 місяців тому

    thanks! This is a great help!

  • @AnupKumar-nz2qq
    @AnupKumar-nz2qq 2 роки тому +1

    Thank you for explaining in this beautiful manner

  • @vipeeera007
    @vipeeera007 2 роки тому +12

    Great video. Could you please also start sharing the code to produce the graphs you use to visualize the concepts you speak about?

    • @michaelmillett1478
      @michaelmillett1478 Рік тому +1

      I was able to figure out how to do the first graphic at 5:26
      ggplot(data = ) +
      geom_density(mapping = aes(lifeExp), fill = "red", alpha = 0.2) +
      geom_vline(xintercept = mean($lifeExp), color = "red", alpha = 0.4, linetype = "dashed", size = 1.5)

    • @michaelmillett1478
      @michaelmillett1478 Рік тому +2

      I was able to figure out how to recreate the 2nd graph too! (not perfect, but pretty close)
      ggplot(data = ) +
      geom_density(aes(lifeExp, color = continent, fill = continent), alpha = 0.3) +
      geom_vline(xintercept = 48.9, color = "red", alpha = 0.4,
      linetype = "dashed", size = 1.2) +
      geom_vline(xintercept = 71.9, color = "cyan4", alpha = 0.4,
      linetype = "dashed", size = 1.2) +
      labs(
      title = "Density Plot of Life Expectency in Africa and Europe",
      y = "",
      x = "Age in yrs") +
      annotate(
      "text", x = 43, y = 0.075, label = "48.9 yrs", color = "red",
      alpha = 0.8, size = 4.5) +
      annotate(
      "text", x = 80, y = 0.075, label = "48.9 yrs", color = "cyan4",
      alpha = 0.8, size = 4.5)
      **NOTE**
      The data frame I had loaded was gapminder filtered(continent %in% c("Africa", "Europe"))

  • @huseyintoptay9666
    @huseyintoptay9666 2 роки тому +1

    Great video. Thank you so much

  • @DavidBarnwell876tkdja
    @DavidBarnwell876tkdja 8 місяців тому

    Thanks for the video. Do you have one that discusses the density plots you created for life expectancy? This is an excellent series, btw.

  • @ssaaurabh456
    @ssaaurabh456 Рік тому

    you are simply awesome Greg i learn alot from You....Thanks to my GURU( means teacher in hindi)

  • @sintubmb
    @sintubmb 2 роки тому

    You are the best, as always. But you could have explained the code for the density plot too. Or have I missed it?

  • @jwenishkumawat3404
    @jwenishkumawat3404 2 роки тому +2

    Thanks a lot! As usual, the explanation was amazing! I used to get confused in t-test but this complicated stuff you have made it so easy!

  • @apelsinbzz
    @apelsinbzz 2 роки тому +1

    work of a genius

  • @thulfiqaral-graiti7131
    @thulfiqaral-graiti7131 2 роки тому +2

    Would be possible to show in the future data analysis episodes the following matters: 1- A decision about making numeric variables as factor or leave it as a numeric as well as how about incase having categorical variables?
    2- What the best decision can be made to deal with data having missing values (NA)?
    As always you made things enjoyable as the best, thanks alot!

    • @RProgramming101
      @RProgramming101  2 роки тому +4

      Will do!! I have a video on missing data using R on my Global Health channel (go to global health with greg martin and you'll find it there)

  • @jimmycliffordoppong7988
    @jimmycliffordoppong7988 Рік тому +2

    Great video. But it will greatly be appreciated if you can share the codes for the graphs?

  • @user-up7fp5tv6j
    @user-up7fp5tv6j 4 місяці тому

    Thanks for such a great and clear explanation. Could you mind making a video on 'how to visualize the T-test result'?

  • @nandecomics
    @nandecomics Рік тому

    Where do you get tidyverse, patchwork and gapminder? I'm using RStudio at the moment.

  • @anggipermanaharianja6122
    @anggipermanaharianja6122 2 роки тому +1

    One of the best t-test and p-values in YT!

  • @VibeZ_1221
    @VibeZ_1221 5 місяців тому

    Can you please share how to create those plots that u were showing during the start of the video

  • @Duncanwg7
    @Duncanwg7 2 роки тому

    Great video. A video on testing data for different distributions would be nice, such as normal, weibull etc.

  • @MauroRenna
    @MauroRenna 2 роки тому +2

    Great video, could you comment a little more about the example you have used for paired t-test? One could guess that the sample used for individuals in 1957 is not the same than that in 2007 even if it is the same continent. The two samples could be considered independent from each other. I other words that we are not using repeated or matched measurements of life exp. and could safely use a two-sample t-test instead of a paired one. Thank you so much.

    • @RProgramming101
      @RProgramming101  2 роки тому +1

      Very interesting observation Mauro. I hadn't thought of that. I think however that in this case, what is being sampled are countries (not individuals). It is the countries that are matched. But its an interested thought and I'll muse over your comment a little.

  • @Victoriataieb
    @Victoriataieb Рік тому

    you are great teacher
    🤩🤩

  • @OFWCREATOR
    @OFWCREATOR 2 роки тому +1

    Thank you sir!

  • @shokhrukhusmanov1049
    @shokhrukhusmanov1049 Рік тому

    Can you explain how you did create plots for t.test?

  • @rodneychisha9972
    @rodneychisha9972 Рік тому

    Life-saver ❤

    • @RProgramming101
      @RProgramming101  Рік тому

      I'm thrilled that my video helped you or provided you with useful information. Thanks for letting me know!

  • @mykamillz
    @mykamillz 2 роки тому +1

    Thanks for sharing

  • @elispot17
    @elispot17 2 роки тому

    Such a great video, can I have that R script?

  • @davidispiryan5689
    @davidispiryan5689 2 роки тому +1

    Can you please do more videos about all tests, and linear and logistic regressions? Other than that, awesome videos, thank you very much!

    • @RProgramming101
      @RProgramming101  2 роки тому +1

      Great suggestion! Thank you for the feedback.

  • @user-yt9ic2hg7f
    @user-yt9ic2hg7f 5 місяців тому

    5:49 hypothesis test
    10:51 test for difference of mean (two side test)
    17:50 test for difference of mean (one side test)

  • @ramoda13
    @ramoda13 6 місяців тому

    nice video thank u

  • @theanita1
    @theanita1 12 днів тому

    bonus learning objective, the dot for piping when it's not the first part of a formula - not what I came to learn but super important point (pun intended)

  • @paulbishop1641
    @paulbishop1641 2 роки тому

    great videos thank you - would you be able to do something on how to work with skewed data

  • @nabeelsiddiqui3377
    @nabeelsiddiqui3377 2 роки тому +1

    Thank you for this. I have seen a lot of people turning to a KW test in R. Can you go over when that is appropriate?

  • @SNAKE1375
    @SNAKE1375 2 роки тому

    Thanks Greg, I can clearly see the use of the t-test to compare two means. But I still don't understand the first example. Why testing a population if we already know its mean? and also what is the use to "sample" it to make a test?

    • @RProgramming101
      @RProgramming101  2 роки тому +3

      Hi Francois - great question. In the fist example, we're comparing our sample data mean to some hypothesised mean (which may be because of previous studies or assumptions). We may, for example, all believe that Irish men are on average 6 foot tall. We can take a sample of men, measure the mean and ask if it is different from that asumptions (the 6 feet)

  • @thedude870
    @thedude870 2 роки тому

    Isn‘t the difference in life expectancy statistically significant when you compare Ireland to Switzerland because you don‘t compare it only for one year but for say the last 30 years?
    Or maybe a general question: Does statistical significance change when you compare more than one event?

  • @karikoga320
    @karikoga320 Рік тому

    Great video. Can you please work on Two One Sided T test (TOST) video which is quite prevalent and widely used in the pharmaceutical industry. Also please address the issue of statistical significance versus practical significance.Thank you

  • @reem19681
    @reem19681 2 роки тому +1

    very clear

  • @twiss9341
    @twiss9341 2 роки тому +1

    Thank you

  • @sushilojha5202
    @sushilojha5202 2 роки тому +2

    please make vedios about principal component analysis in R

  • @wiktoriajedryczka6979
    @wiktoriajedryczka6979 Місяць тому

    Hello, Greg! Thank you for sharing this video!
    I have one question about the plots though - how did you display M on each density plot, and how did you manage to put the plots together?

    • @RProgramming101
      @RProgramming101  Місяць тому +1

      ah - thanks for the questions (good ones). Hard to answer in the comments but I will make a video that explains. Watch this space. Happy day. Greg

    • @wiktoriajedryczka6979
      @wiktoriajedryczka6979 Місяць тому

      @@RProgramming101 Wonderful, thank you! All the best:)

  • @ecc6975
    @ecc6975 2 роки тому

    Hi there, I have followed your instructions for the examples:
    gapminder %>%
    filter(continent == "Africa") %>%
    select(lifeExp) %>%
    t.test(mu = 50)
    as well as
    my_ttest %
    filter(continent == "Africa") %>%
    select (lifeExp) %>%
    t.test (mu = 50)
    however both come up with:
    Error in select(., lifeExp) : unused argument (lifeExp)
    Would you know what could be the cause of this and how to fix it by any chance?

    • @ilkyen
      @ilkyen 2 роки тому

      dplyr::select(lifeExp) %>%
      #MASS and dplyr package Select function clashes, so we tell R to use dplyr

    • @felipem8639
      @felipem8639 Рік тому

      First you need to load the data:
      install.packages("patchwork")
      library(patchwork)
      and if want, you cant attach the data so you dont need to call the data all the time:
      attach(gapminder)
      and if you want to create a object to work with it:
      data("gapminder")
      name_your_data

  • @Asuram23
    @Asuram23 Рік тому +1

    Hello, I tried to follow but it does not find the gapminder. I have many issues with R not finding library vocabularies. Also error on %>% function.

    • @Yourmom-vu5ct
      @Yourmom-vu5ct Рік тому

      I had that issue too and I downloaded the following packages for the function. Maaybe they work for you
      install.packages("magritter")
      install.packages("dplyr")

  • @sciencefliestothemoon2305
    @sciencefliestothemoon2305 2 роки тому

    That might be a stupid question, but how to I create the vertical line for the mean in the graphs?

  • @nat650091
    @nat650091 10 місяців тому

    Why can't I install the packages after typing install.packages(patchwork) and install.packages(gapminder)? :(

  • @ManuelLopez-ej8sn
    @ManuelLopez-ej8sn 2 роки тому

    Ty Greg for yet another great vdo. Two questions.
    1) How do you get the two vlines representing the two countries means in the graph?
    2) I tried Levene’s test. What is wrong with this code?
    library(car)
    gapminder %>%
    filter(country %in% c("Ireland", "Switzerland")) %>%
    leveneTest(lifeExp, country, center = mean)
    Can’t figure out either of those 😊

    • @RProgramming101
      @RProgramming101  2 роки тому +2

      will try to make a video that addresses this.

    • @ManuelLopez-ej8sn
      @ManuelLopez-ej8sn 2 роки тому

      @@RProgramming101 Looking forward to that! Thank you very much

    • @souhaibsebbane5623
      @souhaibsebbane5623 2 роки тому +2

      To answer your question 1, use (geom_vline) at the end of your ggplot code, this is an example using the GAPMINDER dataset:
      gapminder %>%
      select(continent, lifeExp) %>%
      filter(continent == 'Europe') %>%
      ggplot(aes(x = lifeExp))+
      geom_density(fill ='orange', alpha = 0.5)+
      geom_vline(aes(xintercept = mean(lifeExp)),linetype = 'dashed')

    • @ManuelLopez-ej8sn
      @ManuelLopez-ej8sn 2 роки тому +1

      @@souhaibsebbane5623 Thank you very much for your helpful answer! I'm going to try this out right away.

  • @mugomuiruri2313
    @mugomuiruri2313 2 роки тому +1

    I get u lound and clear in this remote place in Africa.
    Good teaching
    Please how did u draw the graphs?

    • @mashfintech
      @mashfintech 2 роки тому

      What village are you in? Kikikikiki

    • @mugomuiruri2313
      @mugomuiruri2313 2 роки тому +1

      @@mashfintech Yamumbi

    • @mashfintech
      @mashfintech 2 роки тому

      @@mugomuiruri2313 nice one brother. I am in Pretoria South Africa hiding from dudula.

    • @sciencefliestothemoon2305
      @sciencefliestothemoon2305 2 роки тому

      They are density plots, easy to make, I just havent figured out the vertical line yet.
      gapminder%>%
      filter(continent %in% c("Africa", "Europe"))%>%
      ggplot(aes(x=lifeExp,
      color=continent,
      fill=continent))+
      geom_density(alpha = 0.2)
      gives you the basic graph

    • @felipem8639
      @felipem8639 Рік тому +1

      @@sciencefliestothemoon2305
      gapminder%>%
      filter(continent %in% c("Africa", "Europe"))%>%
      ggplot(aes(x=lifeExp,
      color=continent,
      fill=continent))+
      geom_density(alpha = 0.2)+
      geom_vline(xintercept = 50, linetype="dashed",
      color = "red", size=0.8) #50 or mu is the median of population in your test

  • @SC-bi6my
    @SC-bi6my 2 роки тому

    Hi, what statistics packages you are using? Can you share your R file?

  • @ajayram3016
    @ajayram3016 9 місяців тому

    May I know he source for DATA?

  • @jamie10157
    @jamie10157 Рік тому

    boom shakalaka - we did this!

  • @petfield100
    @petfield100 7 місяців тому

    One sided test for two different means: alway s the error: groupng factor must have two Steps?

  • @containerhobbyshop9735
    @containerhobbyshop9735 2 роки тому +1

    Please pump up loudness next time.

  • @medicalmarvels976
    @medicalmarvels976 7 місяців тому

    Error: unexpected symbol in:
    "gapminde %>%
    filter(continent %in% c("Africa"."
    >

  • @haraldurkarlsson1147
    @haraldurkarlsson1147 2 роки тому +1

    It is not just simplest to give the 95% confidence interval rather than the p-value. Thus nipping the p-hacking business in the...? There seems to be far too much confusion around the p-values.

    • @RProgramming101
      @RProgramming101  2 роки тому

      Good question. The truth is that there are so many ways that people p hack (even without knowing it). It’s a big problem. The best way forward is to make people aware of it.

  • @boojaado
    @boojaado 4 місяці тому

    This is the 'analyze' tutorial.

  • @matp3209
    @matp3209 Рік тому

    7:32 the P value is not a probability, it’s just a number

  • @andresrengifo7801
    @andresrengifo7801 2 роки тому +2

    Chacalaca

  • @m.arijuanto9821
    @m.arijuanto9821 2 роки тому

    I don't understand