[R] GLS - Plotting Graphs with 95% conf interval

Frank Harrell f.harrell at vanderbilt.edu
Mon Jul 11 23:47:21 CEST 2011


The Gls function in the rms package is a frontend to gls that allows you to
use all the graphics and other methods available in rms.
Frank

SamiC wrote:
> 
> Hi, I am trying to plot the original data with the line of the model using
> the predict function.  I want to add SE to the graph, but not sure how to
> get them out as the predict function for gls does not appear to allow for
> SE=TRUE argument.  
> 
> Here is my code so far:
> 
> f1<-formula(MaxNASC40_50~hu3+flcmax+TidalFlag)
> 
> vf1Exp<-varExp(form=~hu3)
> 
> B1D<-gls(f1,correlation=corGaus(form=Lat~Lon, nugget=TRUE),weights=vf1Exp
> , data=ocean)
> 
> ochu3<-seq(from=2.9,to=4,length=120)
> ocflc<-seq(from=0,to=0.8,length=120)
> tidal1<-rep(c("1"),length=120)
> 
> mydata1<-data.frame(TidalFlag=factor(tidal1),hu3=ochu3,flcmax=ocflc)
> lineNASC1<-predict(B1D,newdata=mydata1,type="response")
> lineNASC1<-as.data.frame(lineNASC1)
> 
> plot(ocean$MaxNASC40_50[ocean$TidalFlag==1]~ocean$flcmax[ocean$TidalFlag==1)
> lines(lineNASC1$lineNASC1~mydata1$flcmax)
> 
> Tidal Flag is a factor (so i assume i have to plot seperate graphs for
> each level).
> 
> When I have tried to use the effects package I get the error:  Error in
> x$formula : object of type 'symbol' is not subsettable.
> 
> Also when i have been trying to predict values from a zero inflated
> negative binomial, I am getting the same line of fit regardless of what is
> on my X axis (depsite different variables have positive and negative
> relationships).
> 
> any imput on any of these problems would be appreciated.
> 
> Thanks
> 


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/GLS-Plotting-Graphs-with-95-conf-interval-tp3659814p3660953.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list