R demo | How to visualize models Part 1 | multiple linear models, all assumptions & post-hocs

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024
  • In this video, we'll visualize in RStudio the results and coefficients of:
    - simple linear models with categorical predictor
    - simple linear models with numeric predictor
    - multiple linear models with numeric and categorical predictors &
    - multiple linear models with interactions
    ...moreover, you'll get:
    bonus 1: check and visualize all the assumption in one line of code ... actually in one command!
    bonus 2: easy post-hocs ... also one line of R code!
    bonus 3: make several models on the same plot quickly! ... without even explicitly modelling! only by using ggplot2 package
    Visualizing model results is the best kind of data visualization, because such data is already processed and delivers even more valuable insights than the row data.
    The code is provided here: yuzar-blog.net...
    Music by Vincent Rubinetti
    Download the music on Bandcamp:
    vincerubinetti...
    Stream the music on Spotify:
    open.spotify.c...
    Enjoy! 🥳

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

  • @angusyoung6932
    @angusyoung6932 6 месяцев назад

    One of the most detailed and enjoyable statistics videos I have ever seen. So many useful tips here and your passion really shines through. Thanks a lot for this!

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  6 месяцев назад +1

      Wow, thank you! Glad you liked it! It this old one was helpful, you might enjoy the more recent videos, especially on emmeans package and all kind of modelling, like bootstrap, quantile or glmulti. Thanks for watching! cheers.

    • @angusyoung6932
      @angusyoung6932 6 месяцев назад

      @@yuzaR-Data-Science Thank you, working with emmeans at the moment so definitely going to have a look. Have a great day!

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  6 месяцев назад

      @@angusyoung6932 thanks! you too! :)

  • @rafaelkenjinishihora9266
    @rafaelkenjinishihora9266 3 года назад

    Dear Dr. Yury Zablotski, thank you very much for this very nice and instructive video. I am looking forward to watching the next one. Congrats! \o/

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад

      Thanks a lot, Rafael! I am sooo glad it is useful!!! The second part of it will be online very soon, I already have the code (about the models I promised in the beginning). Just need to record the video. Stay healthy! Cheers!

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

    This is an amazing tutorial! I love this video; scratch that I love all of your videos. Looking forwarding to more videos. Amazing

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  2 года назад

      Thank you so much for such a nice feedback! And for watching! That encourages to do more!

  • @eddieNyakan
    @eddieNyakan 3 года назад

    Thank you for this great tutorial video that I am going to use to train my students. Again, thank you and I can't wait for more videos from you.

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад

      Dear Eddy, thanks for such a great feedback! It means a lot for me, because I also teach students and colleagues. 😁 In the medical field, where I work, we mostly do classic statistical tests and if this would be of use to you and your students, please, have a look at 3 videos on Box Plots with statistical details I did just recently. My students liked those videos more, since modelling was too fancy and complex for them. Kind regards!

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

    Fantastic!!!!!

  • @amanvashisht4429
    @amanvashisht4429 3 года назад

    This was just awesome, thank you!
    Eagerly looking forward to the next video:)

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад

      Thanks a ton for such a nice feedback, Aman! 😊 I am already working on the second part of it. Will be online latest next week.

  • @AbdulahadSapai
    @AbdulahadSapai 3 года назад

    Thanks, just mind bowling crazy stuff. It really force me to switch from Stata to R

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад

      Thanks for a nice feedback, Abdulahad! I don't know much about Stata, but I certainly love R! :)

  • @udayan62
    @udayan62 3 года назад +1

    Thank you very much for this video. I think I learned a lot from it. Please also make the R script available, perhaps on Github. That will help us try your techniques with our own data. Thanks again.

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад +2

      Thanks a lot for your feedback Udayan! That helps a lot! :) Yes, I have thought about the code, but my Webside, where I usually keep the code isn't running at the moment. Technical reasons, I am not able to solve. So, I plan to get a github profile and produce a new website (blog) where I'll put all the code in the near future. Unfortunately the day job at the university takes the most of my time, so it might take a wile. But when it is done, I'll add the link to the description of the video. So, please, stay tuned. Kind regards! Yury

  • @AmeekBhalla
    @AmeekBhalla 3 года назад +1

    Why do `lm()` and `allEffects()` produce different estimates of the mean of the first level of the factor `jobclass` in the additive model with two categorical predictors (the third model in the video)? This anomaly disappears in the interactive model with the same two predictors (the sixth model).
    Thank you for doing this. Your videos are always relevant, clear, and well produced.

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад +1

      Dear Ameek, thanks for your question and sorry for the late reply, I needed to work a lot. I checked it and in my case the estimates of "1. Industrial" are both identical to the second decimal (rounded, I guess) place, namely, 103.170 in "summary(m)" and 103.1695 in "allEffects(m)". The CIs might sometimes vary though. Kind regards!

    • @AmeekBhalla
      @AmeekBhalla 3 года назад +1

      @@yuzaR-Data-Science Hi Yury, Thank you for the reply. Don't worry about the timing though, you do a lot here already, especially given your day job.
      I got the estimate you got (103.170) from both `lm()` and `allEffects()` when only one predictor was put into the model (your first model). However, with two predictors [as in your third model, lm(salary ~ jobclass + education, d)], I got different estimates. From `lm()` I got "(Intercept)" equalling 83.9, while from `allEffects()` I got "1. Industrial" equalling 109.08.

    • @AmeekBhalla
      @AmeekBhalla 3 года назад

      # proof that the estimate of the first level of the first factor differs between `lm()` and `allEffects()`
      # extracting the estimate produced by `allEffects()`
      factor1_level1_allEffects %
      allEffects() %>%
      pluck("jobclass") %>%
      as_tibble() %>%
      filter(jobclass == '1. Industrial') %>%
      select(fit)
      # extracting the estimate produced by plain `lm()`
      factor1_level1_lm %
      tidy() %>%
      filter(term == '(Intercept)') %>%
      select(estimate)
      isTRUE(factor1_level1_allEffects != factor1_level1_lm)

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад +1

      Hey Ameek, :) nice code, thanks! Yes, now I see where the problem is. In the first model you filter our the jobclass == '1. Industrial', right? But in the second the `(Intercept)` contains both "first" levels of both predictors at the same time, namely, '1. Industrial' from the "jobclass" and `1. < HS Grad` from the "education". The intercept in this model is the reference level for both predictors and for all their categories at the same time.

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  3 года назад +1

      However, in the model with interactions "jobclass * education", the intercept take the first level of the fists predictor, which happens to be "jobclass". So, the intercept here is the `1. Industrial` of the `1. < HS Grad`, and then everything fits :)

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

    Do we have an equivalent package to "sjplot" in the higher versions of r?
    Thank you

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  2 года назад +1

      What do you mean by the higher version of R? Older?

    • @fishfish20
      @fishfish20 2 года назад +1

      @@yuzaR-Data-Science My bad, I tried installing the sjPlot package and got an error message. I saw your reply and concluded that I'm the one who made a typo. Everything is ok.
      Thank you so much.
      Regards

    • @yuzaR-Data-Science
      @yuzaR-Data-Science  2 года назад +1

      @@fishfish20 no worries :) typos make 90% of my code-mistakes 😁