ps1_econ497

.pdf

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

497

Subject

Economics

Date

Feb 20, 2024

Type

pdf

Pages

9

Uploaded by CommodoreStarKangaroo3

Report
Problem Set 1 Rohan Desai 1. Summary statistics. Use Files/problem_sets/ps1/symptoms_by_age_refugee.dta to answer this question. d <- read_stata("C:/Users/rohan/OneDrive - The Pennsylvania State University/Documents/ECON 4 97/ps1_export/symptoms_by_age_refugee.dta") %>% mutate(frac = percent_of_sample/100) # 1a. # Calculate the probability of a refugee being 18 years old prob_18_refugee <- d %>% filter(refugee == 1, tr12_age == 18) %>% summarise(prob = sum(frac)) %>% pull(prob) # Print the probability prob_18_refugee ## [1] 0.0006449175 # 1b. # Plotting the percent of refugees and non-refugees by age d_symptoms <- subset(d, refugee == 1) # Filter dataset for individuals with symptoms ggplot(d_symptoms, aes(x = tr12_age, y = frac)) + geom_bar(stat = "identity", position = "dodge", fill = "red") + labs(title = "Percent of Individuals with Symptoms by Age", x = "Age", y = "Percent") + theme_minimal() # Using a minimal theme for a clean look Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 1 of 9 2/8/2024, 11:38 PM
d_no_symptoms <- subset(d, refugee == 0) # Filter dataset for individuals without symptoms ggplot(d_no_symptoms, aes(x = tr12_age, y = frac)) + geom_bar(stat = "identity", position = "dodge", fill = "blue") + labs(title = "Percent of Individuals without Symptom s by Age", x = "Age", y = "Percent") + theme_minimal() # Using a minimal theme for a clean look ## Warning: Removed 1 rows containing missing values (`geom_bar()`). Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 2 of 9 2/8/2024, 11:38 PM
Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 3 of 9 2/8/2024, 11:38 PM
# 1c. # Probability of a refugee having COVID-19 symptoms prob_refugee_symptoms <- d %>% filter(refugee == 1, symptoms == 1) %>% summarise(prob = sum(frac)) %>% pull(prob) # Probability of being a refugee prob_refugee <- d %>% filter(refugee == 1) %>% summarise(prob = sum(frac)) %>% pull(prob) # Conditional probability of having symptoms given refugee # status conditional_prob_symptoms_given_refugee <- prob_refugee_symptoms/prob_refugee # Probability of being a refugee and having symptoms prob_not_refugee_symptoms <- d %>% filter(refugee == 0, symptoms == 1) %>% summarise(prob = sum(frac)) %>% pull(prob) # Probability of being a refugee prob_not_refugee <- d %>% filter(refugee == 0) %>% summarise(prob = sum(frac)) %>% pull(prob) # Conditional probability of having symptoms given refugee # status conditional_prob_symptoms_given_not_refugee <- prob_not_refugee_symptoms/prob_not_refugee # Print the probabilities conditional_prob_symptoms_given_refugee ## [1] 0.06104043 conditional_prob_symptoms_given_not_refugee ## [1] 0.02960421 Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 4 of 9 2/8/2024, 11:38 PM
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help