Skip to content

testing for temperature differences between years and sites?

2 messages · Jim Lemon, swertie

#
On 01/31/2012 11:34 PM, swertie wrote:
Hi swertie,
Let's say you have monthly temperature readings for four sites:

mon_temp<-data.frame(site=rep(LETTERS[1:4],48),
  year=rep(2008:2011,each=48),month=rep(month.abb,each=4),
  temp=20+rnorm(192)+
  10*sin(rep(rep(seq(1.5*pi,3.5*pi,length.out=12),each=4,4))))

Having gotten some data, you can then display a line plot of the 
temperatures for the sites:

plot(mon_temp$temp[mon_temp$site=="A"],type="b",xaxt="n",ylim=c(0,40),
  main="Temperature by site",xlab="Year",ylab="Temperature")
axis(1,at=seq(6,42,by=12),labels=2008:2011)
lines(mon_temp$temp[mon_temp$site=="B"],type="b",pch=2,col=2)
lines(mon_temp$temp[mon_temp$site=="C"],type="b",pch=3,col=3)
lines(mon_temp$temp[mon_temp$site=="D"],type="b",pch=4,col=4)
legend(24,40,LETTERS[1:4],pch=1:4,col=1:4)

Unless you have some reason to think that the sites vary in some way 
that would affect temperature, for instance altitude, using site as a 
factor in an overall model might not get you much. Also you may want to 
test yearly averages, as there is a strong seasonal component. Thus you 
might want to think about a time series model.

Jim
#
Thank you very much! This is the kind of plot I tried to do. 
For the statistical models, I am a bit confused between which factors to put
as fixed or random effects. I will have a look at time series models as you
suggested. 

swertie

--
View this message in context: http://r.789695.n4.nabble.com/testing-for-temperature-differences-between-years-and-sites-tp4344311p4347278.html
Sent from the R help mailing list archive at Nabble.com.