# How to set up a single continuous independent variable for a repeated measures linear model?

I'm doing an education study and I'm trying to see the effect of website usage on quiz scores in a class of college students. There were 30 students in the class and they took 10 weekly quizzes over the course of the semester. They also had a website where they could log in and use a study tool. The website kept track of the time they were online.

So my dependent variable is quiz score (continuous) and my predictor variable is website usage over the previous seven days (also continuous).

My first instinct was to make a 300-line database, matching up each quiz score with the amount of website usage in the preceding week, and then run a regression. But I can't really do that, can I? Instead of 300 independent measurements, I really have 10 repeated measurements on 30 subjects.

So I tried using "General Linear Model > Repeated Measures" in SPSS, but I can't figure out how to tell the program that all those columns for website usage are a single, continuous predictor variable.

Any guidance? Am I on the right track here? Or should I be using a different analysis altogether?

• You can't do this in SPSS with repeated measures. You need to do a multilevel model to be able to do this. You can do that in SPSS mixed models, which will allow you to have two columns and specify an ID variable, which identifies individuals. – Jeremy Miles Apr 4 '13 at 22:20
• Well these are different quizzes though, right? So I don't really see this as repeated measurement since ostensibly, you'd want to know the information separately for the different quiz topics. Perhaps a fixed effects model would be better here. – RickyB Apr 5 '13 at 0:47
• @Gareth, for the future: don't confuse "general linear model" and "generalized linear model" when tagging your question – ttnphns Apr 5 '13 at 4:52
• @RichardBlissett - Good point, I didn't think of that. You'd want to control for it, but it's probably not interesting. – Jeremy Miles Apr 5 '13 at 5:44
• @JeremyMiles and RichardBlissett Hmm... Let me give a bit more info and see what you both think about the repeated measures question. It was a plant recognition class. Every week the students learned about 20 new plants in the field and every week they took an in-class quiz on their ability to recognize and name about 15 of those plants. The website helped them practice recognition. So I saw it as a repeated measures situation because each student was essentially doing the same task 10 times - learning a new batch of plants and naming them on a test. What do you think? – Gareth Keenan Apr 5 '13 at 10:46

The tests are repeated, but they're not really repeated measures, because you're not (I don't think) interested in the differences between the tests.

You're interested in the relationship between website usage and test scores, but the tests are non-independent, because the same people did them. So if you set your data up in one long column, something like:

ID Test Web  Y
1   1   10   8
1   2    7  15
...
30  10   8   6


You can test the relationship with mixed (multilevel) model. The SPSS menus are completely non-intuitive (IMHO), but the syntax is relatively straightforward.

I believe your syntax will then be something like:

mixed Y by test with web
/print=solution
/fixed = test web
/random intercept | subject(ID) .


You're saying that Y is predicted by the test itself (some will be harder, some easier) and the web time score. Test and web are fixed effects, and people will have varying (random) intercepts, which you'd also like to take into account.

You might also run:

mixed Y by test with web
/print=solution
/fixed = test web
/random intercept web | subject(ID) .


Which adds a random factor for web - that is, it allows the relationship between web and Y to vary between individuals.

It's a while since I've used SPSS, so this code is untested and probably not error-free. Andy Field's book "Discovering Statistics Using SPSS" has a nice chapter on multilevel models in SPSS - it might be worth looking at that, or at any other sources you like - you can find lots of examples with your favorite web search engine.

Edit: Also, I wonder if it's worth thinking about fixed effects regression. Comparing random effects and fixed effects is straightforward in Stata, using xtreg, not sure about SPSS.

• I'm sure you're on the right track here, but I don't see understand why test and ID aren't treated the same way. Can you clarify? – Gareth Keenan Apr 5 '13 at 17:12
• What I mean to ask is this: It seems to me that within the 10 scores for a single student I have to control for the different difficulties of the tests. And within the 30 scores for each test I have to control for the different abilities of the students. So, within the 300 pairs of web and Y, Test and ID are both categories that can shift the intercept up or down. But once I've controlled for those two categorical effects, I should be able to see a linear response between a continuous predictor (web) and a continuous response (Y). Is that what you set up? – Gareth Keenan Apr 5 '13 at 17:27
• Yes (is the short answer). By putting random intercept |subject(ID) I've allowed every student to have their own intercept. So students are assumed sampled from a population of students; and we assume that these intercepts are normally distributed. Test is controlled for by entering it as a dummy variable - we are not making any assumption about the distribution of these averages - these are just the bunch of tests we're interested in (so test is fixed). – Jeremy Miles Apr 5 '13 at 18:13