CS计算机代考程序代写 ###set-up the data for the births example

###set-up the data for the births example
library(MASS)
library(mvtnorm)
library(LearnBayes) #laplace function – not needed for
#simple births model

library(arm)

#setwd(“~/Patrick/Stat314-2018”) #unhash and change to your working folder
#if reading in data; Should not be
#needed if using a Rstudio project;
#Not needed for this example since the
#data is created in the code but any output
#files created will be saved to the current
#home folder

##births by region data

#set-up the data
births <- c(64,365,149,113,30,65,38,95,117,6,12,9,9,137,36,36) popsize <- c(5450,51620,14960,9360,1770,5640,3880,9020,17040, 1420,1600,1290,980,18670,8290,3170) regions <- c("Northland","Auckland","Waikato","Bay of Plenty", "Gisborne","Hawke's Bay","Taranaki", "Manawatu-Wanganui","Wellington","Tasman","Nelson", "Marlborough","West Coast","Canterbury","Otago", "Southland") majurb <- c(0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0) North <- c(1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0) South <- 1- North ###place into a data frame for easier viewing and writing out if necessary births_reg.df <- data.frame(regions,births,popsize,majurb,South) ###Have a look at the data births_reg.df ###Compute the observed birth rates rate <- births / popsize rate