title: “Homework 1A” author: “Christopher Joseph” date: ‘2025-04-14’ output: pdf_document: number_sections: true

Problem 1

Part (a)

setwd(‘/Users/chrisjoseph/Documents/UCSC/Spring 2025/Econ 124/Working Directory HW1’) getwd() survey <- read.csv(“survey.csv”) news <- read.csv(“fakenews.csv”)

Part (b)

cat(“The sample is drawn from people 1208 18+ adults that responded to an -online survey. The sample is most likey not random because the people holding the sample did not take the steps in insuring that it is random. They most likely pulled from local emails and phone numbers they have stored in some local database due to people signing up for it. Most companies do not take the time to do RCT testing due to how much harder, and expensive it is. These people are systemically different from people in the US do to the fact they chose to respond, while most others didnt This could be due to feeling more strongly about politics than others, being older than most, or having certain strong beliefs that influence them, etc. Overall there is a large amount of bias present in this survey due to the nature of this This is also why there predictions for Kamala and Trump were so inaccurate. The methods used to measure who people were voting for had a large amount of, selection bias due to who responded to the phone calls and why.”)

Problem 2

Part (a)

sum(na.omit(news\(fb_share[news\)pro == “Trump”])) x <- sum(na.omit(news\(fb_share[news\)pro == “Trump”]))

sum(na.omit(news\(fb_share[news\)pro == “Clinton”])) y <- sum(na.omit(news\(fb_share[news\)pro == “Clinton”]))

Part (b)

cat(x, “pro-Trump articles were shared on Facebook, and”,y, “pro-Clinton articles were shared, in this dataset.”, sep=” “)

Problem 3

buzzfeed_only <- mean(news\(buzzfeed==1&news\)snopes==0&news\(politifact==0)*100 round(buzzfeed_only) snopes_only <- mean(news\)buzzfeed==0&news\(snopes==1&news\)politifact==0)100 round(snopes_only) politifact_only <- mean(news\(buzzfeed==0&news\)snopes==0&news$politifact==1)100 round(politifact_only)

#Snope has the highest exclusive articles # Buzzfeed = 6, Snopes =79, Politifact = 6

Problem 4

mean(survey\(MediaMinutesPerDay) Avg_Election_Consumption <- mean(survey\)MediaMinutesPerDay) round(Avg_Election_Consumption)

((survey\(SocialMediaMinutesPerDay / survey\)MediaMinutesPerDay)[survey$MediaMinutesPerDay > 0]) * 100

round(mean((survey\(SocialMediaMinutesPerDay/survey\)MediaMinutesPerDay) [survey\(MediaMinutesPerDay> 0])*100) avg_SM_Mins <- round(mean((survey\)SocialMediaMinutesPerDay/survey\(MediaMinutesPerDay) [survey\)MediaMinutesPerDay> 0])*100) avg_SM_Mins

cat(“Respondants who consumed election news on average reported spending at least” ,avg_SM_Mins,“minutes on social media. Most people spent their time on social media over consuming election news.”)

Problem 5

Source_Count <- table(survey$MostImportantSource)/15 barplot(sort(Source_Count), main = “Respondants Most Used Sources”, las = 2) #Social Media is the 3rd most important behind Cable and Websites