Multiple linear regression with interaction in R

  Рет қаралды 39,243

Equitable Equations

Equitable Equations

2 жыл бұрын

Need to include interaction with a categorical variable in your linear model in R? Start here.
If this vid helps you, please help me a tiny bit by mashing that 'like' button. For more #rstats joy, crush that 'subscribe' button!

Пікірлер: 31
@EquitableEquations
@EquitableEquations Жыл бұрын
You can find the script from this vid (and others) at github.com/equitable-equations/youtube.
@timeiswhat
@timeiswhat Жыл бұрын
THANK YOU. This is the clearest explanation I've found. It's not that complicated but for some reason it's so hard to find a clear explanation.
@EquitableEquations
@EquitableEquations Жыл бұрын
I know, right?!
@nyatonkitnya4267
@nyatonkitnya4267 2 жыл бұрын
Very helpful. Thanks.
@santiagosotelo6881
@santiagosotelo6881 Жыл бұрын
great video really well explained.
@romanvasiura6705
@romanvasiura6705 Жыл бұрын
Thank you!
@anitasosa3755
@anitasosa3755 Жыл бұрын
Hey, thanks a lot for this video!! Made my study a bit clearer. However, I'm struggling with my data bundle, and I'd like to ask for your help. In my case, the equivalent to bodymass would be transcripts per million (TPM: the amount of normalized transcripts of a specific gene). Flipper length would be a categorical variable, 'Exponential' and 'Stationary', and the Species would be the Treatment to which the cells have been submitted (Solid or Liquid growth). I'm struggling with the concept of the slope because my x variable is not numerical. Would you have some input about this? Thank you very much!
@JWL100
@JWL100 2 жыл бұрын
great video
@EquitableEquations
@EquitableEquations 2 жыл бұрын
Thanks!
@neiltalbert7091
@neiltalbert7091 4 ай бұрын
Helped with a conference paper. Thanks
@max5916
@max5916 2 жыл бұрын
Great video we hope more about logistic regression
@EquitableEquations
@EquitableEquations 2 жыл бұрын
Yes! It's on my list, I promise. I have a few others to do first, I'm afraid.
@brazilfootball
@brazilfootball 2 жыл бұрын
Multiple logistic regression too, please! :D
@meseretmuche6984
@meseretmuche6984 6 ай бұрын
Impressive video, thank you so much. Q. how to add confidence interval, statistics like p-value and correlation in multiple regression? Thank for your time and collaboration.
@brazilfootball
@brazilfootball 2 жыл бұрын
Great video, thank you! I'm confused though about the equation for the theory vs. in R. Why is the equation y = b0 + b1x1 +b2x2 +b3x1*x2, but we write it in R as glm(x1 ~ x2*x3...) instead of glm(x1 ~ x2 + x3 + x2*x3...)? As in: body_mass_g ~ flipper_length_mm + species + flipper_length_mm * species? Hopefully that's clear, haha.
@EquitableEquations
@EquitableEquations 2 жыл бұрын
Hi! First off, there's no need to use glm here instead of lm since there's no link function involved. Regardless, either command will include individual terms all interaction variables by default when you use *. This is generally best practice, but if you need to override it, you can do so but replacing x2*x3 with x2:x3.
@brazilfootball
@brazilfootball 2 жыл бұрын
@@EquitableEquations Ah, yes, sorry for confusion. I copied the glm part from my code. Thank you!
@samanthajooodemannn7987
@samanthajooodemannn7987 Жыл бұрын
Can you do multiple interactions with this method? Like if you wanted to split up the data for flipper length for male Chinstrap, female Chinstrap, male Gentoo, and female Gentoo so you get 4 lines to compare to each other.
@EquitableEquations
@EquitableEquations Жыл бұрын
Sure, but I've always avoided this in practice. Overfitting is a risk.
@haraldurkarlsson1147
@haraldurkarlsson1147 6 ай бұрын
Here is my question. How do we know which is which in terms of the dependent and independent variables? In other words which is true? Flipper length controls body mass or body mass controls flipper length?
@ConorBlunt
@ConorBlunt Жыл бұрын
Thanks very much for the great instructional video. Much appreciated! Can you help me with a minor detail please? I have 4 levels of a categorical variable('biostimulant') and my linear model summary output lists this variable by name then a number eg, Biostimulant1, Biostimulant2 etc. How does one identify what the variable name is, that R has assigned 1,2,3,4? Thanks in advance!
@EquitableEquations
@EquitableEquations Жыл бұрын
Hi! R goes alphabetically by default. Use summary() to see the details of the model with variables listed by name.
@brazilfootball
@brazilfootball Жыл бұрын
Would you recommend mean-centering "flipper_length_mm" first or is it not necessary? If so, can you recommend a resource for how to do it in R and how to interpret the results?
@EquitableEquations
@EquitableEquations Жыл бұрын
Off the top of my head I can’t think of a reason it would be helpful in this setting. But it’s a wide world full of mystery and wonder, and I only understand little corners of it.
@brazilfootball
@brazilfootball Жыл бұрын
@@EquitableEquations No problem, thank you 😁
@jgreeneblose
@jgreeneblose 9 ай бұрын
@@EquitableEquations in a related question, if there are two scale variables, does R automatically mean-center before calculating the interaction or do we need to do this first before using the lm() function?
@freshhbresh3068
@freshhbresh3068 Жыл бұрын
If you had say 5 dependant variables and a 2 level factor variables, say species, do you need to multiply every dependent by species in the lm function?
@EquitableEquations
@EquitableEquations Жыл бұрын
Model selection is really complicated! In the end you just have to respect the data (though all else being equal I like simpler models without lots of higher-order terms).
@chasechristian9309
@chasechristian9309 2 жыл бұрын
dang i wish u were my teacher
@Jaymastia
@Jaymastia Жыл бұрын
You look and sound like little finger from game of thrones
@EquitableEquations
@EquitableEquations Жыл бұрын
Ouch dude 🤣🤣🤣
Essential R tools for regression modeling
9:27
Equitable Equations
Рет қаралды 2,5 М.
Adding variables to your multiple regression model
28:40
R Programming 101
Рет қаралды 4,1 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 38 МЛН
Advanced Regression - Categorical X variables and Interaction terms
23:19
Interpreting R's regression table
17:11
James Scott
Рет қаралды 15 М.
Interpreting Interaction in Linear Regression with R | R Tutorial 5.10 | MarinStatsLectures
6:43
MarinStatsLectures-R Programming & Statistics
Рет қаралды 110 М.
Linear Regression Summary in R
10:05
Dataslice
Рет қаралды 58 М.
Multiple regression - making sure that your assumptions are met
22:09
R Programming 101
Рет қаралды 2,1 М.
Scatterplots and regression lines in R
15:00
Equitable Equations
Рет қаралды 8 М.
Statistics 101: Multiple Linear Regression, Dummy Variables
20:59
Brandon Foltz
Рет қаралды 340 М.
Logistic Regression in R, Clearly Explained!!!!
17:15
StatQuest with Josh Starmer
Рет қаралды 512 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН