• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Analysis Factor

The Analysis Factor

Statistical Consulting, Resources, and Statistics Workshops for Researchers

  • our programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • statistical resources
  • blog
  • about
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • contact
  • login

graph

Member Training: How to Avoid Common Graphical Mistakes

by guest contributer 

Good graphs are extremely powerful tools for communicating quantitative information clearly and accurately.

Unfortunately, many of the graphs we see today confuse, mislead, or deceive the reader.

These poor graphs result from two key limitations. One is a graph designer who isn’t familiar with the principles of effective graphs. The other is software with a poor choice of default settings.

[Read more…] about Member Training: How to Avoid Common Graphical Mistakes

Tagged With: communicate results, formatting graphs, graph, graphics, graphing, quantitative research, software, Statistical Software, tables

Related Posts

  • Member Training: An Introduction into the Grammar of Graphics
  • Same Statistical Models, Different (and Confusing) Output Terms
  • Member Training: Communicating Statistical Results: When to Use Tables vs Graphs to Tell the Data’s Story
  • Member Training: Introduction to Stata Software Tutorial

Using the Collapse Command in Stata

by Jeff Meyer  12 Comments

Have you ever worked with a data set that had so many observations and/or variables that you couldn’t see the forest for the trees? You would like to extract some simple information but you can’t quite figure out how to do it.

Get to know Stata’s collapse command–it’s your new friend. Collapse allows you to convert your current data set to a much smaller data set of means, medians, maximums, minimums, count or percentiles (your choice of which percentile).

Let’s take a look at an example. I’m currently looking at a longitudinal data set filled with economic data on all 67 counties in Alabama. The time frame is in decades, from 1960 to 2000. Five time periods by 67 counties give me a total of 335 observations.

What if I wanted to see some trend information, such as the total population and jobs per decade for all of Alabama? I just want a simple table to see my results as well as a graph. I want results that I can copy and paste into a Word document.

Here’s my code:

preserve
collapse (sum) Pop Jobs, by(year)
graph twoway (line Pop year) (line Jobs year), ylabel(, angle(horizontal))
list

And here is my output:
image002
image004

By starting my code with the preserve command it brings my data set back to its original state after providing me with the results I want.

What if I want to look at variables that are in percentages, such as percent of college graduates, mobility and labor force participation rate (lfp)? In this case I don’t want to sum the values because they are in percent.

Calculating the mean would give equal weighting to all counties regardless of size.

Fortunately Stata gives you a very simple way to weight your data based on frequency. You have to determine which variable to use. In this situation I will use the population variable.

Here’s my coding and results:

Preserve
collapse (mean) lfp College Mobil [fw=Pop], by(year)
graph twoway (line lfp year) (line College year) (line Mobil year), ylabel(, angle(horizontal))
list

image006
image008
It’s as easy as that. This is one of the five tips and tricks I’ll be discussing during the free Stata webinar on Wednesday, July 29th.

Jeff Meyer is a statistical consultant with The Analysis Factor, a stats mentor for Statistically Speaking membership, and a workshop instructor. Read more about Jeff here.

Tagged With: collapse, graph, preserve, Stata

Related Posts

  • Stata Loops and Macros for Large Data Sets: Quickly Finding Needles in the Hay Stack
  • Using Stored Calculations in Stata to Center Predictors: an Example
  • Loops in Stata: Making coding easy
  • Statistical Software Access From Home

R Graphics: Plotting in Color with qplot Part 2

by guest contributer  1 Comment

by David Lillis, Ph.D.

In the last lesson, we saw how to use qplot to map symbol colour to a categorical variable. Now we see how to control symbol colours and create legend titles.
[Read more…] about R Graphics: Plotting in Color with qplot Part 2

Tagged With: colors, ggplot2, graph, plots, plotting, qplot, R

Related Posts

  • R Graphics: Plotting in Color with qplot
  • Doing Scatterplots in R
  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots
  • Graphing Non-Linear Mathematical Expressions in R

R Graphics: Plotting in Color with qplot

by guest contributer  1 Comment

by David Lillis, Ph.D.

In this lesson, let’s see how to use qplot to map symbol colour to a categorical variable.

Copy in the following data set (a medical data set relating to patients in a randomised controlled trial):

[Read more…] about R Graphics: Plotting in Color with qplot

Tagged With: colors, graph, plots, plotting, qplot, R

Related Posts

  • R Graphics: Plotting in Color with qplot Part 2
  • Doing Scatterplots in R
  • Graphing Non-Linear Mathematical Expressions in R
  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots

Doing Scatterplots in R

by guest contributer  1 Comment

by David Lillis, Ph.D.

In this lesson, we see how to use qplot to create a simple scatterplot.

The qplot (quick plot) system is a subset of the ggplot2 (grammar of graphics) package which you can use to create nice graphs. It is great for creating graphs of categorical data, because you can map symbol colour, size and shape to the levels of your categorical variable. To use qplot first install ggplot2 as follows:
[Read more…] about Doing Scatterplots in R

Tagged With: graph, plots, plotting, R

Related Posts

  • R Graphics: Plotting in Color with qplot Part 2
  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots
  • R Graphics: Plotting in Color with qplot
  • Graphing Non-Linear Mathematical Expressions in R

Graphing Non-Linear Mathematical Expressions in R

by guest contributer  1 Comment

by David Lillis, Ph.D.

In Part 20 of this series, let’s see how to create mathematical expressions for your graph in R.  We’ll use an example of graphing a cosine curve, along with relevant Greek letters as the axis label [Read more…] about Graphing Non-Linear Mathematical Expressions in R

Tagged With: expressions, graph, mathematical, nonlinear, plots, plotting, R

Related Posts

  • R Graphics: Plotting in Color with qplot Part 2
  • R Graphics: Plotting in Color with qplot
  • Doing Scatterplots in R
  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • Member Training: Moderated Mediation, Not Mediated Moderation

Upcoming Workshops

    No Events

Upcoming Free Webinars

TBA

Quick links

Our Programs Statistical Resources Blog/News About Contact Log in

Contact

Upcoming

Free Webinars Membership Trainings Workshops

Privacy Policy

Search

Copyright © 2008–2023 The Analysis Factor, LLC.
All rights reserved.

The Analysis Factor uses cookies to ensure that we give you the best experience of our website. If you continue we assume that you consent to receive cookies on all websites from The Analysis Factor.
Continue Privacy Policy
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT