代做Assignment 3代做留学生R程序

Assignment 3

Instructions

For Part 1, you will use R and the dataset assignnment3.csv. Make sure you include library(tidyverse) when you start your session!

The dataset you will be working with is a cross-section of countries (unit of analysis, or rows, are a country) with data from the World Bank. The variables in the dataset are as follows:

• cerealcrops: the metric tons of cereal crops the country produced (tons of corn, rice, oats, wheat, ect.)

• primeduc: the percentage of persons over 15 who have primary school as their highest educational attainment (note, a country that is high on this dimension means most adults have not completed high school, whereas a country that is low is one where most adults have completed a level of school higher than primary.)

• gdp: the most recent gross domestic product of the country

• smoke: the percentage of the adult population that reports smoking tobacco products.

• infmort: the rate of infant mortality per 1,000 births.

• lifeexp: the life expectancy of women in the country

• pop: the total population count

• urbpop: the percentage of the population that lives in urban areas.

• continent: the continent the country is in.

• democ: a binary measure of whether the country is a democracy.

For R related questions:

• You do not need to copy and paste every plot into your answer document - I will know what the plots look like, you can instead just copy and paste your script. in the end, and if anything seems off, I will check your code for partial credit.

• Be sure to provide complete comments on what you see: if you see a histogram, comment on the shape, if you run a regression, tell me what the direction of the relationship is, what it means in substantive terms, and whether it is statistically significant.

• Reach out with any questions!

For Part 2, you are given a set of cases to examine to select case studies. You will not need to run any R code for Part 2!

Part 1

Question 1

A. Provide a five number summary of infant mortality

summary(df$infmort)

What is the median, mean, and interquartile range of infant mortality? What do these metrics help us describe?

B. Make a histogram of the relationship

ggplot(df, aes(infmort)) +

geom_histogram()

Describe the shape and spread of the distribution. Based on your answer in Part A, are you surprised by the shape, or does it seem consistent with the central tendency and spread that you found earlier?

C. Your friend says that there must be a problem with the data, since the Central Limit Theorem implies the shape should be a symmetric and unimodal bell curve. How would you respond to them?

Question 2

You theorize that democracies are more responsive to needs of the people they govern, therefore, the life expectancy in democratic states should be longer than in autocratic ones.

A. By adapting what you did in Assignment 2 to find difference in means, find the difference in means for life expectancy between democracies and non democracies (using the variable democ). Be sure to do a t-test, and describe the substantive and statistical signifigance of what you see.

B. Now, suppose we run a regression instead to evaluate our hypothesis. Run the regression

m = lm(lifeexp ~ democ, data = df)

summary(m)

Interpret the regression results in the same way (describing substantive and statistical significance). Does the difference in means test match the regression test?

Question 3

Below are four regressions where life expectancy is the dependent variable and the independent variables are: primeduc (percentage of adults who have only completed primary school, nothing beyond), urbpop (percentage of persons living in cities), smoke (percentage of adults that smoke), and pop (total population).

For each plot, comment on i.) the direction of the relationship ii.) the strength of the relationship and iii.) whether the plots show any signs that linear regression may be inappropriate.

A. IV Primary education

ggplot(df, aes(primeduc, lifeexp)) +

geom_point() +

geom_smooth(method = 'lm')

B. IV Urban population

ggplot(df, aes(urbpop, lifeexp)) +

geom_point() +

geom_smooth(method = 'lm')

C. IV Smoking

ggplot(df, aes(smoke, lifeexp)) +

geom_point() +

geom_smooth(method = 'lm')

D. IV population

ggplot(df, aes(pop, lifeexp)) +

geom_point() +

geom_smooth(method = 'lm')

Question 4

Suppose you have a theory that countries that grow cereal crops (grains, including rice, wheat, corn, oats) have better economies. Use the data on cerealcrops and gdp to make a scatter plot of the relationship. The code below will also include a regression line through the points and will label the name of the country that corresponds to each point.

ggplot(df, aes(cerealcrops, gdp, label = country)) +

geom_point() +

geom_smooth(method = 'lm') + geom_text(vjust = -1, hjust = 0.5)

A. Do any of the points look like outliers? Why or why not?

B. If any points look like outliers, are the residuals positive or negative in each case? What would a positive or negative residual mean?

Question 5

A. Show the correlation between smoking and infant mortality. Comment on the sign and strength of the relationship.

cor(df$smoke, df$infmort)

B. Generate a scatter plot of the relationship - does it match the correlation? Describe what you see in the plot, does it match what you would have assumed?

ggplot(df, aes(smoke, infmort)) +

geom_point()

C. Suppose we want to run a regression. What are the advantages of running a regression versus correlation?

D. Now let’s run the regression. What do the results tell you? If 10 percent more persons aged over 15 began smoking, what would happen to infant mortality?

m = lm(infmort ~ smoke, data = df)

summary(m)

E. Applying the regression mistakes discussed in lecture and the Wheelen reading, what may be explaining the relationship? Discuss at least 2 that may and one that does not not apply.

F. Now, let’s generate a plot highlighting points by country. What does this show? What concept from lecture does this remind you of?

ggplot(df, aes(smoke, infmort, color = continent)) +

geom_point(size = 1.5)

G. Run the following regression including what continent the country is from as a control variable. Comment on the sign, strength, statistical, and practical significance of the estimated relationship between smoking and infant mortality when adjusting estimates for what continent the country is in. Does this change the answer? Use what you see from the plot in part F to to explain what you found.

m = lm(infmort ~ smoke + continent, data = df)

summary(m)

Part 2

You don’t need to use R for this part!

Suppose you have collected data on 25 countries (called “case1” “case2” etc.). These counties are displayed in Table 1. For each country, you have data on per capita income, the percent of the population who are high school graduates, and the percent of the eligible adult population that turned out to vote in the last national election. You also have information about how tough it is for voters to register in each country — an ordinal scale ranging from very low (easy to register) to very high (hard to register). (Assume this is a reliable and valid measure based on whether there is same day voter registration, poll taxes, accessible polling places etc.).

Summary statistics for each variable are also provided below.

HS Grad Summary

## Min. 1st Qu. Median Mean 3rd Qu. Max.

## 31.00 42.00 59.00 57.24 70.00 86.00

Income Summary

## Min. 1st Qu. Median Mean 3rd Qu. Max.

## 5626 15189 20740 25192 32047 49754

Turnout Summary

## Min. 1st Qu. Median Mean 3rd Qu. Max.

## 44.00 60.00 68.00 69.96 83.00 90.00

Regisration Requirement Summary

##

## high low medium very high very low

## 5 6 12 1 1

Table 1: Candidate Cases

Case

Percap_I

HSgrad

RegReq

Turnout

case1

15189

60

high

44

case2

44090

31

medium

68

case3

29709

79

low

85

case4

15697

63

low

74

case5

14224

32

high

51

case6

29713

50

medium

64

case7

17636

64

medium

57

case8

32047

35

medium

65

case9

38800

70

high

52

case10

31003

74

low

83

case11

19584

42

medium

58

case12

13875

49

high

87

case13

20740

86

medium

90

case14

45726

76

very low

90

case15

18718

47

medium

69

case16

24416

59

medium

73

case17

43115

78

medium

77

case18

7922

53

low

66

case19

42669

69

medium

90

case20

14047

54

very high

56

case21

49754

84

medium

84

case22

27160

40

high

63

case23

15889

70

low

63

case24

5626

32

low

80

case25

12455

34

medium

60

Assume we have elected to conduct case studies to test our hypothesis, and that the 25 counties we have here are the population of counties within a given state.

A. Say we want to test a hypothesis: higher levels of income and education lead to greater voter turnout. What other functions could case studies serve besides testing a hypothesis?

B. If you want to choose a “deviant’ ’ case, assuming our hypothesis is that higher levels of income and education lead to greater voter turnout. What may you choose and why?

C. Name a case selection (you only need to provide 1 county) that may be seen as “cherry picking’ ’ to support the income and education hypothesis discussed thus far - why would cherry picking be concerning?

D. Several scholars have argued that less restrictive (low to medium) voter registration is a necessary condition for high voter turnout. Are there any cases in your data set that would provide evidence against this argument?

E. Suppose we want to examine the effect of only education on turnout. Pick a set of 3 cases that would be a good choice for causal inference. What kind of a sampling strategy would this be?

F. Name three cases that would be bad to choose due to selection on the dependent variable. Why would this be a problem?

G.Your friend wants to test the theory that income predicts turnout. They run a regression of turnout on income and produces the following plot. They say Case 17 is the clear choice to test the hypothesis, and should be the only one that is sampled. What would we call this sampling approach, and what are the drawbabcks if our goal is hypothesis testing? When may we want to use the sampling approach that they proposed?




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图