Karen Grace-Martin

How to Effortlessly Create SPSS Syntax and Automatically Add it to your Output

October 16th, 2009 by

So hopefully I’ve extolled the benefits of using SPSS Syntax enough that you’re convinced it is something you should regularly use.

Even if you don’t start programming, there are two things you can do to begin learning Syntax and give you the communication and tracking benefits.

1. From now on, when you use menus for an analysis, instead of clicking the “OK” button, click “Paste.”*

When you use the menus and click OK, SPSS is translating your menu choices into syntax.  You just don’t see it.

When you click Paste, though, SPSS opens a syntax window and writes a copy of this syntax.  To run it, simply go to the Syntax window, highlight the procedure you want to run, and click the Run button, which looks like a triangle facing right.

This will get you used to the kind of language SPSS Syntax uses. You can, if you wish, start to edit it.

But even if you don’t, over time you’ll start to notice how logical it is and how the menu choices correspond to phrases in the syntax. And you’ll (more…)


The 3 Stages of Mastering Statistical Analysis

October 14th, 2009 by

Like any applied skill, mastering statistical analysis requires:

1. building a body of knowledge

2. adeptness of the tools of the trade (aka software package)

3. practice applying the knowledge and using the tools in a realistic, meaningful context.

If you think of other high-level skills you’ve mastered in your life–teaching, survey design, programming, sailing, landscaping, anything–you’ll realize the same three requirements apply.

These three requirements need to be developed over time–over many years to attain mastery. And they need to be developed together. Having more background knowledge improves understanding of how the tools work, and helps the practice go better. Likewise, practice in a real context (not perfect textbook examples) makes the knowledge make more sense, and improves skills with the tools.

I don’t know if this is true of other applied skills, but from what I’ve seen over many years of working with researchers as they master statistical analysis, the journey seems to have 3 stages. Within each stage, developing all 3 requirements–knowledge, tools, and experience–to a level of mastery sets you up well for the next stage. (more…)


5 Reasons to use SPSS Syntax

October 7th, 2009 by

You don’t rely on only SPSS menus to run your analysis, right?  (Please, please tell me you don’t).

There’s really nothing wrong with using the menus.  It’s a great way to get started using SPSS and it saves you the hassle of remembering all that code.

But there are some really, really good reasons to use the syntax as well.

 

1. Efficiency

If you’re figuring out the best model and have to refine which predictors to include, running the same descriptive statistics on a  bunch of variables, or defining the missing values for all 286 variable in the data set, you’re essentially running the same analysis over and over.

Picking your way through the menus gets old fast.  In syntax, you just copy and paste and change or add variables names.

A trick I use is to run through the menus for one variable, paste the code, then add the other 285. You can even copy the names out of the Variable View and paste them into the code. Very easy.

2. Memory

I know that while you’re immersed in your data analysis, you can’t imagine you won’t always remember every step you did.

But you will.  And sooner than you think.

Syntax gives you a “paper” trail of what you did, so you don’t have to remember. If you’re in a regulated industry, you know why you need this trail. But anyone who needs to defend their research needs it.

3. Communication

When your advisor, coauthor, colleague, statistical consultant, or Reviewer #2 asks you which options you used in your analysis or exactly how you recoded that variable, you can clearly communicate it by showing the syntax.  Much harder to explain with menu options.

When I hold a workshop or run an analysis for a client, I always use syntax.  I  send it to them to peruse, tweak, adapt, or admire.  It’s really the only way for me to show them exactly what I did and how to do it.

If your client, advisor, or colleague doesn’t know how to read the syntax, that’s okay. Because you have a clear answer of what you did, you can explain it.

4. Efficiency again

When the data set gets updated, or a reviewer (or your advisor, coauthor, colleague, or statistical consultant) asks you to add another predictor to a model, it’s a simple matter to edit and rerun a syntax program.

In menus, you have to start all over. Hopefully you’ll remember exactly which options you chose last time and/or exactly how you made every small decision in your data analysis (see #2: Memory).

5. Control

There are some SPSS options that are available in syntax, but not in the menus.

And others that just aren’t what they seem in the menus.

The menus for the Mixed procedure are about the most unintuitive I’ve ever seen.  But the syntax for Mixed is really logical and straightforward.  And it’s very much like the GLM syntax (UNIANOVA), so if you’re familiar with GLM, learning Mixed is a simple extension.

Bonus Reason to use SPSS Syntax: Cleanliness

Luckily, SPSS makes it exceedingly easy to create syntax.  If you’re more comfortable with menus, run it in menus the first time, then hit PASTE instead of OK.  SPSS will automatically create the syntax for you, which you can alter at will.  So you don’t have to remember every programming convention.

When refining a model, I often run through menus and paste it.  Then I alter the syntax to find the best-fitting model.

At this point, the output is a mess, filled with so many models I can barely keep them straight.  Once I’ve figured out the model that fits best, I delete the entire output, then rerun the syntax for only the best model.  Nice, clean output.

The Take-away: Reproducibility

What this all really comes down to is your ability to confidently, easily, and accurately reproduce your analysis. When you rely on menus, you are relying on your own memory to reproduce. There are too many decisions, judgments, and too many places to make easy mistakes without noticing it to ever be able to rely totally on your memory.

The tools are there to make this easy. Use them.

 


The First Three Steps to Performing Any Statistical Model: Define and Design Webinar

September 29th, 2009 by

The next webinar in the Craft of Statistical Analysis series is:

The First Three Steps to Performing Any Statistical Model: Define and Design

All statistical modeling–whether ANOVA, Multiple Regression, Poisson Regression, Multilevel Model–is about understanding the relationship between independent and dependent variables. The first 3 steps in modeling set up the entire rest of the analysis.

This webinar will go into more detail on these first three steps:

1. Write out research questions in theoretical and operational terms

2. Design the study or define the design

3. Choose the variables for answering research questions and determine their level of measurement

It is the way you do these three steps that determines the rest of the analysis. Doing them explicitly and doing them well can save you days of time and endless frustration.

This webinar has already taken place, but the recording of it is available in our Statistically Speaking membership program.

**********************************************

What’s a The Craft of Statistical Analysis Webinar?  It’s a regular webinar series for researchers to help you hone the craft of statistical analysis.  Each webinar is about a single statistical topic that is often confusing, misunderstood, or not well known to researchers.  Check it out and pass the word along–they’re free!

 

 


A Resource for SPSS Algorithms

September 25th, 2009 by

As a data analyst, you will occasionally need to know how your software package is calculating the statistics.

SPSS makes the algorithms for many of its tests available at:

IBM SPSS Documentation

> Here it is for SPSS 28

Don’t expect them to be user-friendly if you’re not a statistician–these are the actual equations SPSS is using.   But some have more detailed explanations than others, and sometimes you just need to make sure that the equation that SPSS is using is indeed the same one that your nicely detailed text is so nicely describing.  This can be really useful when there are different versions of a test.

 


6 Types of Dependent Variables that will Never Meet the Linear Model Normality Assumption

September 17th, 2009 by

The assumptions of normality and constant variance in a linear model (both OLS regression and ANOVA) are quite robust to departures.  That means that even if the assumptions aren’t met perfectly, the resulting p-values will still be reasonable estimates.

But you need to check the assumptions anyway, because some departures are so far off that the p-values become inaccurate.  And in many cases there are remedial measures you can take to turn non-normal residuals into normal ones.

But sometimes you can’t.

Sometimes it’s because the dependent variable just isn’t appropriate for a linear model.  The (more…)