Controlling for a variable in R's LM function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Controlling for a variable in R's LM function

Corvus_Callosum
Hello! I'm a student working on my senior thesis and I'm currently using R's linear model function to predict voting behavior based on a psychological construct (implicit theories of leadership or ILT's)

My data includes ~500 observations where the participants rated ILT's, reported their demographic information, and who they voted for (or would have wanted to vote for) in 2016. I have demographic information, voting behavior, and political affiliation in dummy-code data frame.

My LM model looks like this:

summary(lm(formula = revolushun.calculations$i.iltdim.sensitivity ~ dummy.vote.frame$donald + dummy.vote.frame$ben +dummy.vote.frame$bernie))

This line of code produces results that look like this:

Call:
lm(formula = revolushun.calculations$i.iltdim.sensitivity ~ dummy.vote.frame$donald +
    dummy.vote.frame$ben + dummy.vote.frame$bernie)

Residuals:
    Min      1Q  Median      3Q     Max
-6.6318 -0.7464  0.5870  1.0348  1.8810

Coefficients:
                        Estimate Std. Error t value Pr(>|t|)    
(Intercept)               9.0797     0.1063  85.410  < 2e-16 ***
dummy.vote.frame$donald  -0.6214     0.3458  -1.797  0.07293 .  
dummy.vote.frame$ben     -0.9607     0.3227  -2.977  0.00304 **
dummy.vote.frame$bernie  -0.4479     0.1449  -3.091  0.00210 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.612 on 546 degrees of freedom
Multiple R-squared:  0.02824, Adjusted R-squared:  0.0229
F-statistic: 5.289 on 3 and 546 DF,  p-value: 0.001335

I believe this is doing what I needed it to, but is there a way to alter the command so that R will run the linear model and control for gender?
Reply | Threaded
Open this post in threaded view
|

Re: Controlling for a variable in R's LM function

Corvus_Callosum
(I'm sure it's already obvious, but I am very new to using R in any capacity, so please let me know if I'm doing something egregiously wrong)