R语言 | 统计代写 | 经济代写 | 金融代写 | 商科代写 | 代写report | project – CASA 0005 – coursework/casa 0005 – final-exam-YI-KI Private

CASA 0005 – coursework/casa 0005 – final-exam-YI-KI Private

R语言 | 统计代写 | 经济代写 | 代写report | project – 这个题目属于一个report的代写任务, 涵盖了report/security等方面, 这个项目是project代写的代写题目

report代写 代做report

casa 0005 – final-exam-YI-KI/exam_response.Rmd

YI-KIAdd files via upload

2 contributors

Code Issues Pull requests Actions Projects security Insights

main

175 lines (131 sloc) 7.89 KB

9 # Originality declaration
10
11 I, [Yi Ki Lai], confirm that the work presented in this assessment is my own. Where inf
12
13 date: `r format(Sys.time(), '%d %B, %Y')`
14
15 # Initial  project scope
16 This  report presents the findings of relationship between obesity and diet in the city
17 ### Data exploration
18 Grocery weight, volume and nutrients_weights are selected from the dataset to set up th
19 The BMI of children in London is averaged to be 21.72 while adults 20.88 both of a slig
20
21 ```{r }
22 library(sf)
23 library(tmap)
24 library(tmaptools)
25 library(RSQLite)
26 library(tidyverse)
27 #read in the shapefile
28
29 shape <- st_read(
30 "data/statistical-gis-boundaries-london/ESRI/MSOA_2004_London_High_Resolution.shp")
31 # read in the obesity data
32 obesitycsv <- read.csv("data/obesity-revise.csv", header = TRUE,

33 sep = ",", 34 encoding = "latin1") 35 36 grocerycsv <- read.csv("data/Apr_msoa_grocery.csv", header = TRUE, 37 sep = ",", 38 encoding = "latin1") 39 summary(obesitycsv) 40 41 ## Too many 42 summary(grocerycsv$weight) 43 summary(grocerycsv$volume) 44 summary(grocerycsv$h_nutrients_weight) 45 46 47 48 49 **### Delete the N/A values** 50{r results = ‘hide’} 51 na.omit(obesitycsv) 52 na.omit(grocerycsv) 53 54 55 56 **### Making map** 57 The map is drawn on MSOA level and the map of London is derived as such. 58{r} 59 ## checking the obesity data 60 head(obesitycsv) 61 # obesitycsv$X..of.measured.children.in.Year.6.who.were.classified.as.obese..2009.10. 62 # obesitycsv$Percentage.of.the.population.aged.16..with.a.BMI.of.30…modelled.estimate 63 colnames(obesitycsv) <- c("MSOC.Code", "MSOA.Name", "children", "Growup") 64 head(obesitycsv) 65 qtm(shape) 66 67 68 69 **### OBESITY DISTRIBUTION ACROSS LONDON** 70 71 Obesity rate of measured children in Year 6 agglomerate on the center of London distric 72{r} 73 ## merge the data 74 head(shape) 75 obesitymap <- merge(obesitycsv,shape,by.x="MSOC.Code",by.y="MSOA_CODE") 76 library(tmap) 77 library(tmaptools) 78 head(obesitymap) 79 newobesitymap_f<-st_as_sf(obesitymap) 80 tmap_mode("plot") 81 qtm(newobesitymap_f, 82 fill = "children") + tm_scale_bar(position = c("left", "bottom")) +

83 tm_layout(title = "The obesity rate (%) of measured children in Year 6", legend.posi 84

85
86 “`
87

88 Percentage of 16+ obesity rate is higher in the eastern area of the city. According to 89 90 {r} 91 tmap_mode("plot") 92 qtm(newobesitymap_f, 93 fill = "Growup", borders = "gray", palette="Blues") + tm_scale_bar(position = c( 94 tm_layout(title = "Percentage of the population aged 16+ with a BMI of 30+, modelled 95 96 97 98 The diet distribution in London. This heat map presents the weight of average food purc 99 {r} 100 ## display the grocery data 101 102 alldata <-merge(obesitymap,grocerycsv, by.x="MSOC.Code",by.y="X.ef..bb..bf.area_id") 103 newallmap_f<-st_as_sf(alldata) 104 tmap_mode("plot") 105 qtm(newallmap_f, 106 fill = "weight") + tm_scale_bar(position = c("left", "bottom")) + 107 tm_layout(title = "Weight of the average food product, in grams", legend.position = c 108 109 110 111 ## The Spatial autocorrelation 112 113 The Spatial autocorrelation of obesity and deit consumption is analyzed in this section 114 115 “`{r} 116 library(spdep) 117 118 119 MSOA.nb <- poly2nb(newallmap_f) 120 MSOA.wt <- nb2listw(MSOA.nb) 121 MSOA.wt 122 ## Spatial autocorrelation 123 #summary(unlist(MSOA.wt$children)) 124 ## Spatial autocorrelation test of weight 125 moransWeight <- moran.test(newallmap_f$weight, MSOA.wt) 126 moransWeight 127 128 129 ## Spatial autocorrelation test of children obesity 130 #moranschildren <- moran.test(newallmap_f$children, MSOA.wt) 131 #moranschildren 132 133 134 ## Spatial autocorrelation test of adult obesity

135 moransgrowup <- moran.test(newallmap_f$Growup, MSOA.wt) 136 moransgrowup

137
138 “`

139 ## Regression analysis 140 ### The relationships of children obesity and diet 141 The overall model is significant in accounting for childrens BMI with product amount, 142 143 {r} 144 ## relationships between variables 145 ## child obesity 146 147 reg1 <- lm(newallmap_f$children~newallmap_f$weight+newallmap_f$volume+newallmap_f$h_nut 148 summary(reg1) 149 library(broom) 150 tidy(reg1) 151 glance(reg1) 152 153 154 155 ### The relationships of adult obesity and diet 156 The pattern with grownups slightly differ from that of children, as in the correlation 157 158 {r} 159 ## relationships between variables 160 ## Growup obesity 161 162 reg2 <- lm(newallmap_f$Growup~newallmap_f$weight+newallmap_f$volume+newallmap_f$h_nutri 163 summary(reg2) 164 library(broom) 165 tidy(reg2) 166 glance(reg2) 167 168 169 170 ### Conclusion 171 The spatial analysis indicate that the obese children and adults are of different distr 172 However, the analysis risk overlooking the variables of correlation between Children an 173 174 175