Place your order now for a similar assignment and have exceptional work written by our team of experts, At affordable rates
For This or a Similar Paper Click To Order Now
R – Tables and plots
1. In this exercise you will use your final steps data to make tables that will be included in
your presentation.
2. Create a new R program and save it. I named mine R ex 8 code.R
3. You will need to access the packages:
library(stargazer)
library(broom.mixed)
library(tidyr)
library(ggstance)
library(ggplot2)
library(GGally)
library(jtools)
4. You will make a summary statistics table in stargazer. It will need to have a title and
should not include all of the summary stats in the default table. There are too many of
them. In your summary stats table include only the means, standard deviations, the min,
and the max. The number of observation should be noted in your presentation, but since
it is the same for all variables, it doesn’t belong in the table. You should include the
variables: steps, high, low, percip. You don’t need the day dummies. My code for this
table is
stargazer(d_stepsn2, type=”text”, title=”Table 1: Summary Statistics”,
digits = 1, digit.separator=””,
summary.stat=c(“mean”, “sd”, “max”, “min”),out = “summary stat table.doc”)
Note that my data frame is d_stepsn. I created a csv data file with only the variables I
wanted to include in summary stats (and some of the visualizations). I gave the variables
“full” names in this file. So, precipitation, not percip, high temperature, not high, and so
on. Stargazer puts a . in the blank in a name like high temperature, but you can take that
out in the word file table or the power point table. The column c(“mean”, …) tells
stargazer which stats to include. I also created a title, set the maximum number of digits
behind the decimal to 1, took out the “,” that it used when a number was in the thousands,
and outputted the table as a word document. Mine is below. I didn’t like some things, so
I changed them in the tables on the next page. You can edit directly in word, and then cut
and paste into power point.
Table 1: Summary Statistics
==========================================
Statistic Mean St. Dev. Max Min
——————————————
steps 6963.5 4491.3 18688 9
high.temperature 49.4 14.6 80 18
low.temperature 31.0 12.1 58 4
percipitation 0.1 0.3 2 0
——————————————
Table 1: Summary Statistics
==========================================
Variable Mean St Dev Max Min
——————————————
steps 6963.5 4491.3 18688 9
high temperature 49.4 14.6 80 18
low temperature 31.0 12.1 58 4
precipitation 0.1 0.3 2 0
——————————————
5. You will next create a ggpairs visualization. You created this plot during our in-class
exercise and in R exercise 5. The code is
ggpairs(d_steps[c(3,4,5,6)], columnLabels = c(“steps”, “high temperature”, “low
temperature”, “precipitation”), title = “Figure 1: Relationship Among Variables”)
The plot uses columns 3, 4, 5, and 6 in my steps data. Yours may be different. The
columnLabels option allows me to choose nice names. You can copy and paste your
output into a power point slide.
6. Run four regressions. Steps is the dependent variable in each regression. In one
regression have only high, in another have only precip, in another include both precip and
high, and in the last one include high, precip, and day dummy variables. These are your
basic regression results and you will make a “pretty” stargazer table to present them. The
code for my data is
stargazer(r_1, r_2,r_3,r_4,type=”text”,
digits=1, digit.separator=””,
title = “Table 2: Regression Results”,dep.var.caption=””,
covariate.labels = c(“high temperature”,
“precipitation”,”Monday”,”Tuesday”,”Wednesday”,
“Thursday”,”Friday”,”Saturday”),
omit.stat = c(“ser”,”n”), out= “reg results.doc”)
It’s a long piece of code. Pretty comes with a price. What do the options do?
digits – controls the number of digits behind the decimal
digit.separator = “” – tells R that I don’t want any separator for numbers in thousands (or
higher) so I want 3451 and not 3,451.
title – We have put titles in before
covariate.labels – allows me to use names the consumer of the table will understand more
readily. Monday instead of m or precipitation instead of precip.
omit.stat – allows me to omit stats. The stat ser is the standard error of the regression. It is in the
default R output, but unless you are going to use it for something, it is just a distraction. n is the
number of observations. n is the same for all of your regression. You can tell the consumer this
information in a footnote. My table is (see next page)
Table 2: Regression Results
==============================================================================================
steps
(1) (2) (3) (4)
———————————————————————————————-
high temperature 97.8*** 97.0*** 50.4**
(28.7) (29.2) (24.2)
precipitation -967.2 -244.1 -460.9
(1432.3) (1376.2) (1137.9)
Monday -3575.4***
(1212.0)
Tuesday 1170.3
(1240.0)
Wednesday -4085.3***
(1240.1)
Thursday -5651.1***
(1265.6)
Friday -6157.2***
(1275.4)
Saturday -5851.1***
(1203.5)
Constant 2134.6 7283.7*** 2207.7 7946.4***
(1538.1) (491.5) (1600.4) (1578.9)
———————————————————————————————-
R2 0.1 0.01 0.1 0.5
Adjusted R2 0.1 -0.01 0.1 0.4
F Statistic 11.6*** 0.5 5.8*** 9.8***
==============================================================================================
Note: Standard errors are in parentheses. The sample size is 92. *, **, *** indicate
significance at the 10%, 5%, and 1% levels, respectively.
I outputted the table as a word file and I did some editing in word. In particular, I made the
“Note” section at the bottom of the table prettier and more informative. Here is where I put the
sample size and I wrote out the meaning of *, **, and *** in words instead of throwing a p-value
at the consumer. I also told the consumer that standard errors are in parentheses. This is
important information because sometimes people put t-stats there. I had to use a very small font,
8.
7. The next visualization is the distribution of the coefficient estimates on high and precip in
the models with and without the dummies. We have created this visualization in an
earlier assignment. The code is
plot_summs(r_3,r_4,scale=TRUE, plot.distributions = TRUE,
coefs= c(“High Temp”=”high”, “Rain and Snow”=”precip”),
legend.title=”Distribution of Coefficient Estimates”,
model.names=c(“Without Day Dummies”, “with Day Dummies”), robust=TRUE)
I added some options for looks. Coefs allows me to make nicer names. Legend.title
allows for a more informative legend name than Models, and model names does the
same
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.