# Defining a simple linear regression of reaction times against stimulus number

I have reaction times for each of nine stimuli (the stimuli being the numbers 1 to 9), all 9 variables being arranged as columns, and with subjects across rows. I would like to regress those scores (Y) against their respective numbers (X), but have trouble understanding how to define this regression in my stats package (Statistica), whose help suggests that each of the two variables (X and Y) should be selected from the variables list. X in my case would just be the numbers 1 to 9, whereas Y would be each of the 9 columns (variables).

How should this simple regression be defined? Should it be a special type of regression given that the X variable is really categorical rather than continuous? Thanks!

• Thanks Nick, your description of the dataset is correct, basically each subject has a certain mean reaction time (Y, expressed in ms) for each condition (X=1 through 9). Although I've never done regression in Statistica before, I think that a table like the one you described would probably allow me to get a mean regression slope for the dataset, but the problem is that (I thought) having repeated measures across rows is not statistically correct. Is this where I am wrong? This is the reason why I had each of the 9 means arranged as columns as opposed to making a dummy variable out of it. – z8080 Jul 21 '14 at 23:36

## 1 Answer

Since you've confirmed my interpretation, here's how I'd arrange the data as per my comment:\begin{array}{rcl}\rm Subject\ ID&X&Y\\\hline1&1&Y_{1,1}\\1&2&Y_{1,2}\\&...\\2&1&Y_{2,1}\\&...\\n&9&Y_{n,9}\end{array}‌​Your $X$ is nested within subjects. With a hierarchical linear model, you can control subject variance in $Y$ that's unrelated to $X$ and also estimate whether $X$ relates to $Y$ differently for different subjects (i.e., model individual differences as a moderator, effectively). I've never used Statistica before, but it looks like StatSoft covers the details well; see Basic Example 5: Mixed-Model Nested ANOVA Design.

If $X$ is ordered (e.g., $1<2<...<9$), you might also want to consider penalized regression, which I've described in previous posts. I'm not certain the penalization method can smooth ordinal dummy coefficients in a multilevel model, but I also don't see why not. The motivation would be to reduce overfitting of big differences among adjacent levels of $X$, as may arise due to sampling error.

• Thanks Nick! I was wondering also, what about calculating the betas for each subject, and then just doing a one-sample t-test to see if it is significatly different from zero? – z8080 Jul 23 '14 at 9:15
• But doesn't each subject only have one observation of $Y$ per level of $X$? You'd only get one $\beta$ per subject based on 9 observations each, right? I don't think these would be as accurate as what you would get from a hierarchical linear model. Moreover, there's no guarantee that they'd fit the assumptions of a one-sample t-test...Is this just a way around figuring out how to do HLM, or are there other reasons to do what you propose? – Nick Stauner Jul 23 '14 at 9:21
• Sorry, I should have made it more clear: there are several (about 5 I think) observations of Y per level of X, so there would be some accuracy, although probably not as much as you'd obtain from the HLM. Basically, my data can be plotted something like this - goo.gl/bA2R9i, where error bars denote between-subject variability and each subject's mean for a given value of X comes from averaging several observations. I need to see if the regression line Y=f(X) is significantly different from zero. Sorry if I've explained this poorly. – z8080 Jul 23 '14 at 9:56
• Oh, yeah, that's interesting. You could also control for order of observations within levels of $X$ (and within subjects) then. Maybe more trouble than it's worth to you though. I'm not sure how your simpler alternative would compare. It might work, but it doesn't strike me as appropriate, so proceed with it at your own risk if you wish. HLM might give you richer and clearer info, but I'll admit I haven't even performed it yet myself – I've only studied it. It is a little tricky. – Nick Stauner Jul 23 '14 at 10:04