Re: [R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Peter Dalgaard BSA
Rashid Nassar <[EMAIL PROTECTED]> writes:

> Many thanks to all for the very quick replies.  I should have stated the
> apparent problem more clearly: round() does not seem to always round 5 to
> the nearest even value as I expected, as my examples (repeated below)
> showed:
> 
> > round(2.45, 1)
> [1] 2.5   # shouldn't this be 2.4?
> 
> > round(1.05, 1)
> [1] 1.1   #  1.0 ?
> 
> > signif(3.445, 3)
> [1] 3.45 # 3.44 ?
> 
> Apologies for not stating this more clearly in my first message, and again
> thanks for the replies.

Yes. From my reading of the code, I would expect 2.4 in the first case
as well. It appears that the intention is to subtract off the integer
part, scale according to the number of digits and round nnn.5 +- eps
towards even values of nnn, but that's not what is happening. 

Anyone want to trace through the code and see what is going on?

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Rashid Nassar
Many thanks to all for the very quick replies.  I should have stated the
apparent problem more clearly: round() does not seem to always round 5 to
the nearest even value as I expected, as my examples (repeated below)
showed:

> round(2.45, 1)
[1] 2.5   # shouldn't this be 2.4?

> round(1.05, 1)
[1] 1.1   #  1.0 ?

> signif(3.445, 3)
[1] 3.45 # 3.44 ?

Apologies for not stating this more clearly in my first message, and again
thanks for the replies.

Rashid Nassar



On Sat, 15 Mar 2003, Warnes, Gregory R wrote:

> Actually, under the default IEEE rounding mode, decimal values ending in 5
> are always rounded to the nearest even value.   This intended to ensure that
> rounding does not systematically bias computations in one direction, as
> would happen if 5's were always rounded either up or down.
>
> A very useful review of the issues in floating point computations on
> computer and under IEEE standard arithmetic is the paper "What Every
> Computer Scientist Should Know About Floating-Point Arithmetic", by David
> Goldberg, published in the March, 1991 issue of Computing Surveys.  This
> paper is reprinted on the Sun website at
> http://docs.sun.com/source/806-3568/ncg_goldberg.html.
>
> -Greg
>
> > -Original Message-
> > From: Marc R. Feldesman [mailto:[EMAIL PROTECTED]
> > Sent: Saturday, March 15, 2003 5:49 PM
> > To: Rashid Nassar; r-help
> > Subject: Re: [R] round() seems inconsistent when rounding 5s
> >
> >
> > At 01:53 PM 3/15/2003, Rashid Nassar wrote:
> >  >It may be my lack of unerstanding, but round() seems to me to give
> >  >inconsistent results when rounding 5s as in the following examples?
> >
> > Not really.  Floating point numbers can't be precisely represented in
> > binary and so the internal representation of 1.5 might be
> > very different
> > from what you think it is.  If you've done any programming at
> > all, this is
> > one of the first lessons you learn about "real" numbers and computers.
> >
> >
> > Dr. Marc R. Feldesman
> > Professor and Chairman Emeritus
> > Anthropology Department - Portland State University
> > email:  [EMAIL PROTECTED]
> > email:  [EMAIL PROTECTED]
> > fax:503-725-3905
> >
> >
> > "Sometimes the lights are all shining on me, other times I
> > can barely see,
> > lately it's occurred to me, what a long strange trip it's
> > been..."  Jerry &
> > the boys
> >
> > __
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
>
>
> LEGAL NOTICE
> Unless expressly stated otherwise, this message is confidential and may be 
> privileged. It is intended for the addressee(s) only. Access to this E-mail by 
> anyone else is unauthorized. If you are not an addressee, any disclosure or copying 
> of the contents of this E-mail or any action taken (or not taken) in reliance on it 
> is unauthorized and may be unlawful. If you are not an addressee, please inform the 
> sender immediately.
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Warnes, Gregory R
Actually, under the default IEEE rounding mode, decimal values ending in 5
are always rounded to the nearest even value.   This intended to ensure that
rounding does not systematically bias computations in one direction, as
would happen if 5's were always rounded either up or down.

A very useful review of the issues in floating point computations on
computer and under IEEE standard arithmetic is the paper "What Every
Computer Scientist Should Know About Floating-Point Arithmetic", by David
Goldberg, published in the March, 1991 issue of Computing Surveys.  This
paper is reprinted on the Sun website at
http://docs.sun.com/source/806-3568/ncg_goldberg.html.

-Greg

> -Original Message-
> From: Marc R. Feldesman [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 15, 2003 5:49 PM
> To: Rashid Nassar; r-help
> Subject: Re: [R] round() seems inconsistent when rounding 5s
> 
> 
> At 01:53 PM 3/15/2003, Rashid Nassar wrote:
>  >It may be my lack of unerstanding, but round() seems to me to give
>  >inconsistent results when rounding 5s as in the following examples?
> 
> Not really.  Floating point numbers can't be precisely represented in 
> binary and so the internal representation of 1.5 might be 
> very different 
> from what you think it is.  If you've done any programming at 
> all, this is 
> one of the first lessons you learn about "real" numbers and computers.
> 
> 
> Dr. Marc R. Feldesman
> Professor and Chairman Emeritus
> Anthropology Department - Portland State University
> email:  [EMAIL PROTECTED]
> email:  [EMAIL PROTECTED]
> fax:503-725-3905
> 
> 
> "Sometimes the lights are all shining on me, other times I 
> can barely see,
> lately it's occurred to me, what a long strange trip it's 
> been..."  Jerry &
> the boys
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


LEGAL NOTICE\ Unless expressly stated otherwise, this message is... [[dropped]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Marc R. Feldesman
At 01:53 PM 3/15/2003, Rashid Nassar wrote:
>It may be my lack of unerstanding, but round() seems to me to give
>inconsistent results when rounding 5s as in the following examples?
Not really.  Floating point numbers can't be precisely represented in 
binary and so the internal representation of 1.5 might be very different 
from what you think it is.  If you've done any programming at all, this is 
one of the first lessons you learn about "real" numbers and computers.

Dr. Marc R. Feldesman
Professor and Chairman Emeritus
Anthropology Department - Portland State University
email:  [EMAIL PROTECTED]
email:  [EMAIL PROTECTED]
fax:503-725-3905
"Sometimes the lights are all shining on me, other times I can barely see,
lately it's occurred to me, what a long strange trip it's been..."  Jerry &
the boys
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Spencer Graves
Consider the following:
> tst <- .5-1e-9
> tst
[1] 0.5
> round(tst)
[1] 0
> tst1 <- .5+1e-9
> tst1
[1] 0.5
> round(tst1)
[1] 1
Does this answer the question?
Spencer Graves

Rashid Nassar wrote:
It may be my lack of unerstanding, but round() seems to me to give
inconsistent results when rounding 5s as in the following examples?

round(1.45, 1)
[1] 1.4   # OK


round(2.45, 1)
[1] 2.5   # shouldn't this be 2.4?


round(1.05, 1)
[1] 1.1   #  1.0 ?

and signif():


signif(2.445, 3)
[1] 2.44 # OK


signif(3.445, 3)
[1] 3.45 # 3.44 ?



version
 _
platform i586-pc-linux-gnu
arch i586
os   linux-gnu
system   i586, linux-gnu
status
major1
minor6.2
year 2003
month01
day  10
language R
Many thanks!

Rashid Nassar

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] round() seems inconsistent when rounding 5s

2003-03-15 Thread Rashid Nassar
It may be my lack of unerstanding, but round() seems to me to give
inconsistent results when rounding 5s as in the following examples?

> round(1.45, 1)
[1] 1.4   # OK

> round(2.45, 1)
[1] 2.5   # shouldn't this be 2.4?

> round(1.05, 1)
[1] 1.1   #  1.0 ?

and signif():

> signif(2.445, 3)
[1] 2.44 # OK

> signif(3.445, 3)
[1] 3.45 # 3.44 ?


> version
 _
platform i586-pc-linux-gnu
arch i586
os   linux-gnu
system   i586, linux-gnu
status
major1
minor6.2
year 2003
month01
day  10
language R

Many thanks!

Rashid Nassar

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Help.start, .Renviron , and .Rprofile

2003-03-15 Thread Fredrik Lundgren
Thanks to Brain Ripley!

Enabling Java and Java Script under edit/preferences/advanced
fixed the problem with netscape (4.8)  "Search Engine & Keywords".

Fredrik


lördagen den 15 mars 2003 21.04 skrev du:
> On Sat, 15 Mar 2003 [EMAIL PROTECTED] wrote:
> > On Sat, 15 Mar 2003, Fredrik Lundgren wrote:
> > > I'm converting from S-Plus Win 98SE to
> > > SuSE 8.1, R 1.62 and have run into som problems.
> > >
> > > 1) When I use help.start() netscape comes up OK and all links are
> > > accessible except "Search Engine & Keywords" : search doesn't work and
> > > the keywords from base doesn't respond either. ?command within R gets
> > > netscape running and works OK.
> >
> > Which netscape is this, what Java do you have installed and is it
> > enabled? ?help.start does contain some details of what you need.
>
> Sorry, ?browseURL in current R: it has been moved.
>
> Also, you could consult the R-help archives there has been much discussion
> of this.  I've never seen a problem recently in RH Linux with a properly
> installed Java plugin, but Mozilla in particular had a broken plugin
> installation.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Help.start, .Renviron , and .Rprofile

2003-03-15 Thread ripley
On Sat, 15 Mar 2003 [EMAIL PROTECTED] wrote:

> On Sat, 15 Mar 2003, Fredrik Lundgren wrote:
> 
> > I'm converting from S-Plus Win 98SE to
> > SuSE 8.1, R 1.62 and have run into som problems.
> > 
> > 1) When I use help.start() netscape comes up OK and all links are accessible 
> > except "Search Engine & Keywords" : search doesn't work and the keywords from base 
> > doesn't respond either. ?command within R gets netscape running and works OK. 
> 
> Which netscape is this, what Java do you have installed and is it enabled?
> ?help.start does contain some details of what you need.

Sorry, ?browseURL in current R: it has been moved.

Also, you could consult the R-help archives there has been much discussion
of this.  I've never seen a problem recently in RH Linux with a properly
installed Java plugin, but Mozilla in particular had a broken plugin
installation.

-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Help.start -

2003-03-15 Thread rob
Hi,

Further on Fredrik's question, I have encountered the same difficulty on
MAC OS X. Neither will clicking on any link work. None of the browsers
seem to work (Safari, Camino, Mozilla, Netscape, IE).
I've tried to set enableSearch tp true, but that does not help either.
From within R, after help.start() search does not work, but e.g.
help(eigen) does work.
Thanks,
Rob
On Saturday, March 15, 2003, at 10:47 AM, Fredrik Lundgren wrote:

Hello experienced R-ers,

I'm converting from S-Plus Win 98SE to
SuSE 8.1, R 1.62 and have run into som problems.
1) When I use help.start() netscape comes up OK and all links are 
accessible except "Search Engine & Keywords" : search doesn't work and 
the keywords from base doesn't respond either. ?command within R gets 
netscape running and works OK.
2) I haven't been able to get Renviron.site, Rprofile.site, .Renviron, 
and .Rprofile to work and affect my sessions. To the best of my 
knowledge I have handled these files according to "Invoking R under 
Unix" in Rintro. .First within R works OK and this is the way I 
customize R at the present time.

Hopefully someone out there realizes what I'm doing wrong.

Thanks in advance

Sincerely Fredrik Lundgren

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Help.start, .Renviron , and .Rprofile

2003-03-15 Thread ripley
On Sat, 15 Mar 2003, Fredrik Lundgren wrote:

> Hello experienced R-ers,
> 
> I'm converting from S-Plus Win 98SE to
> SuSE 8.1, R 1.62 and have run into som problems.
> 
> 1) When I use help.start() netscape comes up OK and all links are accessible except 
> "Search Engine & Keywords" : search doesn't work and the keywords from base doesn't 
> respond either. ?command within R gets netscape running and works OK. 

Which netscape is this, what Java do you have installed and is it enabled?
?help.start does contain some details of what you need.

> 2) I haven't been able to get Renviron.site, Rprofile.site, 
.Renviron, and .Rprofile to work and affect my sessions. 
To the best of my knowledge I have handled these files according 
to "Invoking R under Unix" in Rintro. .First within R works OK and 
this is the way I customize R at the present time.

No idea: do the examples in ?Startup work for you?

Please learn to wrap the lines in email messages.

-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Help.start, .Renviron , and .Rprofile

2003-03-15 Thread Fredrik Lundgren
Hello experienced R-ers,

I'm converting from S-Plus Win 98SE to
SuSE 8.1, R 1.62 and have run into som problems.

1) When I use help.start() netscape comes up OK and all links are accessible except 
"Search Engine & Keywords" : search doesn't work and the keywords from base doesn't 
respond either. ?command within R gets netscape running and works OK. 
2) I haven't been able to get Renviron.site, Rprofile.site, .Renviron, and .Rprofile 
to work and affect my sessions. To the best of my knowledge I have handled these files 
according to "Invoking R under Unix" in Rintro. .First within R works OK and this is 
the way I customize R at the present time.

Hopefully someone out there realizes what I'm doing wrong.

Thanks in advance

Sincerely Fredrik Lundgren

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] plots to metafile and x/y ratio

2003-03-15 Thread juli g. pausas
[EMAIL PROTECTED] wrote:

On Sat, 15 Mar 2003, juli g. pausas wrote:

I have a problem which I'm not sure if it is due to my machine or if I'm 
doing something wrong.

I'm ploting a little map using  plot(val, type="l", asp=1)  where val is 
the object with the latitude/longitude data.
In the screen the figure is perfect, and I can copy to the clipboard and 
paste it to other places. I can also saved using png() or jpeg(), 
althoug the quality is much lower. However when I try to save it as 
metafile (from the plot window or by using win.matafile), the file I 
obtain do not keep the x/y ratio. I'm interested in this metafile 
because the quality in much higher then the png, jpeg.  Any suggestion?
   

The quality is even higher in postscript or PDF.

 

I'm working with R.1.6.1. on Windows.
If somebody is interested, I could send them the files, they are very 
small (45 KB).
   

You cannot look at a win.metafile (it is a binary file in a proprietary
format); you need an application to display it and there is no reason why
that application should preserve the aspect ratio.  I just tried pasting
into Word, inserting in Word and a clipboard viewer and all preserved the
aspect ratio, but in each case it could be lost by resizing.
What exactly did you do with the metafile?
 

I visualised the win.metafile files with ACDSee ver 3.0 (with resizing 
options off). Using this application, I see correctly the figure when 
saved as jpg or png file, but I do not see the metafile correctly. It 
may be a feature of the ACDSee.
Thnaks

Juli

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] plots to metafile and x/y ratio

2003-03-15 Thread ripley
On Sat, 15 Mar 2003, juli g. pausas wrote:

> I have a problem which I'm not sure if it is due to my machine or if I'm 
> doing something wrong.
> 
> I'm ploting a little map using  plot(val, type="l", asp=1)  where val is 
> the object with the latitude/longitude data.
> In the screen the figure is perfect, and I can copy to the clipboard and 
> paste it to other places. I can also saved using png() or jpeg(), 
> althoug the quality is much lower. However when I try to save it as 
> metafile (from the plot window or by using win.matafile), the file I 
> obtain do not keep the x/y ratio. I'm interested in this metafile 
> because the quality in much higher then the png, jpeg.  Any suggestion?

The quality is even higher in postscript or PDF.

> I'm working with R.1.6.1. on Windows.
> If somebody is interested, I could send them the files, they are very 
> small (45 KB).

You cannot look at a win.metafile (it is a binary file in a proprietary
format); you need an application to display it and there is no reason why
that application should preserve the aspect ratio.  I just tried pasting
into Word, inserting in Word and a clipboard viewer and all preserved the
aspect ratio, but in each case it could be lost by resizing.

What exactly did you do with the metafile?


-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] plots to metafile and x/y ratio

2003-03-15 Thread juli g. pausas
Dear all,
I have a problem which I'm not sure if it is due to my machine or if I'm 
doing something wrong.

I'm ploting a little map using  plot(val, type="l", asp=1)  where val is 
the object with the latitude/longitude data.
In the screen the figure is perfect, and I can copy to the clipboard and 
paste it to other places. I can also saved using png() or jpeg(), 
althoug the quality is much lower. However when I try to save it as 
metafile (from the plot window or by using win.matafile), the file I 
obtain do not keep the x/y ratio. I'm interested in this metafile 
because the quality in much higher then the png, jpeg.  Any suggestion?

I'm working with R.1.6.1. on Windows.
If somebody is interested, I could send them the files, they are very 
small (45 KB).
Thanks in advance.

Juli

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] formula, how to express for transforming the whole model.matrix,data=Orthodont

2003-03-15 Thread Peng
Hi, R or S+ users,

I want to make a simple transformation for the model,
but for the whole design matrix.
The model is distance ~ age * Sex, where Sex is a
factor. So the design matrix may look like the
following:
(Intercept) age SexFemale age:SexFemale
1 1   8 0 0
2 1  10 0 0
3 1  12 0 0
4 1  14 0 0
5 1   8 0 0
6 1  10 0 0
7 1  12 0 0
8 1  14 0 0
... 
101   1   8 1 8
102   1  10 110
103   1  12 112
104   1  14 114
105   1   8 1 8
106   1  10 110
107   1  12 112
108   1  14 114

I want to have the whole design matrix transformed by
a vector of multiplicator, say c(m1, m2, m3, ... ,
m26, m27 ), for each Subject. Then the design matrix
will look like this.
(Intercept)age SexFemale age:SexFemale
1m18m1 0 0
2m1   10m1 0 0
3m1   12m1 0 0
4m1   14m1 0 0
5m28m2 0 0
6m2   10m2 0 0
7m2   12m2 0 0
8m2   14m2 0 0
... 
101 m26   8m26   m26  8m26
102 m26  10m26   m26 10m26
103 m26  12m26   m26 12m26
104 m26  14m26   m26 14m26
105 m27   8m27   m27  8m27
106 m27  10m27   m27 10m27
107 m27  12m27   m27 12m27
108 m27  14m27   m27 14m27

I tried to add a new column in the data, say "m". But
the following formula expression does not work. Since
Sex is a factor.
y ~ m + I(m*age) + I(m*Sex) + I(m*age*Sex)
Moreover, in order to implement the EM from "Robust
Estimation in Linear Mixed-Effects Models
Using the Multivariate t-Distribution" by Dr.
Pinheiro, I also need to transform the response, y, in
the same way. 
I did it by writing SAS liked codes (making a new
table, coding factors, finishing transformation,
making groupedData, call lme), but that is not
readable, and it will be complicated to realized that
for any other datasets.

I am wondering whether the formula has some sorts of
expression to realize transformation for the whole
design matrix, especially when having factors in the
formula.

Thanks a lot!

Peng

Peng Liu
--
Peng Liu  |
Division of Statistics|
Northern Illinois University  |
De Kalb, IL 60115, USA|
E-mail: [EMAIL PROTECTED] |
--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] configure, IBM AIX and checking whether leap seconds are treatedaccording to POSIX...

2003-03-15 Thread Laurent Gautier
Hi,

I am trying to compile R for 64 bits on a mainframe running
IBM AIX. Setting the environment variable OBJECT_MODE=64
leads to hanging while checking whether leap seconds are treated according to POSIX...
Interestingly, it works fine when OBJECT_MODE=32...

Any pointer would help me much...


Thanks,



L.


-- 
--
currently at the National Yang-Ming University in Taipei, Taiwan
--
Laurent Gautier CBS, Building 208, DTU
PhD. StudentDK-2800 Lyngby,Denmark  
tel: +45 45 25 24 89http://www.cbs.dtu.dk/laurent

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help