[R] Change plot order in lattice xyplot
Greetings, I am writing with a question regarding plotting using the xyplot command in lattice. I currently have the commands shown below, but I need to produce a plot that orders the Month variable differently. I was told to use the lattice.options command (shown below) to change the plot order, and this helped by starting the plot at a point other than the bottom-left origin, but this did not transpose the plot in the way I need. I need the plot to begin with June, then July, August, September, October, beginning at the top left side of the plot area. Does anyone now how to make this happen? A section of my data and the commands I am currently using are shown below. Thank you for any assistance! Data: Month Log10_echo_integration_dens Log10_trawl_dens June -2.55876 -2.74726 June -2.24346 -3.7015 July -3.14616 -2.83227 July -2.69961 -3.7015 August -2.96135 -3.7015 August -2.29246 -2.29232 September -2.2096 -2.20181 September -1.80488 -1.81614 October -2.28896 -1.84266 October -2.4 -2.35319 #Commands lattice.options(default.args = list(as.table = TRUE)) xyplot(Log10_trawl_dens~Log10_echo_integration_dens | Month, data = (subset(T.A., Net_Type=="T")),ylim=c(-4,0),xlim=c(-4,0),xlab="Log density from hydroacoustics (integration)",ylab="Log density from Tucker trawl",main="Density estimates, Tucker Trawl", cex=1.5) Best, Paul S. [[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.
[R] Tukey test on ANCOVA
Greetings! I have one quick question: How do you do a Tukey test on an ANCOVA? Thanks for any tips! -Paul __ 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.
[R] Fonts and axes using persp3d
Greetings, I am making 3D plots using persp3d, and would like to set z-axis limits and make axis labels (the automatic numbers at tick marks) bold. I have tried "zlim", but this does not seem to force the plot to restrain itself within certain bounds (e.g., 0-1). The surface I am plotting (z values) does contain some values outside the range I am setting. Maybe this overrides the "zlim"? Is there a way to fix this without manually removing negative z values? Also, is there any way to make the numerical axis labels bold, or generally darker or larger? My code currently reads: xtemp <- 6:22 ylight <- seq(from=-7.5, to=-5, by=0.5) wDeltaT <- 0 code<- 1 grid.tld <- expand.grid(temp=xtemp, logwm2=ylight, DeltaT=wDeltaT, code=code) YaoRasPred<-predict(YaoRas.Distribution.T.L.DT.gamm$gam,newdata=grid.tld,se.fit=T) Rel.Dens <- matrix(YaoRasPred$fit, nrow=17 , byrow=F) # use predict instead here library(rgl) persp3d(xtemp,ylight,Rel.Dens, zlim=c(min=0.0,max=0.032),xlab="",ylab="",zlab="",col="gray") Thanks for any advice, and thanks again to Duncan Murdoch for suggesting persp3d for my purposes! Sincerely, Paul Simonin __ 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.
[R] 3-D Plotting of predictions from GAM/GAMM object
Hello all, Thank you for the previous assistance I received from this listserve! My current question is: How can I create an appropriate matrix of values from a GAM (actually a GAMM) to make a 3-D plot? This model is fit as a tensor product spline of two predictors and I have used it to make specific predictions by calling: YoyRasPred6<-predict(YoyRas.Distribution.T.L.DT.gamm$gam,newdata=YoyRasSubset6,se.fit=T) However, this type of command, I believe, produces only a vector of values. I have plotted these values and know how to do so in 2-D. However, I would like to create a 3-D plot, which I believe will require an entire matrix of predictions (z values) based on all possible inputs (x and y values). What is an efficient way to do this? It seems there must be a better way than simply predicting vector after vector ... as I am now, then piecing these together. Thank you very much for any answers or assistance in general! Best wishes. Sincerely, Paul Simonin __ 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.
[R] Fortran vs R
Hello R users, I have a basic "computer programing" question. I am a student currently taking a course that uses Fortran as the main programming language, but the instructors are open to students using any language they are familiar with. I have used R previously, and am wondering if there is any benefit to my learning Fortran, or whether I should stick with R for this class. Any advice? Are there clear benefits to using Fortran, or things Fortran can do that R cannot? Thank you very much for any thoughts! Sincerely, Paul S. __ 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.
[R] Comparing GAMMs
Greetings! I am looking for advice regarding the best way to compare GAMMs. I know other model outputs return enough information for R's AIC, ANOVA, etc. commands to function, but this is not the case with GAMM unless one specifies the gam or lme portion. I know these parts of the gamm contain items that will facilitate comparisons between gamms. Is it correct to simply use these values for this purpose? For example, the lme portion of the gamm returns a log liklihood value that could be used to calculate information criteria. However, I am wondering whether entire gamms be compared using this, or only the lme part. Maybe my thinking about the lme and gam portions of gamms is incorrect? If this appears to be the case, let me know! In general, if someone could clarify my understanding in any way it would be much appreciated. Thank you very much! Sincerely, Paul Simonin __ 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.
[R] Model fitting with GAM and "by" term
Hello R Users, I have a question regarding fitting a model with GAM{mgcv}. I have data from several predictor (X) variables I wish to use to develop a model to predict one Y variable. I am working with ecological data, so have data collected many times (about 20) over the course of two years. Plotting data independently for each date there appears to be relationships between Y (fish density) and at least several X variables (temperature and light). However, the actual value of X variables (e.g., temperature) changes with date/season. In other words, fish distribution is likely related to temperature, but available temperatures change through the season. Thus, when data from all dates are combined to create a model from the entire dataset, I think I need to include some type of metric/variable/interaction term to account for this date relationship. I have written the following code using a "by" term: Distribution.s.temp.logwm2.deltaT<-gam(yoyras~s(temp,by=datecode)+s(logwm2,by=datecode)+s(DeltaT,by=datecode),data=AllData) However, I am not convinced this is the correct way to account for this relationship. What do you think? Is there another way to include this in my model? Maybe I should simply include date ("datecode") as another term in the model? I also believe there may be an interaction between temperature and light (logwm2), and based on what I have read the "by" method may be the best way to include this. Correct? Thank you for any input, tips, or advice you may be able to offer. I am new to R, so especially grateful! Thanks again, Paul Simonin (PhD student) PS- If you would like additional information let me know. Also, if this question is inappropriate for the help list please let me know. __ 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.
[R] GAM function with interaction
Hello R Users, I have a question regarding fitting a model with GAM{mgcv}. I have data from several predictor (X) variables I wish to use to develop a model to predict one Y variable. I am working with ecological data, so have data collected many times (about 20) over the course of two years. Plotting data independently for each date there appears to be relationships between Y (fish density) and at least several X variables (temperature and light). However, the actual value of X variables (e.g., temperature) changes with date/season. In other words, fish distribution is likely related to temperature, but available temperatures change through the season. Thus, when data from all dates are combined to create a model from the entire dataset, I think I need to include some type of metric/variable/interaction term to account for this date relationship. I have written the following code using a "by" term: Distribution.s.temp.logwm2.deltaT<-gam(yoyras~s(temp,by=datecode)+s(logwm2,by=datecode)+s(DeltaT,by=datecode),data=AllData) However, I am not convinced this is the correct way to account for this relationship. What do you think? Is there another way to include this in my model? Maybe I should simply include date ("datecode") as another term in the model? I also believe there may be an interaction between temperature and light (logwm2), and based on what I have read the "by" method may be the best way to include this. Correct? Thank you for any input, tips, or advice you may be able to offer. I am new to R, so especially grateful! Thanks again, Paul Simonin (PhD student) __ 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.
[R] GAM function with interaction
Hello R Users, I have a question regarding fitting a model with GAM{mgcv}. I have data from several predictor (X) variables I wish to use to develop a model to predict one Y variable. I am working with ecological data, so have data collected many times (about 20) over the course of two years. Plotting data independently for each date there appears to be relationships between Y (fish density) and at least several X variables (temperature and light). However, the actual value of X variables (e.g., temperature) changes with date/season. In other words, fish distribution is likely related to temperature, but available temperatures change through the season. Thus, when data from all dates are combined to create a model from the entire dataset, I think I need to include some type of metric/variable/interaction term to account for this date relationship. I have written the following code using a "by" term: Distribution.s.temp.logwm2.deltaT<-gam(yoyras~s(temp,by=datecode)+s(logwm2,by=datecode)+s(DeltaT,by=datecode),data=AllData) However, I am not convinced this is the correct way to account for this relationship. What do you think? Is there another way to include this in my model? Maybe I should simply include date ("datecode") as another term in the model? I also believe there may be an interaction between temperature and light (logwm2), and based on what I have read the "by" method may be the best way to include this. Correct? Thank you for any input, tips, or advice you may be able to offer. I am new to R, so especially grateful! Thanks again, Paul Simonin (PhD student) __ 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.