Quantcast
Channel: Active questions tagged lm - Stack Overflow
Viewing all articles
Browse latest Browse all 105

How to use a subset of multiple columns with some conditions in lm function?

$
0
0

I would like to study the effect of party identification on attitude towards an issue. I'm using a large poll data Democracy Checkup 2020. My regression function goes as follow:

mod1 <- lm(dc20_pos_jobs ~ dc20_party_id + dc20_education, data,            subset = ("dc20_pos_jobs" < 5 && "dc20_party_id" != c("6","7","8"))

I can't seem to get the subset to work, although I don't get any errors. Here are the specs I need in my subset:

  1. dc20_pos_jobs: use all values but don't use 5. It's an ordinal variable (1, 2, 3, 4, 5)
  2. dc20_party_id: use all values but don't use 6, 7 and 8. It's a nominal variable (1 through 8)

and if possible

  1. add another specific variable in lm every time dc20_party_id has a certain value. For example:dc20_party_id equals 1? Add dc20_party_rating_23 as a control variable in lm.dc20_party_id equals 2? Add dc20_party_rating_24 as a control variable in lm.... up to dc20_party_id equals 5? Add dc20_party_rating_24 as a control variable in lm.

All the different party_ratings are interval variables going from 0 to 100.

I tried moving the arguments around, different operators.


Viewing all articles
Browse latest Browse all 105

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>