Skip to content

lme() direction

6 messages · Michael Lawrence, Dieter Menne

#
Hi guRus,

I'm looking for advice on a good way to approach analysis of some
multi-level data I've obtained. I had humans classify words and
measured response time. Words were 10 positive words ("happy", "joy",
etc) and 10 negative words ("sad","grumpy", etc). Words were also
presented in either white, red or green color. All variables were
manipulated within-Ss and for each word-color combination I collected
10 observations.

So the data would be something like:

set.seed(1)
a=rbind(
	cbind(
		type='positive'
		,expand.grid(
			id=1:10
			,color=c('white','red','green')
			,word=c('happy','joy')
			,repetition = 1:10
		)
	)
	,cbind(
		type='negative'
		,expand.grid(
			id=1:10
			,color=c('white','red','green')
			,word=c('sad','grumpy')
			,repetition = 1:10
		)
	)
)

#add some fake rt data
a$rt=rnorm(length(a[,1]))

#And because people make errors sometimes:
a$error = rbinom(length(a[,1]),1,.1)

#remove error trials because they're not psychologically interesting:
a=a[a$error==0,]


I'm most interested in the interaction between color and type, but I
know that there is likely an effect of word. Yet since word is not
completely crossed with type, simply adding it to an aov() won't work.
A colleague recommended I look into lme() but so far I can't figure
out the proper call.

Another issue is whether to collapse across repetition before running
the stats, particularly since errors will leave unequal numbers of
observations per cell if it's left in.

Any advice anyone can provide would be great!

Mike
#
Mike Lawrence <mike <at> thatmike.com> writes:

Thanks for the excellent reproducible sample set!
Without word, it would be

summary(lme(rt~type*color, data=a,random=~1|id))

With the interaction, the extreme would be 
summary(lme(rt~type*color*word, data=a,random=~1|id))

or, less extreme

summary(lme(rt~type*color+color:word, data=a,random=~1|id))

but all these fail because of the rather degenerate structure 
of you data set. While lmer in package lme4 allows for a wider
set of solutions, I currently do not see how it could help,
but I might be wrong with p=0.5.


               word happy joy sad grumpy
type     color                          
positive white         93  90   0      0
         red           90  88   0      0
         green         88  87   0      0
negative white          0   0  88     95
         red            0   0  91     85
         green          0   0  88     88
That's one of the points where you have little to bother with the lme
approach. Collapsing would give equal weights to unequal numbers of
repeat, and might of minor importance when not too extreme, though.

Dieter


set.seed(1)
a=rbind(
	cbind(
		type='positive'
		,expand.grid(
			id=1:10
			,color=c('white','red','green')
			,word=c('happy','joy')
			,repetition = 1:10
		)
	)
	,cbind(
		type='negative'
		,expand.grid(
			id=1:10
			,color=c('white','red','green')
			,word=c('sad','grumpy')
			,repetition = 1:10
		)
	)
)

#add some fake rt data
a$rt=rnorm(length(a[,1]))

#And because people make errors sometimes:
a$error = rbinom(length(a[,1]),1,.1)

#remove error trials because they're not psychologically interesting:
a=a[a$error==0,]

library(nlme)
ftable(a[,c(1,3,4)])
summary(lme(rt~type*color, data=a,random=~1|id))
#
Would it improve things if "type" were a continuous variable rather
than categorical? I chose words at the extreme ends of a valence
rating scale but I still have the raw valence ratings for each word.

On Sat, Feb 7, 2009 at 12:02 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:

  
    
#
Mike Lawrence <mike <at> thatmike.com> writes:
..
Something like

summary(lme(rt~type*color+color:as.numeric(word), data=a,random=~1|id))

(please replace as.numeric() by the raw valence, the example above it
simply wrong)

could gain you a few degrees of freedom if you are willing to accept the 
linear hypothesis. And as there is something like raw valence, one should
not throw away details about a-priori ordering in favor of a categorical
hypothesis.

Dieter
#
And if I decided to ignore the "type" variable altogether and simply
use the continuous "valence" variable, this is what I'd use?

summary(lme(
	fixed = rt~valence*color
	, data = a
	,random = ~1|id
))

I also have continuous luminance measurements of each color that vary
from participant to participant (we used different monitors). If I
were interested in luminance *instead* of color, would the following
be appropriate, or do I need to do something special to account for
the fact that each participant has different values of luminance?

summary(lme(
	fixed = rt~valence*luminance
	, data = a
	,random = ~1|id
))


On Sat, Feb 7, 2009 at 12:34 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:

  
    
#
Mike Lawrence <mike <at> thatmike.com> writes:
Both might be appropriate, but be sure to understand the implications.
Both valence and luminance now are to be interpreted as slopes.
Since slope-interactions are a bit awkward to interpret, I would 
prefer to start with

fixed = rt~valence+luminance
fixed = rt~valence*luminance-valence:luminance

Both mean the same, the latter is ridiculous here, but may be useful
when you have more terms to remove higher ones. Also look at the 
meaning of ^2, and the difference of I()^2.

You might have a look at stepwise procedures in stepAIC, even if
in my field there are good reasons to avoid this type of model
selection.

It can be tricky to explain slope interactions in papers, but it's
probably easier in psychology where people are ready to accept
models than in medicine, were everything beyond a t-test is frowned
upon by reviewers.

Dieter