canWeather: Canadian Weather data

Description Usage Format Details Source References Examples

Description

Data on temperature throughout the year at 35 Canadian locations, originally form the fda package.

Usage

1
data(canWeather)

Format

The CanWeather data frame has the following 5 columns

time

Day of year from 1 to 365.

T

Mean temperature for that day in centigrade.

region

A four level factor classifiying locations as Arctic, Atlantic, Continental or Pacific.

latitude

Degrees north of the equator.

place

A factor with 35 levels: the names of each locagtion.

Details

The data provide quite a nice application of function on scalar regression. Note that the data are for a single year, so will not generally be cyclic.

Source

Data are from the fda package.

https://cran.r-project.org/package=fda

References

Ramsay J.O. and B.W. Silverman (2006) Functional data analysis (2nd ed). Springer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require(gamair);require(mgcv)
data(canWeather)
reg <- unique(CanWeather$region)
place <- unique(CanWeather$place)
col <- 1:4;names(col) <- reg
for (k in 1:35) {
  if (k==1) plot(1:365,CanWeather$T[CanWeather$place==place[k]],
            ylim=range(CanWeather$T),type="l",
	    col=col[CanWeather$region],xlab="day",ylab="temperature") else
	    lines(1:365,CanWeather$T[CanWeather$place==place[k]],
            col=col[CanWeather$region[CanWeather$place==place[k]]])
}

## Function on scalar regression.
## T(t) = f_r(t) + f(t)*latitude + e(t)
## where e(t) is AR1 Gaussian and f_r is
## a smooth for region r.
## 'rho' chosen to minimize AIC or (-ve) REML score. 

b <- bam(T ~ region + s(time,k=20,bs="cr",by=region) +
         s(time,k=40,bs="cr",by=latitude),
         data=CanWeather,AR.start=time==1,rho=.97)

## Note: 'discrete==TRUE' option even faster.

par(mfrow=c(2,3))
plot(b,scale=0,scheme=1)
acf(b$std)

gamair documentation built on Aug. 23, 2019, 5:03 p.m.