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
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
# 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
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) # 2a. Assuming d is your dataframe ggplot(data = d, aes(x = tr12_age, y = frac, fill = as.factor(refugee))) + geom_bar(data = subset(d, symptoms == 1), stat = "identity", position = "dodge") + scale_fill_manual(values = c(`0` = "blue", `1` = "red"), labels = c("Non-refugee", "Refugee")) + labs(title = "Fraction of Refugees and Non-refugees with COVID-19 Symptoms by Age", x = "Age", y = "Fraction", fill = "Refugee Status") + theme_minimal() # 2b. # Graph for non-refugees with COVID-19 symptoms non_refugee_data <- d %>% filter(refugee == 0, symptoms == 1) ggplot(non_refugee_data, aes(x = tr12_age, y = frac)) + geom_point() + geom_smooth(method = "lm", se = FALSE, color = "blue") + labs(title = "Fraction of Non-refugees with COVID-19 Symptoms by Age with Linear Fit", x = "Age", y = "Fraction") Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 5 of 9 2/8/2024, 11:38 PM
## `geom_smooth()` using formula = 'y ~ x' # 2c. ggplot(non_refugee_data, aes(x = tr12_age, y = frac)) + geom_point() + geom_smooth(method = "lm", se = FALSE, color = "red", aes(weight = frac)) + labs(title = "Weighted Linear Fit for Non-refugees with COVID-19 Symptoms by Age", x = "Age", y = "Fraction") ## `geom_smooth()` using formula = 'y ~ x' Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 6 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
Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 7 of 9 2/8/2024, 11:38 PM
d <- read_stata("C:/Users/rohan/OneDrive - The Pennsylvania State University/Documents/ECON 4 97/ps1_export/symptoms_by_governorate_refugee.dta") %>% mutate(frac = percent_of_sample/100) # Calculate the probability for refugees in Mafraq with # COVID-19 symptoms prob_symptoms_refugee_mafraq <- d %>% filter(h1_curr_res_gov == 3, refugee == 1, symptoms == 1) %>% summarise(prob_symptoms = sum(frac)) %>% pull(prob_symptoms) prob_refugee_mafraq <- d %>% filter(h1_curr_res_gov == 3, refugee == 1) %>% summarise(prob = sum(frac)) %>% pull(prob) conditional_prob_symptoms_refugee_mafraq <- prob_symptoms_refugee_mafraq/prob_refugee_mafraq # Conditional probability for non-refugees in Mafraq prob_symptoms_nonrefugee_mafraq <- d %>% filter(h1_curr_res_gov == 3, refugee == 0, symptoms == 1) %>% summarise(prob_symptoms = sum(frac)) %>% pull(prob_symptoms) prob_nonrefugee_mafraq <- d %>% filter(h1_curr_res_gov == 3, refugee == 0) %>% summarise(prob = sum(frac)) %>% pull(prob) conditional_prob_symptoms_nonrefugee_mafraq <- prob_symptoms_nonrefugee_mafraq/prob_nonrefuge e_mafraq # Output the conditional probabilities conditional_prob_symptoms_refugee_mafraq ## [1] 0.02843435 conditional_prob_symptoms_nonrefugee_mafraq ## [1] 0.03249908 Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 8 of 9 2/8/2024, 11:38 PM
# 2b. print("The problem set data indicates a conditional probability of 0.061 for refugees showing COVID-19 symptoms, compared to a lower rate of 0.030 for non-refugees. In Mafraq, the conditi onal probabilities are 0.028 for refugees and 0.032 for non-refugees, suggesting regional dif ferences. Comparatively, the IPA study on Rohingya refugees in Cox's Bazar reported a 25% sym ptom prevalence in camp residents versus 13% in the host community, indicating a higher overa ll symptom prevalence among refugees in Cox's Bazar than what's observed in the problem set d ata. These differences highlight how context-specific factors, such as living conditions, acc ess to healthcare, and public health measures, can influence the prevalence of COVID-19 sympt oms among refugee populations.") ## [1] "The problem set data indicates a conditional probability of 0.061 for refugees showin g COVID-19 symptoms, compared to a lower rate of 0.030 for non-refugees. In Mafraq, the condi tional probabilities are 0.028 for refugees and 0.032 for non-refugees, suggesting regional d ifferences. Comparatively, the IPA study on Rohingya refugees in Cox's Bazar reported a 25% s ymptom prevalence in camp residents versus 13% in the host community, indicating a higher ove rall symptom prevalence among refugees in Cox's Bazar than what's observed in the problem set data. These differences highlight how context-specific factors, such as living conditions, ac cess to healthcare, and public health measures, can influence the prevalence of COVID-19 symp toms among refugee populations." Problem Set 1 file:///C:/Users/rohan/Downloads/ps1_template.html 9 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