# Untitled

unknown
plain_text
a month ago
2.1 kB
14
Indexable
Never
```### Question 3

When examining hypotheses, it is always important to have an appropriate comparison group. One may argue that comparing tech workers to everybody else as we did in Question 2 may be problematic due to a variety of confounding variables (such as skill level and employment status). First, create a single factor variable group which takes a value of tech if someone is employed in tech, whitecollar if someone is employed in other "white-collar" jobs (such as law or finance), other if someone is employed in any other sector, and unemployed if someone is unemployed. Then, compare the support for H-1B across these conditions by using the linear regression. Interpret the results: is this comparison more or less supportive of the labor market hypothesis than the one in Question 2?

```{r}
immig\$group <- factor(NA, levels=c('Tech', 'Other white-collar', 'Other sectors', 'Unemployed'))

immig\$group[immig\$tech.whitcol==1 & immig\$nontech.whitcol==0 & immig\$employed==1] <-
"Tech"

immig\$group[immig\$tech.whitcol==0 & immig\$nontech.whitcol==1 & immig\$employed==1] <-
"Other white-collar"

immig\$group[immig\$tech.whitcol==0 & immig\$nontech.whitcol==0 & immig\$employed==1] <-
"Other sectors"

immig\$group[immig\$employed==0] <- "Unemployed"

model3 <- lm(immig\$h1bvis.supp~immig\$group)
summary(model3)
```

Now, one may also argue that those who work in the tech sector are disproportionately young and male which may confound our results. To account for this possibility, fit another linear regression but also include age and female as pre-treatment covariates (in addition to group). Does it change the results and, if so, how?

```{r}
model3.agesex <- lm(immig\$h1bvis.supp~immig\$group + immig\$female + immig\$age)
summary(model3.agesex)
```

Finally, fit a linear regression model with all threat indicators (`group`, `expl.prejud`, `impl.prejud`) and calculate its R2. How much of the variation is explained? Based on the model fit, what can you conclude about the role of threat factors?

```{r}
model3.threats <- lm(immig\$h1bvis.supp ~ immig\$group + immig\$expl.prejud + immig\$impl.prejud)

summary(model3.threats)\$r.squared
``````