Re: [R] Trying to write a linear regression using MLE and optim()

2005-05-30 Thread Gabor Grothendieck
On 5/30/05, Ajay Shah <[EMAIL PROTECTED]> wrote:
> 
> I wrote this:
> 
> # Setup problem
> x <- runif(100)
> y <- 2 + 3*x + rnorm(100)
> X <- cbind(1, x)
> 
> # True OLS --
> lm(y ~ x)
> 
> # OLS likelihood function --
> ols.lf <- function(theta, K, y, X) {
>  beta <- theta[1:K]
>  sigma <- exp(theta[K+1])
>  e <- (y - X%*%beta)/sigma
>  logl <- sum(log(dnorm(e)))
>  return(logl)
> }
> 
> optim(c(2,3,0), ols.lf, gr=NULL,
>  method="BFGS", lower=-Inf, upper=Inf,
>  control=list(trace=2, fnscale=-1),
>  # Now for the "..." stuff
>  K, y, X)

The last line should be:

K=K, y=y, X=X)

and also you have to set K.


> 
> 
> I get:
> 
> Error in fn(par, ...) : argument "X" is missing, with no default
> In addition: Warning message:
> numerical expression has 100 elements: only the first used in: 1:K
> Execution halted
> 
> If someone can show me the way, it'll be most appreciated. :-)
> 
> __
> 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] Installing RGL on SuSE 9.3

2005-05-30 Thread Shige Song
I am running R 2.10 on SuSE 9.3. When I tried to install the package
"rgl", I got error message:

...
In file included from pixmap.cpp:13:
pngpixmap.h: In static member function `static void
   PNGPixmapFormat::Load::info_callback(png_struct*, png_info*)':
pngpixmap.h:149: error: invalid conversion from `long unsigned int*' to `
   png_uint_32*'
pngpixmap.h:149: error: invalid conversion from `long unsigned int*' to `
   png_uint_32*'
make: *** [pixmap.o] Error 1
ERROR: compilation failed for package 'rgl'
** Removing '/usr/local/lib/R/library/rgl'
** Restoring previous '/usr/local/lib/R/library/rgl'
...

Any ideas why?

Shige

__
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] Trying to write a linear regression using MLE and optim()

2005-05-30 Thread Ajay Shah

I wrote this:

# Setup problem
x <- runif(100)
y <- 2 + 3*x + rnorm(100)
X <- cbind(1, x)

# True OLS --
lm(y ~ x)

# OLS likelihood function --
ols.lf <- function(theta, K, y, X) {
  beta <- theta[1:K]
  sigma <- exp(theta[K+1])
  e <- (y - X%*%beta)/sigma
  logl <- sum(log(dnorm(e)))
  return(logl)
}

optim(c(2,3,0), ols.lf, gr=NULL,
  method="BFGS", lower=-Inf, upper=Inf,
  control=list(trace=2, fnscale=-1),
  # Now for the "..." stuff
  K, y, X)


I get:

Error in fn(par, ...) : argument "X" is missing, with no default
In addition: Warning message:
numerical expression has 100 elements: only the first used in: 1:K 
Execution halted

If someone can show me the way, it'll be most appreciated. :-)

__
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] Formatting numbers with a limited amount of digits consistently

2005-05-30 Thread Gabor Grothendieck
On 5/30/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck wrote:
> > On 5/30/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> >
> >>Henrik Andersson wrote:
> >>
> >>>I have tried to get signif, round and format to display numbers like
> >>>these consistently in a table, using e.g. signif(x,digits=3)
> >>>
> >>>17.01
> >>>18.15
> >>>
> >>>I want
> >>>
> >>>17.0
> >>>18.2
> >>>
> >>>Not
> >>>
> >>>17
> >>>18.2
> >>>
> >>>
> >>>Why is the last digit stripped off in the case when it is zero!
> >>
> >>signif() changes the value; you don't want that, you want to affect how
> >>a number is displayed.  Use format() or formatC() instead, for example
> >>
> >> > x <- c(17.01, 18.15)
> >> > format(x, digits=3)
> >>[1] "17.0" "18.1"
> >> > noquote(format(x, digits=3))
> >>[1] 17.0 18.1
> >>
> >
> >
> > That works in the above context but I don't think it works generally:
> >
> > R> f <- head(faithful)
> > R> f
> >   eruptions waiting
> > 1 3.600  79
> > 2 1.800  54
> > 3 3.333  74
> > 4 2.283  62
> > 5 4.533  85
> > 6 2.883  55
> >
> > R> format(f, digits = 3)
> >   eruptions waiting
> > 1  3.60  79
> > 2  1.80  54
> > 3  3.33  74
> > 4  2.28  62
> > 5  4.53  85
> > 6  2.88  55
> >
> > R> # this works in this case
> > R> noquote(prettyNum(round(f,1), nsmall = 1))
> >  eruptions waiting
> > [1,] 3.6   79.0
> > [2,] 1.8   54.0
> > [3,] 3.3   74.0
> > [4,] 2.3   62.0
> > [5,] 4.5   85.0
> > [6,] 2.9   55.0
> >
> > and even that does not work in the desired way (which presumably
> > is not to use exponent format) if you have some
> > large enough numbers like 1e6 which it will display using
> > the e notation rather than using ordinary notation.
> 
> formatC with format="f" seems to work for me, though it assumes you're
> specifying decimal places rather than significant digits.  It also wants
> a vector of numbers as input, not a dataframe.  So the following gives
> pretty flexible control over what a table will look like:
> 
>  > data.frame(eruptions = formatC(f$eruptions, digits=2, format='f'),
> +waiting = formatC(f$waiting, digits=1, format='f'))
>eruptions waiting
> 1 100.1179.0
> 2   1.8054.0
> 3   3.3374.0
> 4   2.2862.0
> 5   4.5385.0
> 6   2.8855.0
> 
> >
> > I have struggled with this myself and have generally been able
> > to come up with something for specific instances but I have generally
> > found it a pain to do a simple thing like format a table exactly as I want
> > without undue effort.  Maybe someone else has figured this out.
> 
> I think that formatting tables properly requires some thought, and R is
> no good at thinking.  You can easily recognize a badly formatted table,
> but it's very hard to write down rules that work in general
> circumstances.  It's also a matter of taste, so if I managed to write a
> function that matched my taste, you would find you wanted to make changes.
> 
> It's sort of like expecting plot(x, y) to always come up with the best
> possible plot of y versus x.  It's just not a reasonable expectation.
> It's better to provide tools (like abline() for plots or formatC() for
> tables) that allow you to tailor a plot or table to your particular needs.
> 

Thanks.  That seems to be the idiom I was missing.  One thing that would
be nice would be if formatC could handle data frames.

__
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] Problem going back to a viewport with gridBase

2005-05-30 Thread Gabor Grothendieck
I am setting up base plots -- one in viewport A and and one in B.  This part
works fine.  But if I go back to A after having done B and add
horizontal lines it seems
to not use the correct coordinates.  How do I tell it to resume using A's
coordinates?  I am already using par(fig = gridFIG()) but it seems that that's
not enough to reestablish them.  What happens is that when I go back to 
A it draws the horizontal lines as if its relative to B's coordinates
rather than
restablishing A's coordinates.  As a result the horizontal lines are
drawn near the
bottom of the graph instead of at the correct heights.  Try running the code
below to see what I mean.

I have also tried to use baseViewports with this but did not have any
success.

How do I modify this example so that the horizontal red lines come out
at the appropriate levels?Note that this is just an example and in 
the future I will want to have multiple viewports each with a base plot and
add arbitrary additional line or point plots to them so the solution needs
to be sufficiently general that I can so generalize it.

Thanks.


library(gridBase)

opar <- par(no.readonly = TRUE)
grid.newpage()

# two columns, one row
unit. <- unit(c(1,1), c("null","null"))
pushViewport(viewport(layout = grid.layout(1, 2, widths = unit.)))

# draw green graph in first column (viewport A)
pushViewport(viewport(layout.pos.col = 1, name = "A"))
par(fig = gridFIG()); par(new = TRUE)
plot(1:10, col = "green", pch = 20)
upViewport(1)

# draw purple graph in second column (viewport B)
pushViewport(viewport(layout.pos.col = 2, name = "B"))
par(fig = gridFIG()); par(new = TRUE)
plot(1:100, col = "purple", pch = 18)
upViewport()

# go back to A and add horizontal grid lines
seekViewport("A")
par(fig = gridFIG())
abline(h=1:10, col = "red")   THESE DO NOT GET DRAWN AS EXPECTED
popViewport()

# go back to B and add vertical grid lines
seekViewport("B")
par(fig = gridFIG())
abline(v=1:10, col = "red")
popViewport()
par(opar)

__
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] R GUI for Linux?

2005-05-30 Thread White, Charles E WRAIR-Wash DC
John:

Thank you for your interest. After more investigation I see that my problem is 
with linking tcltk to R. tcl 8.4.7-2 and tk 8.4.7-2 are tuned to fc3 (Fedora 
Core 3) and part of the standard installation. However, required file locations 
are different than what is expected by R. I set the locations for tclConfig.sh 
and tkConfig.sh using ./configure but R tells me something to the effect that 
Tcl and Tk major or minor versions disagree. Your help or the help of others on 
the R-List would be appreciated. FYI, I am also including the locations of 
important files and directories.

tclConfig.sh: /usr/lib
tkConfig.sh:  /usr/lib
tcl library:  /usr/lib/tcl8.4 (symbolically linked from /usr/share/tcl8.4)
tk library:   /usr/lib/tk8.4 (separate copy in /usr/share/tk8.4)
tcl.h:I can't find it with full drive search
tk.h: I can't find it with full drive search

Thanks for your time.

Chuck
-Original Message-
From: John Fox [mailto:[EMAIL PROTECTED]
Sent: Mon 5/30/2005 4:20 PM
To: White, Charles E WRAIR-Wash DC
Cc: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch
Subject: RE: [R] R GUI for Linux?
 
Dear Charles,


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of White, 
> Charles E WRAIR-Wash DC
> Sent: Monday, May 30, 2005 10:52 AM
> To: r-help@stat.math.ethz.ch
> Cc: [EMAIL PROTECTED]
> Subject: [R] R GUI for Linux?
> 

. . .

I haven't tried the Rcmdr package with FC3, but I ran it under an older
version of Red Hat Linux some time ago, and the current version (Rcmdr
1.0-2) under Quantian.

Can you be more specific about the problems that you encountered? Are these
general to the tcltk package or specific to the Rcmdr?

I'm sorry that you're experiencing problems.

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


Re: Re: [R] labels on map

2005-05-30 Thread jose silva
thanks Duncan, thats what I was looking for :)

p.s. xlab in map() gives the same result as in axis()

j. silva

jose silva wrote: 
> dear all: 
> 
> Im trying to obtain maps on R, under mapdata library, but I cannot define the 
> labels. 
> Here is an example: 
> 
> library(mapdata) 
> map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5)) 
> axis(1,at=seq(-12,3,3)) 
> axis(2) 
> 
> when I try the parameter xlab or ylab in axis, i get: 
> parameter "ylab" couldn't be set in high-level plot() function 
> 
> any suggestion? thanks in advance for your always useful advices 

Despite their names, x and y axis labels aren't really part of the axis, 
they're titles in the margins of the plot. Use the title() function to 
set them. 

You could probably also set them in map(), but I don't have it installed 
to check. mtext() is another general purpose way to put text in the 
margins. 

Duncan Murdoch
[[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] labels on map

2005-05-30 Thread Mulholland, Tom
What makes you think that there is a ylab parameter?

> args(map)
function (database = "world", regions = ".", exact = FALSE, boundary = TRUE, 
interior = TRUE, projection = "", parameters = NULL, orientation = NULL, 
fill = FALSE, col = 1, plot = TRUE, add = FALSE, namesonly = FALSE, 
xlim = NULL, ylim = NULL, wrap = FALSE, resolution = if (plot) 1 else 0, 
type = "l", bg = par("bg"), mar = c(0, 0, par("mar")[3], 
0.1), border = 0.01, ...) 
NULL
>

Just because there are ellipses does not mean that ylab is an appropriate 
parameter. If you type map you'll see the function. Go looking for where the 
ellipses are used and you find

polygon(coord, col = col, ...)
lines(coord, col = col, type = type, ...)

So how why would these functions take a ylab parameter, they are for use within 
a plot. You have to remember that each function will only do what the author 
has programmed it to do.

So if you need to put a label somewhere you could always use mtext(side = 
2,line = 1,"A label on side 2")

Tom

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of jose silva
> Sent: Tuesday, 31 May 2005 8:12 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] labels on map
> 
> 
> dear all:
> 
> Im trying to obtain maps on R, under mapdata library, but I 
> cannot define the labels.
> Here is an example:
> 
> library(mapdata)
> map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5))
> axis(1,at=seq(-12,3,3))
> axis(2)
> 
> when I try the parameter xlab or ylab in axis, i get: 
> parameter "ylab" couldn't be set in high-level plot() function 
> 
> any suggestion?  thanks in advance for your always useful advices
> 
> j. silva
>   [[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-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] labels on map

2005-05-30 Thread Duncan Murdoch

jose silva wrote:

dear all:

Im trying to obtain maps on R, under mapdata library, but I cannot define the 
labels.
Here is an example:

library(mapdata)
map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5))
axis(1,at=seq(-12,3,3))
axis(2)

when I try the parameter xlab or ylab in axis, i get: 
parameter "ylab" couldn't be set in high-level plot() function 


any suggestion?  thanks in advance for your always useful advices


Despite their names, x and y axis labels aren't really part of the axis, 
they're titles in the margins of the plot.  Use the title() function to 
set them.


You could probably also set them in map(), but I don't have it installed 
to check.  mtext() is another general purpose way to put text in the 
margins.


Duncan Murdoch

__
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] Piecewise Linear Regression

2005-05-30 Thread roger koenker
It is conventional to fit piecewise linear models by assuming  
Gaussian error and
using least squares methods, but one can argue that median regression  
provides
a more robust approach to this problem.  You might consider the  
following fit:


 x = c 
(6.25,6.25,12.50,12.50,18.75,25.00,25.00,25.00,31.25,31.25,37.50,37.50,5 
0.00,50.00,62.50,62.50,75.00,75.00,75.00,100.00,100.00)
 y = c 
(0.328,0.395,0.321,0.239,0.282,0.230,0.273,0.347,0.211,0.210,0.259,0.186 
,0.301,0.270,0.252,0.247,0.277,0.229,0.225,0.168,0.202)

library(quantreg)
plot(x,y)
fit <- rqss(y ~ qss(x))
plot(fit)

it gives 5 segments not 3, but this can be controlled by the choice  
of lambda in the qss

function, for example, try:

fit <- rqss(y ~ qss(x,lambda=3)
plot(fit,col="red")

which gives a fit like you suggest might be reasonable with only  
three segments.




url:www.econ.uiuc.edu/~rogerRoger Koenker
email   [EMAIL PROTECTED]   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On May 30, 2005, at 6:38 PM, Abhyuday Mandal wrote:


Hi,

I need to fit a piecewise linear regression.

x = c 
(6.25,6.25,12.50,12.50,18.75,25.00,25.00,25.00,31.25,31.25,37.50,37.50 
,50.00,50.00,62.50,62.50,75.00,75.00,75.00,100.00,100.00)
y = c 
(0.328,0.395,0.321,0.239,0.282,0.230,0.273,0.347,0.211,0.210,0.259,0.1 
86,0.301,0.270,0.252,0.247,0.277,0.229,0.225,0.168,0.202)


there are two change points. so the fitted curve should look like



\
 \  /\
  \/  \
   \
\

How do I do this in R ?

Thank you,
Abhyuday

__
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


Re: [R] persp, add lines/highlights

2005-05-30 Thread Paul Murrell

Hi


[EMAIL PROTECTED] wrote:

Hello R-sters,

I'm trying to add several lines to a response surface that I've plotted
using persp().  I've tried lines() using the "trans3d" function but I've
been unsuccessful in getting it to work (R v2.0.1).  Essentially, I'm
trying to highlight one or more of the surface wireframe lines in a
bolder (or different) color.  Any tips from those of you who have some
experience with this would be greatly appreciated.  [Would it be easier
using wireframe() in library(lattice) instead?]



Here's an example that just overlays two persp() plots ...

x <- seq(-10, 10, length= 30)
y <- x
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
z[is.na(z)] <- 1
op <- par(bg = "white")
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
  zlim=range(z))

# overlay plot with just "highlighted" surface area
par(new=TRUE)
z2 <- matrix(NA, ncol=30, nrow=30)
xi <- 15:18
yi <- 13:14
z2[xi, yi] <- z[xi, yi]
persp(x, y, z2, theta = 30, phi = 30, expand = 0.5,
  zlim=range(z), border="red", col="pink", box=FALSE, axes=FALSE)



And, any suggestions on how to add text outside of the persp() plot next
to the highlighted line would be much appreciated.



Do you mean like a legend?

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/

__
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] labels on map

2005-05-30 Thread jose silva
dear all:

Im trying to obtain maps on R, under mapdata library, but I cannot define the 
labels.
Here is an example:

library(mapdata)
map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5))
axis(1,at=seq(-12,3,3))
axis(2)

when I try the parameter xlab or ylab in axis, i get: 
parameter "ylab" couldn't be set in high-level plot() function 

any suggestion?  thanks in advance for your always useful advices

j. silva
[[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] Piecewise Linear Regression

2005-05-30 Thread Sean Davis

Abhyuday,

There are a number of answers in the archives:

http://www.google.com/u/newcastlemaths?q=piecewise+linear+regression&sa=Google+Search

Do any of those meet your needs?

Sean

- Original Message - 
From: "Abhyuday Mandal" <[EMAIL PROTECTED]>

To: 
Sent: Monday, May 30, 2005 7:38 PM
Subject: [R] Piecewise Linear Regression



Hi,

I need to fit a piecewise linear regression.

x = 
c(6.25,6.25,12.50,12.50,18.75,25.00,25.00,25.00,31.25,31.25,37.50,37.50,50.00,50.00,62.50,62.50,75.00,75.00,75.00,100.00,100.00)
y = 
c(0.328,0.395,0.321,0.239,0.282,0.230,0.273,0.347,0.211,0.210,0.259,0.186,0.301,0.270,0.252,0.247,0.277,0.229,0.225,0.168,0.202)


there are two change points. so the fitted curve should look like



\
\  /\
 \/  \
  \
   \

How do I do this in R ?

Thank you,
Abhyuday

__
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] Piecewise Linear Regression

2005-05-30 Thread Abhyuday Mandal
Hi,

I need to fit a piecewise linear regression.

x = 
c(6.25,6.25,12.50,12.50,18.75,25.00,25.00,25.00,31.25,31.25,37.50,37.50,50.00,50.00,62.50,62.50,75.00,75.00,75.00,100.00,100.00)
y = 
c(0.328,0.395,0.321,0.239,0.282,0.230,0.273,0.347,0.211,0.210,0.259,0.186,0.301,0.270,0.252,0.247,0.277,0.229,0.225,0.168,0.202)

there are two change points. so the fitted curve should look like



\ 
 \  /\
  \/  \
   \
\

How do I do this in R ?

Thank you,
Abhyuday

__
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] R GUI for Linux?

2005-05-30 Thread Patrick Connolly
On Mon, 30-May-2005 at 08:29PM +0200, Sander Oom wrote:


|> .. I have 
|> given up on any instructions that tell me to run 'make'. Linux 
|> distributions are just to[o] idiosyncratic for it to be worth the effort. 

That might be true of Linux distributions in general, but installing R
is *very* easy.  There are a couple of lines you can paste from the
README file to get the configure and make thing working.  Depending on
your machine, it might take some time to do all its stuff which is
extensive and thorough.

Installing ESS is only slightly different.  Simply extract the tar.gz
file, find the README file and adjust your .emacs file to let it know
where you've installed ESS.

Granted, it does take a bit to get used to the way Emacs does things,
but you need only about 1% of its capability and then it is extremely
easy to use.  Many questions asked on this list just don't arise.

best

-- 
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand 
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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] persp, add lines/highlights

2005-05-30 Thread jjorgensen
Hello R-sters,

I'm trying to add several lines to a response surface that I've plotted
using persp().  I've tried lines() using the "trans3d" function but I've
been unsuccessful in getting it to work (R v2.0.1).  Essentially, I'm
trying to highlight one or more of the surface wireframe lines in a
bolder (or different) color.  Any tips from those of you who have some
experience with this would be greatly appreciated.  [Would it be easier
using wireframe() in library(lattice) instead?]

And, any suggestions on how to add text outside of the persp() plot next
to the highlighted line would be much appreciated.

Thanks,

Jeff Jorgensen

__
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] R GUI for Linux?

2005-05-30 Thread John Fox
Dear Charles,


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of White, 
> Charles E WRAIR-Wash DC
> Sent: Monday, May 30, 2005 10:52 AM
> To: r-help@stat.math.ethz.ch
> Cc: [EMAIL PROTECTED]
> Subject: [R] R GUI for Linux?
> 

. . .

> 
> Rcmdr: There are all sorts of things in FC3 that seem to be 
> tcl/tk related but Rcmdr doesn't seem to work with them. 
> Since some are part of the base FC3 installation, I'm 
> nervious about replacing them or installing competing 
> software. Potentially conflicting software in FC3 are listed below:
> 
> tcl.i386 8.4.7-2  
>   installed
> tclx.i3868.3.5-4  
>   installed
> db4-tcl.i386 4.2.52-6   base
> postgresql-tcl.i386  7.4.8-1.FC3.1
>   updates-released
> ruby-tcltk.i386  1.8.2-1.FC3.1
>   updates-released
> tcl-devel.i386   8.4.7-2base
> tcl-html.i3868.4.7-2base
> tclx-devel.i386  8.3.5-4base
> tclx-doc.i3868.3.5-4base
> 

. . .

I haven't tried the Rcmdr package with FC3, but I ran it under an older
version of Red Hat Linux some time ago, and the current version (Rcmdr
1.0-2) under Quantian.

Can you be more specific about the problems that you encountered? Are these
general to the tcltk package or specific to the Rcmdr?

I'm sorry that you're experiencing problems.

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] "FANNY" function in R package "cluster"

2005-05-30 Thread Aamir M
Dear All,

I am attempting to use the FANNY fuzzy clustering function in R
(Kaufman & Rousseeuw, 1990), found in the "cluster" package. I have
run into a variety of difficulties; the two most crucial difficulties
are enumerated below.

1. Where is the 'm' parameter in FANNY? 
In _Finding Groups in Data: An Introduction to Cluster Analysis_
(1990) by Kaufman & Rousseeuw, the authors discuss the FANNY
algorithm. On pages 189-190, they attempt to demonstrate an
equivalence between Fuzzy c-Means (FCM) and FANNY. In doing so they,
appear to be assuming that the value of the 'm' parameter in FCM (a
measure of the fuzziness) is fixed at m=2. Although this is how FCM
was originally formulated, it eventually became apparent that m should
be a user-specified parameter and not a fixed value of m=2.  My
question, then, is twofold. Firstly, am I correct in saying that
Kaufman & Rousseeuw have assumed m=2 in their formulation of Fuzzy
c-Means and FANNY? Secondly, is it possible to modify the FANNY
algorithm to allow user-specification of the m (fuzziness) parameter?

2. What do I do with training data?
Is there any way to use FANNY for assigning clustering membership
values to new, test data? In Fuzzy c-Means, new data is compared to
the cluster centers in order to assign clustering membership values to
the test data. However, in FANNY these centers do not exist. Is there,
then, any way to compute the FANNY clustering membership values of a
test data point without affecting the clustering membership values of
the training data? Perhaps there are enough conditions to use the
objective function as a way of computing the membership values of the
test data?

Aamir M
University of Toronto

__
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] Unique arrangements of a vector

2005-05-30 Thread Tarmo Remmel
Dear List,

Running on a PC (Windows 2000) with 256 MB RAM, Version R1.9.1

I have a relatively simple problem, which I can solve for relatively small
datasets, but run into difficulties with larger ones.  I believe that my
approach is a hack rather than something elegant and I was hoping that
somebody on this list might help me improve my code.  Basically, given a
vector of values (e.g., 0,0,1,1), I want to generate all of the unique
arrangements of these values, of which there are 4!/(2!2!) = 6.

0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0

Using unique() in conjunction with expand.grid(), and later filtering
impossible results, I can obtain the answer.  However, this is slow, and
does not work for large initial vectors and is difficult to filter when
using values beyond 0,1.  Is there some mathematically elegant method for
doing this?  I'd hope to have initial vectors significantly longer than the
demonstrated 4 values (e.g., thousands).

Any help is appreciated and I will gladly SUM afterwards.

Thank you,

Tarmo

__
Tarmo Remmel  Ph.D.
GUESS Lab, Department of Geography
University of Toronto at Mississauga
Mississauga, Ontario, L5L 1C6
Tel: 905-828-3868
Fax: 905-828-5273
Skype: tarmoremmel
http://eratos.erin.utoronto.ca/remmelt

__
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] Formatting numbers with a limited amount of digits consistently

2005-05-30 Thread Duncan Murdoch

Gabor Grothendieck wrote:

On 5/30/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:


Henrik Andersson wrote:


I have tried to get signif, round and format to display numbers like
these consistently in a table, using e.g. signif(x,digits=3)

17.01
18.15

I want

17.0
18.2

Not

17
18.2


Why is the last digit stripped off in the case when it is zero!


signif() changes the value; you don't want that, you want to affect how
a number is displayed.  Use format() or formatC() instead, for example

> x <- c(17.01, 18.15)
> format(x, digits=3)
[1] "17.0" "18.1"
> noquote(format(x, digits=3))
[1] 17.0 18.1




That works in the above context but I don't think it works generally:

R> f <- head(faithful)
R> f
  eruptions waiting
1 3.600  79
2 1.800  54
3 3.333  74
4 2.283  62
5 4.533  85
6 2.883  55

R> format(f, digits = 3)
  eruptions waiting
1  3.60  79
2  1.80  54
3  3.33  74
4  2.28  62
5  4.53  85
6  2.88  55

R> # this works in this case
R> noquote(prettyNum(round(f,1), nsmall = 1))
 eruptions waiting
[1,] 3.6   79.0   
[2,] 1.8   54.0   
[3,] 3.3   74.0   
[4,] 2.3   62.0   
[5,] 4.5   85.0   
[6,] 2.9   55.0   


and even that does not work in the desired way (which presumably
is not to use exponent format) if you have some
large enough numbers like 1e6 which it will display using
the e notation rather than using ordinary notation.


formatC with format="f" seems to work for me, though it assumes you're 
specifying decimal places rather than significant digits.  It also wants 
a vector of numbers as input, not a dataframe.  So the following gives 
pretty flexible control over what a table will look like:


> data.frame(eruptions = formatC(f$eruptions, digits=2, format='f'),
+waiting = formatC(f$waiting, digits=1, format='f'))
   eruptions waiting
1 100.1179.0
2   1.8054.0
3   3.3374.0
4   2.2862.0
5   4.5385.0
6   2.8855.0



I have struggled with this myself and have generally been able
to come up with something for specific instances but I have generally 
found it a pain to do a simple thing like format a table exactly as I want 
without undue effort.  Maybe someone else has figured this out.


I think that formatting tables properly requires some thought, and R is 
no good at thinking.  You can easily recognize a badly formatted table, 
but it's very hard to write down rules that work in general 
circumstances.  It's also a matter of taste, so if I managed to write a 
function that matched my taste, you would find you wanted to make changes.


It's sort of like expecting plot(x, y) to always come up with the best 
possible plot of y versus x.  It's just not a reasonable expectation. 
It's better to provide tools (like abline() for plots or formatC() for 
tables) that allow you to tailor a plot or table to your particular needs.


Duncan Murdoch

__
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] R GUI for Linux?

2005-05-30 Thread Sander Oom

Hi Charles,

Warm felt sympathies for your struggles. I consider myself a happy GUI 
user and have also struggled with the 'command line' history and lack of 
out-of-the-box functionality associated with Linux. However, Linux does 
have many, many advantages over other OS's, so I will stick to it. That 
said, I am reluctantly suggesting it to others, as there are lots of 
other things one can do on a Saturday afternoon. ;-)


After many long afternoons, I have come to the conclusion that accepting 
what comes as standard is the best approach to using Linux if you do 
have better things to do. I tried ESS, but I found it impenetrable at my 
first try, so gave up.


I run SuSE linux and R without any problem. The RPM was downloaded from 
CRAN and installed without any errors. I run update.packages to 
download, install and refresh all contributed and other packages.


I also looked for an R GUI, but must admit I stopped way before you did. 
I ended up using my favorite editor (Kate, comes standard with KDE) and 
cut and paste code into an R console (available as standard in the Kate 
window). Gives a nice clean window for writing code and running R. Of 
course Kate has code highlighting facilities (as standard). I soon 
realized that the console has a limited buffer for commands, such that 
long code sequences are abruptly ended part way through. Thus I have a 
second console open from which I source whole R files. The setup gives a 
relatively comfortable code debugging environment!


I was amazed when I read the instruction for JGR on Linux. I thought the 
whole point of Java was to create platform independent software. I have 
given up on any instructions that tell me to run 'make'. Linux 
distributions are just to idiosyncratic for it to be worth the effort. 
I'll just wait until Novell packs JGR with the new version of SuSE 
Linux. Even if I have to pay something for the added bonus!


Will keep following the GUI developments with interest,

Sander.


White, Charles E WRAIR-Wash DC wrote:

I feel your pain.  I am a new Linux user who has spent most of the 
weekend trying to get a functional R setup. When I installed Fedora Core 3 (FC3) on 
my home computer, I thought using R in a terminal would be a snap. I installed R 
using the rpm packages and tried to use it with the FC3 default terminal (GNOME 
Terminal 2.7.3). Before long, I found out the terminal was rudely discarding output 
beyond a set number of lines. I could increase the number of lines kept by the 
terminal but that didn't strike me as an acceptable solution. Cutting to my stress 
relieving intermediate solution, I am currently using xemacs with ESS as my R 
programming environment under FC3. Eventually, I will want to run JGR as my 
programming environment and Rcmdr as both a teaching tool and means to distribute 
code to some of my clients. On my way to xemacs, I also tried to install emacs and 
gnomeGUI. I will briefly document my experience with trying to install each of these 
packages below:

XEMACS with ESS: XEMACS is within the 'walled garden' of packages tuned 
specifically to run under FC3 and XEMACS provides a tuned installation for ESS. 
Since I had already compiled R from source with shared libraries enabled (the 
rmp does not enable shared libraries), I don't know if XEMACS will work with 
the rpm version of R. Note also that I installed this package using yum; 'Add 
or Remove Applications' lists xemacs but wouldn't allow me to install.

JGR: I have installed jdk1.5.0_03 and MOST of the the output from make looks 
like JGR is compiling correctly. JavaGD and rJava are not finding jini.h. I 
don't see an explicit statement of how to start JGR but I assume that is done 
by typing JGR (or maybe jgr) in a terminal window. Nothing happens. Two 
potential problems are: (a) I never should have downloaded JavaGD and rJava 
from CRAN (they won't uninstall, deleting the directories doesn't stop the 
problem, and I can't use yum to remove R to start over because yum doesn't 
recognise that R is installed.) or (b) I need to uninstall some of the stray 
versions of java littering my hard drive. I haven't removed the symbolic link 
between jre1.5.0_02 and firefox.

Rcmdr: There are all sorts of things in FC3 that seem to be tcl/tk related but 
Rcmdr doesn't seem to work with them. Since some are part of the base FC3 
installation, I'm nervious about replacing them or installing competing 
software. Potentially conflicting software in FC3 are listed below:

tcl.i386 8.4.7-2installed
tclx.i3868.3.5-4installed
db4-tcl.i386 4.2.52-6   base
postgresql-tcl.i386  7.4.8-1.FC3.1  updates-released
ruby-tcltk.i386  1.8.2-1.FC3.1  updates-released
tcl-devel.i386   8.4.7-2base
tcl-html.i3868.4.

Re: [R] Formatting numbers with a limited amount of digits consistently

2005-05-30 Thread Gabor Grothendieck
On 5/30/05, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> Henrik Andersson wrote:
> > I have tried to get signif, round and format to display numbers like
> > these consistently in a table, using e.g. signif(x,digits=3)
> >
> > 17.01
> > 18.15
> >
> > I want
> >
> > 17.0
> > 18.2
> >
> > Not
> >
> > 17
> > 18.2
> >
> >
> > Why is the last digit stripped off in the case when it is zero!
> 
> signif() changes the value; you don't want that, you want to affect how
> a number is displayed.  Use format() or formatC() instead, for example
> 
>  > x <- c(17.01, 18.15)
>  > format(x, digits=3)
> [1] "17.0" "18.1"
>  > noquote(format(x, digits=3))
> [1] 17.0 18.1
> 

That works in the above context but I don't think it works generally:

R> f <- head(faithful)
R> f
  eruptions waiting
1 3.600  79
2 1.800  54
3 3.333  74
4 2.283  62
5 4.533  85
6 2.883  55

R> format(f, digits = 3)
  eruptions waiting
1  3.60  79
2  1.80  54
3  3.33  74
4  2.28  62
5  4.53  85
6  2.88  55

R> # this works in this case
R> noquote(prettyNum(round(f,1), nsmall = 1))
 eruptions waiting
[1,] 3.6   79.0   
[2,] 1.8   54.0   
[3,] 3.3   74.0   
[4,] 2.3   62.0   
[5,] 4.5   85.0   
[6,] 2.9   55.0   

and even that does not work in the desired way (which presumably
is not to use exponent format) if you have some
large enough numbers like 1e6 which it will display using
the e notation rather than using ordinary notation.

R> f[1,1] <- 1e6 + 0.11
R> noquote(prettyNum(round(f,1), nsmall = 1))
 eruptions waiting
[1,] 1.0e+06   79.0   
[2,] 1.8e+00   54.0   
[3,] 3.3e+00   74.0   
[4,] 2.3e+00   62.0   
[5,] 4.5e+00   85.0   
[6,] 2.9e+00   55.0   

I have struggled with this myself and have generally been able
to come up with something for specific instances but I have generally 
found it a pain to do a simple thing like format a table exactly as I want 
without undue effort.  Maybe someone else has figured this out.

__
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] problem in R2.2-dev

2005-05-30 Thread Duncan Murdoch
ronggui wrote:
> when i install the R2.2-dev(customed install,the with the chinese translation 
> msg ,etc.),i found the tanslated GUI can not display correctly.totally unlike 
> Chinese characters.

I don't think you've given nearly enough information for anyone to act
on this.  Please describe what OS you're on, what customizations you did
during installation, and give an example of something that should work
but doesn't.

Hopefully someone who uses a Chinese locale will be able to help you.

Duncan Murdoch

__
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] Formatting numbers with a limited amount of digits consistently

2005-05-30 Thread Duncan Murdoch

Henrik Andersson wrote:
I have tried to get signif, round and format to display numbers like 
these consistently in a table, using e.g. signif(x,digits=3)


17.01
18.15

I want

17.0
18.2

Not

17
18.2


Why is the last digit stripped off in the case when it is zero!


signif() changes the value; you don't want that, you want to affect how 
a number is displayed.  Use format() or formatC() instead, for example


> x <- c(17.01, 18.15)
> format(x, digits=3)
[1] "17.0" "18.1"
> noquote(format(x, digits=3))
[1] 17.0 18.1


Is this a "feature" of R or did I miss something?


I'd say both.

Duncan Murdoch

__
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] problem in R2.2-dev

2005-05-30 Thread ronggui
when i install the R2.2-dev(customed install,the with the chinese translation 
msg ,etc.),i found the tanslated GUI can not display correctly.totally unlike 
Chinese characters.

__
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 invert the matrix with quite small eigenvalues

2005-05-30 Thread Thomas Lumley

On Mon, 30 May 2005, huang min wrote:>

My intention is to invert the covariance matrix to perform some
algorithm which is common in the estimating equations like GEE.


In that case there is no benefit in being able to invert very extreme 
covariance matrices. The asymptotic approximations to the distribution of 
regression coefficients will break down really badly with such extreme 
working covariance matrices.


I think in a case like this you should either
1) report an error and stop
2) shrink the covariance matrix towards a diagonal one, eg increase the 
diagonal entries until the condition number becomes reasonable.
3) Use a one-step estimator from the independence working model (which is 
asymptotically equivalent to the full solution and better behaved).


Remember that in GEE the matrix V^{-1} is just a set of weights, chosen to 
get good efficiency.   Your matrix solve(a) is not a good set of weights.


I think in an earlier thread on this topic Brian Ripley recommended using 
the singular value decomposition if you really have to compute something 
like D^TV^{-1}D.  In your example this still isn't good enough.




Another strange point is that my friend use the LU decomposition in
Fortran to solve the inverse matrix of aa for me. He used double
precision of course, otherwise no inverse matrix in Fortran too. He
show that the product of the two matrix is almost identity(The biggest
off-digonal element is about 1e-8). I copy his inverse matrix(with 31
digits!) to R and read in aa I sent to him(16 digits). The product is
also not an identity matrix. It is fairly strange! Any suggestion?



It isn't that strange.  The system is computationally singular, meaning 
that you should expect to get different answers with apparently similar 
computations on different systems.


Also remember that what you care about for GEE is the result of 
solve(a,y-mu), rather than solve(a,a). Getting one of these right is no 
guarantee of getting the other one right.


If you really had to work with this matrix in double precision you would 
need to track very carefully the error bounds on all your computations, 
which would be very difficult.  Fortunately this is almost never necessary 
in statistics, and I don't think it's necessary in your case.


A good habit to get into when you aren't tracking error bounds carefully 
is to think of the last couple of digits of the result of any calculation 
as random.



-thomas

__
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 access to sum of dissimilarities in CLARA

2005-05-30 Thread TEMPL Matthias
Hello,

#Example:

data(xclara)
p <- clara(xclara,3)
names(p)
p$diss

Best,
Matthias

> Dear All ,
> Since dissimilarity is one of quality measures in clustering 
> , I'm trying to access to the sum of dissimilarity as a whole 
> measure. But after running my data using CLARA I obtain : 
> 1128 dissimilarities, summarized :
> Min.  1st Qu.   Median Mean  3rd Qu. Max. 
> 0.033155 0.934630 2.257000 2.941600 4.876600 8.943700 
> But I can not find the sum of dissimilarity.How can i access to it?
>  
> Thanks a lot
> Safari
> 
> __
> 
> 
> 
>   [[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-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] R GUI for Linux?

2005-05-30 Thread White, Charles E WRAIR-Wash DC
I feel your pain.  I am a new Linux user who has spent most of the 
weekend trying to get a functional R setup. When I installed Fedora Core 3 
(FC3) on my home computer, I thought using R in a terminal would be a snap. I 
installed R using the rpm packages and tried to use it with the FC3 default 
terminal (GNOME Terminal 2.7.3). Before long, I found out the terminal was 
rudely discarding output beyond a set number of lines. I could increase the 
number of lines kept by the terminal but that didn't strike me as an acceptable 
solution. Cutting to my stress relieving intermediate solution, I am currently 
using xemacs with ESS as my R programming environment under FC3. Eventually, I 
will want to run JGR as my programming environment and Rcmdr as both a teaching 
tool and means to distribute code to some of my clients. On my way to xemacs, I 
also tried to install emacs and gnomeGUI. I will briefly document my experience 
with trying to install each of these packages below:

XEMACS with ESS: XEMACS is within the 'walled garden' of packages tuned 
specifically to run under FC3 and XEMACS provides a tuned installation for ESS. 
Since I had already compiled R from source with shared libraries enabled (the 
rmp does not enable shared libraries), I don't know if XEMACS will work with 
the rpm version of R. Note also that I installed this package using yum; 'Add 
or Remove Applications' lists xemacs but wouldn't allow me to install.

JGR: I have installed jdk1.5.0_03 and MOST of the the output from make looks 
like JGR is compiling correctly. JavaGD and rJava are not finding jini.h. I 
don't see an explicit statement of how to start JGR but I assume that is done 
by typing JGR (or maybe jgr) in a terminal window. Nothing happens. Two 
potential problems are: (a) I never should have downloaded JavaGD and rJava 
from CRAN (they won't uninstall, deleting the directories doesn't stop the 
problem, and I can't use yum to remove R to start over because yum doesn't 
recognise that R is installed.) or (b) I need to uninstall some of the stray 
versions of java littering my hard drive. I haven't removed the symbolic link 
between jre1.5.0_02 and firefox.

Rcmdr: There are all sorts of things in FC3 that seem to be tcl/tk related but 
Rcmdr doesn't seem to work with them. Since some are part of the base FC3 
installation, I'm nervious about replacing them or installing competing 
software. Potentially conflicting software in FC3 are listed below:

tcl.i386 8.4.7-2installed
tclx.i3868.3.5-4installed
db4-tcl.i386 4.2.52-6   base
postgresql-tcl.i386  7.4.8-1.FC3.1  updates-released
ruby-tcltk.i386  1.8.2-1.FC3.1  updates-released
tcl-devel.i386   8.4.7-2base
tcl-html.i3868.4.7-2base
tclx-devel.i386  8.3.5-4base
tclx-doc.i3868.3.5-4base

EMACS with ESS: A version of EMACS is tuned to FC3 but ESS has to be obtained 
elsewhere. Installing ESS requires editing the hidden .emacs file. I know how 
to see hidden files but this one does not appear to be where the ESS directions 
say to look.

gnomeGUI: Error message says that I don't have Gnome installed. It would be 
nice and GNU to have a working copy of gnome GUI.

I hope you have found my message to be entertaining. If anybody can stop me 
before I do something else stupid, I'd appreciate it. Thanks.

Chuck

Charles E. White, Senior Biostatistician, MS
Walter Reed Army Institute of Research
503 Robert Grant Ave., Room 1w102
Silver Spring, MD 20910-1557
Personal/Professional Site: http://users.starpower.net/cwhite571/professional/

__
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] How to access to sum of dissimilarities in CLARA

2005-05-30 Thread Amir Safari
 
 
Dear All ,
Since dissimilarity is one of quality measures in clustering , I'm trying to 
access to the sum of dissimilarity as a whole measure. But after running my 
data using CLARA I obtain :
1128 dissimilarities, summarized :
Min.  1st Qu.   Median Mean  3rd Qu. Max. 
0.033155 0.934630 2.257000 2.941600 4.876600 8.943700 
But I can not find the sum of dissimilarity.How can i access to it?
 
Thanks a lot
Safari

__



[[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] Incompatibility with VGAM

2005-05-30 Thread Thomas Lumley

On Mon, 30 May 2005, Thomas Yee wrote:


Hello,


It seems that if glm used a namespace then the conflict would be avoided?



No.  glm does use a namespace, so this can't be true.  Remember that R 
passes arguments by value, and consider

  glm(y~x, family=poisson())

The namespace ensures that functions called from glm are looked up in the 
stats namespace, but family() not called from glm(). It is called by the 
user and the result is passed as an argument to glm().


The exception is when no family argument is supplied. In that case the 
default argument is created by a call to family() from inside glm(), which 
should always find stats::family


-thomas

__
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] a question about read.marrayRaw

2005-05-30 Thread shizhu zang

Hi, everyone,

I ran the test case in "Introduction to the Bioconductor

marrayInput package first. When I ran the session in (read.marrayRaw) I got the 
following error messages. Other sessions work well.

The functions and errors are labled with blue and red respectively.

>mraw <- read.Spot(path = datadir, layout = galinfo$layout, gnames = 
>galinfo$gnames, target = swirlTargets)

Error in file(con, "r") : unable to open connection

In addition: Warning message: 

cannot open file `C:/PROGRA~1/R/rw1091/library/marray/swirldata/81'

> fnames <- as.vector([EMAIL PROTECTED],1])

> swirl.raw <- read.marrayRaw(fnames, path = datadir,

+ name.Gf = "Gmean", name.Gb = "morphG",

+ name.Rf = "Rmean", name.Rb = "morphR",

+ layout = swirl.layout,

+ gnames = swirl.gnames,

+ targets = swirlTargets)

Error in file(con, "r") : unable to open connection

In addition: Warning message: 

cannot open file `C:/PROGRA~1/R/rw1091/library/marray/swirldata/81' 

> array1.raw <- read.Spot(fnames, path=datadir)

Error in file(con, "r") : unable to open connection

In addition: Warning messawell

cannot open file `C:/PROGRA~1/R/rw1091/library/marray/swirldata/81'

I copy and paste the whole set of examples. 

Is it possible something is not right with the spot files?

I really need your help to solve this problem.

Thank you very much!!

Best regards

Zang Shizhu 

 

 

 




-

×¢²áÊÀ½çÒ»Á÷Æ·ÖʵÄÑÅ»¢Ãâ·ÑµçÓÊ
[[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] rbind wastes memory

2005-05-30 Thread Roger D. Peng
Rather than 'rbind' in a loop, try putting your dataframes in a list and 
then doing something like 'do.call("rbind", list.of.data.frames")'.


-roger

[EMAIL PROTECTED] wrote:

Hello everybody,

if I try to (r)bind a number of large dataframes I run out of memory because R
wastes memory and seems to "forget" to release memory. 

For example I have 10 files. Each file contains a large dataframe "ds" (3500 cols 
by 800 rows) which needs ~20 MB RAM if it is loaded as the only object.

Now I try to bind all data frames to a large one and need more than 1165MB (!)
RAM (To simplify the R code, I use the same file ten times):

 start example 1 __
load(myFile)
ds.tmp  <- ds
for (Cycle in 1:10) {
ds.tmp  <- rbind(ds.tmp, ds)
}
 end example 1 __



Stepping into details I found the following (comment shows RAM usage after this line 
was executed):

load(myFile)# 40MB (19MB for R itself)
ds.tmp  <- ds# 40MB; => only a pointer seems to be 
copied
x<-rbind(ds.tmp, ds) # 198MB
x<-rbind(ds.tmp, ds)		# 233MB; the same instruction a second time leads to  
# 35MB more RAM usage - why?



Now I played around, but I couldn't find a solution. For example I bound each dataframe 
step by step and removed the variables and cleared memory, but I still need 1140MB(!) 
RAM:


 start example 2 __
tmpFile<- paste(myFile,'.tmp',sep="")
load(myFile)
ds.tmp   <- ds
save(ds.tmp, file=tmpFile, compress=T)

for (Cycle in 1:10) {
ds  <- NULL
ds.tmp <- NULL
rm(ds, ds.tmp)
gc()
load(tmpFile)
load(myFile)
ds.tmp  <- rbind(ds.tmp, ds)
save(ds.tmp,file=tmpFile, compress=T)
cat(Cycle,': ',object.size(ds),object.size(ds.tmp),'\n')
}
 end example 1 __


platform i386-pc-solaris2.8
arch i386  
os   solaris2.8
system   i386, solaris2.8  
status 
major1 
minor9.1   
year 2004  
month06
day  21
language R   





How can I avoid to run in that memory problem? Any ideas are very appreciated. 
Thank you in advance & kind regards,




Lutz Thieme
AMD Saxony/ Product Engineering AMD Saxony Limited Liability Company & Co. KG
phone:  + 49-351-277-4269   M/S E22-PE, Wilschdorfer Landstr. 101
fax:+ 49-351-277-9-4269 D-01109 Dresden, Germany

__
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



--
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

__
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 "singlify" entries

2005-05-30 Thread Charles Plessy
On Mon, May 30, 2005 at 09:09:27AM -0400, Gabor Grothendieck wrote :

> Try using reshape, e.g. if dd is your data frame:
> 
> reshape(dd, dir = "wide", idvar = "F1", timevar = "F2", 
> varying = list(c("VX","VY")))


Thank you very much, and to Petr Pikal too. Reshape is exactly what I had 
forgotten.

Now the bad news is that I have simplified my example ; I am in a
slightly more complex situation :

I have three factors, and one value

> count_per_tc[1:10,]
   rna   lib   tc x
1  CAB 114BA T01F00380F47 1
2  CAE 114BB T01F00381273 1
3  CAJ 114BA T01F0048F6D1 1
4  CAB 114BC T01F0048F6D1 1
5  CAB 114BA T01F00498689 2
6  CAC 114BA T01F00498689 1
7  CAE 114BA T01F00498689 2
8  CAG 114BA T01F00498689 2
9  CAH 114BA T01F00498689 1
10 CAI 114BA T01F00498689 2

I would like a data frame where I have the value of x for each combination of
"rna" and "lib", for each "tc"

> reshape(count_per_tc[1:10,], direction="wide", timevar="tc", 
> idvar=c("rna","lib"))
   rna   lib x.T01F00380F47 x.T01F00381273 x.T01F0048F6D1 x.T01F00498689
1  CAB 114BA  1 NA NA  2
2  CAE 114BB NA  1 NA NA
3  CAJ 114BA NA NA  1 NA
4  CAB 114BC NA NA  1 NA
6  CAC 114BA NA NA NA  1
7  CAE 114BA NA NA NA  2
8  CAG 114BA NA NA NA  2
9  CAH 114BA NA NA NA  1
10 CAI 114BA NA NA NA  2

oops, the other way round :

> t(reshape(count_per_tc[1:10,], direction="wide", timevar="tc", 
> idvar=c("rna","lib")))
   1   2   3   4   6   7   8   9   
10 
rna"CAB"   "CAE"   "CAJ"   "CAB"   "CAC"   "CAE"   "CAG"   "CAH"   
"CAI"  
lib"114BA" "114BB" "114BA" "114BC" "114BA" "114BA" "114BA" "114BA" 
"114BA"
x.T01F00380F47 " 1"NA  NA  NA  NA  NA  NA  NA  
NA 
x.T01F00381273 NA  " 1"NA  NA  NA  NA  NA  NA  
NA 
x.T01F0048F6D1 NA  NA  " 1"" 1"NA  NA  NA  NA  
NA 
x.T01F00498689 " 2"NA  NA  NA  " 1"" 2"" 2"" 1"
" 2"   

The ultimate goal is (after proper renaming of the columns) to do things like

plot(CAA-114BA[CAA-114BA >0 & CAA-114BB > 0], CAA-114BB[CAA-114BA >0 & 
CAA-114BB > 0])

(this combination will appear if I reshape the whole data frame, which has 
200,000 rows.)

and then proper statistical tests (which I still have to learn / remember from
12 years ago).

once again, thank you, and please warn me if I am doing something stupid with
this transposition of the reshaped table.

Best regards,

-- 
Charles

__
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] Formatting numbers with a limited amount of digits consistently

2005-05-30 Thread Henrik Andersson
I have tried to get signif, round and format to display numbers like 
these consistently in a table, using e.g. signif(x,digits=3)


17.01
18.15

I want

17.0
18.2

Not

17
18.2


Why is the last digit stripped off in the case when it is zero!

Is this a "feature" of R or did I miss something?



-
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577473
[EMAIL PROTECTED]
http://www.nioo.knaw.nl/ppages/handersson

__
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] Reference Card?

2005-05-30 Thread TEMPL Matthias
> Hello!
> 
> For LaTeX I found a reference Card at 
> http://www.cs.ualberta.ca/~c603/LaTeX_docs/Symbol_Source/latex
> _symbols.pdf
> 
> Is there something available for R?

Hello Martin,

See the reference cards on
http://cran.r-project.org/other-docs.html

Best,
Matthias

> 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


Re: [R] Reference Card?

2005-05-30 Thread Kevin Wang

Hi,

Have you tried looking under Documentation -> Contributed, under CRAN?

Kev

Martin Klaffenboeck wrote:

Hello!

For LaTeX I found a reference Card at
http://www.cs.ualberta.ca/~c603/LaTeX_docs/Symbol_Source/latex_symbols.pdf

Is there something available for R?

thanks,
Martin

__
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



--
Ko-Kang Kevin Wang
PhD Student
Centre for Mathematics and its Applications
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 0200
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7407
Ph (M): +61-40-451-8301

__
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] Reference Card?

2005-05-30 Thread Martin Klaffenboeck
Hello!

For LaTeX I found a reference Card at
http://www.cs.ualberta.ca/~c603/LaTeX_docs/Symbol_Source/latex_symbols.pdf

Is there something available for R?

thanks,
Martin

__
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] Egarch

2005-05-30 Thread Friedrich, Andreas (dit)
Hallo,

I got to implement parameter estimation for Egarch(p,q) processes.
My question: has anyone done that so far or are there implementations for
other asymmetric garch models?

Andreas

[[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] rbind wastes memory

2005-05-30 Thread Duncan Murdoch

[EMAIL PROTECTED] wrote:

Hello everybody,

if I try to (r)bind a number of large dataframes I run out of memory because R
wastes memory and seems to "forget" to release memory. 

For example I have 10 files. Each file contains a large dataframe "ds" (3500 cols 
by 800 rows) which needs ~20 MB RAM if it is loaded as the only object.

Now I try to bind all data frames to a large one and need more than 1165MB (!)
RAM (To simplify the R code, I use the same file ten times):

 start example 1 __
load(myFile)
ds.tmp  <- ds
for (Cycle in 1:10) {
ds.tmp  <- rbind(ds.tmp, ds)
}
 end example 1 __



Stepping into details I found the following (comment shows RAM usage after this line 
was executed):

load(myFile)# 40MB (19MB for R itself)
ds.tmp  <- ds# 40MB; => only a pointer seems to be 
copied
x<-rbind(ds.tmp, ds) # 198MB
x<-rbind(ds.tmp, ds)		# 233MB; the same instruction a second time leads to  
# 35MB more RAM usage - why?


I'm guessing your problem is fragmented memory.  You are creating big 
objects, then making them bigger.  This means R needs to go looking for 
large allocations for the replacements, but they won't fit in the spots 
left by the things you've deleted, so those are being left empty.


A solution to this is to use two passes:  first figure out how much 
space you need, then allocate it and fill it.  E.g.


for (Cycle in 1:10) {
rows[Cycle] <-  some calculation based on the data ...
}

ds.tmp <- data.frame(x=double(sum(rows)), y=double(sum(rows)), ...

for (Cycle in 1:10) {
ds.tmp[ appropriate rows, ] <- new data
}


Duncan Murdoch

__
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] rbind wastes memory

2005-05-30 Thread Douglas Bates
[EMAIL PROTECTED] wrote:
> Hello everybody,
> 
> if I try to (r)bind a number of large dataframes I run out of memory because R
> wastes memory and seems to "forget" to release memory. 
> 
> For example I have 10 files. Each file contains a large dataframe "ds" (3500 
> cols 
> by 800 rows) which needs ~20 MB RAM if it is loaded as the only object.
> Now I try to bind all data frames to a large one and need more than 1165MB (!)
> RAM (To simplify the R code, I use the same file ten times):
> 
>  start example 1 __
> load(myFile)  
> ds.tmp<- ds   
> for (Cycle in 1:10) {
>   ds.tmp  <- rbind(ds.tmp, ds)
> }
>  end example 1 __
> 
> 
> 
> Stepping into details I found the following (comment shows RAM usage after 
> this line 
> was executed):
> load(myFile)  # 40MB (19MB for R itself)
> ds.tmp<- ds   # 40MB; => only a pointer seems to be 
> copied
> x<-rbind(ds.tmp, ds)  # 198MB
> x<-rbind(ds.tmp, ds)  # 233MB; the same instruction a second time 
> leads to  
>   # 35MB more RAM usage - why?
> 
> 
> Now I played around, but I couldn't find a solution. For example I bound each 
> dataframe 
> step by step and removed the variables and cleared memory, but I still need 
> 1140MB(!) 
> RAM:
> 
>  start example 2 __
> tmpFile<- paste(myFile,'.tmp',sep="")
> load(myFile)
> ds.tmp <- ds
> save(ds.tmp, file=tmpFile, compress=T)
> 
> for (Cycle in 1:10) {
>   ds  <- NULL
>   ds.tmp <- NULL
>   rm(ds, ds.tmp)
>   gc()
>   load(tmpFile)
>   load(myFile)
>   ds.tmp  <- rbind(ds.tmp, ds)
>   save(ds.tmp,file=tmpFile, compress=T)
>   cat(Cycle,': ',object.size(ds),object.size(ds.tmp),'\n')
> }
>  end example 1 __
> 
> 
> platform i386-pc-solaris2.8
> arch i386  
> os   solaris2.8
> system   i386, solaris2.8  
> status 
> major1 
> minor9.1   
> year 2004  
> month06
> day  21
> language R   
> 
> 
> 
> 
> How can I avoid to run in that memory problem? Any ideas are very 
> appreciated. 
> Thank you in advance & kind regards,

If you are going to look at the memory usage you should use gc(), and
perhaps repeated calls to gc(), before checking the memory footprint.
This will force a garbage collection.

Also, you will probably save memory by treating your data frames as
lists and concatenating them, then converting the result to a data frame.

__
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] rbind wastes memory

2005-05-30 Thread lutz . thieme
Hello everybody,

if I try to (r)bind a number of large dataframes I run out of memory because R
wastes memory and seems to "forget" to release memory. 

For example I have 10 files. Each file contains a large dataframe "ds" (3500 
cols 
by 800 rows) which needs ~20 MB RAM if it is loaded as the only object.
Now I try to bind all data frames to a large one and need more than 1165MB (!)
RAM (To simplify the R code, I use the same file ten times):

 start example 1 __
load(myFile)
ds.tmp  <- ds   
for (Cycle in 1:10) {
ds.tmp  <- rbind(ds.tmp, ds)
}
 end example 1 __



Stepping into details I found the following (comment shows RAM usage after this 
line 
was executed):
load(myFile)# 40MB (19MB for R itself)
ds.tmp  <- ds   # 40MB; => only a pointer seems to be copied
x<-rbind(ds.tmp, ds)# 198MB
x<-rbind(ds.tmp, ds)# 233MB; the same instruction a second time 
leads to  
# 35MB more RAM usage - why?


Now I played around, but I couldn't find a solution. For example I bound each 
dataframe 
step by step and removed the variables and cleared memory, but I still need 
1140MB(!) 
RAM:

 start example 2 __
tmpFile<- paste(myFile,'.tmp',sep="")
load(myFile)
ds.tmp   <- ds
save(ds.tmp, file=tmpFile, compress=T)

for (Cycle in 1:10) {
ds  <- NULL
ds.tmp <- NULL
rm(ds, ds.tmp)
gc()
load(tmpFile)
load(myFile)
ds.tmp  <- rbind(ds.tmp, ds)
save(ds.tmp,file=tmpFile, compress=T)
cat(Cycle,': ',object.size(ds),object.size(ds.tmp),'\n')
}
 end example 1 __


platform i386-pc-solaris2.8
arch i386  
os   solaris2.8
system   i386, solaris2.8  
status 
major1 
minor9.1   
year 2004  
month06
day  21
language R   




How can I avoid to run in that memory problem? Any ideas are very appreciated. 
Thank you in advance & kind regards,



Lutz Thieme
AMD Saxony/ Product Engineering AMD Saxony Limited Liability Company & Co. KG
phone:  + 49-351-277-4269   M/S E22-PE, Wilschdorfer Landstr. 101
fax:+ 49-351-277-9-4269 D-01109 Dresden, Germany

__
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] values of bars in barplot

2005-05-30 Thread Petr Pikal


On 30 May 2005 at 15:19, luc tardieu wrote:

> Hi, 
> 
> I couldn't find how to have the values written on the
> top of each bar in a barplot. When using hist(), it is
> possible to use labels=T, but this option does not
> seem to exist for barplot().

Hallo

>From help page

Value:

 A numeric vector (or matrix, when 'beside = TRUE'), say 'mp',
 giving the coordinates of _all_ the bar midpoints drawn, useful
 for adding to the graph.


e.g.

> dat<-trunc(runif(5)*10)
> dat
[1] 5 7 1 9 5
> bpl<-barplot(dat, ylim=c(0,10))
> text(bpl,dat+.2, dat)

HTH
Petr


> 
> Is there a trick I could use to do that ?
> 
> Thanks to all
> 
> Luc
> 
> __
> 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

Petr Pikal
[EMAIL PROTECTED]

__
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] values of bars in barplot

2005-05-30 Thread joerg van den hoff

luc tardieu wrote:
Hi, 


I couldn't find how to have the values written on the
top of each bar in a barplot. When using hist(), it is
possible to use labels=T, but this option does not
seem to exist for barplot().

Is there a trick I could use to do that ?

Thanks to all

Luc

__
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



something like:


x <- 1:3
#ensure some free space above the bar and remember midpoints:
bmp <- barplot(x, ylim = c(0, 1.1*max(x)))

text(bmp, x + .03*max(x), x)


should do.

__
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] values of bars in barplot

2005-05-30 Thread Gabor Grothendieck
On 5/30/05, luc tardieu <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I couldn't find how to have the values written on the
> top of each bar in a barplot. When using hist(), it is
> possible to use labels=T, but this option does not
> seem to exist for barplot().
> 
> Is there a trick I could use to do that ?
> 
> Thanks to all
> 

Here is an example you can modify:

x <- c(44,56,34,35,44,51,55)
nams <- LETTERS[1:7]
bp <- barplot(x,horiz=T,col="light blue",xlim=c(0,60))
text(30,-1.25,xpd=NA,"Networks",cex=1.5) # x title
text(-6,4,xpd=NA,"Research Areas",cex=1.5,srt=90)  # y title
text(x,bp,x,pos=4) # place numbers to right of bars
text(0,bp,nams,cex=1.2,pos=4)  # label bars right on the bars themselves

__
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 "singlify" entries

2005-05-30 Thread Petr Pikal


On 30 May 2005 at 21:56, Charles Plessy wrote:

> On Mon, May 30, 2005 at 09:15:32AM +, zhihua li wrote :
> > hi netters
> > 
> > I have a rather simple question.  I have a data frame with two
> > variables X and Y, both of which are factors. X has 100 levels while
> > Y has 10 levels only. The data frame has 100 rows in all, so for X
> > the values are unique, and Y has many replicate values.  Now I wanna
> > reduce the data frame into 10 rows only, according to the 10 levels
> > of Y.  I don't care which value of X is in the same row with Y in
> > the final data frame, as long as it is in agreement with the
> > original data frame.
> 
> Dear list,
> 
> I am a new subscriber, using R to analyse genomics data. I have a
> similar question, maybe even identical, but I am not sure...

Hallo

Me neither.

?reshape

> dat<-read.table("clipboard", header=T)
> dat
  F1 F2 V
1  A  X 3
2  A  Y 6
3  B  X 5
4  C  X 9
5  C  Y 3
> reshape(dat, idvar="F1", timevar="F2",direction="wide")
  F1 V.X V.Y
1  A   3   6
3  B   5  NA
4  C   9   3


Homework: change NA to zero.

HTH
Petr

> 
> >From a data frame with two factors and one value, I would like to
> >obtain a data
> frame with one factor and one value per level in the removed factor.
> 
> For instance:
> 
> F1  F2  V
> -
> A   X   3
> A   Y   6
> B   X   5
> C   X   9
> C   Y   3
> 
> Would become:
> 
> F1  VX  VY
> --
> A   3   6
> B   5   0
> C   9   3
> 
> I am sure I have seen a tool to do this some time ago, but I do not
> remember its name.
> 
> Can somebody help me ?
> 
> Best regards,
> 
> -- 
> Charles Plessy, Ph.D. - Genome Science Laboratory
> The Institute for Physical and Chemical Research (RIKEN)
> 2-1 Hirosawa, Wako, Saitama 351-0198, Japan
> [EMAIL PROTECTED] --  Fax: 048-462-4686  --  Tel: 048-467-9515
> 
> __
> 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

Petr Pikal
[EMAIL PROTECTED]

__
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] values of bars in barplot

2005-05-30 Thread luc tardieu
Hi, 

I couldn't find how to have the values written on the
top of each bar in a barplot. When using hist(), it is
possible to use labels=T, but this option does not
seem to exist for barplot().

Is there a trick I could use to do that ?

Thanks to all

Luc

__
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 "singlify" entries

2005-05-30 Thread Gabor Grothendieck
On 5/30/05, Charles Plessy <[EMAIL PROTECTED]> wrote:
> On Mon, May 30, 2005 at 09:15:32AM +, zhihua li wrote :
> > hi netters
> >
> > I have a rather simple question.  I have a data frame with two variables X
> > and Y, both of which are factors. X has 100 levels while Y has 10 levels
> > only. The data frame has 100 rows in all, so for X the values are unique,
> > and Y has many replicate values.  Now I wanna reduce the data frame into 10
> > rows only, according to the 10 levels of Y.  I don't care which value of X
> > is in the same row with Y in the final data frame, as long as it is in
> > agreement with the original data frame.
> 
> Dear list,
> 
> I am a new subscriber, using R to analyse genomics data. I have a
> similar question, maybe even identical, but I am not sure...
> 
> >From a data frame with two factors and one value, I would like to obtain a 
> >data
> frame with one factor and one value per level in the removed factor.
> 
> For instance:
> 
> F1  F2  V
> -
> A   X   3
> A   Y   6
> B   X   5
> C   X   9
> C   Y   3
> 
> Would become:
> 
> F1  VX  VY
> --
> A   3   6
> B   5   0
> C   9   3
> 
> I am sure I have seen a tool to do this some time ago, but I do not remember
> its name.
> 
Try using reshape, e.g. if dd is your data frame:

reshape(dd, dir = "wide", idvar = "F1", timevar = "F2", 
varying = list(c("VX","VY")))

__
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] You can appreciate the reduced prices on rxdrugs and check our weekly specials.

2005-05-30 Thread michale baillet
Check our cybershop and you will uncover how others cut their expenses on
rxmeds significantly. 
 
Check our cybershop for quality rxdrugs on male tissue dysfunction, pain,
affliction, relaxants for muscles, man's care, over-wt. and other
discomforts. Our company provides customers quick and reliable distribution
services.

You can appreciate the reduced prices on rxdrugs and check our weekly
specials.

http://xyne.4.sinkinpleasure.com/s6/

Have your case profile checked by licensed experts in a timely manner.


-original message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 6, 2005 4:02PM
To: Reginald; [EMAIL PROTECTED]; ; Roscoe; Dannie
Subject: The company provides complimentary case profile check. Our
customers choose us for this simple convenience.

I was not aware how much eshopping could reduce my expenses. Placing the
or-der at your cybershop is a right decision for me. I just got the tableets
the other day. The rxdrugs are as effective as the ones bought from the
local stores. Thank you for your great items. -- Cindy W. in OH


slowly se, Persian, The Biblic books  evel that lift to pass and 
cont and
u are diseas'd,  inue beyond.  You are also asking me questions and I hear
you,  inquiringly,
or rheumatic, or a pros began
and prophets, and deep idyls of the Nazarene, The 1 on the 46  Iliad,
Odyssey, plots, do other side,

__
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 "singlify" entries

2005-05-30 Thread Charles Plessy
On Mon, May 30, 2005 at 09:15:32AM +, zhihua li wrote :
> hi netters
> 
> I have a rather simple question.  I have a data frame with two variables X 
> and Y, both of which are factors. X has 100 levels while Y has 10 levels 
> only. The data frame has 100 rows in all, so for X the values are unique, 
> and Y has many replicate values.  Now I wanna reduce the data frame into 10 
> rows only, according to the 10 levels of Y.  I don't care which value of X 
> is in the same row with Y in the final data frame, as long as it is in 
> agreement with the original data frame.

Dear list,

I am a new subscriber, using R to analyse genomics data. I have a
similar question, maybe even identical, but I am not sure...

>From a data frame with two factors and one value, I would like to obtain a data
frame with one factor and one value per level in the removed factor.

For instance:

F1  F2  V
-
A   X   3
A   Y   6
B   X   5
C   X   9
C   Y   3

Would become:

F1  VX  VY
--
A   3   6
B   5   0
C   9   3

I am sure I have seen a tool to do this some time ago, but I do not remember
its name.

Can somebody help me ?

Best regards,

-- 
Charles Plessy, Ph.D. - Genome Science Laboratory
The Institute for Physical and Chemical Research (RIKEN)
2-1 Hirosawa, Wako, Saitama 351-0198, Japan
[EMAIL PROTECTED] --  Fax: 048-462-4686  --  Tel: 048-467-9515

__
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] Re: Vector Manipulation

2005-05-30 Thread Gabor Grothendieck
x[cumsum(x!=0)!=0]

or 

x[!!cumsum(!!x)]

will also do it.

On 5/30/05, ManojW <[EMAIL PROTECTED]> wrote:
> OK...x[min(which(x!=0)):length(x)] does the trick!
> 
> I guess the coffee is slowly but surely working! .
> 
> Manoj
>  - Original Message -
>  From: ManojW
>  To: R-help
>  Sent: Monday, May 30, 2005 2:12 PM
>  Subject: Re: Vector Manipulation
> 
> 
>  I should clarify that I tried x[cumsum(x)!=0] but the problem is that I 
> might have negative numbers in the vector that can potentially make cumsum(x) 
> equal to zero somewhere down the line in the vector.
> 
>  Manoj
>- Original Message -
>From: ManojW
>To: R-help
>Sent: Monday, May 30, 2005 2:00 PM
>Subject: Vector Manipulation
> 
> 
>Dear All,
>For any given vector, I want to extract a sub-vector such that the new 
> vector skips all zeros, if any , at the start of vector. Is it possible to 
> achieve this w/o looping?
> 
>E.G : >x= c(0,0,1,2,3,4,5,0,0,8,9)
> >y= somefunc(x);
>> y
>[1]1 2 3 4 5 0 0 8 9
> 
>In the example above, I want to skip the two leading zeroes till I hit 
> the non-zero (1 in the above case). I also want to retain all zero after the 
> first non-zero digit (again 1 in this case).
> 
>Hope I am not confusing you guys. Thanks in advance for your help.
> 
>Regards
> 
>Manoj
> 
> 
> 
> 
>[[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-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] sapply following using by with a list of factors

2005-05-30 Thread Frank E Harrell Jr

McClatchie, Sam (PIRSA-SARDI) wrote:

Background:
OS: Linux Mandrake 10.1
release: R 2.0.0
editor: GNU Emacs 21.3.2
front-end: ESS 5.2.3
-
Colleagues

I am having some trouble extracting results from the function by, used to
average variables in a data.frame first by one factor (depth) and then by a
second factor (station). The real data.frame is quite large 


dim(data.2001)


[1] 32049  11

Here is a snippet of code:

## bin density data for each station into 1 m depth bins, containing means
data.2001.test$integer.Depth <- as.factor(round(data.2001.test$Depth,
digits=0))
attach(data.2001.test)
binned.data.2001 <- by(data.2001.test[,5:11], list(depth=integer.Depth,
station=Station), mean)

and here is a snippet of the data.frame



dim(data.2001.test)


[1] 150  11


dump("data.2001.test", file=stdout())


data.2001.test <-
structure(list(Cruise = structure(as.integer(c(1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), .Label =
"Ngerin01", class = "factor"), 
Station = structure(as.integer(c(2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 4, 4, 4, 4, 5, 5)), .Label = c("a1", "a2", "a3", 
"a4", "a5", "a6", "a7", "a8", "a9", "b1", "b2", "b3", "b4", 
"b5", "b6", "b7", "c1", "c2", "c3", "c4", "c5", "c6", "c7", 
"d1", "d2", "d3", "d4", "d5", "d6", "e1", "e2", "e3", "e4", 
"e5", "e6", "e7", "f1", "f2", "f3", "f4", "f5", "f6", "f7", 
"f8", "f9", "g1", "g10", "g11", "g2", "g3", "g4", "g5", "g6", 
"g7", "g8", "g9", "gsvc1", "gsvc2", "gsvc3", "gsvc4", "gsvc5", 
"gsvc6", "gsvc7", "gsvc8", "gsvc9", "gsvd1", "gsvd2", "gsvd3", 
"gsvd4", "gsvd5", "gsvd6", "gsvd7", "gsvd8", "h1", "h11", 
"h2", "h3", "h4", "h5", "h6", "h7", "h8", "h9", "i1", "i10", 
"i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "j1", "j10", 
"j2", "j3", "j4", "j5", "j6", "j7", "j8", "j9", "k1", "k10", 
"k2", "k3", "k4", "k5", "k6", "k7", "k8", "k9", "l1", "l10", 
"l11", "l12", "l2", "l3", "l4", "l5", "l6", "l7", "l8", "l9", 
"m1", "m10", "m11", "m2", "m3", "m4", "m5", "m6", "m7", "m8", 
"m9", "mx", "n1", "n10", "n11", "n2", "n3", "n4", "n5", "n6", 
"n7", "n8", "n9", "nx", "o1", "o10", "o11", "o13", "o2", 
"o3", "o4", "o5", "o6", "o7", "o8", "o9", "ox", "p10", "p11", 
"p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9", "px", "q1", 
"q10", "q11", "q12", "q13", "q2", "q3", "q4", "q5", "q6", 
"q7", "q8", "q9", "qx", "r1", "r10", "r11", "r12", "r13", 
"r14", "r15", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", 
"rx", "s1", "s10", "s11", "s12", "s13", "s14", "s15", "s16", 
"s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "sgc1", "sgc2", 
"sgc3", "sgc4", "sgc5", "sgc6", "sgc7", "sx", "t1", "t10", 
"t11", "t12", "t13", "t14", "t15", "t16", "t2", "t3", "t4", 
"t5", "t6", "t7", "t8", "t9", "tx", "u1", "u10", "u11", "u12", 
"u13", "u14", "u15", "u2", "u3", "u4", "u5", "u6", "u7", 
"u8", "u9", "ux", "v1", "v10", "v11", "v2", "v3", "v4", "v5", 
"v6", "v7", "v8", "v9", "vx", "w2", "w3", "w4", "w5", "w6", 
"w7", "w8", "w9", "wx", "x2", "x3", "x4", "x5", "x6", "x7", 
"x8"), class = "factor"), Lon = c(138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 13

Re: [R] how to invert the matrix with quite small eigenvalues

2005-05-30 Thread Ted Harding
On 30-May-05 huang min wrote:
> Maybe I should state more clear that I define b to get the
> orthogonal matrix bb$vectors.

OK. Certainly bbv<-bb$vectors is close to orthogonal: bbv%*%bbv
differs from the unit matrix only in that the off-diagonal
terms are O(10^(-16)).

> We also can define diag(b)<-diag(b)+100, which will make the
> eigenvalues of b much bigger to make sure the orthogonal matrix is
> reliable.
> 
> My intention is to invert the covariance matrix to perform some
> algorithm which is common in the estimating equations like GEE.

Which comes back to my general question: why do you need to ensure
that you get correct results for matrices like these? This matrix
is very nearly singular, and in many contexts you would interpret
it as exactly singular (e.g. if I got such a matrix as the
empirical covariance matrix from a sample, or by computation from
the structure of a model such as a design matrix, I would not
normally want to preserve this very small margin of non-singularity:
I would replace it with the lower-dimensional singular version,
e.g. by decomposing it with eigen() or svd() and reconstructing
the singular version after setting very small eigenvalues to 0).

But then of course there would be no inverse, which might be
required by the further computational expressions you want to
evaluate. However, in that case (depending on your application),
you may be able to proceed satisfactorily by using ginv() (see
package MASS) instead of solve(). But if you take that route,
then you have to bear in mind that a generalised inverse is
not a true inverse (if only because the latter does not exist):
the only property required for G=ginv(M) is that

  M%*%G%*%M = M

If such a matrix G will work for the rest of your calculations,
then you are OK, in particular if what you need is a possible
solution to an under-determined system of linear equations.
If not, then you should seriously consider whether your
computational strategy is suitable for the problem you have
in hand.

> [...]
> Another strange point is that my friend use the LU decomposition
> in Fortran to solve the inverse matrix of aa for me. He used
> double precision of course, otherwise no inverse matrix in
> Fortran too. He show that the product of the two matrix is
> almost identity (The biggest off-digonal element is about 1e-8).
> I copy his inverse matrix(with 31 digits!) to R and read in aa
> I sent to him(16 digits). The product is also not an identity
> matrix. It is fairly strange! Any suggestion?

These phenomena are yet another instance of the fact that at the
margins of computability the results will be anomalouus. Your
friend is simply using a narrower margin, but it is still not
exact! Not strange at all.

Best wishes,
Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 30-May-05   Time: 11:41:28
-- XFMail --

__
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] joining files after canonical correlation

2005-05-30 Thread Duncan Murdoch

Brett Stansfield wrote:

Dear R,
I recently did a canonical correlation analysis on two subsets of data
(location and weather). So I now have canonical scores for location and
weather. but I'd now like to do a scatterplot matrix using the pairs
statement. 


Is there a way to somehow join location.U and weather.V to become a new data
set from which I could undertake a scatterplot matrix of the canonical
variates?


cbind() can create a matrix by binding together the columns of two (or 
more) input matrices.


Duncan Murdoch

__
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] Chars as numbers

2005-05-30 Thread Martin Maechler
Package 'sfsmisc'
has a function  AsciiToInt() and a few useful related "R-code"
only functions such as chars8bit();  see the help pages once
you've installed and attached the package.

But do note that these things do depend on the encoding, as Uwe
Ligges has already told you.
Things work fine for pure  ASCII {independently of encoding}
but already differ for Umlauts / Accents
between iso-latin-1 or Unicode.

Martin Maechler, ETH Zurich

__
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 "singlify" entries

2005-05-30 Thread Petr Pikal
Hallo

On 30 May 2005 at 9:15, zhihua li wrote:

> hi netters
> 
> I have a rather simple question.  I have a data frame with two

Well, I do not understand you simple question fully. You have 
something like that

dat<-data.frame(X=1:100, Y=sample(1:10,10))
dat$X<-factor(dat$X)
dat$Y<-factor(dat$Y)
dat$Y[5]<-10

> variables X and Y, both of which are factors. X has 100 levels while Y
> has 10 levels only. The data frame has 100 rows in all, so for X the
> values are unique, and Y has many replicate values.  Now I wanna
> reduce the data frame into 10 rows only, according to the 10 levels of
> Y.  I don't care which value of X is in the same row with Y in the
> final data frame, as long as it is in agreement with the original data
> frame.

Do you want to choose only some rows from your data frame to 
get unique Y and any corresponding X?

dat[!duplicated(dat$Y),]

Or do you want something different?

HTH
Petr

> 
> I think this task can be carried out with some function like
> aggregate. but I failed in figuring it out. Could anybody give me a
> hint?
> 
> Thanks a lot!
> 
> __
> 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

Petr Pikal
[EMAIL PROTECTED]

__
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 invert the matrix with quite small eigenvalues

2005-05-30 Thread huang min
Maybe I should state more clear that I define b  to get the orthogonal
matrix bb$vectors.

We also can define diag(b)<-diag(b)+100, which will make the
eigenvalues of b much bigger to make sure the orthogonal matrix is
reliable.

My intention is to invert the covariance matrix to perform some
algorithm which is common in the estimating equations like GEE.

I meet difficulty to invert the covariance matrix. Two possibilities here:

1. The rounding error in defining the covariance matrix make the
eigenvalue to small.

2. The solve function in R can not cope with the matrix with so small
an eigenvalue.

For the first possibility, I think it can not be improved unless we
can  define more precise number than the double precision. So I ask
for the possiblity of coping with the second.

I can not find the default way to invert the matrix with solve().

For the symmetric matrix, I wonder if there are some algorithm which
can naturally make the inverse matrix symmetric and make sure it is
the inverse in the sense that the product is an identity matrix. I
know there are many decompositions which can be used to find the
inverse of a matrix. QR, SVD, Chol, and maybe some iterative method. I
wonder anyone can suggest me which algorithm might be good.

Another strange point is that my friend use the LU decomposition in
Fortran to solve the inverse matrix of aa for me. He used double
precision of course, otherwise no inverse matrix in Fortran too. He
show that the product of the two matrix is almost identity(The biggest
off-digonal element is about 1e-8). I copy his inverse matrix(with 31
digits!) to R and read in aa I sent to him(16 digits). The product is
also not an identity matrix. It is fairly strange! Any suggestion?

Regards,

Huang


On 5/30/05, Ted Harding <[EMAIL PROTECTED]> wrote:
> On 30-May-05 huang min wrote:
> > Dear all,
> >
> > I encounter some covariance matrix with quite small eigenvalues
> > (around 1e-18), which are smaller than the machine precision. The
> > dimension of my matrix is 17. Here I just fake some small matrix for
> > illustration.
> >
> >  a<-diag(c(rep(3,4),1e-18)) # a matrix with small eigenvalues
> >  b<-matrix(1:25,ncol=5) # define b to get an orthogonal matrix
> >  b<-b+t(b)
> 
> NB: b is not *orthogonal*! Each row of b is equal to the preceding
> row plus (row2 - row1) (and similar for the columns), and b has
> rank 2 (though eigen(b) taken literally says that it has 5 non-zero
> eugenvalues; however, 3 of these are snaller that 10^(-14)).
> 
> Perhaps you meant "define b to get a symmetric matrix".
> 
> >  bb<-eigen(b,symmetric=T)
> >  aah<-bb$vectors%*%diag(1/sqrt(diag(a)))
> >  aa<-aah%*%t(aah) # aa should have the same eigenvalues as a and
> > should be #invertable,however,
> >  solve(aa) # can not be solved
> 
> Well, I did get a (non-symmetric) result for solve(aa) ...
> 
> >  solve(aa,tol=1e-19) # can be inverted, however, it is not symmetric
> > and furthermore,
> 
> and an idenitical (to solve(aa)) result for this.
> 
> >  solve(aa,tol=1e-19)%*%aa # deviate much from the identity matrix
> 
> But here I agree with you!
> 
> > I have already define aa to make sure it is symmetric. So the inverse
> > should be symmetric.
> >
> > Does the problem come from the rounding error since the eigenvalue is
> > smaller than the machine precision? In fact, the eigenvalue of aa is
> > negative now, but at least, it is still invertable. How can I get the
> > inverse? Thanks.
> 
> It does indeed, like the eigenvalue result for b above, come from
> the rounding error.
> 
> You should clarify in your mind why you want to ensure that you get
> correct results for matrices like these.
> 
> You are (and in your example deliberately so) treading on the very
> edge of what is capable of being computed, and results are very likely
> to lead to unexpected gross anomalies (such as being unable to
> invert a mathematically invertible matrix, or getting a non-symmetric
> inverse to a symmetric matrix [depending on the algorithm], or
> getting non-zero values for eigenvalues which should be zero, or
> the gross difference from the identity matrix which you expected).
> 
> It is like using a mechanical ditch-digger to peel an apple.
> 
> Exactly what will happen in any particular case can only be
> determined by a very fine-grained analysis of the operation
> of the numerical algorithm, which is beyond your reach in the
> normal usage of R.
> 
> Best wishes,
> Ted.
> 
> 
> 
> E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
> Fax-to-email: +44 (0)870 094 0861
> Date: 30-May-05   Time: 09:43:56
> -- XFMail --
>

__
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] Menu Language

2005-05-30 Thread Uwe Ligges

Hafner, Reinhold (Risklab) wrote:

Hello,
In my windows xp system the regional settings are set to German. However, I
still would like to use the English version of R with English menu items and
texts. RWinEdt tells me this is necessary in order to use the mdi framework.
How can this be achieved with the 2.1 version. In 2.0.1 this wasn't a
problem.


Yes, because R-2.0.1 has not had any translations.
You can set an envrionment variable  LANGUAGE=en  for exmaple...
See the new documentation and the most recent R Newsletter which has 
some nice articles on languages and internationalization by Brian Ripley.


Uwe Ligges



Reinhold


[[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-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] how to "singlify" entries

2005-05-30 Thread zhihua li

hi netters

I have a rather simple question.  I have a data frame with two variables X 
and Y, both of which are factors. X has 100 levels while Y has 10 levels 
only. The data frame has 100 rows in all, so for X the values are unique, 
and Y has many replicate values.  Now I wanna reduce the data frame into 10 
rows only, according to the 10 levels of Y.  I don't care which value of X 
is in the same row with Y in the final data frame, as long as it is in 
agreement with the original data frame.


I think this task can be carried out with some function like aggregate. but 
I failed in figuring it out. Could anybody give me a hint?


Thanks a lot!

__
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 invert the matrix with quite small eigenvalues

2005-05-30 Thread Ted Harding
On 30-May-05 huang min wrote:
> Dear all,
> 
> I encounter some covariance matrix with quite small eigenvalues
> (around 1e-18), which are smaller than the machine precision. The
> dimension of my matrix is 17. Here I just fake some small matrix for
> illustration.
> 
>  a<-diag(c(rep(3,4),1e-18)) # a matrix with small eigenvalues
>  b<-matrix(1:25,ncol=5) # define b to get an orthogonal matrix
>  b<-b+t(b)

NB: b is not *orthogonal*! Each row of b is equal to the preceding
row plus (row2 - row1) (and similar for the columns), and b has
rank 2 (though eigen(b) taken literally says that it has 5 non-zero
eugenvalues; however, 3 of these are snaller that 10^(-14)).

Perhaps you meant "define b to get a symmetric matrix".

>  bb<-eigen(b,symmetric=T)
>  aah<-bb$vectors%*%diag(1/sqrt(diag(a)))
>  aa<-aah%*%t(aah) # aa should have the same eigenvalues as a and
> should be #invertable,however,
>  solve(aa) # can not be solved

Well, I did get a (non-symmetric) result for solve(aa) ...

>  solve(aa,tol=1e-19) # can be inverted, however, it is not symmetric
> and furthermore,

and an idenitical (to solve(aa)) result for this.

>  solve(aa,tol=1e-19)%*%aa # deviate much from the identity matrix

But here I agree with you!

> I have already define aa to make sure it is symmetric. So the inverse
> should be symmetric.
> 
> Does the problem come from the rounding error since the eigenvalue is
> smaller than the machine precision? In fact, the eigenvalue of aa is
> negative now, but at least, it is still invertable. How can I get the
> inverse? Thanks.

It does indeed, like the eigenvalue result for b above, come from
the rounding error.

You should clarify in your mind why you want to ensure that you get
correct results for matrices like these.

You are (and in your example deliberately so) treading on the very
edge of what is capable of being computed, and results are very likely
to lead to unexpected gross anomalies (such as being unable to
invert a mathematically invertible matrix, or getting a non-symmetric
inverse to a symmetric matrix [depending on the algorithm], or
getting non-zero values for eigenvalues which should be zero, or
the gross difference from the identity matrix which you expected).

It is like using a mechanical ditch-digger to peel an apple.

Exactly what will happen in any particular case can only be
determined by a very fine-grained analysis of the operation
of the numerical algorithm, which is beyond your reach in the
normal usage of R.

Best wishes,
Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 30-May-05   Time: 09:43:56
-- XFMail --

__
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] Menu Language

2005-05-30 Thread Hafner, Reinhold (Risklab)
Hello,
In my windows xp system the regional settings are set to German. However, I
still would like to use the English version of R with English menu items and
texts. RWinEdt tells me this is necessary in order to use the mdi framework.
How can this be achieved with the 2.1 version. In 2.0.1 this wasn't a
problem.
Reinhold


[[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] how to invert the matrix with quite small eigenvalues

2005-05-30 Thread huang min
Dear all,

I encounter some covariance matrix with quite small eigenvalues
(around 1e-18), which are smaller than the machine precision. The
dimension of my matrix is 17. Here I just fake some small matrix for
illustration.

 a<-diag(c(rep(3,4),1e-18)) # a matrix with small eigenvalues
 b<-matrix(1:25,ncol=5) # define b to get an orthogonal matrix
 b<-b+t(b)
 bb<-eigen(b,symmetric=T)
 aah<-bb$vectors%*%diag(1/sqrt(diag(a)))
 aa<-aah%*%t(aah) # aa should have the same eigenvalues as a and
should be #invertable,however,
 solve(aa) # can not be solved
 solve(aa,tol=1e-19) # can be inverted, however, it is not symmetric
and furthermore,
 solve(aa,tol=1e-19)%*%aa # deviate much from the identity matrix

I have already define aa to make sure it is symmetric. So the inverse
should be symmetric.

Does the problem come from the rounding error since the eigenvalue is
smaller than the machine precision? In fact, the eigenvalue of aa is
negative now, but at least, it is still invertable. How can I get the
inverse? Thanks.

__
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