GV900 Political Explanation, 2017/2018
30 October, 2018
Homework assignment 2
Due Week 7 (13 November)
Write an R code file named (gv900-HW2.R) to complete the following tasks. The easiest
way to write an R code file is to start with an existing file: Duplicate an existing R code file
that you have (e.g., gv900-week4-JointExercise.R) and modify the file contents accordingly.
Rules
• Submit two files, and two files only. That is, submit (1) the coversheet (ESSAY COVERSHEET
2018-2019.docx, available on Moodle) and (2) your R code file (gv900-HW2.R). Don’t
submit your graph or other outputs. You’ll earn 5 points if you do all of these correctly.
• Make sure that you delete your name from your R code file. You’ll earn 5 points if you
do this correctly.
• Execute everything before you submit (e.g., CTRL + A & CTRL + Return on a Windows
PC; Command + A & Command + Enter on a Mac machine), and make sure your file
runs without an error. I will execute your file to check if you did it. You’ll earn 5 points
if your R file runs without an error.
• Your file must have a proper header. You’ll earn 5 points if you do this correctly.
• Add comments and annotations to everything you do. Try to make your code file look
like my code file. If your code file doesn’t have a proper annotation, you’ll lose 5 points.
Don’t copy and paste all the questions into your R code file, but do show me the question
number for each question. You’ll earn 5 points if you do this correctly.
Tasks (5 points each × 15 = 75 points)
1. Load the “world” dataset (world.csv), and store it as an object named world.data.
2. The data set contains a dummy variable (i.e., a nominal variable with two categories)
named oecd that classifies countries into two groups, OECD member countries and nonmember
countries. One way to describe and summarize the information contained in a
nominal variable is to describe the distribution numerically. As we learned during the
past weeks, we describe the distribution of a nominal variable numerically by creating a
frequency table. Create a frequency table of this variable and store it into a data frame
object ft.oecd. The table has to have three columns: values (initially called “Var1”),
frequency (called “Freq”), and percentage (should be called “Percentage”). Change the
column name of the first column to “OECD Member?”.
3. According to the frequency table you created above, (A) how many countries in the data
set are OECD members? (B) How many countries in the data set are not? (C) What
percentage of countries are OECD members? (D) What percentage of countries are nonmembers?
Give me four answers (four numbers) as a comment. Note: for this task, you
1
don’t need an R command. Just read the table and tell me the numbers. Don’t forget to
comment them out.
4. Another way to describe and summarize a nominal variable is to draw a frequency distribution
graph. For nominal variables, we draw a bar chart. Using the functions available
in the ggplot2 package (e.g., geom bar), draw a bar chart of the dummy variable that
measures OECD membership.
• Hint 1: Don’t forget to load the package using the library function. It’s usually a
good idea to do so at the beginning of your R code file.
• Hint 2: Don’t forget to change the axis labels using the xlab and ylab options. The
appropriate label for the X axis would be “OECD membership”, whereas the label
for the Y axis could be “Number of countries”.
5. List three countries that are coded as OECD member states. List three countries that
are non-democratic according to the democracy dummy variable. Note: Again, you don’t
need a command for this one; I only need six country names.
6. The data set contains a numerical variable (interval-level variable) named gdp 10 thou
that records a country’s per capita GDP in 10,000 US dollars. Note that this variable
measures per capita GDP in 10,000 dollars, not in dollars. This means that, when this
variable takes a value of 4, for example, then that country’s per cpaita GDP is 40,000
dollars, not 4 dollars. Describe this variable numerically by calculating the following
statistics:
• Range (minimum and maximum), median, mean, 1st and 3rd quartile values (Hint:
this can be done at once with one command)
• Standard deviation (Hint: you need to take care of missing values using the na.rm
option)
Note: You need to provide R commands, not just numerical answers for this one.
7. It appears that the mean and the median of this per capita GDP variable are far apart:
the mean is 6,018 dollars whereas the median is 1,897 dollars. Given that the mean is
much higher than the median, the distribution of this variable is very skewed (i.e., not
symmetric). In which way does the skew go? Answer this question by choosing between
two options: (A) negatively skewed (skewed to the left) or (B) positively skewed (skewed
to the right). Note: Give me your answer in words, not in R commands.
8. Describe this per capita GDP variable graphically by drawing a histogram.
• Hint: Don’t forget to change the axis labels using the xlab and ylab options. The
appropriate label for the X axis would be “Per capita GDP (in 10,000 US dollars)”,
whereas the label for the Y axis could be “Number of countries”.
9. There are two countries in the data set whose per capita GDP is greater than 40,000 US
dollars. Identify these two countries. For this task, I need an R command that gives us
the name of the two countries. Your command will probably generate the <NA> symbols
(14 of them), along with the name of the two countries, but that’s fine.
10. We have calculated the sample mean of this per capita GDP variable in task 6. We
have also calculated its standard deviation. We also know from task 6 that there are 14
observations (countries) where this variable is missing, so we have 191 (total number of
countries in the data set) −14 = 177 observations (i.e., n = 177). Therefore, we have all
the building blocks to calculate the standard error of the mean. Calculate the standard
2
error (the answer should be 0.07091015). Note that I need R commands, not just the
numerical answer.
11. Using the calculated standard error and the mean value, construct the 95 % confidence
GV900留学生作业代写
interval of the sample mean of gdp 10 thou. For this, I need both R commands and the
numerical answer.
12. Draw histograms of per capita GDP variable, one for democracies and the other for nondemocracies.
• Hint 1: Use the democ regime variable to classify the countries into democracies and
non-democracies.
• Hint 2: Use the facet wrap option. For this task, you may actually have three
histograms (No, Yes, and NA), and that’s OK. We will correct it below.
13. We find (I mean, I find) a few things about this graph unsatisfactory. First, it is a little
bit aesthetically unpleasing that we have a blank graph on the far right. This happens
because there are missing values. Second, the labels “No” and “Yes” are not intuitive at
all (readers can’t know what “Yes” and “No” mean simply by looking at the graph). So
let’s now fix these two things. Create a new data frame named dem.gdp that excludes
those rows where the democ regime variable is missing. Use the is.na function for this.
Then, create a new variable dem.dum within this new data set, which has two nominal
values, “Democracy” and “Autocracy”, instead of “Yes” and “No”. Then, recreate the
histograms you drew in 12. It should look like the following:
Autocracy Democracy
0 1 2 3 4 5 0 1 2 3 4 5
0
10
20
30
Per capita GDP (in 10,000 US dollars)
Number of countries
14. The graph above appears to suggest that democracies tend to have higher per capita
GDP. Let’s document this relationship by calculating the mean value of per capita GDP
for each group. In doing so, report the 95 % confidence intervals as well. For task 14,
calculate the mean of per capita GDP for democracies, along with the 95 % confidence
interval. Please provide both the commands as well as the results (numbers).
15. Similarly, calculate the mean of per capita GDP for autocracies (non-democracies), along
with the 95 % confidence interval.
End of file

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或 微信:codehelp

GV900 Political Explanation的更多相关文章

  1. [REP]AWS Regions and Availability Zones: the simplest explanation you will ever find around

    When it comes to Amazon Web Services, there are two concepts that are extremely important and spanni ...

  2. False Discovery Rate, a intuitive explanation

    [转载请注明出处]http://www.cnblogs.com/mashiqi Today let's talk about a intuitive explanation of Benjamini- ...

  3. MSAA, UIA brief explanation

    MSAA, UIA brief explanation 2014-07-24 Reference [1] MSAA, UIA brief explanation [2] Testing Tools [ ...

  4. Explanation About Initilizing A DirextX3D Class 关于初始化Direct3D类的解释

    目录 DirectX11 Study Note Create a DirectX graphics interface factory.创建一个DirectX图形界面工厂 CreateDXGIFact ...

  5. [转]An Intuitive Explanation of Convolutional Neural Networks

    An Intuitive Explanation of Convolutional Neural Networks https://ujjwalkarn.me/2016/08/11/intuitive ...

  6. 每日英语:Political Gridlock, Beijing Style

    To admirers outside the country, China's political system stands far above the dysfunctional democra ...

  7. What is an intuitive explanation of the relation between PCA and SVD?

    What is an intuitive explanation of the relation between PCA and SVD? 36 FOLLOWERS Last asked: 30 Se ...

  8. Foundations of Machine Learning: The Margin Explanation for Boosting's Effectiveness

    Foundations of Machine Learning: The Margin Explanation for Boosting's Effectiveness 在这一节,我们要回答的一个问题 ...

  9. Spoken English Practice(Don't get me wrong, that explanation makes no difference, I'm still mad at you. Come on, be reasonable!)

    绿色:连读:                  红色:略读:               蓝色:浊化:               橙色:弱读     下划线_为浊化 口语蜕变(2017/7/11) ...

随机推荐

  1. python学习第一天第二天总结

    变量赋值 1, 变量由字⺟, 数字,下划线搭配组合⽽成 2, 不可以⽤数字开头,更不能是全数字 3,不能是pythond的关键字, 这些符号和字⺟已经被python占⽤, 不可以更改 4,不要⽤中⽂ ...

  2. 如何使用pm2一键部署node应用

    准备工作 准备一台linux服务器(本文档以阿里centos为例) 安装nodejs.git.pm2等环境 项目代码 本地已经安装用于连接 Linux 实例的工具,如 Xshell 基本流程 前两步传 ...

  3. vue 渐变 进度条 progress

    废话 不多少说 ,直接上代码 新建文件 gradual-progress.vue <!-- * @Author: gfc * @Date: 2019-11-07 14:00:11 * @Last ...

  4. Redisson实现分布式锁(3)—项目落地实现

    Redisson实现分布式锁(3)-项目落地实现 有关Redisson实现分布式锁前面写了两篇博客作为该项目落地的铺垫. 1.Redisson实现分布式锁(1)---原理 2.Redisson实现分布 ...

  5. ASP.NET MVC IOC依赖注入之Autofac系列开篇

    Autofac为IOC组件,实现控制反转,主要结合面向接口编程,完成较大程度的解耦工作. 使用IOC,必须面向接口编程,所谓的面向接口编程,即程序中依赖于抽象,而不依赖于具体实现. 需要所有的业务逻辑 ...

  6. Python切片中的误区与高级用法

    众所周知,我们可以通过索引值(或称下标)来查找序列类型(如字符串.列表.元组...)中的单个元素,那么,如果要获取一个索引区间的元素该怎么办呢? 切片(slice)就是一种截取索引片段的技术,借助切片 ...

  7. php中搭建Web服务器和服务器配置

    1.搭建Web服务器     1.1目录结构 1.2访问服务器 访问规则:http://服务器ip地址/php页面 比如: http://localhost/demo.php http://127.0 ...

  8. Oracle 去重后排序

    因项目需求,需要将查询结果,去重后,在按照主键(自增列)排序,百度一番,记录下来 DEMO SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY S ...

  9. 科技风商务项目管理PPT模板

    模板来源:http://ppt.dede58.com/peixunyanjiang/26267.html

  10. JDK内置工具命令

    javap Java反编译工具,主要用于根据Java字节码文件反汇编为Java源代码文件用法:javap 用法 描述 javap -help —help -? 输出此用法消息 javap -versi ...