Re: [R] pie chart in lattice - trellis class

2007-05-28 Thread Patrick Giraudoux
Jim Lemon a écrit :
> Patrick Giraudoux wrote:
>> Dear all,
>>
>> After going through the Lattice doc and R-help list and google, I got 
>> the feeling that there is no function in lattice or other package to 
>> compute a pie chart object  of class "trellis". Although pie charts 
>> are obviously not considered optimal even in the pie() doc ;-) ,  pie 
>> chart trellis objects would be easy positioned e.g. over a map drawn 
>> with the grids package.
>>
>> Can anybody confirm this absence or indicate a package/function able 
>> to draw a pie chart  object of class trellis?
>>
> Hi Patrick,
> Floating.pie was written to solve this problem, but it only works in 
> standard graphics. Perhaps it might help, though.
>
> Jim

Hey ! Looks like exactly the one I was looking for... For info to other 
R-users, it can be found in the 'plotrix' package. Meanwhile I had 
dropped some line codes with the same target, still  not fully achieved 
(the argument center is not taken into account yet... needs one line more).

Thanks a lot!

Patrick


polycirc2<-function (radius=1, center = c(0, 0), edges = 50, init=pi/2, 
angle=pi/2)
{
circ = NULL
angles <- seq(init, init+angle, l = edges)
for (i in angles) {
circ <- rbind(circ, cbind(radius * sin(i), radius * cos(i)))
}
circ<-rbind(c(0,0),circ)
return(cbind(circ[, 1] + center[1], circ[,2] + center[2]))
}


pie2<-function(x,col=NULL,...){
x<-x/sum(x)
xC<-cumsum(x)
xC<-xC/xC[length(xC)]
init=0
for (i in 1:length(x)) {
angle<-x[i]*2*pi
polygon(polycirc2(init=init,angle=angle),col=col[i],...)
init<-xC[i]*2*pi
}
}

# example
ex<-rpois(10,2)
plot(c(-1,+1),c(-1,+1),type="n",asp=1)
pie2(ex,col=c(1:length(ex)))

__
R-help@stat.math.ethz.ch 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.


Re: [R] pie chart in lattice - trellis class

2007-05-28 Thread Patrick Giraudoux
Deepayan Sarkar a écrit :
> On 5/27/07, Patrick Giraudoux <[EMAIL PROTECTED]> wrote:
>> Dear all,
>>
>> After going through the Lattice doc and R-help list and google, I got
>> the feeling that there is no function in lattice or other package to
>> compute a pie chart object  of class "trellis". Although pie charts are
>> obviously not considered optimal even in the pie() doc ;-) ,  pie chart
>> trellis objects would be easy positioned e.g. over a map drawn with the
>> grids package.
>>
>> Can anybody confirm this absence or indicate a package/function able to
>> draw a pie chart  object of class trellis?
>
> I can confirm that lattice does not produce "trellis" objects
> representing pie charts (although I guess it can be made to do so with
> a user supplied panel function). However, I don't see how that would
> have helped you with the map example, as plotting a "trellis" object
> would also include the axes, labels, etc. What you really want is the
> ability to draw a circle with differently colored angular segments,
> which can be reasonably approximated by polygons. polygon() and
> grid.polygon() do these for traditional and grid graphics
> respectively.
>
> -Deepayan
>
>
Yes indeed. Thats' likely what I am going to do. Anyway, to plot axes, 
labels of sophisticated graphs on maps may be interesting anyway. For 
instance, we are monitoring fox and hare populations in tens of game 
areas. Drawing observations (panel.xyplot) over time and representing 
the trend variations (panel.loess) at the very place on the map where 
the observations were done gives an absolutely interesting view where 
spatial relationships between trends can be visualized.

Patrick

__
R-help@stat.math.ethz.ch 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] pie chart in lattice - trellis class

2007-05-27 Thread Patrick Giraudoux
Dear all,

After going through the Lattice doc and R-help list and google, I got 
the feeling that there is no function in lattice or other package to 
compute a pie chart object  of class "trellis". Although pie charts are 
obviously not considered optimal even in the pie() doc ;-) ,  pie chart 
trellis objects would be easy positioned e.g. over a map drawn with the 
grids package.

Can anybody confirm this absence or indicate a package/function able to 
draw a pie chart  object of class trellis?

Thanks in advance,

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] interaction term and scatterplot3d

2007-02-20 Thread Patrick Giraudoux
Sorry to answer to myself. A solution was trivial with lattice... (as 
often !)

library(lattice)

modbusetmp<-lm(IKA_buse ~ Ct *Cc,data=dtbuse)

G1<-cloud(IKA_buse~Ct*Cc,type="h",data=dtbuse)
G2<-cloud(IKA_buse~Ct*Cc,data=dtbuse)

seqCc<-seq(min(dtbuse$Cc),max(dtbuse$Cc),l=20)
seqCt<-seq(min(dtbuse$Ct),max(dtbuse$Ct),l=20)
grille<-expand.grid(Cc=seqCc,Ct=seqCt)
zbuse<-predict(modbusetmp,newdata=grille,type=response)
G3<-wireframe(zbuse~grille$Ct*grille$Cc)

print(G3,more=T)
print(G1,more=T)
print(G2)

Some obvious improvements can be done with labels and differencial 
colors (above or below the surface) can be attributed comparing 
observations to predicted values at the same x y values...


Patrick Giraudoux a écrit :
> Dear Listers,
>
> I would be interested in representing a trend surface including an 
> interaction term z = f(x,y,x.y) - eg the type of chart obtained with 
> persp() or wireframe(), then adding datapoints as a cloud, ideally 
> with dots which are under the surface in a color, and those who are 
> above in another color. An other option would be to draw segments 
> between the dots and the ground of the chart.
>
> scatterplot3d looks like being close to do such things except it does 
> not to include (to my knowledge) a coefficient for the interaction 
> term (thus just model z = f(x,y).
>
> Does anybody has an idea where to start with this and the main steps? 
> Or a place/website where some script examples can be found?
>
> Patrick
>
>

__
R-help@stat.math.ethz.ch 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] interaction term and scatterplot3d

2007-02-20 Thread Patrick Giraudoux
Dear Listers,

I would be interested in representing a trend surface including an 
interaction term z = f(x,y,x.y) - eg the type of chart obtained with 
persp() or wireframe(), then adding datapoints as a cloud, ideally with 
dots which are under the surface in a color, and those who are above in 
another color. An other option would be to draw segments between the 
dots and the ground of the chart.

scatterplot3d looks like being close to do such things except it does 
not to include (to my knowledge) a coefficient for the interaction term 
(thus just model z = f(x,y).

Does anybody has an idea where to start with this and the main steps? Or 
a place/website where some script examples can be found?

Patrick

__
R-help@stat.math.ethz.ch 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] negative binomial family glm R and STATA

2007-01-06 Thread Patrick Giraudoux
Dear Lister,

I am facing a strange problem fitting a GLM of the negative binomial 
family. Actually, I tried to estimate theta (the scale parameter) 
through glm.nb from MASS and could get convergence only relaxing the 
convergence tolerance to 1e-3. With warning messages:

 glm1<-glm.nb(nbcas~.,data=zonesdb4,control=glm.control(epsilon = 1e-3))
There were 25 warnings (use warnings() to see them)
 > warnings()
Warning messages:
1: iteration limit reached in: theta.ml(Y, mu, n, w, limit = 
control$maxit, trace = control$trace >   ...
2: NaNs produced in: sqrt(1/i)

etc

The estimate of theta was: 0.0939. When trying to compute confidence 
interval then, I got this message:

 > confint(glm1a)
Waiting for profiling to be done...
Error in profile.glm(object, which = parm, alpha = (1 - level)/4, trace 
= trace) :
profiling has found a better solution, so original fit had not 
converged

Moreover, trying some other solutions "by hand" (without warnings 
produced, here) with glm( family=negative.binomial(1)),  I found 
that theta = 0.7 lead to a much lower AIC (AIC= 1073) than theta = 1 
(AIC=1211).

Facing such unstable results my first reaction has been to forget about 
fitting a negative binomial model on this data set. The reader will find 
the dataset in a dumped format below for trials.

A friend of mine tried the same with STATA and got the following result 
without any warning  from STATA :

. glm nbcas pop area v_100khab gares ports axe_routier lacs, 
family(nbinomial) link(log) eform
 
Iteration 0:   log likelihood = -616.84031 
Iteration 1:   log likelihood = -599.77767 
Iteration 2:   log likelihood = -597.22486 
Iteration 3:   log likelihood = -597.14784 
Iteration 4:   log likelihood = -597.14778 
Iteration 5:   log likelihood = -597.14778 
 
Generalized linear models  No. of obs  
=92
Optimization : ML  Residual df 
=84
   Scale parameter 
= 1
Deviance =  597.0007978(1/df) Deviance =  
7.107152
Pearson  =  335.6135273(1/df) Pearson  =  
3.995399
 
Variance function: V(u) = u+(1)u^2 [Neg. Binomial]
Link function: g(u) = ln(u)[Log]
 
   AIC =  
13.15539
Log likelihood   = -597.1477759BIC =  
217.1706
 
-- 

 | OIM
   nbcas |IRR   Std. Err.  zP>|z| [95% Conf. 
Interval]
-+ 

 pop |   1.11   1.82e-06 6.02   0.000 1.07
1.14
area |   1.14   .244 0.57   0.569 .661
1.62
   v_100khab |   2.485394   .7924087 2.86   0.004 1.330485
4.642806
   gares |   2.185483   .7648255 2.23   0.025 1.100686
4.339418
   ports |   .1805793.100423-3.08   0.002 .0607158
.5370744
 axe_routier |.828243   .2258397-0.69   0.489 .4853532
1.413376
lacs |   20.50183   12.17126 5.09   0.000 6.404161
65.63311


Has somebody an idea about (1) why the AIC values given are so different 
between softwares (R = 1211, STATA= 13.15) for the same model and (2) 
what can explain so different behaviour between R and STATA ?

Here below the data.frame:


zonesdb4 <-
structure(list(nbcas = as.integer(c(318, 0, 42, 3011, 6, 911,
45, 273, 0, 0, 89, 122, 407, 83, 0, 1844, 58, 0, 0, 0, 0, 8926,
0, 0, 0, 0, 108, 0, 13, 1884, 0, 0, 0, 0, 963, 0, 199, 735, 0,
2182, 971, 0, 65, 0, 7927, 30, 0, 186, 0, 1363, 808, 0, 0, 0,
0, 135, 0, 1338, 0, 0, 488, 0, 344, 0, 0, 454, 4808, 0, 692,
0, 0, 24, 1301, 0, 0, 474, 228, 0, 0, 98, 44, 0, 0, 0, 1562,
375, 327, 0, 0, 0, 0, 0)), pop = as.integer(c(247215, 55709,
63625, 253153, 51789, 142806, 129839, 95799, 129996, 8, 76043,
267232, 153200, 136333, 264888, 198244, 233600, 89152, 128085,
71803, 81911, 122523, 149806, 122470, 50979, 160773, 80700, 56146,
226965, 245322, 165768, 215129, 46843, 108471, 108690, 188724,
161794, 226965, 95850, 156326, 145291, 51789, 218808, 53189,
245854, 152047, 146509, 243765, 65012, 226830, 66742, 144762,
93858, 73793, 123107, 189793, 91013, 135212, 67487, 105050, 194903,
206606, 62169, 96832, 145570, 167062, 1598576, 146509, 103928,
118334, 91509, 295644, 139650, 106980, 66529, 126126, 257341,
56973, 33793, 164072, 145225, 155638, 131100, 100880, 245482,
166213, 127365, 113713, 57540, 78571, 62499, 81916)), Area = c(10027.1,
9525.3, 638.646, 861.486, 4966.32, 11973, 1823.89, 1327.45, 789.595,
4892.38, 638.908, 15959.8, 2036.56, 7397.62, 4626.03, 10237.5,
9823.24, 4253.59, 2448.78, 12280.2, 910.972, 16365, 2041.92,
4343.46, 1081.42, 1601.11, 4664.47, 335.865, 2818.68, 7348.1,
1148.41, 265.158, 148

[R] plot methods in sp

2006-12-30 Thread Patrick Giraudoux
Dear listers,

I am working since a while with the sp package and still wonder how the 
plot methods are managed with sp spatial objects. For instance, 
SpatialPolygonsDataFrame objects have obviously a plot method. However 
it cannot be found in the list provided by methods(plot) . Furthermore 
?plot.SpatialPolygonsDataFrame, nor ?plot.SpatialPolygons, etc.. provide 
a help, though the lattice function spplot is adequately documented.

On the other hand, plot(myobject, border="grey"), with myobject a 
SpatialPolygonsDataframe is well interpreted and recalls the syntax of 
plot.polylist of matools (though myobject is far from being a polylist...).

Can anybody (especially the package's authors...) comment on this? Where 
a help with the list of the plot function arguments can be found?

Thanks for any hint,

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] X11 fonts and Ubuntu

2006-12-17 Thread Patrick Giraudoux
Did try it. Works fine now. Just need to reboot after having modified 
/etc/X11/ xorg.conf as following according to your instructions:

Section "Files"

# path to defoma fonts
FontPath "/usr/share/fonts/X11/misc"
FontPath "/usr/share/fonts/X11/cyrillic"
FontPath "/usr/share/fonts/X11/100dpi/:unscaled"
FontPath "/usr/share/fonts/X11/75dpi/:unscaled"
FontPath "/usr/share/fonts/X11/Type1"
FontPath "/usr/share/fonts/X11/100dpi"
FontPath "/usr/share/fonts/X11/75dpi"
FontPath "/usr/share/fonts/X11/misc"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Thanks a lot,

Patrick


Ilias Soumpasis a écrit :
> 2006/12/17, Patrick Giraudoux <[EMAIL PROTECTED]>:
>> Hi,
>>
>> I am moving from Windows XP to Ubuntu 6.10 and installed R 2.4.0. When I
>> run eg plot.lm  (things work fine with plot.default - eg
>> plot(rnorm(30),rnorm(30)))
>>
>> plot(lmobject)
>>
>> I can get the first plot and then this message:
>>
>> Hit  to see next plot:
>> Error in text.default(x, y, labels.id[ind],cex=cex, xpd=TRUE, :
>> could not find any X11 fonts
>> Check that the Font Path is correct
>>
>> I have googled through the R-help list and it seems that such troubles
>> already occured sometimes (see link below and threads)
>>
>> http://lists.freebsd.org/pipermail/freebsd-ports/2005-June/024091.html
>> http://tolstoy.newcastle.edu.au/R/help/06/03/23864.html
>>
>> but did not find solution. Some messages claim it is a X11 problem (not
>> R) some others suggest it may come from R. Some also mention that UTF-8
>> may be a problem (though I don't have specific message on this from R).
>> I have re-installed x11-common via the Synaptic package manager (so I
>> suppose X11 is well installed) without improvement. I have checked
>> /etc/X11/ xorg.conf
>>
>> Section "Files"
>> FontPath "/usr/share/X11/fonts/misc"
>> FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
>> FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
>> FontPath "/usr/share/X11/fonts/Type1"
>> FontPath "/usr/share/X11/fonts/100dpi"
>> FontPath "/usr/share/X11/fonts/75dpi"
>> FontPath "/usr/share/fonts/X11/misc"
>> FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
>> Endsection
>
> You 'll have  to change the /usr/share/X11/fonts/ to
> /usr/share/fonts/X11/. I have read many having similar problems and
> solved them this way. The location changed so that all the fonts to be
> under fonts). So give it a try and I believe that it will be fine.
>
>>
>> but cannot identify where the problem is actually thus no remedy.
>>
>> Any idea?
>>
>> __
>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] X11 fonts and Ubuntu

2006-12-17 Thread Patrick Giraudoux
Hi,

I am moving from Windows XP to Ubuntu 6.10 and installed R 2.4.0. When I 
run eg plot.lm  (things work fine with plot.default - eg 
plot(rnorm(30),rnorm(30)))

plot(lmobject)

I can get the first plot and then this message:

Hit  to see next plot:
Error in text.default(x, y, labels.id[ind],cex=cex, xpd=TRUE, :
could not find any X11 fonts
Check that the Font Path is correct

I have googled through the R-help list and it seems that such troubles 
already occured sometimes (see link below and threads)

http://lists.freebsd.org/pipermail/freebsd-ports/2005-June/024091.html
http://tolstoy.newcastle.edu.au/R/help/06/03/23864.html

but did not find solution. Some messages claim it is a X11 problem (not 
R) some others suggest it may come from R. Some also mention that UTF-8 
may be a problem (though I don't have specific message on this from R). 
I have re-installed x11-common via the Synaptic package manager (so I 
suppose X11 is well installed) without improvement. I have checked 
/etc/X11/ xorg.conf

Section "Files"
FontPath "/usr/share/X11/fonts/misc"
FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
FontPath "/usr/share/X11/fonts/Type1"
FontPath "/usr/share/X11/fonts/100dpi"
FontPath "/usr/share/X11/fonts/75dpi"
FontPath "/usr/share/fonts/X11/misc"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
Endsection

but cannot identify where the problem is actually thus no remedy.

Any idea?

__
R-help@stat.math.ethz.ch 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.


Re: [R] lattice layout multiple pages

2006-11-19 Thread Patrick Giraudoux
Thanks a lot to Deepayan Sarkar, Prof. Bryan Ripley and R François (the 
latter off list),

To recap after trial (for further users who may want to search the 
r-help list):

grid::grid.prompt(TRUE)
xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4))
(and FALSE to restore).

is exactly what I need... Now I have just to copy one hundred times 
"lattice is based on grid and not on graphics" to keep that in mind (I 
knew it!!!).

Regarding win.metafile(), those two options make it:

win.metafile("Rplot%d.emf")
xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4))
dev.off()

win.metafile("Rplot%02d.emf")
xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4))
dev.off()

The second inserts a number on two digits ("01", "02", "03", etc...) and 
the image are thus sorted from the first to the last in the folder 
including when there are 10 images and more.

Thanks again,

Patrick








Prof Brian Ripley a écrit :
> On Sat, 18 Nov 2006, Deepayan Sarkar wrote:
>
>> On 11/18/06, Patrick Giraudoux <[EMAIL PROTECTED]> wrote:
>
> [...]
>
>>> Also I would like to print those pages to a device (eg using
>>> win.metafile(filename = "myfile")), but I wonder how to manage not to
>>> make each page file created overwritten by the next one in this 
>>> context.
>>
>> Don't know about win.metafile (have you tried it? Does it really
>> overwrite previous pages?), but pdf etc have options (described in
>> their help page) to produce either a single multi-page files or
>> multiple single-page files.
>
> So does win.metafile: the only difference is that the default is the 
> clipboard, and that does hold only one page at a time. Try
>
> win.metafile("Rplot%d.emf")
>

__
R-help@stat.math.ethz.ch 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] lattice layout multiple pages

2006-11-18 Thread Patrick Giraudoux
Dear all,

Using  lattice I would like to print a conditionnal plot of 32 panels in 
a limited number of panels (eg 4) in each of several pages:

xyplot(pds~time|Idnid,data=croispond3,layout=c(4,4))

This works well in principle, but the pages are printed without any 
possibility of stopping  the printing process before each next page. I 
have tried  par(ask=T) before the xyplot command line but it does not 
work for some reasons.

Also I would like to print those pages to a device (eg using  
win.metafile(filename = "myfile")), but I wonder how to manage not to 
make each page file created overwritten by the next one in this context.

Thanks in advance for any hint,

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] plot.POSIXct plot.POSIXlt

2006-10-29 Thread Patrick Giraudoux
Hi Spencer,

Sorry not to have thought about a self contained example. One can make:

dur <-
c(17, 6, 12, 20, 24, 8, 16, 12, 8, 8, 9, 9, 13, 24, 14, 15, 10,
13, 14, 21, 14, 12, 10, 17, 11, 10, 14, 15, 13, 11, 14, 10, 12,
16, 10)

DP <-
structure(c(1144360800, 1145656800, 1143583200, 1144360800, 1145052000,
1143496800, 1144274400, 114462, 1143669600, 1147039200, 1146607200,
1143583200, 1143327600, 1144965600, 1144015200, 1144274400, 1144360800,
1144015200, 1144101600, 1144792800, 1144274400, 117200, 117200,
1144533600, 1144360800, 1143842400, 1143928800, 1144533600, 1143928800,
1143928800, 1144188000, 1143928800, 1144015200, 117200, 1143842400
), class = c("POSIXt", "POSIXct"), tzone = "")

plot(dur~DP, format="%d %b")

I will follow your hint further.

Thanks a lot for your kind concern,

All the best,

Patrick



Spencer Graves a écrit :
>  Your example is not self contained, and I was unable to generate 
> an example that produced the warning messages you've mentioned.
>  Have you tried 'options(warn=2)', then running your example?  
> This will turn the warning into an error.  Then you might be able to 
> get something from 'traceback'.  I also encourage you to experiment 
> with 'debug'.  I've discussed how to do this in previous posts.  
> 'RSiteSearch("debug spencer")' produced 124 hits for me just now.  
> Number 7 on that list looked like it might help you:  
> "http://finzi.psych.upenn.edu/R/Rhelp02a/archive/79251.html";.
>  Hope this helps.  Spencer Graves
>
> Patrick Giraudoux wrote:
>> Hi,
>>
>> Just to signal that when I want to plot POSIXct variable on x using 
>> format within plot(), I get what I want on the plot but with a number 
>> of warnings:
>>
>>  > plot(y~x,format="%y-%m")
>> Warning messages:
>> 1: "format" is not a graphical parameter in: plot.window(xlim, ylim, 
>> log, asp, ...)
>> 2: "format" is not a graphical parameter in: plot.xy(xy, type, pch, 
>> lty, col, bg, cex, lwd, ...)
>> 3: "format" is not a graphical parameter in: axis(side, at, labels, 
>> tick, line, pos, outer, font, lty, lwd, 4: "format" is not a 
>> graphical parameter in: box(which = which, lty = lty, ...)
>> 5: "format" is not a graphical parameter in: title(main, sub, xlab, 
>> ylab, line, outer, ...)
>>
>> I suppose that format may not be at the right place in plot() or/and 
>> not handled by the functions called from there, however the 
>> documentation (?plot.POSIXct) seems to allow passing this argument:
>>
>>  ...: Further arguments to be passed from or to other methods,
>>   typically graphical parameters or arguments of
>>   'plot.default'.  For the 'plot' methods, also 'format'.
>>
>> Any comment?
>>
>> Patrick
>>
>> __
>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] one is not one

2006-10-21 Thread Patrick Giraudoux
Folks,

I have got a strange behaviour when testing this:

sum(x) != 1

let us set

x<-c(70,134,1,5,0)

and transform it in a vector of probabilities

x<-x/sum(x)

One expect  sum(x) should be equal to 1, which is apparently the case

> sum(x)
[1] 1

However, when I try to test it I get:

> if(sum(x) !=1) print("lost") else ("OK")
[1] "lost"

Which means that actually sum(x) is NOT considered equal to 1...

Any idea about what is going wrong?

Patrick

__
R-help@stat.math.ethz.ch 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] plot.POSIXct plot.POSIXlt

2006-10-21 Thread Patrick Giraudoux
Hi,

Just to signal that when I want to plot POSIXct variable on x using 
format within plot(), I get what I want on the plot but with a number of 
warnings:

 > plot(y~x,format="%y-%m")
Warning messages:
1: "format" is not a graphical parameter in: plot.window(xlim, ylim, 
log, asp, ...)
2: "format" is not a graphical parameter in: plot.xy(xy, type, pch, lty, 
col, bg, cex, lwd, ...)
3: "format" is not a graphical parameter in: axis(side, at, labels, 
tick, line, pos, outer, font, lty, lwd, 
4: "format" is not a graphical parameter in: box(which = which, lty = 
lty, ...)
5: "format" is not a graphical parameter in: title(main, sub, xlab, 
ylab, line, outer, ...)

I suppose that format may not be at the right place in plot() or/and not 
handled by the functions called from there, however the documentation 
(?plot.POSIXct) seems to allow passing this argument:

 ...: Further arguments to be passed from or to other methods,
  typically graphical parameters or arguments of
  'plot.default'.  For the 'plot' methods, also 'format'.

Any comment?

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] hcc not found, rcmd build

2006-09-29 Thread Patrick Giraudoux
Exactly that... Shame on me, ashes on my head and all those sort of 
things...

Thanks for the hint anyway...

Patrick

Uwe Ligges a écrit :
>
>
> Patrick Giraudoux wrote:
>> Working under Windows XP, I am compiling a package called 'pgirmess' 
>> with the command
>>
>> rcmd build --binary --auto-zip pgirmess
>>
>> I have this message error after having listed: functions text html 
>> latex example chm
>> 
>> zipping help file
>> hcc: not found
>> cp: cannot stat 'c:/TEMP/Rbuild365620874/pgirmess/chm/pgirmess.chm': 
>> No such file or directory
>> make[1]: *** [chm-pgirmess] Error 1
>> make: *** [pkg-pgirmess] Error 2
>> *** Installation of pgirmess failed ***
>>
>> I have recently installed MikTex 2.5 and Perl (I have been obliged to 
>> format my hard disk and reinstall everything after a computer crash...).
>>
>> Has anyone an idea about what means hcc: not found and how to make 
>> "hcc" available to the programme?
>
>
> Microsoft's html help compiler is not in your path (or not even 
> installed). See the R Installation and Administration manual.
>
> Uwe Ligges
>
>
>
>> Thanks in advance for any hint,
>>
>> Patrick
>>
>> __
>> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] hcc not found, rcmd build

2006-09-29 Thread Patrick Giraudoux

Working under Windows XP, I am compiling a package called 'pgirmess' 
with the command

rcmd build --binary --auto-zip pgirmess

I have this message error after having listed: functions text html latex 
example chm

zipping help file
hcc: not found
cp: cannot stat 'c:/TEMP/Rbuild365620874/pgirmess/chm/pgirmess.chm': No 
such file or directory
make[1]: *** [chm-pgirmess] Error 1
make: *** [pkg-pgirmess] Error 2
*** Installation of pgirmess failed ***

I have recently installed MikTex 2.5 and Perl (I have been obliged to 
format my hard disk and reinstall everything after a computer crash...).

Has anyone an idea about what means hcc: not found and how to make "hcc" 
available to the programme?

Thanks in advance for any hint,

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] diff, POSIXct, POSIXlt, POSIXt

2006-07-23 Thread Patrick Giraudoux
OK. Got it. Thanks a lot everybody.

I however feel that although the problem can be technically handled by 
any user aware of it, it should be fixed in R in a more general way, 
either by modifying the diff() code so that it really handles any kind 
of POSIXt (POSIXlt and POSIXct) with the same final result (as claimed 
in the documentation), or mentioning explicitely in de documentation 
that diff(), as it is written currently, can handle correctly only 
POSIXct (and not any POSIXt or POSIXlt).

There is a kind of danger of wrong output for users (even those reading 
the documentation) if things are left as they are, and I have detected 
this problem just by chance.

All the best,

Patrick

Gabor Grothendieck a écrit :
> Just one more comment. It is possible to define length.POSIXlt yourself
> in which case diff works with POSIXlt objects.
>
>> length.POSIXlt <- function(x) length(x[[1]])
>> diff(dts)
> Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days
>
>
> On 7/23/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
>> Moving this to r-devel.
>>
>> Looking at the diff.POSIXt code we see the problem is that it takes the
>> length of the input using length which is wrong since in the case
>> of POSIXlt the length is always 9 (or maybe length should be
>> defined differently for POSIXlt?).  Try this which gives the same
>> problem:
>>
>>   dts[-1] - dts[-length(dts)]
>>
>> We get a more sensible answer if length is calculated correctly:
>>
>>  dts[-1] - dts[-length(dts[[1]])]
>>
>>
>> On 7/23/06, Patrick Giraudoux <[EMAIL PROTECTED]> wrote:
>> > > Try converting to POSIXct:
>> > That's what I did finally (see the previous e-mail).
>> >
>> > 
>> dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
>>  
>>
>> >
>> > dts <- as.POSIXct(strptime(dts, "%d/%m/%Y"))
>> > diff(dts)
>> >
>> > Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days
>> >
>> > > What is the problem you are trying to solve?
>> > Actually, I don't understand why using diff() and POSIXct provides the
>> > expected result and not using POSIXlt. Both POSIXct and POSIXlt are of
>> > class POSIXt. The doc of diff() stresses that <'diff' is a generic
>> > function with a default method and ones for classes '"ts"', '"POSIXt"'
>> > and '"Date"'>. It does not mention differences between POSIXct and 
>> POSIXlt.
>> >
>> > Moreover, using diff() with POSIXlt has provided (wrong) numbers... 
>> and
>> > not an error. This may be difficult to detect sometimes along 
>> programme
>> > lines. Must one keep in mind that diff() is reliably applicable 
>> only on
>> > POSIXct? In this case, should not it bve mentionned in the 
>> documentation?
>> >
>> > All the best,
>> >
>> > Patrick
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > jim holtman a écrit :
>> > > Try converting to POSIXct:
>> > >
>> > > > str(dts)
>> > > 'POSIXlt', format: chr [1:10] "2003-04-15" "2003-07-15" "2003-10-15"
>> > > "2004-04-15" "2004-07-15" "2004-10-15" "2005-04-15" ...
>> > > > dts
>> > >  [1] "2003-04-15" "2003-07-15" "2003-10-15" "2004-04-15" 
>> "2004-07-15"
>> > > "2004-10-15" "2005-04-15" "2005-07-15"
>> > >  [9] "2005-10-15" "2006-04-15"
>> > > > dts <- as.POSIXct(dts)
>> > > > dts
>> > >  [1] "2003-04-15 EDT" "2003-07-15 EDT" "2003-10-15 EDT" "2004-04-15
>> > > EDT" "2004-07-15 EDT" "2004-10-15 EDT"
>> > >  [7] "2005-04-15 EDT" "2005-07-15 EDT" "2005-10-15 EDT" 
>> "2006-04-15 EDT"
>> > > > diff(dts)
>> > > Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days
>> > > >
>> > >
>> > >
>> > >
>> > > On 7/23/06, *Patrick Giraudoux* <[EMAIL PROTECTED]
>> > > <mailto:[EMAIL PROTECTED]>> wrote:
>

Re: [R] diff, POSIXct, POSIXlt, POSIXt

2006-07-23 Thread Patrick Giraudoux
> Try converting to POSIXct:
That's what I did finally (see the previous e-mail).

dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
 

dts <- as.POSIXct(strptime(dts, "%d/%m/%Y"))
diff(dts)

Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days

> What is the problem you are trying to solve?
Actually, I don't understand why using diff() and POSIXct provides the 
expected result and not using POSIXlt. Both POSIXct and POSIXlt are of 
class POSIXt. The doc of diff() stresses that <'diff' is a generic 
function with a default method and ones for classes '"ts"', '"POSIXt"' 
and '"Date"'>. It does not mention differences between POSIXct and POSIXlt.

Moreover, using diff() with POSIXlt has provided (wrong) numbers... and 
not an error. This may be difficult to detect sometimes along programme 
lines. Must one keep in mind that diff() is reliably applicable only on 
POSIXct? In this case, should not it bve mentionned in the documentation?

All the best,

Patrick







jim holtman a écrit :
> Try converting to POSIXct:
>  
> > str(dts)
> 'POSIXlt', format: chr [1:10] "2003-04-15" "2003-07-15" "2003-10-15" 
> "2004-04-15" "2004-07-15" "2004-10-15" "2005-04-15" ...
> > dts
>  [1] "2003-04-15" "2003-07-15" "2003-10-15" "2004-04-15" "2004-07-15" 
> "2004-10-15" "2005-04-15" "2005-07-15"
>  [9] "2005-10-15" "2006-04-15"
> > dts <- as.POSIXct(dts)
> > dts
>  [1] "2003-04-15 EDT" "2003-07-15 EDT" "2003-10-15 EDT" "2004-04-15 
> EDT" "2004-07-15 EDT" "2004-10-15 EDT"
>  [7] "2005-04-15 EDT" "2005-07-15 EDT" "2005-10-15 EDT" "2006-04-15 EDT"
> > diff(dts)
> Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days
> >
>
>
>  
> On 7/23/06, *Patrick Giraudoux* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Dear Listers,
>
> I have encountered a strange problem using diff() and POSIXt:
>
> 
> dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
>
> dts <- strptime(dts, "%d/%m/%Y")
> class(dts)
>
> [1] "POSIXt"  "POSIXlt"
>
> diff(dts)
>
> Time differences of  7862400,  7948800, 15811200,  7862400,  7948800,
> 15724800,  7862400,  7948800,0 secs
>
> In this case the result is not the one expected: expressed in seconds
> and not in days, and the difference between the two last dates is
> not 0.
>
> Now, if one use a vector of 9 dates only (whatever the date removed),
> things come well:
>
> diff(dts[-1])
>
> Time differences of  92, 183,  91,  92, 182,  91,  92, 182 days
>
> Also if one contrains dts to POSIXct
>
> 
> dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
>
> dts <- as.POSIXct(strptime(dts, "%d/%m/%Y"))
> diff(dts)
>
> Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days
>
> Any rational in that?
>
> Patrick
>
> __
> R-help@stat.math.ethz.ch <mailto:R-help@stat.math.ethz.ch> 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.
>
>
>
>
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve? 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] diff, POSIXct, POSIXlt, POSIXt

2006-07-23 Thread Patrick Giraudoux
Dear Listers,

I have encountered a strange problem using diff() and POSIXt:

dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
dts <- strptime(dts, "%d/%m/%Y")
class(dts)

[1] "POSIXt"  "POSIXlt"

diff(dts)

Time differences of  7862400,  7948800, 15811200,  7862400,  7948800, 
15724800,  7862400,  7948800,0 secs

In this case the result is not the one expected: expressed in seconds 
and not in days, and the difference between the two last dates is not 0.

Now, if one use a vector of 9 dates only (whatever the date removed), 
things come well:

diff(dts[-1])

Time differences of  92, 183,  91,  92, 182,  91,  92, 182 days

Also if one contrains dts to POSIXct

dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006")
dts <- as.POSIXct(strptime(dts, "%d/%m/%Y"))
diff(dts)

Time differences of  91,  92, 183,  91,  92, 182,  91,  92, 182 days

Any rational in that?

Patrick

__
R-help@stat.math.ethz.ch 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.


Re: [R] nlme: correlation structure in gls and zero distance

2006-07-02 Thread Patrick Giraudoux


Joris De Wolf a écrit :
> Have you tried to define 'an' as a group? Like in
>
> gls(IKAfox~an,correlation=corExp(2071,form=~x+y|an,nugget=1.22),data=renliev) 
>
>
> A small data set might help to explain the problem.
>
> Joris
Thanks. Seems to work with a small artificial data set:


an<-as.factor(rep(2001:2004,each=10))
x<-rep(rnorm(10),times=4)
y<-rep(rnorm(10),times=4)
IKA<-rpois(40,2)
site<-as.factor(rep(letters[1:10],times=4))


library(nlme)

mod1<-gls(IKA~an-1,correlation=corExp(form=~x+y))

 >Error in getCovariate.corSpatial(object, data = data) :
Cannot have zero distances in "corSpatial"


mod2<-gls(IKA~an-1,correlation=corExp(form=~x+y|an))

 > mod2
Generalized least squares fit by REML
  Model: IKA ~ an - 1
  Data: NULL
  Log-restricted-likelihood: -73.63998

Coefficients:
  an2001   an2002   an2003   an2004
1.987611 2.454520 2.429907 2.761011

Correlation Structure: Exponential spatial correlation
 Formula: ~x + y | an
 Parameter estimate(s):
range
0.4304012
Degrees of freedom: 40 total; 36 residual
Residual standard error: 1.746205





>
> Joris
>
> Patrick Giraudoux wrote:
>> Dear listers,
>>
>> I am trying to model the distribution of  fox density over years  in 
>> the Doubs department. Measurements have been taken on 470 plots in 
>> March each year and georeferenced. Average density is supposed to be 
>> different each year.
>>
>> In a first approach, I would like to use a general model of this 
>> type, taking spatial correlation into account:
>>
>> gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev) 
>>
>>
>> but I get
>>
>>  > 
>> gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev) 
>>
>> Error in getCovariate.corSpatial(object, data = data) :
>> Cannot have zero distances in "corSpatial"
>>
>> I understand that the 470 geographical coordinates are repeated three 
>> times (measurement are taken each of the three years at the same 
>> place) which obviously cannot be handled there.
>>
>> Does anybody know a way to work around that except jittering slightly 
>> the geographical coordinates?
>>
>> Thanks in advance,
>>
>> Patrick
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>
>
> confidentiality notice:
> The information contained in this e-mail is confidential a...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] nlme: correlation structure in gls and zero distance

2006-07-01 Thread Patrick Giraudoux
Dear listers,

I am trying to model the distribution of  fox density over years  in the 
Doubs department. Measurements have been taken on 470 plots in March 
each year and georeferenced. Average density is supposed to be different 
each year.

In a first approach, I would like to use a general model of this type, 
taking spatial correlation into account:

gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev)

but I get

 > 
gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev)
Error in getCovariate.corSpatial(object, data = data) :
Cannot have zero distances in "corSpatial"

I understand that the 470 geographical coordinates are repeated three 
times (measurement are taken each of the three years at the same place) 
which obviously cannot be handled there.

Does anybody know a way to work around that except jittering slightly 
the geographical coordinates?

Thanks in advance,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] default value for cutoff in gstat variogram()

2006-06-05 Thread Patrick Giraudoux


Edzer J Pebesma a écrit :
> Patrick Giraudoux wrote:
>
>> I wonder what is the default value for the argument 'cutoff' when not 
>> specified in the variogram.formula function of gstat. Computing 
>> variogram envelops within gstat, I am comparing the results obtained 
>> with variog in geoR and variogram in gstat, and it took me a while 
>> before understanding that the cutoff default value is not the maximum 
>> distance.
>>
>> Can Edzer tell us about it?
>
> Yes, of course :
>
> the default value is computed in the c code. Without checking
> (meaning: from >10 years memory) I do recall that gstat uses
> one third of the diagional of the rectangular (or block for 3D)
> that spans the data locations.
>
> Why? In time series you compute ACF's up to one half
> of the length of the series; after this things start to oscillate
> because you lack independent replication at large distance;
> look at what is meant by ergodicity for further reading.
> Variograms are basically flipped & unscaled acf's for higher
> dimensions.
>
> Some books (Journel & Huijbregts?) gave suggestions
> that half the max. distance in the data set is a good guideline,
> back in 1978. I used  one third of the diagonal because
> I thought finding the maximum distance between any
> too point pairs may be expensive to find for large data
> sets. The parameter "one third" can be overridden by
> those who don't like it.
>
> Please keep us updated about your milage comparing
> gstat and geoR; I once spent an afternoon on this, trying
> to reproduce sample variogram across the packages and
> found this hard (but not impossible). I had the feeling
> it had to do with using < or <= to decide whether a
> point pairs falls in a distance interval or not, but didn't 100%
> assure myself.
> -- 
> Edzer
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] default value for cutoff in gstat variogram()

2006-06-03 Thread Patrick Giraudoux
I wonder what is the default value for the argument 'cutoff' when not 
specified in the variogram.formula function of gstat. Computing 
variogram envelops within gstat, I am comparing the results obtained 
with variog in geoR and variogram in gstat, and it took me a while 
before understanding that the cutoff default value is not the maximum 
distance.

Can Edzer tell us about it?

All the best,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] POSIX, time zone and Windows

2006-05-21 Thread Patrick Giraudoux
Excellent! Thanks a lot. Solution general enough, simple and 
understandable. Will try and stick on it...

Should be nice to add this simple and clear example to the as.POSIXxx 
documentation.

Thanks again,

Patrick

jim holtman a écrit :
> forgot, in your case it should be:
>  
> tz="chs-8chd"
>  
> > (x <- as.POSIXct(mydate, tz='chs-8chd'))
> [1] "2006-05-16 11:30:00 chd"
> > format(x, tz="GMT")
> [1] "2006-05-16 02:30:00"
> >
>
>
>  
> On 5/21/06, *Patrick Giraudoux* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Dear Listers,
>
> Apologize to pile up on the 'tz' issue in POSIX objects. I have a
> 'simple' thing on which I must make up my mind but cannot do it
> from the
> existing R-help threads. I am currently working on dog telemetry in
> China, and download time information from GPS collars. I would like to
> set up the corresponding POSIXxx variables in R to a given time
> zone. Eg
> Pekin GMT+8:00.
>
> I cannot find out how to do it properly. For instance:
>
> mydate<-""06/05/16/11:30:00""
> mydate<-strptime(mydate, "%y/%m/%d/%H:%M:%S")
>
> mydate
> [1] "2006-05-16 11:30:00"
> as.POSIXct(mydate)
> [1] "2006-05-16 11:30:00 Paris, Madrid"
>
> Which is obviously not what I wish regarding the specification Paris,
> Madrid...
>
> I have tried to pass something to the argument tz
>
> mydate2<-strptime(mydate, "%y/%m/%d/%H:%M:%S",tz="GMT") or
> mydate2<-strptime(mydate, "%y/%m/%d/%H:%M:%S",tz="GMT+08")
>
> I get this:
>
> mydate2
> [1] NA
>
> Is there a way to specify the time zone on which I was working
> (actually
> GTM + 8:00)? I have read in R-help that this is system dependent, but
> the how to do it still escape. Working with Windows, I have
> checked the
> following address given by Gabor Grothendieck in R-help,
> http://msdn2.microsoft.com/en-us/library/90s5c885.aspx, but I cannot
> manage with the syntax: *TZ*=tzn[+ | –]hh[*:*mm[*:*ss] ][dzn]. They
> mention a three lettre time zone (where can the corresponding codes be
> found?) to which to add a difference in hours between UTC and the
> local
> time... but any trial I did specifying tz="UTM+08" or other
> combination
> leads nowhere...
>
> Thanks for any hint...
>
> Patrick
>
> __
> R-help@stat.math.ethz.ch <mailto:R-help@stat.math.ethz.ch> mailing
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>
>
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390 (Cell)
> +1 513 247 0281 (Home)
>
> What is the problem you are trying to solve? 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] POSIX, time zone and Windows

2006-05-21 Thread Patrick Giraudoux
Dear Listers,

Apologize to pile up on the 'tz' issue in POSIX objects. I have a 
'simple' thing on which I must make up my mind but cannot do it from the 
existing R-help threads. I am currently working on dog telemetry in 
China, and download time information from GPS collars. I would like to 
set up the corresponding POSIXxx variables in R to a given time zone. Eg 
Pekin GMT+8:00.

I cannot find out how to do it properly. For instance:

mydate<-""06/05/16/11:30:00""
mydate<-strptime(mydate, "%y/%m/%d/%H:%M:%S")

mydate
[1] "2006-05-16 11:30:00"
as.POSIXct(mydate)
[1] "2006-05-16 11:30:00 Paris, Madrid"

Which is obviously not what I wish regarding the specification Paris, 
Madrid...

I have tried to pass something to the argument tz

mydate2<-strptime(mydate, "%y/%m/%d/%H:%M:%S",tz="GMT") or
mydate2<-strptime(mydate, "%y/%m/%d/%H:%M:%S",tz="GMT+08")

I get this:

mydate2
[1] NA

Is there a way to specify the time zone on which I was working (actually 
GTM + 8:00)? I have read in R-help that this is system dependent, but 
the how to do it still escape. Working with Windows, I have checked the 
following address given by Gabor Grothendieck in R-help, 
http://msdn2.microsoft.com/en-us/library/90s5c885.aspx, but I cannot 
manage with the syntax: *TZ*=tzn[+ | –]hh[*:*mm[*:*ss] ][dzn]. They 
mention a three lettre time zone (where can the corresponding codes be 
found?) to which to add a difference in hours between UTC and the local 
time... but any trial I did specifying tz="UTM+08" or other combination 
leads nowhere...

Thanks for any hint...

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] lme: null deviance, deviance due to the random effects, residual deviance

2006-05-01 Thread Patrick Giraudoux
Andrew and Spencer,

Thanks for your answers. I was feeling that moving from "variance" and 
least-square estimates to "deviance" and MLE or REML was the reason why 
I could not find easy equivalent estimates for the "proportion of 
variation" of a given effect to the total. Thus this was not a trivial 
issue... I will try and understand Andrew's function which will be 
helpful to make the things clearer in my mind. Your advice both are 
useful and drive people on the good track.

All the best,

Patrick

Spencer Graves a écrit :
>   As far as I know, the term "deviance" has no standard 
> definition.  A good, fairly common definition (I think) is that the 
> deviance is "up to [an additive] constant, minus twice the maximised 
> log-likelihood. Where sensible, the constant is chosen so that a 
> saturated model has deviance zero."  
> ("http://finzi.psych.upenn.edu/R/library/gnm/html/gnm.html";.) Because 
> of this "constant", the "the proportion of deviance 'explained' by the 
> model" in not a well defined concept.  I found this definition using 
> RSiteSearch("deviance define").  However, even this definition is not 
> used consistently;  it's not even used for 'deviance.lm', which I 
> discovered using methods("deviance") and methods("logLik") followed by 
> 'getAnywhere("deviance.lm"), etc.
>
>   This is not a "trivial and stupid question".  Instead, it's 
> connected to subtle issues in statistical methods, and this reply may 
> contribute more obfuscation than enlightenment.  If you describe some 
> more specific application where you might want to use something like 
> this and what you are trying to achieve, you might get a more useful 
> reply.
>
>   hope this helps,
>   spencer graves
>
> Patrick Giraudoux wrote:
>
>> A maybe trivial and stupid question:
>>
>> In the case of a lm or glm fit, it is quite informative (to me) to 
>> have a look to the null deviance and the residual deviance of a 
>> model. This is generally provided in the print method or the summary, 
>> eg:
>>
>> Null Deviance:  658.8
>> Residual Deviance: 507.3
>>
>> and (a bit simpled minded) I like to think that the proportion of 
>> deviance 'explained' by the model is (658.8-507.3)/658.8 = 23%
>>
>> In the case of lme models, is it possible and reasonable to try and 
>> get the:
>> - null deviance
>> - the total deviance due to the the random effect(s)
>> - the residual deviance?
>>
>> With the idea that Null deviance = Fixed effects + Random Effects + 
>> Residuals
>>
>> If yes how to do it ? A lme object provides the following:
>>
>>  > names(glm6)
>>  [1] "modelStruct"  "dims" "contrasts""coefficients"
>>  [5] "varFix"   "sigma""apVar""logLik"  [9] 
>> "numIter"  "groups"   "call" "method" [13] 
>> "fitted"   "residuals""fixDF""family"
>>
>> so no $null.deviance and $deviance elements as in glm objects...
>>
>> I tried to find out an answer on R-help & Pineihro & Bates (2000). 
>> Partial success only:
>>
>> - null deviance: Response: possibly yes: see 
>> http://tolstoy.newcastle.edu.au/R/help/05/12/17796.html (Spencer 
>> Graves). The (null?) deviance is -2*logLik(mylme), but a personnal 
>> trial with some glm objects did not led to the same numbers that the 
>> one given by the print.glm method...
>>
>> - the deviance due to the the random effect(s). I was supposing that 
>> the coefficients given by ranef(mylme) may be an entry... but beyond 
>> this, I guess those coefficients must be weighed in some way... which 
>> is a far beyond my capacities in this matter...
>>
>> - residual deviance. I was supposing that it may be 
>> sum(residuals(mylme)^2). With some doubts as far as I feel that I am 
>> thinking sum of squares estimation in the context of likelihood and 
>> deviance estimations... So  most likely irrelevant. Moreover, in the 
>> case I was exploring, this quantity is much larger than the null 
>> deviance computed as above...
>>
>> Any hint appreciated,
>>
>> Patrick Giraudoux
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] lme: null deviance, deviance due to the random effects, residual deviance

2006-04-23 Thread Patrick Giraudoux
A maybe trivial and stupid question:

In the case of a lm or glm fit, it is quite informative (to me) to have 
a look to the null deviance and the residual deviance of a model. This 
is generally provided in the print method or the summary, eg:

Null Deviance:  658.8
Residual Deviance: 507.3

and (a bit simpled minded) I like to think that the proportion of 
deviance 'explained' by the model is (658.8-507.3)/658.8 = 23%

In the case of lme models, is it possible and reasonable to try and get the:
- null deviance
- the total deviance due to the the random effect(s)
- the residual deviance?

With the idea that Null deviance = Fixed effects + Random Effects + 
Residuals

If yes how to do it ? A lme object provides the following:

 > names(glm6)
 [1] "modelStruct"  "dims" "contrasts""coefficients"
 [5] "varFix"   "sigma""apVar""logLik" 
 [9] "numIter"  "groups"   "call" "method" 
[13] "fitted"   "residuals""fixDF""family"

so no $null.deviance and $deviance elements as in glm objects...

I tried to find out an answer on R-help & Pineihro & Bates (2000). 
Partial success only:

- null deviance: Response: possibly yes: see 
http://tolstoy.newcastle.edu.au/R/help/05/12/17796.html (Spencer 
Graves). The (null?) deviance is -2*logLik(mylme), but a personnal trial 
with some glm objects did not led to the same numbers that the one given 
by the print.glm method...

- the deviance due to the the random effect(s). I was supposing that the 
coefficients given by ranef(mylme) may be an entry... but beyond this, I 
guess those coefficients must be weighed in some way... which is a far 
beyond my capacities in this matter...

- residual deviance. I was supposing that it may be 
sum(residuals(mylme)^2). With some doubts as far as I feel that I am 
thinking sum of squares estimation in the context of likelihood and 
deviance estimations... So  most likely irrelevant. Moreover, in the 
case I was exploring, this quantity is much larger than the null 
deviance computed as above...

Any hint appreciated,

Patrick Giraudoux

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to draw a circle

2006-04-23 Thread Patrick Giraudoux
You may want to have a look at the package pgirmess and the function 
polycirc()

Kind regards,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] TukeyHSDs function (pgirmess package)

2006-04-15 Thread Patrick Giraudoux
Sorry to have been so poorly reactive. I have been abroad for ten days 
and then bogged down with administration for the week when back, so 
totally unproductive!!!

The bug is now fixed in the last release of pgirmess (1.2.6) on its way 
to CRAN and also available on the pgirmess web site 
(http://perso.wanadoo.fr/giraudoux/SiteGiraudoux.html).

Kind regards,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] package installation on Mac OS X 10.3.9

2006-03-08 Thread Patrick Giraudoux
Dear listers,

I am tryin to install a package in a student training room. 
Unsuccessfull! With this message:

 > install.packages("pgirmess")
trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 77400 bytes
opened URL
==
downloaded 75Kb

trying URL `http://cran.r-project.org/src/contrib/pgirmess_1.2.5.tar.gz'
Content type `application/x-tar' length 49962 bytes
opened URL
==
downloaded 48Kb

ERROR: failed to lock directory 
'/Library/Frameworks/R.framework/Versions/2.0.1/Resources/library' for 
modifying
Try removing 
'/Library/Frameworks/R.framework/Versions/2.0.1/Resources/library/00LOCK'

Delete downloaded files (y/N)? N

Can anybody advise a bit more clearly about the origin of this failure 
and anticipate a way to work it around?

Cheers,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Where to declare S4 classes?

2006-03-05 Thread Patrick Giraudoux
OK. Looks like I have got it... going through the source code of sp, 
classes are declared as usual functions in *.R files. With the current 
example, suppose I must write two files of names "class-Prior.R" and 
"class-SamplePrior.R" including 
setClass("Prior",representation(Distrib="character",Params="list")) and 
setClass("SamplePrior",representation("Prior",Sample="list"))  respectively.

Suppose the alphabetical order of each file name may be important 
somehow, since "SamplePrior" cannot be defined without a prior 
definition of "Prior"

Can anybody confirm?

If so, I can go on with validity checking functions...

Patrick

Patrick Giraudoux a écrit :
> Dear listers,
>
> I am making a trial to move from S3 to S4... I have created some 
> classes of interest and they work acceptably well for the purpose. I 
> am now wondering how to make them operate in a package. In clear when 
> a package is loaded (eg library(mypackage)) where should I put the 
> class descriptions:
>
> setClass("Prior",representation(Distrib="character",Params="list"))
> setClass("SamplePrior",representation("Prior",Sample="list"))
>
> so that they are created and then usable for functions after a simple 
> call to library(mypackage).
>
> It is probably something trivial, but I could not find out something 
> clear on this (eg example) in the R-help-list, writing R-extensions, 
> nor in  S programming... and trying to get this info through reading 
> other library codes has been unsuccessful.
>
> Patrick
>
>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Where to declare S4 classes?

2006-03-04 Thread Patrick Giraudoux
Dear listers,

I am making a trial to move from S3 to S4... I have created some classes 
of interest and they work acceptably well for the purpose. I am now 
wondering how to make them operate in a package. In clear when a package 
is loaded (eg library(mypackage)) where should I put the class descriptions:

setClass("Prior",representation(Distrib="character",Params="list"))
setClass("SamplePrior",representation("Prior",Sample="list"))

so that they are created and then usable for functions after a simple 
call to library(mypackage).

It is probably something trivial, but I could not find out something 
clear on this (eg example) in the R-help-list, writing R-extensions, nor 
in  S programming... and trying to get this info through reading other 
library codes has been unsuccessful.

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] subtotal, submean, aggregate

2006-02-26 Thread Patrick Giraudoux
Yes right. Checking some examples, all come out OK.

>> same as your example but I think there are some errors in your example 
>> output.
Simply the 'errors' observed come simply from the seed in

rpois(length(habitats),2)

It is unlikely it is the same on your and my computer...

Cheers,

Patrick


Gabor Grothendieck a écrit :
> We are just comparing the difference to 0 so it does not matter if its 
> positive
> or negative.  All that matters is whether its 0 or not.
>
> In fact, the runno you calculate with the abs is identical to the one
> I posted without the abs:
>
> runno <- cumsum(c(TRUE, abs(diff(as.numeric(transect[,2])))!=0))
> runno2 <- cumsum(c(TRUE, diff(as.numeric(transect[,2])))!=0)
> identical(runno, runno2)  # TRUE
>
>
> On 2/26/06, Patrick Giraudoux <[EMAIL PROTECTED]> wrote:
>   
>> Excellent! I was messing with this problem since the early afternoon.
>> Actually the discrepancy you noticed remaining comes from negative
>> difference in
>> diff(as.numeric(transect[,2]))
>> One can work it around using  abs(diff(as.numeric(transect[,2]))). This
>> makes:
>>
>> runno <- cumsum(c(TRUE, abs(diff(as.numeric(transect[,2])))!=0))
>> aggregate(transect[,1], list(obs = transect[,2], runno = runno), sum)
>>
>> I did not know about this use of diff, which was the key point... and then
>> cumsum for polishing. Really great and also elegant (concise). I like it!
>>
>> Thanks a lot!!!
>>
>> Cheers,
>>
>> Patrick
>>
>>
>> Gabor Grothendieck a écrit :
>> Create another variable that gives the run number and aggregate on
>> 
> both the
>   
>> habitat and run number removing the run number after
>> 
> aggregating:
>
> runno <-
>   
>> cumsum(c(TRUE, diff(as.numeric(transect[,2])) !=0))
>> 
> aggregate(transect[,1],
>   
>> list(obs = transect[,2], runno = runno), sum)[,-2]
>> 
>
> This does not give the
>   
>> same as your example but I think there are some
>> 
> errors in your example
>   
>> output.
>> 
>
> On 2/26/06, Patrick Giraudoux
>   
>> <[EMAIL PROTECTED]> wrote:
>> 
>
>   
>> Dear All,
>> 
>
> I would like to make partial sums (or means or any other
>   
>> function) of
>> 
> the values in intervals along a sequence (spatial transect)
>   
>> where groups
>> 
> are defined.
>
> For
>   
>> instance:
>> 
>
> habitats<-rep(c("meadow","forest","meadow","pasture"),c(10,5,12,6))
> observations<-rpois(length(habitats),2)
> transect<-data.frame(observations=observations,habitats=habitats)
>
> aggregate()
>   
>> is not suitable for my purpose because I want a result
>> 
> respecting the order
>   
>> of the habitats encountered although they may have
>> 
> the same name (and not
>   
>> pooling each group on each level of the factor
>> 
> created). For instance, the
>   
>> output of the ideal function
>> 
> mynicefunction() would be something
>   
>> as:
>> 
>
> mynicefunction(transect$observations,
>   
>> by=list(transect$habitats),sum)
>> 
> meadow 16
> forest 9
> meadow 21
> pasture 17
>
> and
>   
>> not
>> 
>
> aggregate(transect$observations,by=list(transect$habitats),sum)
>   
>> Group.1 x
>> 
> 1 forest 9
> 2 meadow 37
> 3 pasture 17
>
> Did anybody hear about such a
>   
>> function already written in R? If no, any
>> 
> idea to make it simple and elegant
>   
>> to write?
>> 
>
> Cheers,
>
> Patrick
>   
>> Giraudoux
>> 
>
> __
> R-help@stat.math.ethz.ch
>   
>> mailing
>> list
>> 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do
>   
>> read the posting guide!
>> http://www.R-project.org/posting-guide.html
>> 
>
>
>   
>> 
>
>   

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] subtotal, submean, aggregate

2006-02-26 Thread Patrick Giraudoux
Thanks Roger. Again I learn about a new one: rle(). Though working, get 
to be a nice Sunday...

Cheers,

Patrick

Roger Bivand a écrit :
> On Sun, 26 Feb 2006, Patrick Giraudoux wrote:
>
>   
>> Dear All,
>>
>> I would like to make partial sums (or means or any other function) of 
>> the values in intervals along a sequence (spatial transect) where groups 
>> are defined.
>>
>> For instance:
>>
>> habitats<-rep(c("meadow","forest","meadow","pasture"),c(10,5,12,6))
>> observations<-rpois(length(habitats),2)
>> transect<-data.frame(observations=observations,habitats=habitats)
>>
>> aggregate() is not suitable for my purpose because I want a result 
>> respecting the order of the habitats encountered although they may have 
>> the same name (and not pooling each group on each level of the factor 
>> created). For instance, the output of the ideal function 
>> mynicefunction() would be something as:
>>
>> mynicefunction(transect$observations, by=list(transect$habitats),sum)
>> meadow 16
>> forest  9
>> meadow 21
>> pasture17
>>
>> and not
>>
>> aggregate(transect$observations,by=list(transect$habitats),sum)
>>   Group.1  x
>> 1  forest  9
>> 2  meadow 37
>> 3 pasture 17
>>
>> Did anybody hear about such a function already written in R? If no, any 
>> idea to make it simple and elegant to write?
>> 
>
> I got as far as:
>
> rle.habs <- rle(habitats)
> habitats1 <- rep(make.names(rle.habs$values, unique=TRUE), rle.habs$lengths)
> aggregate(observations,by=list(habitats1),sum)
>
> making an extra habitats vector with a unique label for each run. 
>
> Since I don't know your seed, the results are not the same, but rle() is 
> quite good for runs.
>
> Roger
>
>   
>> Cheers,
>>
>> Patrick Giraudoux
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>> 
>
>   

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] subtotal, submean, aggregate

2006-02-26 Thread Patrick Giraudoux
Excellent! I was messing with this problem since the early afternoon.  
Actually the discrepancy you noticed remaining comes from negative 
difference in

diff(as.numeric(transect[,2]))

One can work it around using  abs(diff(as.numeric(transect[,2]))). This 
makes:

runno <- cumsum(c(TRUE, abs(diff(as.numeric(transect[,2])))!=0))
aggregate(transect[,1], list(obs = transect[,2], runno = runno), sum)

I did not know about this use of diff, which was the key point... and 
then cumsum for polishing. Really great and also elegant (concise). I 
like it!

Thanks a lot!!!

Cheers,

Patrick


Gabor Grothendieck a écrit :
> Create another variable that gives the run number and aggregate on
> both the habitat and run number removing the run number after
> aggregating:
>
> runno <- cumsum(c(TRUE, diff(as.numeric(transect[,2])) !=0))
> aggregate(transect[,1], list(obs = transect[,2], runno = runno), sum)[,-2]
>
> This does not give the same as your example but I think there are some
> errors in your example output.
>
> On 2/26/06, Patrick Giraudoux <[EMAIL PROTECTED]> wrote:
>   
>> Dear All,
>>
>> I would like to make partial sums (or means or any other function) of
>> the values in intervals along a sequence (spatial transect) where groups
>> are defined.
>>
>> For instance:
>>
>> habitats<-rep(c("meadow","forest","meadow","pasture"),c(10,5,12,6))
>> observations<-rpois(length(habitats),2)
>> transect<-data.frame(observations=observations,habitats=habitats)
>>
>> aggregate() is not suitable for my purpose because I want a result
>> respecting the order of the habitats encountered although they may have
>> the same name (and not pooling each group on each level of the factor
>> created). For instance, the output of the ideal function
>> mynicefunction() would be something as:
>>
>> mynicefunction(transect$observations, by=list(transect$habitats),sum)
>> meadow 16
>> forest  9
>> meadow 21
>> pasture17
>>
>> and not
>>
>> aggregate(transect$observations,by=list(transect$habitats),sum)
>>  Group.1  x
>> 1  forest  9
>> 2  meadow 37
>> 3 pasture 17
>>
>> Did anybody hear about such a function already written in R? If no, any
>> idea to make it simple and elegant to write?
>>
>> Cheers,
>>
>> Patrick Giraudoux
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>> 
>
>   

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] subtotal, submean, aggregate

2006-02-26 Thread Patrick Giraudoux
Dear All,

I would like to make partial sums (or means or any other function) of 
the values in intervals along a sequence (spatial transect) where groups 
are defined.

For instance:

habitats<-rep(c("meadow","forest","meadow","pasture"),c(10,5,12,6))
observations<-rpois(length(habitats),2)
transect<-data.frame(observations=observations,habitats=habitats)

aggregate() is not suitable for my purpose because I want a result 
respecting the order of the habitats encountered although they may have 
the same name (and not pooling each group on each level of the factor 
created). For instance, the output of the ideal function 
mynicefunction() would be something as:

mynicefunction(transect$observations, by=list(transect$habitats),sum)
meadow 16
forest  9
meadow 21
pasture17

and not

aggregate(transect$observations,by=list(transect$habitats),sum)
  Group.1  x
1  forest  9
2  meadow 37
3 pasture 17

Did anybody hear about such a function already written in R? If no, any 
idea to make it simple and elegant to write?

Cheers,

Patrick Giraudoux

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] lme, nlsList, nlsList.selfStart

2006-02-17 Thread Patrick Giraudoux
Well, right, Dose was indeed in the global environment and not in the 
data.frame. Changing it with

mydata2$Dose<-100 # the real dose at the beginning of the experiment

improves the thing in a sense... but I face a new error:

mymod3<-nlsList(Conc+1 ~ Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)) | Organ,
data=mydata2,
start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
)

Error in exp(-exp(lKa) * Conc + 1 ~ Tps) :
Non-numeric argument to mathematical function
Error in exp(-exp(lKa) * Conc + 1 ~ Tps) :
Non-numeric argument to mathematical function
Error in exp(-exp(lKa) * Conc + 1 ~ Tps) :
Non-numeric argument to mathematical function

I have checked the variables in the data.frame with:

 > sapply(mydata2,is.factor)
  Tps  Conc Organ  Dose
FALSE FALSE  TRUE FALSE
 > sapply(mydata2,is.character)
  Tps  Conc Organ  Dose
FALSE FALSE FALSE FALSE

So everything looks OK on this side...

Furthermore, I have still this "old" error intact:

 > mymod4<-nlsList(SSfol,data=mydata2)
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found


I am really sorry for calling help and boring everybody on this likely 
trivial issue (this looks like asking a community to participate to 
debogging line by line, a shame!!!), but I must admit that I am really 
lost...

Thanks for your concern,

Kind regards,

Patrick


Prof Brian Ripley a écrit :
> We don't have Dose, and I think that is where the error lies.  If Dose 
> were part of mydata2, this is likely to work, but otherwise it is Dose 
> which has the wrong length.
>
> ?nlsList says
>
> data: a data frame in which to interpret the variables named in
>   'model'.
>
> and it means it: you must get all the variables from there.
>
>
> On Fri, 17 Feb 2006, Patrick Giraudoux wrote:
>
>> Spencer,
>>
>> Thanks for the hint. I did not dare to bore people with the full data
>> set and though that this kind of error may have been trivial and often
>> encountered (so leading to a short answer), even though I did not see
>> related messages on the r-help list. I already did the checks suggested
>> before posting, and was aware of the possible confusion between 1 and l
>> (actually the variable names were not given by myself).
>>
>> It seems that the trouble comes when the grouping variable "Organ" is
>> used. The best (?) I can do  is to dump the data.frame here below.
>>
>> With this example, one can get exactly the same errors:
>>
>> mymod2<-nls(Conc~Dose * exp(lKe+lKa-lCl) *
>> (exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
>>data=mydata2,
>>start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
>>)
>>
>> ... works well!!!
>>
>> but we get then:
>>
>> mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) *
>> (exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)) | Organ,
>>data=mydata2,
>>start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
>>)
>> Error in model.frame(formula, rownames, variables, varnames, extras,
>> extranames,  :
>>variable lengths differ
>> Error in model.frame(formula, rownames, variables, varnames, extras,
>> extranames,  :
>>variable lengths differ
>> Error in model.frame(formula, rownames, variables, varnames, extras,
>> extranames,  :
>>variable lengths differ
>>
>>
>> > mymod4<-nlsList(SSfol,data=mydata2)
>> Error in eval(expr, envir, enclos) : object "input" not found
>> Error in eval(expr, envir, enclos) : object "input" not found
>> Error in eval(expr, envir, enclos) : object "input" not found
>>
>>
>> Sorry and apologise for the inconvenience met,
>>
>> Kind regards,
>>
>> Patrick
>>
>>
>>
>> # data.frame just to copy and past into R
>>
>> "mydata2" <-
>> structure(list(Tps = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3,
>> 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
>> 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9,
>> 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 14,
>> 14, 14, 14, 14, 17, 17, 17, 17, 17, 20, 20, 20, 20, 25, 28, 29,
>> 50, 50, 50, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
>> 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
>> 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
>> 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
>> 10, 

Re: [R] lme, nlsList, nlsList.selfStart

2006-02-17 Thread Patrick Giraudoux
quot;80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90",
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100",
"101", "102", "103", "104", "105", "106", "107", "108", "109",
"110", "111", "112", "113", "114", "115", "116", "117", "118",
"119", "120", "121", "122", "123", "124", "125", "126", "127",
"128", "129", "130", "131", "132", "133", "134", "135", "136",
"137", "138", "139", "140", "141", "142", "143", "144", "145",
"146", "147", "148", "149", "150", "151", "152", "153", "154",
"155", "156", "157", "158", "159", "160", "161", "162", "163",
"164", "165", "166", "167", "168", "169", "170", "171", "172",
"173", "174", "175", "176", "177", "178", "179", "180", "181",
"182", "183", "184", "185", "186", "187", "188", "189", "190",
"191", "192", "193", "194", "195", "196", "197", "198", "199",
"200", "201", "202", "203", "204", "205", "206", "207", "208",
"209", "210", "211", "212", "213", "214", "215", "216", "217",
"218", "219", "220", "221", "222", "223", "224", "225", "226",
"227", "228", "229", "230", "231", "232", "233", "234", "235",
"236", "237", "238", "239", "240", "241", "242", "243", "244",
"245", "246", "247", "248", "249", "250", "251", "252", "253",
"254", "255", "256", "257", "258", "259", "260", "261", "262",
"263", "264", "265", "266", "267", "268", "269", "270", "271",
"272", "273", "274", "275", "276", "277", "278", "279", "280",
"281", "282", "283", "284", "285", "286", "287", "288", "289",
"290", "291", "292", "293", "294", "295", "296", "297", "298",
"299", "300"), class = c("nfnGroupedData", "nfGroupedData", "groupedData",
"data.frame"), formula = quote(Conc ~ Tps | Organ), FUN = function (x)
max(x, na.rm = TRUE), order.groups = TRUE)




Spencer Graves a écrit :
>   Regarding the following:   
>
> > mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) *
> > (exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
> >  data=mydata,
> >  start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
> > Error in model.frame(formula, rownames, variables, varnames, extras,
> > extranames,  :
> > variable lengths differ
>
>   This example is NOT self contained and is entirely too 
> complicated for me to try to replicate it myself in a reasonable 
> period of time.  I will therefore ask one short question:  Are all the 
> variable names in the "nlsList" call either columns of "mydata" or 
> parameters to be estimated and therefore spelled out in "start"?  If I 
> were you, I'd check this all very carefully, being especially careful 
> about the distinction between "lCl" and "lC1", in particular.
>
>   If you'd like furt

[R] lme, nlsList, nlsList.selfStart

2006-02-11 Thread Patrick Giraudoux
Dear listers,

I am trying to fit a model using nlsList() using alternately a SSfol() 
selfstart function or its developped equivalent formulae.

This preliminary trial works well

mydata<-groupedData(Conc~Tps|Organ,data=mydata)
mymod1<-nls(Conc~SSfol(Dose,Tps,lKe,lKa,lCl),data=mydata)

as well as a developped form:

mymod2<-nls(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
data=mydata,
start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
)

However when trying to fit the model with nlsList, I get:

mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
 data=mydata,
 start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
 )
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ

Or specifying  the grouping factor explicitely:

mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe))|Organ,
 data=mydata,
 start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
 )

Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ


I cannot find out why the grouping factor cannot be used (it has the 
same length as the other variables...)

Another strange thing occurs: in the example given in the help of 
nlsList.selfstart, the following command works  well:

 fm1 <- nlsList(SSasympOff, CO2)

However its seemingly equivalent applied to the case above fails:

mymod4<-nlsList(SSfol,data=mydata)
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found


Any hint/suggestion appreciated.

Kind regards,

Patrick Giraudoux

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] maptools, write.polylistShape

2006-01-07 Thread Patrick Giraudoux
Dear Roger,

I am trying to use the write.polylistShape() function of maptools for 
the first time and realize that it handles list of polygons of class 
'polylist'. However, it seems that no as.polylist() function exist in 
the package. The question behind that is: in your opinion, which would 
be the best  way to convert a list of matrix of polygon nodes 
coordinates into an object of  class polylist?

All the best,

Patrick

-- 

Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)

tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] glmmPQL and variance structure

2006-01-07 Thread Patrick Giraudoux
Dear listers,

On the line of a last (unanswered) question about glmmPQL() of the 
library MASS, I am still wondering if it is possible to pass a variance 
structure object  to the call to lme() within the functions (e.g. 
weights=varPower(1), etc...). The current weights argument of glmmPQL is 
actually used for a call to glm -and not for lme). I have tried to go 
through the code, and gathered that the variance structure passed to the 
call to lme()  was:

mcall$weights <- quote(varFixed(~invwt))

and this cannot be modified by and argument of glmmPQL().

I have tried to modify the script a bit wildly  and changed varFixed 
into VarPower(~1), in a glmmPQL2 function. I get the following error:

 > glmmPQL2(y ~ trt + I(week > 2), random = ~ 1 | ID,
+ family = binomial, data = bacteria)
iteration 1
Error in unlist(x, recursive, use.names) :
argument not a list

I get the same error whatever the change in variance structure on this line.

Beyond this I wonder why variance structure cannot be passed to lme via 
glmmPQL...

Any idea?

Patrick Giraudoux

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Memory limitation in GeoR - Windows or R?

2006-01-05 Thread Patrick Giraudoux
Thanks a lot Jim. Forwarded to Aaron (who rised the question) and the 
R-help list...

Patrick



jim holtman a écrit :

> The size matrix you are allocating (18227 x 18227) would require 2.6GB 
> of memory and that is what the error message is saying that you only 
> have 0.5GB (512MB) available.  You also need about 3-4x the largest 
> object so that you can do any calculations on it due to extra copies 
> that might be made of the data.
>  
> Now your 2000 x 2000 will require about 32MB of memory that that is 
> why it is comfortable in running on your system with 512MB.
>  
> If you are running on a Windows machine, you may want to use the 
> --max-memory command line parameter to set the memory size.  I have 
> 1GB and set the max to 800MB.  You may also want to remove any extra 
> objects and do 'gc()' before working with a large object to try and 
> get memory cleared up.
>
>  
> On 1/5/06, *Patrick Giraudoux* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Dear Aaron,
>
> I am really  a tool user and not a tool maker (actually an ecologist
> doing some biostatistics)... so, I take the liberty of sending a
> copy of
> this e-mail to the r-help list where capable computer persons and true
> statisticians may provide more relevant information and also to Paulo
> Ribeiro and Peter Diggle, the authors of geoR..
>
> I really feel that your huge matrix cannot be handled in R that easy,
> and I get the same kind of error as you:
>
> > m=matrix(1,ncol=18227, nrow=18227)
> Error: cannot allocate vector of size 2595496 Kb
> In addition: Warning messages:
> 1: Reached total allocation of 511Mb: see help( memory.size)
> 2: Reached total allocation of 511Mb: see help(memory.size)
>
> However, if you want to compute a distance matrix, have a look to the
> function:
>
> ?dist
>
> and try it... You will not have to create the distance matrix
> yourself
> from the coordinates file (but you may meet meory problem anyway).
> Still
> more straigthfully, if you intend to use interpolation methods such as
> kriging, you don't need to manage the distance matrix building by
> yourself. See:
>
> library(geoR)
> library(help=geoR)
> ?variog
> ?variofit
> ?likfit?
>
> etc...
>
> If you want further use geostatics (eg via geoR or gstat), you will
> anyway have to manage with memory limits (not due to R). On my
> computer
> (portable HP compaq nx7000) I can hardly manage with more than 2000
> observations using geoR (far from your 18227 observations). I had to
> krige on a dataset with 9000 observations recently and has been led to
> subsample randomly 2000 values. You can however try and  increase the
> memory allocated to R on your computer. The size limit is hardware
> dependent, eg:
>
> ?memory.size
> ?memory.limit
> / memory.limit(size=5) /
>
> Another way may be to perform local kriging (eg kriging within the
> dataset on a fixed radius), but to my knowldege this cannot be
> done with
> geoR (unfortunately). The library gstat offers this option, but
> has much
> more limited possibilities than geoR considering other issues
> (variogram
> analysis, etc...).
>
> library(gstat)
> ?krige
>
> see argument 'maxdist'
>
> Hope this can help,
>
> Kind regards
>
>
> Patrick Giraudoux
> --
>
> Department of Environmental Biology
> EA3184 usc INRA
> University of Franche-Comte
> 25030 Besancon Cedex
> (France)
>
> tel. +33 381 665 745
> fax +33 381 665 797
> http://lbe.univ-fcomte.fr
>
>
> Aaron Swoboda a écrit :
>
> > Dear Sir:
> >
> >
> > I ran across your post to the R-help archive from February 9it is
> > attached below since it was nearly two years ago!). I am
> beginning to
> > learn R and am interested in analyzing some of my data in a spatial
> > context. I am having a problem that seems similar to the problem you
> > encountered, trying to work with a large matrix in Windows XP).
> I am
> > wondering if you could help steer me in the direction that
> helped you
> > solve your problem. I am trying to construct a distance matrix
> > containing the all of the distances between my 18,000 observations.
> > Trying to make a matrix that large gets an error message...
> >
> > m=matrix(1,ncol=18227, nrow=18227)
> >
>   

Re: [R] Memory limitation in GeoR - Windows or R?

2006-01-05 Thread Patrick Giraudoux
Dear Aaron,

I am really  a tool user and not a tool maker (actually an ecologist 
doing some biostatistics)... so, I take the liberty of sending a copy of 
this e-mail to the r-help list where capable computer persons and true 
statisticians may provide more relevant information and also to Paulo 
Ribeiro and Peter Diggle, the authors of geoR..

I really feel that your huge matrix cannot be handled in R that easy, 
and I get the same kind of error as you:

 > m=matrix(1,ncol=18227, nrow=18227)
Error: cannot allocate vector of size 2595496 Kb
In addition: Warning messages:
1: Reached total allocation of 511Mb: see help(memory.size)
2: Reached total allocation of 511Mb: see help(memory.size)

However, if you want to compute a distance matrix, have a look to the 
function:

?dist

and try it... You will not have to create the distance matrix yourself 
from the coordinates file (but you may meet meory problem anyway). Still 
more straigthfully, if you intend to use interpolation methods such as 
kriging, you don't need to manage the distance matrix building by 
yourself. See:

library(geoR)
library(help=geoR)
?variog
?variofit
?likfit?

etc...

If you want further use geostatics (eg via geoR or gstat), you will 
anyway have to manage with memory limits (not due to R). On my computer 
(portable HP compaq nx7000) I can hardly manage with more than 2000 
observations using geoR (far from your 18227 observations). I had to 
krige on a dataset with 9000 observations recently and has been led to 
subsample randomly 2000 values. You can however try and  increase the 
memory allocated to R on your computer. The size limit is hardware 
dependent, eg:

?memory.size
?memory.limit
/ memory.limit(size=5) /

Another way may be to perform local kriging (eg kriging within the 
dataset on a fixed radius), but to my knowldege this cannot be done with 
geoR (unfortunately). The library gstat offers this option, but has much 
more limited possibilities than geoR considering other issues (variogram 
analysis, etc...).

library(gstat)
?krige

see argument 'maxdist'

Hope this can help,

Kind regards


Patrick Giraudoux
-- 

Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)

tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr


Aaron Swoboda a écrit :

> Dear Sir:
>
>
> I ran across your post to the R-help archive from February 9it is 
> attached below since it was nearly two years ago!). I am beginning to 
> learn R and am interested in analyzing some of my data in a spatial 
> context. I am having a problem that seems similar to the problem you 
> encountered, trying to work with a large matrix in Windows XP). I am 
> wondering if you could help steer me in the direction that helped you 
> solve your problem. I am trying to construct a distance matrix 
> containing the all of the distances between my 18,000 observations. 
> Trying to make a matrix that large gets an error message...
>
> m=matrix(1,ncol=18227, nrow=18227)  
>
> Error: cannot allocate vector of size 2595496 Kb
> In addition: Warning messages:
> 1: Reached total allocation of 1023Mb: see help(memory.size)
>
> Thank you for any help you may be able to send my way.
>
> ~Aaron Swoboda
>
> Below is your posting to the R-help list...
>
>
> Dear all,
>
> I a read with great interest the e-mails related to Arnav Sheth about 
> memory limitation when computing a distance matrix. I suspect
> that I will also meet some memory limitation using GeoR. I am 
> currently running GeoR on a geodata object including 2686 geographical
> coordinates.
>
> krige.conv() can handle it (it takes 10-15 mn of computing) but 
> requests an increased memory.
>
> /> memory.limit(size=5) /
>
> When the computing is completed, the computer speed is considerably 
> slowed down for any application. It is thus most necessary to
> shut it down and restart. I will probably have to handle a set of 
> 5000-6000 coordinates in once in the next few months. I wonder if
> it will go through it on my plateform (Windows XP and compaq nx7000). 
> If not, will the limitation due to R or to Windows? Does an
> alternate solution exist?
>
> Thanks for any hint,
>
> Patrick Giraudoux
>
>-- 
>Dr. Aaron M. Swoboda
>3208 Posvar Hall
>Graduate School of Public and International Affairs
>University of Pittsburgh
>Pittsburgh, PA 15260
>
>e-mail: [EMAIL PROTECTED]
>Office: 412-648-7604
>Fax:412-648-2605
>  
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] glmmPQL and variance structure

2005-12-27 Thread Patrick Giraudoux
Dear listers,

glmmPQL (package MASS) is given to work by repeated call to lme. In the 
classical outputs glmmPQL  the Variance Structure is given  as " fixed 
weights,  Formula: ~invwt".  The script shows that the function 
varFixed() is used, though the place where 'invwt' is defined remains 
unclear to me.  I wonder if there is an easy way to specify another 
variance structure (eg varPower, etc..), preferably using an lme object 
of the varFunc classes ? Some trials show that the 'weights' argument of 
glmmPQL is just the same as in glm (which is clearly stated in the help) 
and I wonder actually, if not a nonsense, how to pass eg a 'weights' 
arguments as used in lme (eg weights=varPower()) to specify a variance 
function (in the same way as a correlation structure can be passed easy).

Thanks in advance for any hint,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] repeated values, nlme, correlation structures

2005-11-20 Thread Patrick Giraudoux
Looks fine... and at least accessible to my current understanding and 
capacity.  I wonder if this kind of problem/method would not make a pure 
Bayesian very excited (I know one quite obsessional about it)... and 
propose an alternate approach from there (though beyond my own skill)...

Thanks a lot again. Will do like that ASAP (means w.e.).

Patrick

-- 

Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)

tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr




Spencer Graves a écrit :

> ANOTHER CONCRETE SUGGESTION:
>
>   Have you considered Monte Carlo?  Take your best model (and 
> perhaps some plausible alternatives), and simulate data like what you 
> have, but retaining the simulated chick identities.  Then analyze the 
> simulated data both with and without the chick identities, averaging 
> over the nestboxes, as you've done.  This is easy to do in R.
>
> PHILOSOPHY:
>
>   At a general, conceptual level, nlme and most other "parametric" 
> statistical procedures use maximum likelihood.  The likelihood is the 
> probability (density) of what we observe, considered as a function of 
> the unknown parameters.  With mixed models, we use a marginal 
> likelihood, integrating out the individual parameters for all the 
> nestboxes and chicks, leaving the "fixed effect" parameters and the 
> (co)variance parameters of the random effects.  This leads to a 
> generalized least-squares problem, with the (co)variance parameters 
> embedded in some way in the residual covariance matrix.
>
>   This converts the problem to one of understanding and modeling 
> the covariance structure of the residuals.  If I've lost the identity 
> of the chicks but I've got a good model for the covariance structure 
> of the residuals, I think the answer using nestbox averages should be 
> fairly close to the answer I'd get if I thought really hard and 
> developed a likelihood more accurately suited to the problem.  This 
> will be less true with a nonlinear model, and even less true if the 
> number of chicks who die before the end of the experiment.  To answer 
> these questions, I'd use Monte Carlo, as I suggested above.
>
>   Best Wishes,
>   Spencer Graves
> 
> Patrick Giraudoux wrote:
>
>> Spencer Graves a écrit :
>>
>>>   You are concerned that, "using the mean of each age category 
>>> as variable leads to a loss of information regarding the variance on 
>>> the weight at each age and nestbox."  What information do you think 
>>> you lose?
>>
>>
>>
>> The variance  around the mean weight of each age category. This 
>> variation is a priori not considered in the model when using the mean 
>> only, and not each value used to compute the mean..
>>
>>>
>>>   In particular, have you studied the residuals from your fit?  
>>> I would guess that the you probably have heterscedasticity with the 
>>> variance of the residuals probably increasing with the age.  Plots 
>>> of the absolute residuals might help identify this.  
>>
>>
>>
>> Yes, of course. At this stage using a  Continuous AR(1) as 
>> Correlation Structure, reduces considerably heteroscedasticity up to 
>> quasi-normal.
>>
>>> Also, is the number of blue tits in each age constant, or does it 
>>> change, e.g., as some of the chicks die?
>>
>>
>>
>> Yes, unfortunately, it may happen eventually.
>>
>>>
>>>   To try to assess how much information I lost (especially if 
>>> some of the chicks died), I might plot the weights in each nest box 
>>> and connect the dots manually, attempting to assign chick identity 
>>> to the individual numbers.  I might do it two different ways, one 
>>> best fit, and another "worst plausible".  Then I might try to fit 
>>> models to these two "augmented data sets" as if I had the true chick 
>>> identity.  Then comparing these fits with the one you already have 
>>> should help you evaluate what information you lost by using the 
>>> averages AND give you a reasonable shot at recovering that 
>>> information.  If the results were promising, I might generate more 
>>> than two sets of assignments, involving other people in that task.
>>
>>
>>
>> OK, should not be that difficult (actually the data were given with 
>> pseudo-ID numbers on each chicks and I started with this... until I 
>> learned they were corresponding to nothing). I suppose one could go 
>> as far as possible w

Re: [R] repeated values, nlme, correlation structures

2005-11-19 Thread Patrick Giraudoux
Spencer Graves a écrit :

>   You are concerned that, "using the mean of each age category as 
> variable leads to a loss of information regarding the variance on the 
> weight at each age and nestbox."  What information do you think you lose?

The variance  around the mean weight of each age category. This 
variation is a priori not considered in the model when using the mean 
only, and not each value used to compute the mean..

>
>   In particular, have you studied the residuals from your fit?  I 
> would guess that the you probably have heterscedasticity with the 
> variance of the residuals probably increasing with the age.  Plots of 
> the absolute residuals might help identify this.  

Yes, of course. At this stage using a  Continuous AR(1) as Correlation 
Structure, reduces considerably heteroscedasticity up to quasi-normal.

> Also, is the number of blue tits in each age constant, or does it 
> change, e.g., as some of the chicks die?

Yes, unfortunately, it may happen eventually.

>
>   To try to assess how much information I lost (especially if some 
> of the chicks died), I might plot the weights in each nest box and 
> connect the dots manually, attempting to assign chick identity to the 
> individual numbers.  I might do it two different ways, one best fit, 
> and another "worst plausible".  Then I might try to fit models to 
> these two "augmented data sets" as if I had the true chick identity.  
> Then comparing these fits with the one you already have should help 
> you evaluate what information you lost by using the averages AND give 
> you a reasonable shot at recovering that information.  If the results 
> were promising, I might generate more than two sets of assignments, 
> involving other people in that task.

OK, should not be that difficult (actually the data were given with 
pseudo-ID numbers on each chicks and I started with this... until I 
learned they were corresponding to nothing). I suppose one could go as 
far as possible with the "worst possible" with random assignements and 
permutations, and thus comparing the fits.

Many thanks for the hint. I was really wondering what may mean no answer 
on the list... Problem not clear enough, trivial solution or real 
trouble for statisticians with such data? Quite  scaring to a 
biologist...  Now, I am fixed.

> If the results were promising, I might generate more than two sets of 
> assignments, involving other people in that task. 

Of course if some capable mixed-effect models specialist is interested 
in having a look to the data set, I can send it off list.

Many thanks again, Spencer, I can stick on the track, now...

Best regards,

Patrick


>   Bon Chance
>   Spencer Graves
>
> Patrick Giraudoux wrote:
>
>> Dear listers,
>>
>> My request of last week seems not to have drawn someone's attention. 
>> Suppose it was not clear enough.
>>
>> I am coping with an observational study where people's aim was to fit 
>> growth curve for a population of young blue tits. For logistic 
>> reasons, people have not been capable to number each individual, but 
>> they have a method to assess their age. Thus, nestboxes were visited 
>> occasionnally, youngs aged and weighted.
>>
>> This makes a multilevel data set, with two classification factors:
>>
>> - the nestbox (youngs shared the same parents and general feeding 
>> conditions)
>> - age in each nestbox (animals from the same nestbox have been 
>> weighed along time, which likely leads to time correlation)
>>
>> Life would have been heaven if individuals were numbered, and thus 
>> nlme correlation structure implemented in the package be used easy. 
>> As mentioned above, this could not be the case. In a first approach, 
>> I actually used the mean weight of the youngs weighed at each age in 
>> nest boxes for the variable "age", and could get a nice fit with 
>> "nestbox" as random variable and corCAR1(form=~age|nestbox) as 
>> covariation structure.
>>
>> modm0c<-nlme(pds~Asym/(1+exp((xmid-age)/scal)),
>> fixed=list(Asym~1,xmid~1,scal~1),
>> random=Asym+xmid~1|nestbox,data=croispulm,
>> start=list(fixed=c(10,5,2.2)),
>> method="ML",
>> corr=corCAR1(form=~age|nestbox)
>> )
>>
>> Assuming that I did not commited some error in setting model 
>> parameters (?), this way of doing is not fully satisfying, since 
>> using the mean of each age category as variable  leads to a  loss of 
>> information regarding the variance on the weight at each age and 
>> nestbox.
>>
>> My question is: is there a way to handle repeate

[R] generalised linear mixed effect model, glmmPQL

2005-11-16 Thread Patrick Giraudoux
Dear listers,

I am trying to get more familiar with concepts underlying generalised 
linear mixed models, mainly through Venables and Ripley (fourth edition) 
and the R-list archive. Of course, as a  possibly tool-user biologist I 
am not that easy with every détails of the mathematical aspects of the 
optimisation methods described. I am trying to sort out which could be 
an acceptable strategy for model comparisons and selection. I have 
understood from the R-list archive that AIC and similar approaches are 
not valid for model comparisons with PQL. On the other hand, table 10.4 
in Venables and Ripley compares the results of various fitting methods 
(thus the fitting methods), but my wonder is about  comparing  models 
(or parameter estimates) given a  method.

Can somebody put me on the track with some hints or  basic references 
for "dummies" if any...

Thanks in advance,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] repeated values, nlme, correlation structures

2005-11-11 Thread Patrick Giraudoux
Dear listers,

My request of last week seems not to have drawn someone's attention. 
Suppose it was not clear enough.

I am coping with an observational study where people's aim was to fit 
growth curve for a population of young blue tits. For logistic reasons, 
people have not been capable to number each individual, but they have a 
method to assess their age. Thus, nestboxes were visited occasionnally, 
youngs aged and weighted.

This makes a multilevel data set, with two classification factors:

- the nestbox (youngs shared the same parents and general feeding 
conditions)
- age in each nestbox (animals from the same nestbox have been weighed 
along time, which likely leads to time correlation)

Life would have been heaven if individuals were numbered, and thus nlme 
correlation structure implemented in the package be used easy. As 
mentioned above, this could not be the case. In a first approach, I 
actually used the mean weight of the youngs weighed at each age in nest 
boxes for the variable "age", and could get a nice fit with "nestbox" as 
random variable and corCAR1(form=~age|nestbox) as covariation structure.

modm0c<-nlme(pds~Asym/(1+exp((xmid-age)/scal)),
fixed=list(Asym~1,xmid~1,scal~1),
random=Asym+xmid~1|nestbox,data=croispulm,
start=list(fixed=c(10,5,2.2)),
method="ML",
corr=corCAR1(form=~age|nestbox)
)

Assuming that I did not commited some error in setting model parameters 
(?), this way of doing is not fully satisfying, since using the mean of 
each age category as variable  leads to a  loss of information regarding 
the variance on the weight at each age and nestbox.

My question is: is there a way to handle repeated values per group (here 
several youngs in an age category in each nestbox) in such a case?

I would really appreciate an answer, even negative...

Kind regards,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] repeated values, nlme, correlation structures

2005-11-07 Thread Patrick Giraudoux
Dear listers,

As an exercise, I am trying to fit a logistic model with nlme.  Blue tit 
pulli (youngs) were weighted occasionnally (for field reasons) along 
time in 17 nestboxes. Individuals where not idenfied but their age was 
known. This means that for a given age several measurements were done 
but individuals could not be identified from a time to the other. This 
makes repeated values for a given age group in each nestbox. The aim is 
to get an acceptable growth curve (weight against age).

As far as repeated values cannot be handled with standard coStruct 
classes of nlme, I have done a first fit with nlme using the mean of 
each group. Comparing several models, the best fit is:

modm0c<-nlme(pds~Asym/(1+exp((xmid-age)/scal)),
fixed=list(Asym~1,xmid~1,scal~1),
random=Asym+xmid~1|nichoir,data=croispulm,
start=list(fixed=c(10,5,2.2)),
method="ML",
corr=corCAR1()
)

with pds = weight, age = mean age of each age group, nichoir = nestbox 
(a factor of 17 levels)

Based on the empirical autocorrelation function of the normalised 
residuals drawn from this model one can acceptaly assume that  the 
normalized residuals behave like uncorrelated noise.

Though this could be quite satisfying at first sight,  I am quite 
frustrated with starting from the mean weight of each age group, thus 
not being capable to manage and incorporate the variability around the 
mean weight of each age group in the model. My bible is Pinheiro & Bates 
(2000), but I did not find an example to board this problem.

Is there an affordable way (=not that much complicated for a biologist 
familiar to some general statistics) to handle this in nlme?

Any hint?

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] nlme, predict.nlme, levels not allowed

2005-11-06 Thread Patrick Giraudoux
Going through the R-Dev list, I have found this (from Pedro Afalo), 
dated 8 April 2004:

> Dear Richard,
>
> The problem that you report is documented (but no solution given) in the
> file ch08.R in the scripts directory of nlme package.
>
> I have found the following workaround just by chance, but it may
> give a clue of what is the problem to those who know how to program
> in R.
>
> The solution is to add an explicit call to factor in the nlme call.
> In the case of the error reported by Richard the following call to nlme
> in the ch08.R file can be used:
>
> fm4CO2.nlme <- update( fm3CO2.nlme,
>fixed = list(Asym + lrc ~ factor(Type) * factor(Treatment), c0 ~ 1),
>start = c(fm3CO2.fix[1:5], 0, 0, 0, fm3CO2.fix[6]) )
>
> instead of:
>
> fm4CO2.nlme <- update( fm3CO2.nlme,
>fixed = list(Asym + lrc ~ Type * Treatment, c0 ~ 1),
>start = c(fm3CO2.fix[1:5], 0, 0, 0, fm3CO2.fix[6]) )
>
> I hope this helps,
>
> Pedro. 


I have tried the workaround for my own case and it works...

Any news since then about fixing the problem?

Patrick


Patrick Giraudoux a écrit :

> Dear listers,
>
> I am trying to fit a nlme model with "age" and "pds" as reals, and 
> "zone" a factor  with two levels "Annaba" and "Boumalek" . The "best" 
> model found is the following:
>
> > modm3
> Nonlinear mixed-effects model fit by maximum likelihood
>  Model: pds ~ Asym/(1 + exp((xmid - age)/scal))
>  Data: croispulm
>  Log-likelihood: -91.86667
>  Fixed: list(Asym ~ zone, xmid ~ zone, scal ~ 1)
> Asym.(Intercept) Asym.zoneBoumalek  xmid.(Intercept) 
> xmid.zoneBoumalek  scal
>   9.995510790.394239664.97981027
> 0.069698072.23116661
>
> Random effects:
> Formula: list(Asym ~ 1, xmid ~ 1)
> Level: nichoir
> Structure: General positive-definite, Log-Cholesky parametrization
> StdDev   Corr Asym.(Intercept) 1.796565e-06 As.(I)
> xmid.(Intercept) 1.219400e-04 0Residual 6.163282e-01 
> Correlation Structure: Continuous AR(1)
> Formula: ~age | nichoir
> Parameter estimate(s):
>  Phi
> 0.3395242
> Number of Observations: 102
> Number of Groups: 17
>
>
> Everything normal so far.
>
> Things come to be strange when I try to compute predicted values:
>
> > pred<-predict(modm3,newdata=mydata,type="response")
> Error in predict.nlme(modm3, newdata = mydata, type = "response") :
>Levels Annaba,Boumalek not allowed for zone
>
> I have checked and re-checked that zone in the newdata is well a 
> factor with the "good" levels, and I can hardly understand why these 
> two levels used when fitting the model are now rejected when used for 
> computing predicted values.
>
> Any hint welcome,
>
> Best regards,
>
> Patrick
>
>
>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] nlme, predict.nlme, levels not allowed

2005-11-05 Thread Patrick Giraudoux
Dear listers,

I am trying to fit a nlme model with "age" and "pds" as reals, and 
"zone" a factor  with two levels "Annaba" and "Boumalek" . The "best" 
model found is the following:

 > modm3
Nonlinear mixed-effects model fit by maximum likelihood
  Model: pds ~ Asym/(1 + exp((xmid - age)/scal))
  Data: croispulm
  Log-likelihood: -91.86667
  Fixed: list(Asym ~ zone, xmid ~ zone, scal ~ 1)
 Asym.(Intercept) Asym.zoneBoumalek  xmid.(Intercept) 
xmid.zoneBoumalek  scal
   9.995510790.394239664.97981027
0.069698072.23116661

Random effects:
 Formula: list(Asym ~ 1, xmid ~ 1)
 Level: nichoir
 Structure: General positive-definite, Log-Cholesky parametrization
 StdDev   Corr 
Asym.(Intercept) 1.796565e-06 As.(I)
xmid.(Intercept) 1.219400e-04 0
Residual 6.163282e-01  

Correlation Structure: Continuous AR(1)
 Formula: ~age | nichoir
 Parameter estimate(s):
  Phi
0.3395242
Number of Observations: 102
Number of Groups: 17


Everything normal so far.

Things come to be strange when I try to compute predicted values:

 > pred<-predict(modm3,newdata=mydata,type="response")
Error in predict.nlme(modm3, newdata = mydata, type = "response") :
Levels Annaba,Boumalek not allowed for zone

I have checked and re-checked that zone in the newdata is well a factor 
with the "good" levels, and I can hardly understand why these two levels 
used when fitting the model are now rejected when used for computing 
predicted values.

Any hint welcome,

Best regards,

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] LaTex error when creating DVI version when compiling package

2005-10-29 Thread Patrick Giraudoux
Thanks both Explanations perfectly clear. Also you make me discover 
there was a 'pgirmess-manual.log', with error lines detected and 
commented, indeed... (shame on me!!!) which would have been of great 
help during the past decade... The misuse of _ should be the origin.

I should manage with, now.

Thank again,

Patrick

>The general answer is to look through the (often very long) *.log file in 
>the *.Rcheck directory until you find the problem. That will typically 
>give you a line number in the *.tex file, which shows not only where the 
>error occurred, but the *.log file entry often shows what it is. My 
>typical errors are using LaTeX special symbols, and most often having 
>unprotected $ and _. I see quite a lot of _ below in \value{}, so I'd try 
>\_ there first.
>
>Roger
>


Berwin A Turlach a écrit :

>G'day Patrick
>
>  
>
>>>>>>"PG" == Patrick Giraudoux <[EMAIL PROTECTED]> writes:
>>>>>>
>>>>>>
>
>PG> \value{ A list with the following items: \item{AIC}{a
>PG> data.frame including LL, the maximized log-likelihood; K the
>PG> number of estimated parameters; N2K, number of observations/K;
>PG> AIC, the Akaike index criterion; deltAIC, the difference
>PG> between AIC and the lowest AIC value; w_i, the Akaike weights;
>w_i is LaTeX notation for "w subscript i" and needs to be inside a
>maths environment otherwise there will be a LaTeX error.  Change this
>to, e.g. \eqn{w_i}
>
>PG> AICc, the second order Akaike criterion; deltAICc, the
>PG> difference between AICc and the lowest AICc value; w_ic, the
>w_ic is LaTeX notation for "w subscript i followed by c".  This needs
>to be insite a maths environment to avoid a LaTeX error.  But I
>presume that your intention is actuall "w subscript {ic}", thus change
>this to, e.g. \eqn{w_{ic}}
>
>HTH.
>
>Cheers,
>
>Berwin
>
>PS:  Would make life simple for checker if you sent along the .log
> file in future. :)
>
>  
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] LaTex error when creating DVI version when compiling package

2005-10-29 Thread Patrick Giraudoux
Dear Listers,

I got this message when compiling a package:

* creating pgirmess-manual.tex ... OK
* checking pgirmess-manual.text ... ERROR
LaTex errors when creating DVI version.
This typically indicates Rd problems.

The message is quite explicit but I struggled a lot before understanding 
that the trouble comes from a single file "selMod.rd" among 44 topics. 
Even though I have checked it ten times and even rewrite it on 
prompt(selMod), I cannot find out what is wrong with it.

Can somebody used with LaTex and the format of R *.rd file have a quick 
look to the attached contents and tell me if he can detect some obvious 
faulty writing?

Thanks in advance,

Patrick



\name{selMod}
\alias{selMod}
\alias{selMod.lm}
\alias{selMod.glm}
\alias{selMod.list}

\title{ Model selection according to information theoretic methods }
\description{
 Handles lm, glm and list of models lm, glm, lme and nlme objects and 
provides parameters to compare models according to Anderson et al. (1998)
}
\usage{
selMod(aModel, Order = "AICc", ...) group method

selMod.lm(aModel, Order = "AICc", dropNull = FALSE, selconv=TRUE, ...)
selMod.list(aModel, Order = "AICc", ...)
}

\arguments{
  \item{aModel}{ a lm or glm model or a list of lm or glm models }
  \item{dropNull}{ if TRUE, drops the simplest model (e.g. 'y~1')  }
  \item{Order}{ if set to "AICc" (default) sort the models on this 
parameter, otherwise "AIC" is allowed }
  \item{selconv}{ if TRUE (default) keep the models for which 
convergence is obtained (glm object only) and with no anova singularity 
(lm and glm) }
  \item{...}{ other parameters to be passed as arguments (not used here) }
}

\details{
  This function provides parameters used in the information theoretic 
methods for model comparisons. lm and glm objects can be passed directly 
as the upper scope of term addition (all terms added).
  Every model from 'y~1' is computed adding one term at a time until the 
upper scope model is derived. A list of user specified lm, glm, lme or 
nlme objects can alternately be passed.
}

\value{
 A list with the following items:
  \item{AIC}{a data.frame including LL, the maximized log-likelihood; K 
the number of estimated parameters; N2K, number of observations/K; AIC, 
the Akaike index criterion; deltAIC, the difference between AIC and the 
lowest AIC value; w_i, the Akaike weights; AICc, the second order Akaike 
criterion; deltAICc, the difference between AICc and the lowest AICc 
value; w_ic, the AICc weights }
  \item{models}{the list of models}
}
\references{
Anderson, D.R., Link, W.A., Johnson, D.H. and Burnham, K.P. (2001). 
Suggestions for presenting the results of data analyses. Journal of 
Wildlife Management, 65, 373-378; Burnham, K.P. and Anderson, D.R. 
(2002) Model Selection and Multimodel Inference: a Practical 
Information-Theoretic Approach, 2nd edn., Springer-Verlag, New York. 353 pp
 }
\author{ Patrick Giraudoux and David Pleydell: [EMAIL PROTECTED], 
[EMAIL PROTECTED] }

\seealso{ \code{\link{AIC}},\code{\link{logLik}} }
\examples{
 library(MASS)
 anorex.1 <- lm(Postwt ~ Prewt*Treat, data = anorexia)
 selMod(anorex.1)
 anorex.2 <- glm(Postwt ~ Prewt*Treat, family=gaussian,data = anorexia)
 selMod(anorex.2)
 anorex.3<-lm(Postwt ~ Prewt+Treat, data = anorexia)
 selMod(list(anorex.1,anorex.2,anorex.3))
}
\keyword{ models }

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] unexpected error message with variog.mc.env() - geoR

2005-09-04 Thread Patrick Giraudoux
Dear R-listers,

I have got an error with variog.mc.env() package:geoR that I cannot sort 
the origin out.  The origianal data file can be sent to people interested.

bin0<-variog(don1bgeo,estimator.type="modulus",  direction=0)
bin90<-variog(don1bgeo,estimator.type="modulus",  direction=pi/2)
env.variog0<-variog.mc.env(don1bgeo,obj.variog=bin0)
env.variog90<-variog.mc.env(don1bgeo,obj.variog=bin90)

everything goes smoothly with bin90, but using bin0 gives this error
after permutations:

 > Error in variog.mc.env(don1bgeo, obj.variog = bin0) :
 (subscript) logical subscript too long

Any idea about what happens?

Regards,

Patrick

-- 

Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)

tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Set R 2.1.1. in English

2005-08-18 Thread Patrick Giraudoux
OK. ¨Perfectly clear.

This written for other listers:

Shortcut is the shortcuts ("alias") everybody use to launch applications 
(in French: "raccourci"), and for suckers (as I am): one just have to 
right-click the shortcut used to launch Rgui.exe, select properties 
("propriétés" in French) and add in the box target ("cible" in French) 
LANGUAGE=en to the path. In my case: C:\R\rw2011\bin\Rgui.exe. Thus, it 
makes C:\R\rw2011\bin\Rgui.exe LANGUAGE=en. Then click OK.

It works fantastic

Thanks a lot for this. It makes three weeks I was grumling everytime 
(often) I started R, and frustrated with the SDI mode...

Patrick Giraudoux



Prof Brian Ripley a écrit :

> On Thu, 18 Aug 2005, Patrick Giraudoux wrote:
>
>>> (whish R
>>> 2.1.1 could be parametrise 'English' even with a French Windows XP)
>>>
>>> If I understand you correctly, it can.  Just add LANGUAGE=en to the 
>>> shortcut.
>>
>
>> Wonderful hope but not sure to catch what you term "shortcut". I 
>> tried to add this command in C:\R\rw2011\etc\Rprofile, the .Rprofile 
>> in the folder my documents, but this cannot be understood from 
>> there...  which obviously shows that "shortcut" is not a general term 
>> for profiles! I have also
>
>
> See the rw-FAQ Q2.2.
> `Shortcut' is the standard name for files on Windows with extension .lnk.
>
> Another way is to add this to HOME/.Renviron: see the rw-FAQ Q2.17
>
>> unsuccessfully looked for a file "shortcut" in the rw2011 folder. I 
>> also tried and went through the R-help archive. There were some 
>> exchanges on this subject and Asian languages some weeks ago but what 
>> I have tried and adapt on this basis did not work.
>>
>> The objective would be to have R in  English (thus additionnally 
>> allowing MDI mode with R-WinEdt, which is not the case with any other 
>> language) and to keep Windows XP and other applications in the 
>> foreign (= French, here) language.
>>
>> Thanks for any further hint,
>>
>> Patrick Giraudoux
>>
>>
>>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] axTicks and window resizing

2005-08-18 Thread Patrick Giraudoux
OK. Things work now and the window can be resized easy after adding at = 
axTicks() in axis() explicitely. This makes:

profplot<-function(x,y,z=10,...){
op <- par()$mai
par(mai=c(0.95625,0.76875,0.76875,0.95625))
plot(x,y*z, type="l",asp=1,las=1,xlab="",ylab="",yaxt="n",...)
axis(2,at=axTicks(2),labels=axTicks(2)/z,las=1)
axis(4,at=axTicks(2),labels=axTicks(2)/z,las=1)
par(mai=op)
}

Thanks for the hint,

Patrick

Prof Brian Ripley a écrit :

> On Thu, 18 Aug 2005, Patrick Giraudoux wrote:
>
>> Dear listers,
>>
>> I have written a function to facilitate the drawing of altitude profiles
>> with x (distance), y (altitude) and a z  parameter (altitude 
>> magnification).
>>
>> profplot<-function(x,y,z=10,...){
>> op <- par()$mai
>> par(mai=c(0.95625,0.76875,0.76875,0.95625))
>> plot(x,y*z, type="l",asp=1,las=1,xlab="",ylab="",yaxt="n",...)
>> axis(2,labels=axTicks(2)/z,las=1)
>> axis(4,labels=axTicks(2)/z,las=1)
>> on.exit(par(mai=op))
>> }
>>
>> This worked apparently well until I had to resize the graphical window
>> after plotting. In this case, I get this message:
>>
>> >  profplot(prof$dist,prof$alt,col="blue")
>> > Erreur : les longueurs de 'at' et de 'label' diffèrent, 7 != 8
>>
>> Which means Error: length of 'at' and "label' differ, 7!=8 (whish R
>> 2.1.1 could be parametrise 'English' even with a French Windows XP)
>
>
> If I understand you correctly, it can.  Just add LANGUAGE=en to the 
> shortcut.
>
>> At this stage, R crashes (= I cannot get the graphic window
>> working/resized and must interrupt the process from Windows XP, then
>> restart R for good work with the graphical window).
>>
>> The error occur with the difference between the tick number computed
>> from plot() and the one computed with axTicks(). If still equal (slight
>> resizing) everything goes smoothly.
>
>
> The problem is that you need to specify 'at' and 'labels' to axis(): 
> you cannot safely specify just labels.  When re-drawing, 'at' is 
> recomputed, but your specification of 'labels' is not.
>
> I suspect you can just do dev.off() and open a new graphics window.
>
>> Thanks for any comments, even rude... (I am not sure the
>> problem/programme has been tackled relevantly enough)
>>
>> Patrick
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Set R 2.1.1. in English

2005-08-18 Thread Patrick Giraudoux
> (whish R
> 2.1.1 could be parametrise 'English' even with a French Windows XP)
>
> If I understand you correctly, it can.  Just add LANGUAGE=en to the 
> shortcut. 


Wonderful hope but not sure to catch what you term "shortcut". I tried 
to add this command in C:\R\rw2011\etc\Rprofile, the .Rprofile in the 
folder my documents, but this cannot be understood from there...  which 
obviously shows that "shortcut" is not a general term for profiles! I 
have also unsuccessfully looked for a file "shortcut" in the rw2011 
folder. I also tried and went through the R-help archive. There were 
some exchanges on this subject and Asian languages some weeks ago but 
what I have tried and adapt on this basis did not work.

The objective would be to have R in  English (thus additionnally 
allowing MDI mode with R-WinEdt, which is not the case with any other 
language) and to keep Windows XP and other applications in the foreign 
(= French, here) language.

Thanks for any further hint,

Patrick Giraudoux

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] axTicks and window resizing

2005-08-18 Thread Patrick Giraudoux
Dear listers,

I have written a function to facilitate the drawing of altitude profiles 
with x (distance), y (altitude) and a z  parameter (altitude magnification).

profplot<-function(x,y,z=10,...){
op <- par()$mai
par(mai=c(0.95625,0.76875,0.76875,0.95625))
plot(x,y*z, type="l",asp=1,las=1,xlab="",ylab="",yaxt="n",...)
axis(2,labels=axTicks(2)/z,las=1)
axis(4,labels=axTicks(2)/z,las=1)
on.exit(par(mai=op))
}

This worked apparently well until I had to resize the graphical window 
after plotting. In this case, I get this message:

 >  profplot(prof$dist,prof$alt,col="blue")
 > Erreur : les longueurs de 'at' et de 'label' diffèrent, 7 != 8

Which means Error: length of 'at' and "label' differ, 7!=8 (whish R 
2.1.1 could be parametrise 'English' even with a French Windows XP)

At this stage, R crashes (= I cannot get the graphic window 
working/resized and must interrupt the process from Windows XP, then 
restart R for good work with the graphical window).

The error occur with the difference between the tick number computed 
from plot() and the one computed with axTicks(). If still equal (slight 
resizing) everything goes smoothly.

Thanks for any comments, even rude... (I am not sure the 
problem/programme has been tackled relevantly enough)

Patrick

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RCMD check error windows

2005-04-23 Thread Patrick Giraudoux

Ah! See R-2.1.0's version of the manual "R Installation and 
Administration", Sections "Installing R under Windows" and in 
particular Appendix E "The Windows toolset".

Uwe Ligges

OK. Got it... When I started packaging home made functions one year ago, 
I did not use compiled code, and just install  the command line tools 
and perl, and not the following utilities (MinGW compiler, etc...).

Ashes on my head again... and warm thanks to Uwe!
Patrick
Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)
tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr

Uwe Ligges a écrit :
Patrick Giraudoux wrote:
Dear Uwe,
Is this a full installation of R (I guess you have not compiled it 
yourself)? If yes, does gcc, perl and friends work?
In the first place, libR.a must be compiled at this point which 
should happen automatically.
But it is really hard to say which of the tools fails exactly.

Uwe Ligges

I have just intalled R 2.1.0 pre-compiled from CRAN and I can confirm 
this is a full installation. R works wonderfully well (as usual). 
Perl at least work since I have built 'simple' packages since long 
through it, without any problem. John Fox's scripts helped a lot at 
the beginning and now I write the code RCMD... directly. However, I 
don't now about gcc and I don't remember to have installed something 
like this and even how it should be done...   Is there a place where 
I could  find and check step-by-step the sequence of what must be 
done for get and appropriate environment installation under Windows XP?



Ah! See R-2.1.0's version of the manual "R Installation and 
Administration", Sections "Installing R under Windows" and in 
particular Appendix E "The Windows toolset".

Uwe Ligges
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] RCMD check error windows

2005-04-23 Thread Patrick Giraudoux
Dear Uwe,
Is this a full installation of R (I guess you have not compiled it 
yourself)? If yes, does gcc, perl and friends work?
In the first place, libR.a must be compiled at this point which should 
happen automatically.
But it is really hard to say which of the tools fails exactly.

Uwe Ligges
I have just intalled R 2.1.0 pre-compiled from CRAN and I can confirm 
this is a full installation. R works wonderfully well (as usual). Perl 
at least work since I have built 'simple' packages since long through 
it, without any problem. John Fox's scripts helped a lot at the 
beginning and now I write the code RCMD... directly. However, I don't 
now about gcc and I don't remember to have installed something like this 
and even how it should be done...   Is there a place where I could  find 
and check step-by-step the sequence of what must be done for get and 
appropriate environment installation under Windows XP?

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RCMD check error windows

2005-04-23 Thread Patrick Giraudoux
Dear Lister,
I am working with Windows XP and R 2.1.0 and can check and build 
home-made packages easily (just *.r, *.rmd, *.rda files, no compiled 
code). However for some reasons, I cannot check or build the package 
'foreign' from the source (I took it as an exercise...). After some 
lines of sentences OK (here omitted and replaced by ...),  I get a 
message like this:

RCMD check foreign
...
installing R.css in 'C:/R/rw2010/src/library/foreign.Rcheck'
---Making package foreign---
adding build stamp to DESCRIPTION
intalling NAMESPACE file and metadata
making dll
make[4]: ***[libR.a] Error 255
make[3]: ***[libR.] Error 2
make[2]: ***[srcDynlib] Error 2
make[1]: ***[all] Error 2
make: ***[pkg-foreign] Error 2
*** Installation of foreign failed ***
Removing 'C:/R/rw2010/src/library/foreign.Rcheck/foreign'
ERROR
Installation failed
I can hardly find out what it means... I suspect it may come from a path 
not well defined or some batch file lacking, but I can hardly guess 
exactly which ones... The documentation 'writing R extension' pages 8-9 
(high suspicion that if I could understand it fully, I could solve the 
problem) is still obscure to me on this subject.

Can anybody put me on the right track?
Patrick


--
Department of Environmental Biology
EA3184 usc INRA
University of Franche-Comte
25030 Besancon Cedex
(France)
tel. +33 381 665 745
fax +33 381 665 797
http://lbe.univ-fcomte.fr
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] install.packages and MacOS 10.3.8

2005-04-13 Thread Patrick Giraudoux
Dear Uwe,
That install.binaries() was exactly what I needed...
Thanks a lot.
Uwe Ligges a écrit :
Patrick Giraudoux wrote:
Dear Listers,
I am trying to install packages via install.packages() from MacOS 
10.3.8. Installing work fine when run from the menu, but the 
following command (useful for setting up each computer of the student 
computer room)  leads nowhere for some reasons:

pack<-c("ade4","adehabitat","geoR","gstat","KernSmooth","lattice","leaps") 

install.packages(pack,dependencies=T)

trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 51500 bytes
opened URL
==
downloaded 50Kb
also installing the dependencies 'SparseM', 'gee', 'waveslim', 
'splancs', 'maptools', 'spdep', 'pixmap', 'ape', 'tripack'

trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz'

[SNIP]

* Installing *source* package 'SparseM' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'SparseM'
* Installing *source* package 'gee' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: 
command not found
ERROR: compilation failed for package 'gee'

etc...
Can anybody tell me what goes wrong with this command (which usually 
work without any problem with R 2.0.1 and Windows XP).

So at least "make" and probably much more is missing on your machines 
(or not in your path or whatever). You might want to try 
install.binaries() instead (which is similar to install.packages() on 
Windows, since it installs binary packages rather than trying to 
compile and install source packages) - or set up your machines with 
the required set of tools.

Uwe Ligges


Thanks in advance,
Patrick
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] install.packages and MacOS 10.3.8

2005-04-13 Thread Patrick Giraudoux
Dear Listers,
I am trying to install packages via install.packages() from MacOS 
10.3.8. Installing work fine when run from the menu, but the following 
command (useful for setting up each computer of the student computer 
room)  leads nowhere for some reasons:

pack<-c("ade4","adehabitat","geoR","gstat","KernSmooth","lattice","leaps")
install.packages(pack,dependencies=T)
trying URL `http://cran.r-project.org/src/contrib/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 51500 bytes
opened URL
==
downloaded 50Kb
also installing the dependencies 'SparseM', 'gee', 'waveslim', 'splancs', 'maptools', 
'spdep', 'pixmap', 'ape', 'tripack'

trying URL `http://cran.r-project.org/src/contrib/SparseM_0.60.tar.gz'
Content type `application/x-tar' length 1064262 bytes
opened URL
==
downloaded 1039Kb
trying URL `http://cran.r-project.org/src/contrib/gee_4.13-10.tar.gz'
Content type `application/x-tar' length 49586 bytes
opened URL
==
downloaded 48Kb
trying URL `http://cran.r-project.org/src/contrib/waveslim_1.4.tar.gz'
Content type `application/x-tar' length 358305 bytes
opened URL
==
(etc)
* Installing *source* package 'SparseM' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not 
found
ERROR: compilation failed for package 'SparseM'
* Installing *source* package 'gee' ...
** libs
/Library/Frameworks/R.framework/Resources/bin/SHLIB: line 1: make: command not 
found
ERROR: compilation failed for package 'gee'

etc...
Can anybody tell me what goes wrong with this command (which usually 
work without any problem with R 2.0.1 and Windows XP).

Thanks in advance,
Patrick
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: maptools, filename writing shapefiles

2005-03-05 Thread Patrick Giraudoux H

says (p. 6): "All file names adhere to the 8.3 naming convention. The main
file, the index file, and the dBASE file have the same prefix. The prefix
must start with an alphanumeric character (aZ, 09), followed by zero or up
to seven characters (aZ, 09, _, -). The suffix for the main file is .shp.
The suffix for the index file is .shx. The suffix for the dBASE table is
.dbf."
So, the number of characters was the trouble origin (... up to 7 
characters). Easy to manage when known. This also means that ESRI 
ArcGISdoes not itself comply to the standard since one can use much more 
than 7 characters naming shapefiles from there

Thanks a lot for maptools (those fonctions to write shapefiles are really 
useful) and the clarification.

All the best,
Patrick
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] maptools, filename writing shapefiles

2005-03-05 Thread Patrick Giraudoux H
Hi,
I meet a strange trouble writing shapefiles with write.pointShape() from 
maptools.

> write.pointShape(mylines[,5:9], file="Sxtplinshp", mycoordspt)
Error in write.pointShape(mylines[, 5:9], file = "Sxtplinshp", mycoordspt) :
shapefile names must conform to the 8.3 format
It seems that the function request a special shapefile name spelling 
(conformed to 8.3 ESRI format?).

> write.pointShape(mylines[,5:9], file="Sxtplin", mycoordspt)
When just shortened, everything goes smoothly with the file correctly written.
I am not sure about ESRI standard requesting short names (modifying the 
filename by hand keep it readable by any GIS).

Can anybody (especially Roger...) tell us where comes the trouble from?
Patrick Giraudoux
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] New user...tips for spdep

2005-01-30 Thread Patrick Giraudoux H

>Hello List,
>I'm a very new user to the R system. I'm only beginning to learn the 
>basics, but so far I've been able to do little more than try a few 
>examples, and of course begin reading the documentation.
>My primary motivation for exploring R is the availability of tools like the
>'spdep' package for calculating spatial statistics such as Geary's C and
>Moran's I, which I would like to use in an analysis for my thesis. 
>However, I am not really sure how to get started.
>As a simple example, if I have a table with columns containing an ID 
>field, X & Y coordinates, and an observation value, what steps should I 
>follow to pre-process this data in order to use the moran() function? I've 
>been able to duplicate the example in the help documentation (e.g., 
>http://finzi.psych.upenn.edu/R/library/spdep/html/moran.html), but without 
>understanding what the commands really do, I'm unable to proceed much 
>further. How might I figure out the data that gets loaded when I run
>'data(oldcol)' for example?
>Is there anyone that might be able to give me some tips, or point me in 
>the right direction?
>Thanks in advance for any suggestions.
>Mike


You may want to use this function (spdep required) or download the package 
pgirmess from http://lbe.univ-fcomte.fr/telechar/div.html ( I must however 
think to update it to the last version 1.1.3 ASAP) which includes it.

"correlog" <-
function(coords,z,method=c("Moran"),nbclass=NULL){
 x<-require(spdep);if (!x) stop("Package spdep required")
 coords<-as.matrix(coords)
 matdist<-dist(coords)
 if (is.null(nbclass)) nbclass<-nclass.Sturges(matdist)
 etendue<-range(dist(coords))
 breaks1<-seq(etendue[1],etendue[2],l=nbclass+1)
 breaks2<-breaks1+0.01
 breaks<-cbind(breaks1[1:length(breaks1)-1],breaks2[2:length(breaks2)])
 x<-NULL;N=NULL;p=NULL
 for(i in 1:length(breaks[,1])){
 z1<-z
 nb1<-dnearneigh(coords, breaks[i,1],breaks[i,2])
 zero<-which(card(nb1)==0)
 if (length(zero)>0){
 nb1<-dnearneigh(coords[-zero,], breaks[i,1],breaks[i,2])
 z1<-z[-zero]
 }
xt<-switch(pmatch(method,c("Moran","Geary"),nomatch=""),
 "1"=try(moran.test(z1, nb2listw(nb1, style="W")),silent=T),
 "2"=try(geary.test(z1, nb2listw(nb1, style="W")),silent=T),
 stop("Method must be 'Moran' or 'Geary'"))
 if(inherits(xt,"try-error")) {stop("Bad selection of class breaks, 
try another one...")}
 else x<-c(x,xt$estimate[1]);p<-c(p,xt$p.value);N<-c(N,sum(card(nb1)))
 meth<-names(xt[[3]][1])
 }
  names(x)<-NULL
  res<-cbind(dist.class=rowMeans(breaks),coef=x,p.value=p,n=N)
  attributes(res)<-c(attributes(res),list(Method=meth))
  class(res)<-c("correlog","matrix")
  res
}


"plot.correlog"<-function (x,type,xlab,ylab,main,...) {
 if (!inherits(x, "correlog")) stop("Object must be of class 'correlog'")
 if (missing(main)) main<-paste(attributes(res)$Method," = f(distance 
classes)",sep="")
 if (missing(type)) type<-"b"
 if (missing(ylab)) ylab<-attributes(res)$Method
 if (missing(xlab)) xlab<-"distance classes"
 plot(x[,1:2,drop=F],type=type,xlab=xlab,ylab=ylab,main=main,xaxt="n",...)
 inc<-(x[2,1]-x[1,1])/2
 breaks <- pretty(c(x[1,1]-inc,x[length(x[,1]),1]+inc), n = 
length(x[,1]), min.n = 2)
 axis(1,at=breaks,...)
 points(x[x[,3]<0.05,1:2,drop=F],pch=19,col="red",cex=2)
}

"print.correlog"<-function (x) {
 if (!inherits(x, "correlog")) stop("Object must be of class 'correlog'")
 cat(attributes(x)$Method,"\n")
 attributes(x)<-attributes(x)[1:2]
 print(x[,,drop=F])
}



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] MacOS X and vectorized files (emf, wmf,...)

2005-01-30 Thread Patrick Giraudoux H
Dear Listers,
We are organising practical trainings for students with R 2.0.1 under MacOS 
X. I am used with R 2.0.1 under Windows XP and thus has been surprised not 
to find functions in the MacOS X version of R providing vectorized chart 
outputs to a file. For instance the equivalent of:

win.metafile()
or
savePlot()
... including a wmf or emf option.
Can one obtain only jpeg or bitmap or eps files with R under MacOS X or did 
I miss something?

Patrick Giraudoux
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] error preparing a package for lazy loading with R CMD

2005-01-30 Thread Patrick Giraudoux H
Trouble just solved by Uwe Ligge! See below:

You have a wrong "Built" field in your DESCRIPTION file!!!
"Built: R 2.0.1;windows". Please don't specify such a line yourself, "R 
CMD build" does it for you.

Ashes on my head and all these sort of things...
Patrick
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] error preparing a package for lazy loading with R CMD

2005-01-30 Thread Patrick Giraudoux H
Trouble just solved by Uwe Ligge! See below:
You have a wrong "Built" field in your DESCRIPTION file!!!
"Built: R 2.0.1;windows"
Please don't specify such a line yourself, "R CMD build" does it for you.
Ashes on my head and all these sort of things...
Patrick
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] New user...tips for spdep

2005-01-30 Thread Patrick Giraudoux H

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] MacOS X and vectorized files (emf, wmf,...)

2005-01-30 Thread Patrick Giraudoux H

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] MacOS X and vectorized files (emf, wmf,...)

2005-01-30 Thread Patrick Giraudoux H

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] error preparing a package for lazy loading with R CMD

2005-01-29 Thread Patrick Giraudoux H
I have just tried adding a newline at the end of each file. Unsuccessfully. 
Lazy loading is still not accepted and the library can be compiled only 
with the "LazyLoad: no" option in the description file.

Thanks anyway,
Patrick
A 09:05 25/01/2005 +0100, Henrik Bengtsson a écrit :
A wild guess: Do you have one file one function? Could it be that the last
line in one of the files does not end with a newline and this is not taken
care of by the build with lazy loading? Try to add a newline at the end of
each of your files.
Henrik Bengtsson
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Patrick Giraudoux H
> Sent: Tuesday, January 25, 2005 6:25 AM
> To: r-help
> Cc: Liaw, Andy
> Subject: RE: [R] error preparing a package for lazy loading with R CMD
>
>
> That's the way John Fox advised to turn the problem. Indeed
> it works but
> doe snot explain this bug in lazy loading. I don't think that
> it may come
> for a syntax error somewhere. All the functions have been
> checked and the
> problem does not occur if any of the 35 functions is removed.
> Something
> happens when I add another function to the 34 already
> present. Strange.
>
>
> A 08:45 24/01/2005 -0500, vous avez écrit :
> >Not sure if this will help, but have you tried loading the
> package after
> >install with no lazyload?   I've found that if there are
> syntax errors in
> >the R source, that can give the problem you described.  Just a guess.
> >
> >Andy
> >
> > > From: Patrick Giraudoux H
> > >
> > > Dear Lister,
> > >
> > > I  work with R 2.0.1 and Windows XP, and meet a strange trouble
> > > trying to make a R package with a make-package.bat file
> John Fox has
> > > kindly provided
> > > (see detailed script below). I am working with it since some
> > > months with
> > > excellent results (I do'nt use compiled C code so far). Just
> > > adding a new
> > > function in the R directory today, when running
> make-package and thus
> > > excuting the command ..\..\bin\R CMD build --force --binary
> > > --auto-zip
> > > %1,  I got the following message after the "compile" stage,
> > > preparing the
> > > package for lazy loading :
> > >
> > > preparing package pgirmess for lazy loading
> > > Error in "names<-.default"(`*tmp*`, value =c("R", "Platform",
> > > "Date", :
> > >  names attribute[4] must be the same length as the vector
> > > [1] Execution halted
> > > make: ***[lazyload] Error 1
> > > *** Installation of pgirmess failed ***
> > >
> > > (pgirmess is the package name)
> > >
> > > ... and the zip file is not generated.
> > >
> > > I have checked and rechecked everything during this (long)
> > > afternoon... and get nothing except that if I drag out any of the
> > > *.r file of the R folder,
> > > everything comes to be OK (except the function that has been
> > > dragged out is
> > > missing...). It looks like if having added one extra function
> > > in the R
> > > folder on the top of the earlier 32 (+ 2 data frames)
> makes problem.
> > >
> > > I have then consulted John Fox offlist and he seems quite
> perplexed
> > > "I'm not sure why you're experiencing this problem". On
> his advise I
> > > have included "LazyLoad: no" in the package description file. In
> > > this case everything goes smoothly then (except LazyLoad
> will not be
> > > activated), the
> > > zip file is generated and the package can be installed from R.
> > >
> > > Has anybody an idea about why a problem occurs when preparing the
> > > package for lazy loading? Any remedy?
> > >
> > > Kind regards,
> > >
> > > Patrick
> > >
> > > Make-Package script:
> > >
> > > cd c:\R\rw2001\src\library
> > > del %1\INDEX
> > > del %1\data\00Index
> > > del %1\chm\*.* /Q
> > > ..\..\bin\R CMD build --force --binary --auto-zip %1
> ..\..\bin\R CMD
> > > build --force %1 ..\..\bin\R CMD check %1
> > > cd %1.Rcheck
> > > dvipdfm %1-manual
> > > notepad 00check.log
> > > cd ..
> > > cd ..
> > >
> > >
> > > >From: "John Fox" <[EMAIL PROTECTED]>
> > > >To: "'Patrick Giraudoux H'" <[EMAIL PROTECTED]>
> > > >Subj

RE: [R] error preparing a package for lazy loading with R CMD

2005-01-24 Thread Patrick Giraudoux H
That's the way John Fox advised to turn the problem. Indeed it works but 
doe snot explain this bug in lazy loading. I don't think that it may come 
for a syntax error somewhere. All the functions have been checked and the 
problem does not occur if any of the 35 functions is removed. Something 
happens when I add another function to the 34 already present. Strange.

A 08:45 24/01/2005 -0500, vous avez écrit :
Not sure if this will help, but have you tried loading the package after
install with no lazyload?   I've found that if there are syntax errors in
the R source, that can give the problem you described.  Just a guess.
Andy
> From: Patrick Giraudoux H
>
> Dear Lister,
>
> I  work with R 2.0.1 and Windows XP, and meet a strange
> trouble trying to
> make a R package with a make-package.bat file John Fox has
> kindly provided
> (see detailed script below). I am working with it since some
> months with
> excellent results (I do'nt use compiled C code so far). Just
> adding a new
> function in the R directory today, when running make-package and thus
> excuting the command ..\..\bin\R CMD build --force --binary
> --auto-zip
> %1,  I got the following message after the "compile" stage,
> preparing the
> package for lazy loading :
>
> preparing package pgirmess for lazy loading
> Error in "names<-.default"(`*tmp*`, value =c("R", "Platform",
> "Date", :
>  names attribute[4] must be the same length as the vector [1]
> Execution halted
> make: ***[lazyload] Error 1
> *** Installation of pgirmess failed ***
>
> (pgirmess is the package name)
>
> ... and the zip file is not generated.
>
> I have checked and rechecked everything during this (long)
> afternoon... and
> get nothing except that if I drag out any of the *.r file of
> the R folder,
> everything comes to be OK (except the function that has been
> dragged out is
> missing...). It looks like if having added one extra function
> in the R
> folder on the top of the earlier 32 (+ 2 data frames) makes problem.
>
> I have then consulted John Fox offlist and he seems quite
> perplexed "I'm
> not sure why you're experiencing this problem". On his advise I have
> included "LazyLoad: no" in the package description file. In this case
> everything goes smoothly then (except LazyLoad will not be
> activated), the
> zip file is generated and the package can be installed from R.
>
> Has anybody an idea about why a problem occurs when preparing
> the package
> for lazy loading? Any remedy?
>
> Kind regards,
>
> Patrick
>
> Make-Package script:
>
> cd c:\R\rw2001\src\library
> del %1\INDEX
> del %1\data\00Index
> del %1\chm\*.* /Q
> ..\..\bin\R CMD build --force --binary --auto-zip %1
> ..\..\bin\R CMD build --force %1
> ..\..\bin\R CMD check %1
> cd %1.Rcheck
> dvipdfm %1-manual
> notepad 00check.log
> cd ..
> cd ..
>
>
> >From: "John Fox" <[EMAIL PROTECTED]>
> >To: "'Patrick Giraudoux H'" <[EMAIL PROTECTED]>
> >Subject: RE: [R] writing a simple package in R 2.0 under Windows XP
> >Date: Sun, 23 Jan 2005 11:41:25 -0500
> >X-Mailer: Microsoft Office Outlook, Build 11.0.6353
> >X-MIME-Autoconverted: from quoted-printable to 8bit by
> >utinam.univ-fcomte.fr id j0NGfJoD011345
> >
> >Dear Patrick,
> >
> >I'm not sure why you're experiencing this problem.
> >
> >Two suggestions: (1) Since the problem appears to be with
> preparing the
> >package for lazy loading, try adding the directive
> "LazyLoad: no" (without
> >the quotes) to the package's DESCRIPTION file. (2) Rather
> than using my
> >batch file, run the commands one at a time to see exactly
> where the problem
> >is produced; then you could send a message to r-help.
> >
> >I hope this helps,
> >  John
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
--
Notice:  This e-mail message, together with any attachments, contains 
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New 
Jersey, USA 08889), and/or its affiliates (which may be known outside the 
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as 
Banyu) that may be confidential, proprietary copyrighted and/or legally 
privileged. It is intended solely for the use of the individual or entity 
named on this message.  If you are not the intended recipient, and have 
received this message in error, please notify us immediately by reply 
e-mail and then delete it from your system.
-- 

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] error preparing a package for lazy loading with R CMD

2005-01-24 Thread Patrick Giraudoux H
Dear Lister,
I  work with R 2.0.1 and Windows XP, and meet a strange trouble trying to 
make a R package with a make-package.bat file John Fox has kindly provided 
(see detailed script below). I am working with it since some months with 
excellent results (I do'nt use compiled C code so far). Just adding a new 
function in the R directory today, when running make-package and thus 
excuting the command ..\..\bin\R CMD build --force --binary --auto-zip 
%1,  I got the following message after the "compile" stage, preparing the 
package for lazy loading :

preparing package pgirmess for lazy loading
Error in "names<-.default"(`*tmp*`, value =c("R", "Platform", "Date", :
names attribute[4] must be the same length as the vector [1]
Execution halted
make: ***[lazyload] Error 1
*** Installation of pgirmess failed ***
(pgirmess is the package name)
... and the zip file is not generated.
I have checked and rechecked everything during this (long) afternoon... and 
get nothing except that if I drag out any of the *.r file of the R folder, 
everything comes to be OK (except the function that has been dragged out is 
missing...). It looks like if having added one extra function in the R 
folder on the top of the earlier 32 (+ 2 data frames) makes problem.

I have then consulted John Fox offlist and he seems quite perplexed "I'm 
not sure why you're experiencing this problem". On his advise I have 
included "LazyLoad: no" in the package description file. In this case 
everything goes smoothly then (except LazyLoad will not be activated), the 
zip file is generated and the package can be installed from R.

Has anybody an idea about why a problem occurs when preparing the package 
for lazy loading? Any remedy?

Kind regards,
Patrick
Make-Package script:
cd c:\R\rw2001\src\library
del %1\INDEX
del %1\data\00Index
del %1\chm\*.* /Q
..\..\bin\R CMD build --force --binary --auto-zip %1
..\..\bin\R CMD build --force %1
..\..\bin\R CMD check %1
cd %1.Rcheck
dvipdfm %1-manual
notepad 00check.log
cd ..
cd ..

From: "John Fox" <[EMAIL PROTECTED]>
To: "'Patrick Giraudoux H'" <[EMAIL PROTECTED]>
Subject: RE: [R] writing a simple package in R 2.0 under Windows XP
Date: Sun, 23 Jan 2005 11:41:25 -0500
X-Mailer: Microsoft Office Outlook, Build 11.0.6353
X-MIME-Autoconverted: from quoted-printable to 8bit by 
utinam.univ-fcomte.fr id j0NGfJoD011345

Dear Patrick,
I'm not sure why you're experiencing this problem.
Two suggestions: (1) Since the problem appears to be with preparing the
package for lazy loading, try adding the directive "LazyLoad: no" (without
the quotes) to the package's DESCRIPTION file. (2) Rather than using my
batch file, run the commands one at a time to see exactly where the problem
is produced; then you could send a message to r-help.
I hope this helps,
 John
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] matrix and error in points, plot ?

2005-01-02 Thread Patrick Giraudoux H
Hi,
Would a specialist of the "point" or "plot" functions try the following:
mat<-matrix(c(1.836767,4.025989,0.6396777,0.376),ncol=2)
plot(mat)
points(mat[1,],col="red")
..A lag appears on x for mat [1,1] between the two displays.
I wonder if this example may be due to a bug or to the mis-use of a matrix 
in the plot() points()  functions. In case of mise-use which kind can it be?

I am working with R 2.0.1 and Windows XP.
Cheers,
Patrick Giraudoux
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] writing a simple package in R 2.0 under Windows XP

2004-11-07 Thread H Patrick Giraudoux
Dear all,
Following John Fox and Brian Ripley instructions, things come better.  I 
still get errors but they just come at the first step from unappropriate 
DESCRIPTION file (which was expected: I just wanted to check if the 
software installation was OK for building packages with the "crude" 
AnExample from the package.skeleton() doc. I can "quitely" come back to the 
"Writing R extension guide" and work on it now).

One mishaps that can be worthy to bold for other listers is that I did not 
select the installation of the source package tools in an early 
installation of R (it is unselected by default with rw2000.exe). Advised to 
re-install R taking this into account for those who gradually try to move 
from function development to package writing...

Thanks for the hints kindly provided even a Sunday,
Patrick Giraudoux

A 10:24 07/11/2004 -0500, vous avez écrit :
Dear Patrick,
I've prepared some basic instructions and a batch file for building simple
packages under Windows and have given them to several people who have
experienced problems. I've hesitated to send them to this list since they
really just duplicate information available elsewhere, and because the batch
file probably could be improved.
Since there has been a rash of Windows package-building problems recently
(probably because it's no longer possible to bypass the package-building
tools), I've appended the instructions and batch file to this message in the
hope that they prove useful. Of course, comments and suggestions for
improvement are appreciated.
Regards,
 John
-- snip 
Building Simple Packages Under R for Windows
1. Links to tools and additional information are at
<http://www.murdoch-sutherland.com/Rtools/>.
2. Make sure R is *not* installed under c:\Program Files (or in any location
with spaces in the path) and that it is installed with package-building
tools. I use c:\R for the installation; I'll assume this below -- make
changes as necessary.
3. Download <http://www.murdoch-sutherland.com/Rtools/tools.zip> and unzip
e.g. to c:\Program Files\Utilities; put this directory at the beginning of
the path. (It may be necessary to copy sh.exe to c:\bin\sh.exe.)
4. Download Perl from
<http://www.activestate.com/Products/ActivePerl/Download.html> and install
it using defaults.
5. Download fptex from
<http://www.ctan.org/tex-archive/systems/win32/fptex/current/TeXSetup.exe>
and install it. Note: This requires a fast internet connection during the
installation. Don't install latex under c:\Program Files\!
6. Download HTML Help Workshop from
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/h
tml/hwmicrosofthtmlhelpdownloads.asp> and install it. Add c:\Program
Files\HTML Help Workshop to the path.
7. If you want to be able to compile old-style Windows help files (probably
not necessary) download Microsoft Help Workshop
<ftp://ftp.microsoft.com/softlib/mslfiles/hcwsetup.exe> and install it. Add
c:\Program Files\Help Workshop to the path.
8. Put my file make-package.bat in c:\R\rw\src (where  is the
version, e.g., 2000). If necessary, edit this file to reflect the location
of the R installation.
9. Open a DOS (command) window. CD to R\rw\src. Make sure that the
package source files are in the directory package-name under
R\rwxxx\src\library. Enter make-package package-name. Carefully examine the
log file etc.
10. After this process is completed, you'll have both a tar.gz file with the
source package and a .zip file with the Windows binary package. Install the
latter from the "Packages -> Install package(s) from local zip files" menu
in the normal manner.
-- make-package.bat 
cd c:\R\rw2000\src\library
del %1\INDEX
del %1\data\00Index
del %1\chm\*.* /Q
..\..\bin\R CMD build --force --binary --auto-zip %1
..\..\bin\R CMD build --force %1
..\..\bin\R CMD check %1
cd %1.Rcheck
dvipdfm %1-manual
notepad 00check.log
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] writing a simple package in R 2.0 under Windows XP

2004-11-07 Thread H Patrick Giraudoux
Dear listers,

I have developped a set of functions that I would like to package on a 
Windows XP plateform for some friends (this would be more simple than to 
deliver them as a source text file without handy help). I am working under 
Windows XP.

Of course I have gone through the manual "Writing R extension" and try to 
sort out what a most simple "packaging" for beginner (without compiled 
code, etc...)  could be. I also read 
http://www.rap.ucar.edu/staff/ericg/RWinBuild.html It is very easy to build 
R packages in Windows (for Windows)...

Perl has been installed and works fine C:\Perl (source 
http://www.activestate.com/Products/ActivePerl/Download.html).
R Tools have been installed: C:\Perl\Rtools (source: 
http://www.murdoch-sutherland.com/Rtools/tools.zip)
R tools functions delivered work fine (ex: ls, etc...)
R has been installed "at the root" of C:\ to avoid any blank in directory 
names: C:\R\rw2000
The PATH has been defined as environment variable in Windows XP as: 
C:\Perl\Rtools;C:\Perl\bin;...;C:\R\rw2000\bin

A trial package named "AnExample" has been prepared as indicated in the 
example of package.skeleton() of the library "utils" and put in C:\

from there I have typewritten:

C:\>RCMD build AnExample

With this result:

Can't open perl script "C:\R\rw2000/bin/build": No such file or directory

I could catch that indeed 'build.exe' does not exist in this directory 
(which is true...) and tried to find it somewhere on my c: disk. 
Unfortunately, this 'build' or 'build.exe' file does not exist nor a 
'check' file, nor any complementary command of Rcmd

After some research hours (actually since yesterday...), I cannot find 
where I have got wrong yet... and considering the result, I am sure I got 
somewhere!

Can somebody help me on this?

Thanks in advance,

Patrick Giraudoux


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] reading .Rprofile at startup in R 2.0.0

2004-11-06 Thread H Patrick Giraudoux
Thanks for the hint. Having got through the "CHANGES" file as advised by Pr 
Ripley (I unfortunately checked first the "NEWS" file and forgot that 
one..) I found it may be more simple (to me) to put the .RProfile file into 
the "my documents" directory. It works fine now. Setting environment 
variables is probably easy when one knows exactly which file to manage with 
and where it is... which is not the case to me yet (even after having read 
carefully the rw-FAQ 2.13).

All the best,
Patrick
A 09:39 06/11/2004 -0500, vous avez écrit :
Consider setting the environment variable R_USER="c:\Documents and 
Settings\Giraudoux"

MHP
At 08:55 AM 11/06/2004, you wrote:
Dear listers,
Moving from R 1.9.1 to R 2.0.0 today, it happens that the "traditional" 
.RProfile (located in my home directory: C:\Documents and 
Settings\Giraudoux) is not read at startup with R 2.0.

Any suggestion?
Patrick Giraudoux

--
Michael Prager, Ph.D.<[EMAIL PROTECTED]>
NOAA Beaufort Laboratory
Beaufort, North Carolina  28516
http://shrimp.ccfhrb.noaa.gov/~mprager/
***
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] reading .Rprofile at startup in R 2.0.0

2004-11-06 Thread Patrick Giraudoux
Dear listers,
Moving from R 1.9.1 to R 2.0.0 today, it happens that the "traditional" .RProfile (located in my home directory: C:\Documents and 
Settings\Giraudoux) is not read at startup with R 2.0.

Any suggestion?
Patrick Giraudoux
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] conversion of a data.frame of numerics to a data.frame of factors

2004-10-09 Thread Patrick Giraudoux
This work perfectly with a data.frame. Actually my so-called "data.frame" was an 
output of t(), and thus not a data.frame (what I
realise after trying Prof. Ripley's example). If applied to an output of t() (eg 
t(df)), the result is quite unxpected (to me): a
strange list of 989 elements, each of them being a factor of one digit and one level 
corresponding to each cell of the matrix 23
rows x 43 columns...

So in this particular case, advised to write:

mydf<-as.data.frame(t(mydf0))
mydf[] <- lapply(mydf, as.factor)



> - Original Message - 
> From: "Prof Brian Ripley" <[EMAIL PROTECTED]>
> To: "Patrick Giraudoux" <[EMAIL PROTECTED]>
> Cc: "r-help" <[EMAIL PROTECTED]>
> Sent: Saturday, October 09, 2004 4:32 PM
> Subject: Re: [R] conversion of a data.frame of numerics to a data.frame of factors
>
>
> > On Sat, 9 Oct 2004, Patrick Giraudoux wrote:
> >
> > mydf[] <- lapply(mydf, as.factor)
> >
> > would appear to be what you want.
> >
> > For a matrix, I presume you want a factor matrix as the result.  Something
> > like
> >
> > my <- matrix(1:12, 3, 4)
> > dmy <- dim(my)
> > my <- as.factor(my)
> > dim(my) <- dmy
> > my
> >
> > which does not print as a matrix but is one.  If you want a data frame
> > result, convert to a data frame first.
> >
> > > Hi,
> > >
> > > I am trying to convert a data.frame of numerics (this could be a matrix
> > > as well in this case) into a data.frame of factors.
> > >
> > > I did it in a way that is less than direct...
> > >
> > > myforet2<-t(myforet)
> > > for (i in 1:length(myforet2[1,])) {
> > > if (i == 1)myforetfact<-list(as.factor(myforet2[,i]))
> > > else myforetfact<-c(myforetfact,list(as.factor(myforet2[,i])))
> > > }
> > > myforetfact<-data.frame(myforetfact)
> > > names(myforetfact)<-row.names(myforet)
> > >
> > > Here again, I wonder if there are no easier way to go through (the loop is 
> > > not "R" style, for the least). However, I
cannot
> do
> > > it otherway so far...
> > >
> > > Cheers,
> > >
> > > Patrick
> > >
> > > __
> > > [EMAIL PROTECTED] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> > >
> > >
> >
> > -- 
> > Brian D. Ripley,  [EMAIL PROTECTED]
> > Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> > University of Oxford, Tel:  +44 1865 272861 (self)
> > 1 South Parks Road, +44 1865 272866 (PA)
> > Oxford OX1 3TG, UKFax:  +44 1865 272595
>

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] conversion of a data.frame of numerics to a data.frame of factors

2004-10-09 Thread Patrick Giraudoux
Hi,

I am trying to convert a data.frame of numerics (this could be a matrix as well in 
this case) into a data.frame of factors.

I did it in a way that is less than direct...

myforet2<-t(myforet)
for (i in 1:length(myforet2[1,])) {
if (i == 1)myforetfact<-list(as.factor(myforet2[,i]))
else myforetfact<-c(myforetfact,list(as.factor(myforet2[,i])))
}
myforetfact<-data.frame(myforetfact)
names(myforetfact)<-row.names(myforet)

Here again, I wonder if there are no easier way to go through (the loop is not "R" 
style, for the least). However, I cannot do
it otherway so far...

Cheers,

Patrick

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] which() and value replacement in a matrix

2004-10-09 Thread Patrick Giraudoux
Thanks for the clue.

Actually the trouble comes when refering to a data.frame. If I use the matrix from the 
data.frame (matrix(mydataframe)), everything
goes smoothly...

So I wrote:

indices<-which(myforetbin > 0,arr.ind=T)
myforetbin<-as.matrix(myforetbin)
myforetbin[indices]<-1
myforetbin<-as.data.frame(myforetbin)

It works but I wonder if there are no more simple ways...

All the best,

Patrick


- Original Message - 
From: "Liaw, Andy" <[EMAIL PROTECTED]>
To: "'Patrick Giraudoux'" <[EMAIL PROTECTED]>; "r-help" <[EMAIL PROTECTED]>
Sent: Saturday, October 09, 2004 3:00 PM
Subject: RE: [R] which() and value replacement in a matrix


> Use the index vector directly, rather than breaking it up:
>
> > x <- matrix(sample(30), 10, 3)
> > idx <- which(x > 25, arr.ind=TRUE)
> > idx
>  row col
> [1,]   6   1
> [2,]   9   1
> [3,]   4   2
> [4,]   6   2
> [5,]   4   3
> > x[idx] <- 999
> > x
>   [,1] [,2] [,3]
>  [1,]7   14   16
>  [2,]   20   248
>  [3,]   17   18   11
>  [4,]   19  999  999
>  [5,]   234   15
>  [6,]  999  9995
>  [7,]   219   12
>  [8,]   2223
>  [9,]  999   131
> [10,]6   10   25
>
> HTH,
> Andy
>
> > From: Patrick Giraudoux
> >
> > Hi,
> >
> > I cannot go through the archives with which() as key-word...
> > so common. Though I am sure to have seen something about this subject
> > in the past could somebody put me on the track. I have a
> > matrix (actually a data.frame) in which I would replace the
> > non-null values
> > by 1.
> >
> > I tried the following:
> >
> > indices<-which(myforetbin > 0,arr.ind=T)
> > myforetbin[indices[,1],indices[,2]]<-1
> >
> > and get the message:
> >
> > > myforetbin[indices[,1],indices[,2]]<-1
> > Error in "[<-.data.frame"(`*tmp*`, indices[, 1], indices[,
> > 2], value = 1) :
> > duplicate subscripts for columns
> >
> > I get the same with
> >
> > myforetbin[indices]<-1
> >
> > However, with:
> >
> > myforetbin[indices]
> >
> > I well get a vector with the corresponding non-null values.
> >
> > Can somebody put me on the track?
> >
> > All the best,
> >
> > Patrick
> >
> > __
> > [EMAIL PROTECTED] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
>
>
> --
> Notice:  This e-mail message, together with any attachments, contains information of 
> Merck & Co., Inc. (One Merck Drive,
Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known 
outside the United States as Merck Frosst,
Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, 
proprietary copyrighted and/or legally privileged. It
is intended solely for the use of the individual or entity named on this message.  If 
you are not the intended recipient, and have
received this message in error, please notify us immediately by reply e-mail and then 
delete it from your system.
> --

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] which() and value replacement in a matrix

2004-10-09 Thread Patrick Giraudoux
Hi,

I cannot go through the archives with which() as key-word... so common. Though I am 
sure to have seen something about this subject
in the past could somebody put me on the track. I have a matrix (actually a 
data.frame) in which I would replace the non-null values
by 1.

I tried the following:

indices<-which(myforetbin > 0,arr.ind=T)
myforetbin[indices[,1],indices[,2]]<-1

and get the message:

> myforetbin[indices[,1],indices[,2]]<-1
Error in "[<-.data.frame"(`*tmp*`, indices[, 1], indices[, 2], value = 1) :
duplicate subscripts for columns

I get the same with

myforetbin[indices]<-1

However, with:

myforetbin[indices]

I well get a vector with the corresponding non-null values.

Can somebody put me on the track?

All the best,

Patrick

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] cluster analysis and null hypothesis testing

2004-09-14 Thread Patrick Giraudoux
Hi,

I am wondering if a Monte Carlo method (or equivalent) exist permitting to test the 
randomness of a cluster analysis (eg got by
hclust(). I went through the package "fpc" (maybe too superficially) but dit not find 
such method.

Thanks for any hint,

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Writing polyline shapefiles

2004-07-28 Thread Patrick Giraudoux
Stephane, dear R listers,

I wonder if the idea of developping some functions in R writing shapefiles from a 
matrix of coordinates  -eg poly2shape()- is still
with us? I currently manage with a home-made function writing an ASCII grass file, 
then importing it into GRASS as vector file, then
exporting the vector file as a shapefile (ouf!). The main issue to me is still to be 
capable to wite the *.shx and *.shp from
coordinates (the *.dbf is easier to manage, even indirectly, and can for instance be 
completed simply via Excel).  I tried to open
*.shp, etc.. files to understand how they were structured and thus write some 
programme by myself, but unsuccessfully (the way those
files are coded is not ascii)

Maptools is fantastic for importation and data handling within R, but unfortunately 
cannot export to shapefiles.

Any news?

Patrick Giraudoux


PS: ESRI has managed to distribute ArcTools (with ArcGIS) with no way to importe 
generate ASCII formats!!! One must get ArcINFO for
that... No comment!

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: bootstrap and nls

2004-07-24 Thread Patrick Giraudoux
Hi,

Just a recap on the trials done based on Spencer Grave, Bervin A Turlach and Christian 
Ritz's advise.

On their suggestion, the trouble mentioned has well been turned using the function 
try() (using the algorithm "plinear" unstead of
"default" was unsuccessful) in the following way:

library(boot)

dif.param<-function(data,i){
RaiesLossA.nls<-try(nls(SolA~a/(1+b*Tps)^c,start=c(a=31,b=0.5,c=0.6),data[i,]),silent=TRUE)
RaiesLossB.nls<-try(nls(Solb~a/(1+b*Tps)^c,start=c(a=33,b=1.4,c=0.5),data[i,]),silent=TRUE)

if ( (inherits(RaiesLossA.nls,"try-error")) |
(inherits(RaiesLossB.nls,"try-error"))) {return(NA)} else {
return(RaiesLossA.nls$m$getPars()-RaiesLossB.nls$m$getPars())}

}

myboot<-boot(Raies,dif.param,R=1000)


The boot objet "myboot" that one get cannot however be handled, eg with boot.ci(),  
because "myboot$t" has NA values. This can be
corrected in this way:

myboot$t<-na.omit(myboot$t)
myboot$R<-length(myboot$t[,1])

boot.ci(myboot,index=1, type=c("norm","basic","perc", "bca"))

Studentized CI appear to be quite unstable here and were not used.

That's it!

The effect of omitting some bootstrap replicates (the less than 10% that could not 
lead to a propper fit)  is however questionable:
may this
biase the result in a way? I am not too much worried about it for my current purpose 
(crude comparison of parameters), but I
guess that it may be an issue for true statisticians...

Many thanks for the most helpful hints provided,

Patrick Giraudoux




>Hi,
>
>I am trying to bootstrap the difference between each parameters among two non linear 
>regression (distributed loss model) as
>following:
>
># data.frame
>
>
>>Raies[1:10,]
>>
>>
>   Tps  SolA  Solb
>10 32.97 35.92
>20 32.01 31.35
>31 21.73 22.03
>41 23.73 18.53
>52 19.68 18.28
>62 18.56 16.79
>73 18.79 15.61
>83 17.60 13.43
>94 14.83 12.76
>10   4 17.33 14.91
>etc...
>
># non linear model (work well)
>
>RaiesLossA.nls<-nls(SolA~a/(1+b*Tps)^c,start=c(a=32,b=0.5,c=0.6))
>RaiesLossB.nls<-nls(Solb~a/(1+b*Tps)^c,start=c(a=33,b=1.5,c=0.5))
>
>
># bootstrap
>library(boot)
>
>dif.param<-function(data,i){
>RaiesLossA.nls<-nls(SolA[i]~a/(1+b*Tps[i])^c,start=c(a=31,b=0.5,c=0.6))
>RaiesLossB.nls<-nls(Solb[i]~a/(1+b*Tps[i])^c,start=c(a=33,b=1.4,c=0.5))
>RaiesLossA.nls$m$getPars()-RaiesLossB.nls$m$getPars()
>}
>
>
>
>> myboot<-boot(Raies,dif.param,R=1000)
>>
>>
>
>Error in numericDeriv(form[[3]], names(ind), env) :
>Missing value or an Infinity produced when evaluating the model
>
>It seems that the init values (start=) may come not to be suitable while 
>bootstraping. Data can be sent offline to whom wanted to
>try on the dataset.
>
>Any hint welcome!
>
>Best regards,
>
>Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] bootstrap and nls

2004-07-18 Thread Patrick Giraudoux
Hi,

I am trying to bootstrap the difference between each parameters among two non linear 
regression (distributed loss model) as
following:

# data.frame
> Raies[1:10,]
   Tps  SolA  Solb
10 32.97 35.92
20 32.01 31.35
31 21.73 22.03
41 23.73 18.53
52 19.68 18.28
62 18.56 16.79
73 18.79 15.61
83 17.60 13.43
94 14.83 12.76
10   4 17.33 14.91
etc...

# non linear model (work well)

RaiesLossA.nls<-nls(SolA~a/(1+b*Tps)^c,start=c(a=32,b=0.5,c=0.6))
RaiesLossB.nls<-nls(Solb~a/(1+b*Tps)^c,start=c(a=33,b=1.5,c=0.5))


# bootstrap
library(boot)

dif.param<-function(data,i){
RaiesLossA.nls<-nls(SolA[i]~a/(1+b*Tps[i])^c,start=c(a=31,b=0.5,c=0.6))
RaiesLossB.nls<-nls(Solb[i]~a/(1+b*Tps[i])^c,start=c(a=33,b=1.4,c=0.5))
RaiesLossA.nls$m$getPars()-RaiesLossB.nls$m$getPars()
}

>  myboot<-boot(Raies,dif.param,R=1000)

Error in numericDeriv(form[[3]], names(ind), env) :
Missing value or an Infinity produced when evaluating the model

It seems that the init values (start=) may come not to be suitable while bootstraping. 
Data can be sent offline to whom wanted to
try on the dataset.

Any hint welcome!

Best regards,

Patrick Giraudoux


University of Franche-Comté
Department of Environmental Biology
EA3184 af. INRA
F-25030 Besançon Cedex

tel.: +33 381 665 745
fax.: +33 381 665 797
http://lbe.univ-fcomte.fr

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: metafile copy and R 1.9.0, trellis, grid

2004-05-08 Thread Patrick Giraudoux
OK. Deepayan sent me the copy of a chat on another list between John Fox, Duncan 
Murdoch and Paul Murrell.  The bug in the gui.exe
looks like being reported with an example to turn it before he has been definetely 
fixed. Just try:

trellis.device("win.metafile", file="test.emf")
data(iris)
cloud(Sepal.Length ~ Petal.Length * Petal.Width | Species, data =
iris, screen = list(x = -90, y = 70), distance = .4, zoom = .6)
dev.off()

This set of commands create a file ("test.emf") in the working directory, write a 
cloud plot in the file and shut down the device.
The file "test.emf" can then be imported from any software reading metafiles. I tried 
it with my own xyplot trouble and got
absolutely good result. Very easy, even to me!!!

Thanks to them for the hint,

Patrick


- Original Message - 
From: "Patrick Giraudoux" <[EMAIL PROTECTED]>
To: "r-help" <[EMAIL PROTECTED]>
Sent: Saturday, May 08, 2004 3:45 PM
Subject: metafile copy and R 1.9.0


> Dear all,
>
>
> I'm running into problem in R-1.9.0 that hasn't happened  with R-1.8.x
>
> If I make a plot with xyplot(), and use the menu to either save to a metafile or 
> copy to clipboard as a metafile to export to eg
> Powerpoint, I can just copy a blank then. This does not occur with the classical 
> plot(). Thus, I suppose that it may come from
> lattice or grid (going through the R-archives I checked that a similar trouble occur 
> when R has been updated to 1.5).
>
> Has this trouble been met already and is there a way to turn it?
>
> Patrick Giraudoux
>
>
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] metafile copy and R 1.9.0

2004-05-08 Thread Patrick Giraudoux
Dear all,


I'm running into problem in R-1.9.0 that hasn't happened  with R-1.8.x

If I make a plot with xyplot(), and use the menu to either save to a metafile or copy 
to clipboard as a metafile to export to eg
Powerpoint, I can just copy a blank then. This does not occur with the classical 
plot(). Thus, I suppose that it may come from
lattice or grid (going through the R-archives I checked that a similar trouble occur 
when R has been updated to 1.5).

Has this trouble been met already and is there a way to turn it?

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] contourplot, xyplot, aspect ratio, mfrow

2004-05-02 Thread Patrick Giraudoux
Confirmed after checking:

aspect = diff(range(y))/diff(range(x)) in coutourplot looks like being the equivalent 
of asp = 1  (regarding practical result) in
contour().

Essential for maps!

Thanks a lot for the information and other most valuable hints.

Patrick





- Original Message - 
From: "Deepayan Sarkar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Patrick Giraudoux" <[EMAIL PROTECTED]>
Sent: Sunday, May 02, 2004 3:24 PM
Subject: Re: [R] contourplot, xyplot, aspect ratio, mfrow


> On Sunday 02 May 2004 03:30, Patrick Giraudoux wrote:
> > Hi,
> >
> > I am gradually moving from the classical R plot functions to the
> > library Lattice
> >
> > I have some questions about contourplot () and its arguments:
> >
> > 1/ I am working on geographical coordinates which makes necessary
> > that the X (longitude) and Y (latitude) units be represented with the
> > same distance on screen. This was obtained in the classical R plots
> > with plot.default(x,y, asp=1,...)  and then contour(..., add=T). When
> > I try aspect=1 with contour plot, I get a square but not at all the
> > aspect ratio I wish: 1 unit on X = one unit on Y = the same distance
> > on screen. What goes wrong?
>
> Well, aspect works as documented, so nothing goes wrong. The behaviour
> is just different from asp. You could try
>
> aspect = diff(range(y))/diff(range(x))
>
> and if your x and y are factors, aspect = "xy" should help. Maybe there
> should be a new option (perhaps aspect = "data") that should do this.
>
> > 2/ I would also be capable to project points and symbols on a
> > contourplot (the equivalent of points() and symbols() after plot()
> > and contour()), but can hardly guess from the help how to manage
> > with.
>
> You need to use a custom panel function (see the section on 'panel'
> in ?xyplot). There's no equivalent of symbols, unfortunately, but
> see ?panel.abline and ?lpoints.
>
> > 3/ I would also appreciate to manage the equivalent of
> > par(mfrow=c(2,2)) -or any other numbers of screens- and have a
> > "Trellis" plot in each of the sub-screens. It seems that contourplot
> > does not comply with and ignore the above parameters. Right or wrong?
>
> Right.
>
> > If so, which approach can solve this problem?
>
> See ?print.trellis. (Note that this also allows you to place trellis
> plots inside grid viewports, which maybe overkill for your use, but
> gives you more flexibility.)
>
> Deepayan

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] contourplot, xyplot, aspect ratio, mfrow

2004-05-02 Thread Patrick Giraudoux
Hi,

I am gradually moving from the classical R plot functions to the library Lattice

I have some questions about contourplot () and its arguments:

1/ I am working on geographical coordinates which makes necessary that the X 
(longitude) and Y (latitude) units be represented with
the same distance on screen. This was obtained in the classical R plots with 
plot.default(x,y, asp=1,...)  and then contour(...,
add=T). When I try aspect=1 with contour plot, I get a square but not at all the 
aspect ratio I wish: 1 unit on X = one unit on Y =
the same distance on screen. What goes wrong?

2/ I would also be capable to project points and symbols on a contourplot (the 
equivalent of points() and symbols() after plot() and
contour()), but can hardly guess from the help how to manage with.

3/ I would also appreciate to manage the equivalent of par(mfrow=c(2,2)) -or any other 
numbers of screens- and have a "Trellis" plot
in each of the sub-screens. It seems that contourplot does not comply with and ignore 
the above parameters. Right or wrong? If so,
which approach can solve this problem?

Thanks in advance for any hint,

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] log(0) error is not handled in xyplot, Windows

2004-05-01 Thread Patrick Giraudoux
Hi,

We had some exchanges off the list with Deepayan Sarkar about a bug (?) we cannot fix 
(it seems it does not occur under Unix).  It
likely needs the help of somebody on Windows.

The initial problem was that when running the following script (Windows XP, R 1.8.1 as 
well as R 1.9.0):

> lset(col.whitebg())
> xyplot(rdens ~ annee | habitat,
>groups = sp, type = 'b',
>scales = list(y = list(log = TRUE)))

I got a crash (just show the "hourglass" icon, stay on, GUI.exe no longer answer, and 
I must interrupt the process via
Windows...)

When the following is used:

> lset(col.whitebg())
> xyplot(rdens+1 ~ annee | habitat,
>groups = sp, type = 'b',
>scales = list(y = list(log = TRUE)))

It draws the plot OK.

The same (plot drawn OK) , when lset(col.whitebg()) is not used.

The conclusion was that in the  lset(col.whitebg()) environment, log(0) was not 
properly handled (leading to an error message or
something else).

I can provide a data.frame off the list to anybody who wants a reproducible example 
and to look at what happens.

Patrick Giraudoux



- Original Message ----- 
From: "Deepayan Sarkar" <[EMAIL PROTECTED]>
To: "Patrick Giraudoux" <[EMAIL PROTECTED]>
Sent: Saturday, May 01, 2004 2:56 PM
Subject: Re: Fw: log(0) error is not handled in xyplot


> On Saturday 01 May 2004 07:50, Patrick Giraudoux wrote:
> > > library(grid)
> > > x = 1:10 / 11
> > > y = rep(.5, 10)
> > > y[5] = NA
> > > grid.lines(x, y)
> >
> > Does not give a crash and makes this plot:
>
> In that case, you should probably report the original xyplot problem to
> r-help. Hopefully someone on Windows would be able to figure it out.
> Make sure to give a reproducible example.
>
> Deepayan


- Original Message - 
From: "Patrick Giraudoux" <[EMAIL PROTECTED]>
To: "Deepayan Sarkar" <[EMAIL PROTECTED]>
Sent: Thursday, April 29, 2004 4:15 PM
Subject: Re: Fw: log(0) error is not handled in xyplot


> > Hmm, that's very odd. So what exactly were your symptoms ? Did R crash
> > or just hang ?
>
> R crashes actually (just show the "hourglass" icon, stay on, GUI.exe no longer 
> answer, and I must interrupt the process via
> Windows...).
>
> > BTW, if you are not looking for code compatible with S-PLUS, you can
> > omit the panel.superpose call (which is the default anyway when groups
> > are present); e.g.
> >
> > xyplot(rdens ~ annee | habitat,
> >groups = sp, type = 'b',
> >scales = list(y = list(log = TRUE)))
>
> I have just tried and get the same result under lset(col.whitebg()): a crash...
>
> Don't worry too much about this. Things go well when I pass rdens+1 rather than 
> rdens, so the bug (if any bug) can be turned...
>
> Best regards, and warm thanks for all the work you have done (and still do).
>
> Patrick
>
>
>
>
> - Original Message - 
> From: "Deepayan Sarkar" <[EMAIL PROTECTED]>
> To: "Patrick Giraudoux" <[EMAIL PROTECTED]>
> Sent: Thursday, April 29, 2004 3:35 PM
> Subject: Re: Fw: log(0) error is not handled in xyplot
>
>
> > On Thursday 29 April 2004 02:43, Patrick Giraudoux wrote:
> > > > Could you give me a reproducible example ?
> > >
> > > My pleasure.  Actually I have refined the analysis after your e-mail.
> > > The trouble comes from the use of lset(col.whitebg()), scales,
> > > panel.superpose, in combination. This does not simplify the things...
> >
> > Hmm, that's very odd. So what exactly were your symptoms ? Did R crash
> > or just hang ?
> >
> > > Just load the attached file, a data.frame saved with
> > > save(tblcinetique,file="tblcinetique"), and run the following script:
> >
> > Well, I don't see a major problem with either on 1.9.0, and I don't have
> > a 1.8.1 handy right now (I'll try if I get the opportunity).
> >
> > There is a small problem with the first plot, which stems from a grid
> > bug. Effectively what happens is that although NA's are normally
> > removed before the data gets passed to the panel function, in this case
> > the log(0) = -Inf is not being removed. But I'll probably wait for this
> > to be fixed in grid.
> >
> > BTW, if you are not looking for code compatible with S-PLUS, you can
> > omit the panel.superpose call (which is the default anyway when groups
> > are present); e.g.
> >
> > xyplot(rdens ~ annee | habitat,
> >groups = sp, type = 'b',
> >scales = list(y = list(log = TRUE)))
> >
> > Deepayan
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: RWinEdt, R.profile and version 1.9.0

2004-05-01 Thread Patrick Giraudoux
Apologises to reply to myself...

I found where the trouble came from.

The function winMenuAdd() is included in the library utils, not loaded at this stage. 
Now, it works with

library(MASS)
library(lattice)
cat("Load editor?(y/n default = y): ")
nf <- as.character(readLines(n = 1))
if (any(nf=="y",nf=="Y",nf=="")) {library(utils);library(RWinEdt)}
rm(nf)

This loading was not necessary in the version 1.8.1.




----- Original Message - 
From: "Patrick Giraudoux" <[EMAIL PROTECTED]>
To: "r-help" <[EMAIL PROTECTED]>
Sent: Saturday, May 01, 2004 1:39 PM
Subject: RWinEdt, R.profile and version 1.9.0


> Hi,
>
> I have just upgraded from the 1.8.1 to  the 1.9.0 version of R, and have some 
> trouble to run RWinEdt from the .Rprofile file (in
the
> user folder). The script is:
>
> library(MASS)
> library(lattice)
> cat("Load editor?(y/n default = y): ")
> nf <- as.character(readLines(n = 1))
> if ((nf=="y")|(nf=="Y")|(nf=="")) {library(RWinEdt)}
> rm(nf)
>
> When run at start, this prompts:
>
> Loading required package: stats
> Load editor?(y/n default = y): y
> Loading required package: SWinRegistry
> Error in eval(expr, envir, enclos) : couldn't find function "winMenuAdd"
>
> and the WinEdt is not started.
>
> However, if I run
>
> > library(RWinEdt)
>
> from the gui.exe interface, everything goes well.
>
> How can I manage with this "Error in eval(expr, envir, enclos) : couldn't find 
> function "winMenuAdd" generated by a call to
> library(RWinEdt) in the .Rprofile script?
>
> Patrick Giraudoux
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RWinEdt, R.profile and version 1.9.0

2004-05-01 Thread Patrick Giraudoux
Hi,

I have just upgraded from the 1.8.1 to  the 1.9.0 version of R, and have some trouble 
to run RWinEdt from the .Rprofile file (in the
user folder). The script is:

library(MASS)
library(lattice)
cat("Load editor?(y/n default = y): ")
nf <- as.character(readLines(n = 1))
if ((nf=="y")|(nf=="Y")|(nf=="")) {library(RWinEdt)}
rm(nf)

When run at start, this prompts:

Loading required package: stats
Load editor?(y/n default = y): y
Loading required package: SWinRegistry
Error in eval(expr, envir, enclos) : couldn't find function "winMenuAdd"

and the WinEdt is not started.

However, if I run

> library(RWinEdt)

from the gui.exe interface, everything goes well.

How can I manage with this "Error in eval(expr, envir, enclos) : couldn't find 
function "winMenuAdd" generated by a call to
library(RWinEdt) in the .Rprofile script?

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] glm.nb and anova

2004-04-30 Thread Patrick Giraudoux
Hi,

I am trying to fit a negative binomial model with a number of parasite tapeworms as 
response variable to geographical coordinates
(actually preparing a trend surface before kriging). When I try an anova, I get 
warnings:

> glm4.nb<-glm.nb(wb~X4+Y4+I(X4^2)+I(Y4^2))
> anova(glm4.nb)
Analysis of Deviance Table

Model: Negative Binomial(0.0463), link: log

Response: wb

Terms added sequentially (first to last)


 Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL   344  225.7
X41  0.0   343 9578.7   1.0
Y41   1695.7   342 7883.1   0.0
I(X4^2)   1   1992.2   341 5890.9   0.0
I(Y4^2)   1   5687.4   340  203.5   0.0
Warning messages:
1: tests made without re-estimating theta in: anova.negbin(glm4.nb)
2: Algorithm did not converge in: method(x = x[, varseq <= i, drop = FALSE], y = 
object$y, weights = object$prior.weights,
3: Algorithm did not converge in: method(x = x[, varseq <= i, drop = FALSE], y = 
object$y, weights = object$prior.weights,
4: Algorithm did not converge in: method(x = x[, varseq <= i, drop = FALSE], y = 
object$y, weights = object$prior.weights,
>

 Results look like non sense with an intercept deviance smaller than the next 
variables... One can see that X4  has a null deviance.
If X4 is removed from the model, Y4 get a null deviance in the model updated (due to 
an intercept deviance smaller), and so on...
Actually smaller intercept deviance and null deviance for the first variable is 
obtained for every first independant variable,
except when only one is left in the model.

Can somebody tell me what happens?

Thanks in advance,

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] nlme - sum of squares - permutation test

2004-04-17 Thread Patrick Giraudoux
Hi,

1/ I wonder why a anova.lme on a single lme object does not print the sum of squares 
(as expected from the help: "a data frame with the sums of squares, numerator degrees 
of freedom, denominator
degrees of freedom, F-values, and P-values").

Example:

>   fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
> anova(fm2)
numDF denDF  F-value p-value
(Intercept) 180 4123.156  <.0001
age 180  114.838  <.0001
Sex 1259.292  0.0054

How can one get the sum of squares easily?

2/  I have tried a home-made permutation test for comparison with results obtained 
above. I am a quite surprised that the intercept has a probability close to 1:

> lme.perm.test(fm2)
p.value
(Intercept)   0.998
age   0.000
Sex   0.001

The home made function is grounded on 1000 permutations of the response variable 
(distance) and the comparison of the F-values obtained with the F-values observed with 
the original (non permuted)data.

Thanks in advance for any hint,

Patrick Giraudoux



PS: below the current script of the "draft" permutation test:


lme.perm.test<-function(lme.model,pn=1000){

# Giraudoux 17.4.2004 permutation test for linear mixed effect models
# lme.model = a lme object
# pn = permutation number (default = 1000)
# value: a data.frame of the p.values of each independent variable F
# the permutation number is kept in the ouput attributes and thus
# can be called from there
   
an<-anova(lme.model)
Fobs<-an[[3]]
n<-rep(0,length(an[[3]]))

for (i in 1:pn){
lm1<-update(lme.model, sample(.)~.)
an<-anova(lm1)
Frdm<-an[[3]]
for (j in 1:(length(an[[3]]))){
if (Frdm[j]>=Fobs[j]) n[j]<-n[j]+1
}
}
n<-n/pn
names(n)<-row.names(an)
n<-as.data.frame(n)
names(n)<-"p.value"
attributes(n)<-c(attributes(n),permutations=pn)
return(n)
}



[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] adding text in (pair) panels (splom)

2004-04-09 Thread Patrick Giraudoux
OK Paul and Kjetil

I understand that grid.text is part of the library grid. I have tried with Paul's 
arguments. It works perfectly well.

Thanks a lot both,

Patrick


- Original Message - 
From: "Paul Murrell" <[EMAIL PROTECTED]>
To: "Patrick Giraudoux" <[EMAIL PROTECTED]>
Cc: "r-help" <[EMAIL PROTECTED]>
Sent: Saturday, April 10, 2004 4:39 AM
Subject: Re: [R] adding text in (pair) panels (splom)


> Hi
>
>
> Patrick Giraudoux wrote:
> > Hi,
> >
> > I would like to add text in each panel got from the following:
> >
> > splom(~Cs5bis,
> > panel=function(x,y,...){
> > panel.xyplot(x,y,...)
> > panel.abline(lm(y~x),...)
> > })
> >
> > This could be a correlation coefficient or the statistical significance of the 
> > correlation or both, or a star if p < 0.05,
etc...
> > The function text() is useless (probably because I cannot pass appropriates 
> > coordinates in each panel). Googling the R-archives,
I
> > have found only one hint of Andy Liaw relating a rather complex (to me) script 
> > within a home-made panel.myfitline() function.
> >
> > Is there a simple way to add text in panels created eg with:
> >
> > panel=function(x,y,...){
> > panel.xyplot(x,y,...)
> > panel.abline(lm(y~x),...)
> > })
>
>
> text() is useless because splom is a lattice function and lattice is
> based on grid.  To add text in a panel you could use lattice's ltext(),
> but I think the best way would be to use grid.text() as below.  This
> example draws the correlation coefficient 1mm in from the top-left
> corner of the panel.
>
>
> panel=function(x,y,...){
>   panel.xyplot(x,y,...)
>   panel.abline(lm(y~x),...)
>grid.text(round(cor(x, y), 2),
>  x=unit(1, "mm"), y=unit(1, "npc") - unit(1, "mm"),
>  just=c("left", "top"))
> })
>
> Does that do what you want?
>
> Paul
> -- 
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> [EMAIL PROTECTED]
> http://www.stat.auckland.ac.nz/~paul/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] adding text in (pair) panels (splom)

2004-04-09 Thread Patrick Giraudoux
Hi,

I would like to add text in each panel got from the following:

splom(~Cs5bis,
panel=function(x,y,...){
panel.xyplot(x,y,...)
panel.abline(lm(y~x),...)
})

This could be a correlation coefficient or the statistical significance of the 
correlation or both, or a star if p < 0.05, etc...
The function text() is useless (probably because I cannot pass appropriates 
coordinates in each panel). Googling the R-archives, I
have found only one hint of Andy Liaw relating a rather complex (to me) script within 
a home-made panel.myfitline() function.

Is there a simple way to add text in panels created eg with:

panel=function(x,y,...){
panel.xyplot(x,y,...)
panel.abline(lm(y~x),...)
})

?

Any hint appreciated,

Patrick Giraudoux

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] writing polygons/segments to shapefiles (.shp) or other ArcGIS compatible file

2004-02-26 Thread Patrick Giraudoux
Hi,

Thanks for all those information and the most valuable library you have developed.

If somebody is to develop something to write shapefiles from polygon coordinates 
within R (most welcome), I don't think that the
attribute file (dbf) will be an important issue. If we have got an output with the 
index to link the dbf records to each shape of a
shapefile, any text file can be handled in R or Excel to create a dbf. The real issue 
is the encoding of the *.shp and *.shx  etc..
(and an index file for the dbf)

Most important is to consider that ESRI has stopped developping ArcView and AVENUE. 
They have moved to ArGIS and Visual Basic. In
this new generation framework, importation is managed with ArcToolBox which, to my 
knowledge, is very limited considering
importation of text objects (actually I even wonder if one can import something but 
attribute tables without ArcInfo). For instance,
the way I found to solve the problem I met was to write a programme in R to wrap the 
polygon coordinates in a text file readable in
GRASS (an opensource GIS), to import it into GRASS and to export the shapefile from 
GRASS. This shapefile was finally imported to
ArcGIS.  I would not insist on ESRI client policy. I just want to say that the more I 
know corporates the more I love opensource...

Anyway, there are many things that can be made in R which may deserve not only 
importation to R, but also exportation to many kinds
of GIS. To write shapefiles from polygon, points or lines created in R would be most 
useful.

Many thanks for your interest and support,

Patrick Giraudoux


Université de Franche-Comté
Laboratoire de Biologie environnementale
EA3184 usc INRA
F-25030 Besançon Cedex

tél.: +33 381 665 745
fax.: +33 381 665 797
http://lbe.univ-fcomte.fr

"Ce n'est pas en améliorant la bougie que l'on a inventé l'électricité", la recherche 
fondamentale est indispensable !




- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, February 26, 2004 7:11 PM
Subject: Re: [R] writing polygons/segments to shapefiles (.shp) or other ArcGIS 
compatible file


> The main limitation of the shapefiles package that I put together is that it
> does not create shapefiles from R objects - rather it only writes shapefiles
> that have been read into R and manipulated within the constraints of the
> existing file structure.  By this I mean that for example you can change the
> coordinates of points and write them back out.  Or you can add a bunch of
> blank columns in the DBF outside of R and then fill them in with R.  But I
> did not write any code to calculate byte offsets and such and that are
> needed when creating a shapefile from scratch.
>
> So what I do when I want to create a new shapefile from within R is write
> out the format required by the ASCII Tool ArcView (Avenue) script.  This
> script is available at: http://arcscripts.esri.com/details.asp?dbid=11442
> The format is simple:
>
> Works for space delimited ascii to point, polygon and polyline. The format
> for point ascii file is id, x, y (no comma for real data, space delimited).
> For polygon & polyline ascii files, the format is code (1 for start point, 2
> for middle points, 3 for end point), x, y (no comma for real data, space
> delimited). Export shapefile to ascii file works for point, polyline and
> polygon shapefiles. The output format file is id, x, y. For polygon and
> polyline, the id is the sequence id of vertices.
>
> Thus all you have to do is write a text file, install the script in ArcView
> and then use the ArcView extension to create a shapefile from the ASCII
> file.  Unfortunately ASCII tool only works with the geography - you have to
> add the attributes later.
>
> With all of that said, I would like to add to the shapefiles package the
> ability to write out shapefiles from scratch.  Since the shapefiles format
> is rather unique, I think it would be best to use the maptools ShapeList/Map
> class format (or r-spatial's classes).  For starters the package would just
> write out the geography (like the ASCII tool Avenue script).  Later would be
> added the ability to write the dbf data out from the att.data element of the
> Map object.
>
> Unfortunately I don't know when I will have the time to do this.  If anyone
> else wants to do then please go ahead and I can help via email if needed.
> But adding the ability to write out shapefiles from scratch is on my list.
> Once I finish coding our travel demand model and we enter the application
> phase (probably in a few months) then will our demand to output shapefiles
> from R increase and I can justify spending the time to write the code.
>
> I apologize that I have not paid much attention to the r-sig-geo discussi

  1   2   >