[R] How can I get seasonal variation table from generalized additive mixed models in R?
kmmoon100
k.moon at student.unimelb.edu.au
Tue Nov 19 03:29:08 CET 2013
Hello everyone,
I used a function called gamm in mgcv in R program to investigate seasonal
variation of wind speed based on 13 years of measurement dataset. I would
like to use this variation in my formula for my study but as I am new in R,
it's extremely hard to find values on y-axis.. too many sub-directories of
gamm values make me hard to find what directory was actually used for
y-axis.
My data set is like this below:
time /day.of.year/ month /day.of.month /year / WindSpeed
1 1 7 24 2000 23.429
2 2 7 25 2000 29.170
3 3 7 26 2000 16.813
4 4 7 27 2000 15.271
5 5 7 28 2000 10.125
6 6 7 29 2000 13.938
7 7 7 30 2000 15.854
8 8 7 31 2000 10.438
9 9 8 1 2000 7.125
. . . . . .
. . . . . .
As time stamps are separated, I combined all of them first and then ran
additive modelling to look at seasonal and yearly trends of 13 years of wind
data.
My R codes are described below:
ballarat <- read.csv("ballarat seasonal daily.csv", header=TRUE, sep=",")
ballarat1 <- within(ballarat, Date <- as.Date(paste(year, month,
day.of.month, sep = "-")))
plot(WindSpeed ~ Date, data = ballarat1, type = "l")
mod <- gamm(WindSpeed ~ s(day.of.year, bs = "cc") + s(time, bs =
"cr"),
data = ballarat1, method = "REML",
correlation = corAR1(form = ~ 1 | year),
knots = list(day.of.year = c(0, 366)))
summary(mod$gam)
plot(mod$gam, pages = 1)
http://i.stack.imgur.com/wU0AU.jpg
>From the link page of trend graphs, You can see that average wind speed has
about +- 2 km/hr variation. I would like to produce tables (two columns
(first column: x axis values, second column: y axis (variations)) each day
of year) of those two graphs. I assume I need to use gam.predict to get
tables of the prediction? As I am new in R, I still can't understand how I
can make it work even after reading description of ?gam.predict function.
Could you please show me how to do it step by step?
Regards,
Kangmin.
--
View this message in context: http://r.789695.n4.nabble.com/How-can-I-get-seasonal-variation-table-from-generalized-additive-mixed-models-in-R-tp4680710.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list