One-Sample t Test & Confidence Interval in R with Example | R Tutorial 4.1| MarinStatsLectures

Поделиться
HTML-код
  • Опубликовано: 3 янв 2025

Комментарии • 61

  • @marinstatlectures
    @marinstatlectures  5 лет назад +6

    👋🏼 Hello there! In this video we discuss how to conduct the one-sample t-test and calculate the confidence interval with R (with example).📝 Correction (0:01:10): the alternative hypothesis in this video should be mu less than 8; Ho: mu=8 (or more specifically, mu equal or greater than 8) and Ha: mu less than 8 (Thanks to @ShairozSohail for catching this)! Find the free R practice dataset (LungCapData) here: ( www.statslectures.com/r-scripts-datasets ); Like to support us? You can Donate (bit.ly/2CWxnP2), Share our Videos, Leave us a Comment and Give us Thumbs up! Either way We Thank You!

  • @noacaspi8746
    @noacaspi8746 5 лет назад +1

    this was so helpful i have a midterm for this tomorrow and you were the only straight-forward resource on the internet that explained how to change the confidence interval in t-tests

  • @areslusitanii
    @areslusitanii 5 лет назад +1

    I started my PhD two months ago. I didn't "play" with statistics for nearly 12 years. Totally lost, I am (still) finding my way through your videos. Thank you so much for sharing the knowledge!

  • @motylanoga5705
    @motylanoga5705 8 лет назад +8

    I will recommend your tutorials to all people that wanna begin their adventure with R :)

  • @raoufzanati7532
    @raoufzanati7532 7 лет назад +2

    you are amazing MR marin

  • @arunkumardubey120
    @arunkumardubey120 5 лет назад

    Good work Marin. Best wishes

  • @lB061988
    @lB061988 9 лет назад +2

    Mike, thanks for making these videos. They are so helpful to a novice like myself!

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      you're welcome +lB061988 ! we're glad you're finding them helpful!

  • @soha6788
    @soha6788 8 лет назад +1

    why are these videos so good? thank you so much!

  • @pasinduranasinghe7978
    @pasinduranasinghe7978 4 года назад +1

    in the example, the alternative hypothesis is (mu>8), If I am not mistaken then the code has to be corrected as alt="greater" instead of "less
    "

  • @muskansharma8742
    @muskansharma8742 2 года назад

    Thankyou so much👐👐👐

  • @pastorofmuppets7654
    @pastorofmuppets7654 5 лет назад +3

    Thank you sir!

  • @shairozsohail1059
    @shairozsohail1059 10 лет назад +19

    If you specified Ho as mu

    • @marinstatlectures
      @marinstatlectures  10 лет назад +11

      Thanks for catching that Shairoz Sohail , that should be that the alternative is mu=8) and Ha: mu

    • @yekhtiari
      @yekhtiari 6 лет назад +2

      I think thoes thumbs down are because of this mistake.

    • @yaweli2968
      @yaweli2968 2 года назад

      @@marinstatlectures : I just watched your video, I was about to ask the same question.

    • @lillol3245
      @lillol3245 Год назад

      Bro I tought i finally understood which value belongs to alternative then I wanted it confirmed, watched this video and tought I‘m dumb as hell. Thanks for your 8 year old comment mate

  • @joseluisbeltramone599
    @joseluisbeltramone599 4 года назад

    Thank you very much for the good content.

  • @shubhamgupta9495
    @shubhamgupta9495 7 лет назад +1

    HI Marin thanks for all these videos these are very helpful, i would like to do a thorough practice for R. I would like to know if you could put and recommendation material for R and any book?
    Thanks

  • @emmanuel_dean
    @emmanuel_dean Год назад

    how do you know you know to define mu as less than 8? do you just make it up? Like, How did you know to use that specific number

  • @wissalms2820
    @wissalms2820 2 года назад

    Hello ! Can I use the same command for hypothesis test : mean 20???

  • @nilakshidas5676
    @nilakshidas5676 4 года назад

    can we calculate varience from p value and xi2 and no of dof ?

  • @tiisetsomashele1494
    @tiisetsomashele1494 7 лет назад

    Your videos are so helpful. Thank you.How would you perform a test where you test if the variance of one sample is greater than a specified number?

  • @phyzics4all343
    @phyzics4all343 5 лет назад

    Hi, this is probably a silly question, but what exactly is "mu". I know it is a null hypothesis, but a how is it significant? Do I need a value of "mu" to make my t-test mean something? Cause "R" will perform the test either way.
    For one sample I got a t-test value of "0.2" and for the other "0.6". Something tells me that "0.2" one is more accurate but i am not sure.
    Sorry, I am new to this type of data/error analysis but I want to learn it as I study physics (second year).
    Thanks!

  • @ugyennorbu9443
    @ugyennorbu9443 7 лет назад +1

    Thank you for the videos, they are great.
    Can you help me how to do t-test in R if sample mean and sample variance is known but not the individual samples itself.
    In you example, sample mean and variance are calculated from the values in the table. However, I am required to do a test when data is not known, only the mean & variance.

  • @kengking2708
    @kengking2708 9 лет назад +1

    May I know if R can also perform SQL by itself?

    • @marinstatlectures
      @marinstatlectures  9 лет назад +1

      Keng King you will need to use a package, *sqldf* seems to be the most popular. although this is not an area of mine, so i'm not able to comment much.

  • @nalichandi7159
    @nalichandi7159 8 лет назад

    Hi Mike, what i learnt for one sample t test, as null hypothesis we always took mu =110( 110 as a example) and alternative is mu> 110....
    1... My question is , is R always consider the Ho and H1 as you took??
    2... I tried to solve the question which i did in my school with R..But the answers are totally different??
    Data( 156, 123, 92,56,73,101,101,174,100,125,64,165,110,83,109,182) , mu=110, Conf=5%
    3...Do we use t distribution for small sample size??? like n

    • @nalichandi7159
      @nalichandi7159 8 лет назад

      the result of question no 2 by the hand calculation is t=0.34, p-value=1.753 df=15 and we accept H0

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +nali chandi , in R you specify the null value using the *mu* argument (in the video, i use mu=8). the alternative is specified using the *alt* argument, set to greater/less/two.sided. you should always use the t-distribution (you can use Z/normal with really large sample sizes, but as a general rule, the only time you can really use the Z instead of t is when you KNOW the true standard deviation...which is NEVER the case in reality. heres how to do the t.test you want, in R, using an alternative hypothesis of greater than 110, and a null of Ho:mean=110
      *x

    • @nalichandi7159
      @nalichandi7159 8 лет назад +1

      Thanks a lot Mike!!

  • @ryanthoni53
    @ryanthoni53 4 года назад

    What packages do I need to have downloaded to do this? I just downloaded R, and tried and even the box plot step couldn't get done. I assume I need a suite of packages. Frustrating when I can even get past the first step.

  • @jennaproctor280
    @jennaproctor280 9 лет назад

    I want to test between competitions of bacteria but It would mean doing a t-test on every single row. How do I do something called a block, so it I don't have to go through as test every bit of data?

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi Jenna Proctor , the word "block" has many different meanings and uses in statistics, so I'm not sure exactly how you are using the word here. in general, you can use the *apply* function in R to apply a function over rows or columns of a data frame. as an example, you can use *apply(data, 1, t.test)* to apply the t.test to the rows (using 1=rows, 2=columns) of data. this will return messy results though, as it will return all the results. what id suggest is to store them in some object, say *results

    • @jennaproctor280
      @jennaproctor280 9 лет назад

      This helps a lot!! I will try it out and see if it works. Thank you so much!!!! I didn't give a great explanation but I think it may solve the problem :)

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      you're welcome, good luck with your work

    • @jennaproctor280
      @jennaproctor280 9 лет назад

      >Error in apply(data, 1, t.test) : dim(X) must have a positive length
      I got this in the output box of my R script. have I written it wrong? I have three columns with three main treatments SM:SM WS:WS WS:SM I want to do a test on the third column but in each treatment too.

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi Jenna Proctor , things are a bit unclear. in your previous comment you said you want to do a t-test on each row of your data, and this will do that. but now you are saying that you want to do a t-test on the 3rd column of your data, so I'm not really sure what you want to do. in general, the *apply* function can be used to apply a function across rows or columns of a data frame in R.

  • @bettys7298
    @bettys7298 6 лет назад

    Do you also have One-Sample Z Test in R radio available? Thank you!

    • @marinstatlectures
      @marinstatlectures  6 лет назад

      Hi, we have a video showing how to find probabilities for the normal distribution (which is essentially the same thing as the Z test): ruclips.net/video/zUnC1CV4FAc/видео.html
      we dont spefically show Z test, as it is a special (and unrealistic case), and you would generally have to use t, not Z, in any real world application....but you can check out that video for how to find probabilities for Z scores

  • @andredevera1827
    @andredevera1827 6 лет назад

    Hi, how can I actually change my level of significance using R ?

  • @meradrshtikon3223
    @meradrshtikon3223 2 года назад

    how many from cps analytics?

  • @debosreesikdar586
    @debosreesikdar586 4 года назад

    I can't understand why u used mu =8??

  • @kengking2708
    @kengking2708 9 лет назад

    Hi mm. It's me aga. One of your fan. I'm trying to replicate your action TEST$confi.int gives a NULL value
    I realise the language is so sensitive as in the case of TEST$conf.int gives the said value. Are there any way to make R recognize that they're in fact similar commands? cause often at times I either misspelt or had a Upper case error.

    • @marinstatlectures
      @marinstatlectures  9 лет назад +1

      Keng King no, R is case sensitive (meaning upper/lower case are different). the object Test and test, and TEST will all be recognized as different objects in R. you have to be very careful with typing, as mis-spelling, changing upper to lower case, etc, will change the meaning for R.

  • @kidsadeemshow388
    @kidsadeemshow388 4 года назад

    Hello , how are you? I want to contact with you for important lesson , thanks.

  • @anujtiwari7556
    @anujtiwari7556 6 лет назад

    Z test ?????

    • @marinstatlectures
      @marinstatlectures  6 лет назад

      not sure what you're asking... here's some info that may be helpful... the Z-test is mostly just a teaching tool, and rarely/never applicable in a real world. the Z test is for when you KNOW the population standard deviation (sigma), and this is almost never realistic. it is quite rare that you would be trying to estimate the mean of a population, but know the SD of the population.

  • @liammartin6793
    @liammartin6793 5 лет назад

    its really of no help if you use already built data sets

    • @marinstatlectures
      @marinstatlectures  5 лет назад

      Hi, maybe you can elaborate...not sure what you mean here. to analyze data, you need to have some data. this is a dataset that is saved in a spreadsheet and imported into R. not sure exactly what it is you are looking for...i may be able to offer some help if you can clarify what it is you are actually looking to do.

    • @liammartin6793
      @liammartin6793 5 лет назад

      Start with building a matrix from scratch like Matrix A=c(45,56,67,89)
      Then analyze it.

    • @marinstatlectures
      @marinstatlectures  5 лет назад

      oh, i see what you meant to say. that wouldn't really make any sense here. the dataset we work with has 725 rows and 6 columns, so that would require entering 4,350 observations by hand...also, things are never done this way. data is generally imported into R and then worked on...it is pretty much never entered manually into R. In our videos, we try to show real world programming skills.
      we do have a separate video showing how to create a matrix in R, which may be of help if you are looking for that.

    • @liammartin6793
      @liammartin6793 5 лет назад

      How do you create data set and merge them into rows and columns for t testing from scratch ?

    • @liammartin6793
      @liammartin6793 5 лет назад

      I have also seen your video on vectors.So think from a student perspective .What if you were to create a data matrix like air passenger that is available on R studio from scratch ?