[R] (Cross-)validating GLM including factors

2015-02-02 Thread Roland Pape
Dear list,

I would like to validate various GLMs, all of them containing (among others) 
several factors as predictors. I thought about using cv.glm from the boot 
package, but necessarily got the error factor xy has new level z. Is there 
any function to easily cross validate LMs or GLMs containing factors that I 
have missed, or any other work around?
- Having in mind that using cross validation on a small data set is not the 
best solution (I have 50-600 samples, but also three factors with up to 15 
levels): Are there any other approaches?

Any help is greatly appreciated!

Roland

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Conditional coloring of area between curves

2013-06-07 Thread Roland Pape
Hi Duncan,

that's exactly what I was looking for! The series have common times, so that's 
no problem. Thanks a lot!

Roland

Von: Duncan Murdoch [murdoch.dun...@gmail.com]
Gesendet: Donnerstag, 6. Juni 2013 18:45
An: Roland Pape
Cc: r-help@r-project.org
Betreff: Re: [R] Conditional coloring of area between curves

On 06/06/2013 10:41 AM, Roland Pape wrote:
 Dear list,

 I have two time series of temperatures from different sites plotted in the 
 same diagram and would like to color the area between the curves differently, 
 dependent on whether site 1 is cooler than site 2 (colored let's say in blue) 
 or warmer (red). While polygone() works fine to color the enclosed area in 
 general, I'm struggling with this conditional coloring. Any help is greatly 
 appreciated!

Suppose the series are named site1 and site2, and they have common
times in a variable times.  Then the following should do what you want:

smaller - pmin(site1, site2)
plot(x, site1, ylim = range(c(site1, site2)), type=n)
polygon(c(x, rev(x)), c(smaller, rev(site1)), col=red)
polygon(c(x, rev(x)), c(smaller, rev(site2)), col=blue)

If the times for the two series are different it's a little harder;
first you need to give them common times, and that will depend on how
you decide to evaluate the values between observations. Probably linear
interpolation (using approx()) is fine, but it's up to you.

Duncan Murdoch

__
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] Conditional coloring of area between curves

2013-06-06 Thread Roland Pape
Dear list,

I have two time series of temperatures from different sites plotted in the same 
diagram and would like to color the area between the curves differently, 
dependent on whether site 1 is cooler than site 2 (colored let's say in blue) 
or warmer (red). While polygone() works fine to color the enclosed area in 
general, I'm struggling with this conditional coloring. Any help is greatly 
appreciated!

Roland

[[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.