On Fri, Sep 21, 2012 at 3:45 PM, David Winsemius [via R] <ml-node+s789695n4643876...@n4.nabble.com> wrote: > > On Sep 21, 2012, at 7:17 AM, MichelleNCSU wrote: > >> Hello, >> >> First of all, let me apologize that my statistics background is modest at >> best. >> >> I am doing some extreme value analysis on model output (WRF) which have >> the >> following dimensions: >> >> speed(time,lat,lon) > > How is this object structured? Are there multiple time layers where speed is > measured at lat-lon points are successive times?
The object is over space and time. It is model output from the atmospheric science modeling tool WRF (http://www.mmm.ucar.edu/wrf/users/) The data is constructed in 3-dimensions where the wind speed has the dimensions (time, lat lat). There are 67 times with 106 and 193 points lat and lon at each time. This is why I was trying to index it to ensure I am able to perform the task at each grid point. > >> >> I am trying to fit the GPD (gpd.fit) to each point (time,lat,lon) to get a >> return level plot with values at each grid point. (Map with return level >> by >> location.) > > I'm not really sure conducting extreme value analysis is a safe procedure > when your stats background is "modest at best". I have been consulting with a professor in the Statistics department who is an expert in extreme value analysis. What I am doing is "safe", I just can't seem to get it working correctly. I will also run the procedure by her before I publish any research since I do not have a statistics background. > >> >> Here is some code I tried, following similar structure to languages I'm >> more >> familiar with, but it isn't working. >> >> Y = as.matrix(time,lat,lon) > > This suggests to me that you come from a different computing universe where > the as.matrix() function allows multiple objects (presumably vectors) to be > placed "side-by-side" and have a matrix object returned. (In this computing > universe that role is played by the cbind function.) Perhaps: > > Y = cbind(time,lat,lon) # "c" standing for column > I apologize, I was under the impression from previous help that the as.matrix() was the correct way to do this. I frequently use FORTRAN, NCL, MATLAB etc. R is still relatively new to me and most of what I have worked with is 1-D data in this program. When I try the Y = cbind(time,lat,lon) I receive the following error: Warning message: In cbind(time, lat, lon) : number of rows of result is not a multiple of vector length (arg 1) >> >> for (t in 1:67) >> + for (j in 1:106) >> + for (i in 1:193) >> + fit(t,j,i)<-gpd.fit(speed(t,j,i), threshold=17,ydat = Y) >> >> I receive errors at this point, and cant figure out how to get individual >> fits at each grid point. > > It's a puzzle to me why you think that passing a single point to a > regression function will allow any solution. I did a "??" search and find > that there is `gpd.fit` function in the 'ismev' package, but it (like all > other regression functions of which I am aware) appears to take full data > objects rather than single points. You would not need to use for-loops to OK-- in other languages I have used (non-statistical), I have looped through to perform operations on each individual point. That is what i am trying to do here. There are numerous times at each lat/lon poing. The speed will vary greatly point-by-point as the terrain and physical properties driving the speed are different by location. > pass the object. Perhaps: > > fit <-gpd.fit(Y, threshold=17,ydat = Y) > # Not sure where "speed" entered the picture. > # as noted before there is ambiguity in the problem statement > # Or did you do a prior differentiation operation? > # perhaps a 1/ first difference on time? > # perhaps ... if gpd.fit follows the usual R conventions > # return the first point > i=1,j=1,k=1 > pred.ijk <- predict(fit, data,frame(time=i, lat,=j,lon=k) ) > This gives the following error: Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "gpd.fit" > ? expand.grid # to cover a range > > Your placement of a functional form on the LHS of a formula also suggests > recent migration from another statistical universe where assignment is done > into functions, i.e. forms using parentheses, rather than the > extraction/insertion operators: "[" and "[<-", to put values into > structures with dimensions, like matrices and dataframes. > My mistake. > I think you really need to do some more self-study of the introductory R > material rather than making wild guesses at what "might" work based on > experience with Python, Perl, or (less likely in view of that effort to > assign into a function) Matlab. > > You should also read the Posting Guide. > I have worked quite frequently with 1D data, and have studied books that focus on the 1D data, but have yet to find helpful books on R focusing on 3D data. I have the Steward Coles book on Extreme Value modeling, which I reference frequently. If there is a book that focuses on using R over time,lat,lon or other multi-dimensional data, I would appreciate knowing and will immediately buy it. I am not sure what else I can "study." I have also read the posting guide. I know what I am trying to do statistically, and as mentioned before, have gotten feedback from a statistician, it is just performing the task that i do not understand. Thanks, Michelle > -- > David Winsemius, MD > Alameda, CA, USA > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://r.789695.n4.nabble.com/Return-level-plots-tp4643847p4643876.html > To unsubscribe from Return level plots, click here. > NAML -- Michelle Cipullo -- View this message in context: http://r.789695.n4.nabble.com/Return-level-plots-tp4643847p4643950.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.