Regular expression for searching “near” text (i.e., within X words)

The Chrome function for finding text on a webpage (Ctrl-F) is fine, but it doesn’t allow finding one word “near” another one. For example, if the text on the page has many instances of “this” and many instances of “that,” using Ctrl-F to find a spot where it says “this and also that” is tedious.

The Chrome plug-in “Regex Search” allows regular expressions for searching the text on a webpage. Regular expressions are powerful, but they can be a pain to create.

Continue reading “Regular expression for searching “near” text (i.e., within X words)”

Consumer Behavior Case Exam

This file is an old exam for my MBA Consumer Behavior class.  The exam consists of one short case and two essay questions. I created the case to be amenable to a variety of different consumer behavior exam questions.

– Eric DeRosia

SPSS code for calculating the confidence interval of a Pearson correlation

For some reason, SPSS does not offer an option to calculate the confidence interval of an observed value of a Pearson correlation. SAS does it, and so does Stata. But SPSS doesn’t do it. Of course, SPSS will calculate the correlation itself. However, it will not calculate the confidence interval of the correlation.

The SPSS syntax below calculates the confidence interval.  I’ve drawn on some code from the SPSS website; I’ve made the code easier to use and the results easier to interpret. I have verified the calculations against what I get using Stata, and the syntax calculates the confidence intervals correctly.
Continue reading “SPSS code for calculating the confidence interval of a Pearson correlation”

Basic Statistics — Study Materials and Practice Quiz

Some of the students in my marketing research class are a little rusty on inferential statistics. For most students, it’s something they’ve mastered in the past, but without practice it’s easy to forget the answers to questions like these:

  • What is the difference between a standard error and a standard deviation?
  • How should you interpret a histogram?
  • How can you tell whether a variable is binomial or multinomial?

To remind students about these concepts, I give my marketing research students a quiz on basic statistics. To help students prepare for the quiz, Continue reading “Basic Statistics — Study Materials and Practice Quiz”

VBA code for performing many searches-and-replaces in an Excel file

I had a long list of search-and-replace tasks that I needed to do on a text file. I wanted an easy-to-use tool, so I put together something in Excel using VBA. The tool starts with a “BEFORE replacing” worksheet and then creates an “AFTER replacing” worksheet. The replacements are performed based on a “Definitions of Replacements” worksheet, which directs the macro to replace everything in the first column with a paired item in the second column.
Continue reading “VBA code for performing many searches-and-replaces in an Excel file”