[R] hashing

2004-10-16 Thread Søren Merser
is hashing implemented in R
regards søren
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Problem with number characters

2004-10-16 Thread Bobby Corpus
Hi Scott,

What's the result of running  the linux file command on your input file?
Does it give ISO-8859 text  or something else?

example:
[EMAIL PROTECTED] bobby]$ file test2.txt
test2.txt: ISO-8859 text

Best regards,

Bobby


On Thu, 14 Oct 2004 11:31:33 -0700, Scott Waichler
[EMAIL PROTECTED] wrote:
 I am trying to process text fields scanned in from a csv file that is
 output from the Windows database program FileMakerPro.  The characters
 onscreen look like regular text, but R does not like their underlying binary form.
 For example, one of text fields contains a name and a number, but
 R recognizes the number as something other than what it appears
 to be in plain text.  The character string Draszt  03 after being
 read into R using scan and = becomes Draszt 03 where the 3 is
 displayed in my R session as a superscript.  Here is the result pasted
 into this email I'm composing in emacs:  Draszt 0%/1€Œiso8859-15³
 Another clue for the knowledgable:  when I try to display the vector element
 causing trouble, I get
   CHARSXP: Draszt 0%/1€Œiso8859-15³
 where again the superscipt part is just 3 in my R session.  I'm working in
 Linux, R version 1.9.1, 2004-06-21.  Your help will be much appreciated.
 
 Scott Waichler
 Pacific Northwest National Laboratory
 [EMAIL PROTECTED]
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


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


Re: [R] Problem Compiling R-2.0.0 on Linux Alpha

2004-10-16 Thread Peter Dalgaard
Prasad, Rajiv [EMAIL PROTECTED] writes:

 Error in names-.default(`*tmp*`, value = c(R, Platform, Date,
 :
 names attribute [4] must be the same length as the vector [3]
 Execution halted
 make[2]: *** [R] Error 1
 make[2]: Leaving directory
 `/home1/rajiv/software/src-7.2/R-2.0.0/src/library'
 make[1]: *** [R] Error 1
 make[1]: Leaving directory `/home1/rajiv/software/src-7.2/R-2.0.0/src'
 make: *** [R] Error 1
 
 Does this indicate a problem with R, or something in my system
 installation?  A search on R help list archives did not turn up this
 particular error.

Specific to your architecture at least (not too many Alphas around,
but this works elsewhere). It's a pretty odd bug: It would seem to
come from inside .split_description (tools/R/admin.R) where it would
indicate that the Built field has less than three ;  separators, but
the paste construct in .install_package_description that creates the
field does seem to put them in. One conjecture is that a newline
sneaked in somehow...

I'd first look for malformed DESCRIPTION files in your build
directory, then maybe insert some debugging code into
.split_description (e.g. print(sys.status());print(Built) immediately
before the names- bit).

Are you doing this in a clean directory, btw, or might you possibly be
picking up bits of a previous build?

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

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


Re: [R] Problem with number characters

2004-10-16 Thread Prof Brian Ripley
Since ISO-8859 has many different encodings, you need something more
precise.  I am seeing 'iso8859-15' embedded in that email.  AFAIK GNU
`file' or any other Linux utility does not know the encoding of a file,
and it is guessing that it has `ISO-8859 text' when it sees 8-bit files
that are not apparently UTF-8 etc.

R assumes that text files are encoded in the current locale (and does not 
support multibyte locales). That is planned to change one day.

On Sat, 16 Oct 2004, Bobby Corpus wrote:

 Hi Scott,
 
 What's the result of running  the linux file command on your input file?
 Does it give ISO-8859 text  or something else?
 
 example:
 [EMAIL PROTECTED] bobby]$ file test2.txt
 test2.txt: ISO-8859 text
 
 Best regards,
 
 Bobby
 
 
 On Thu, 14 Oct 2004 11:31:33 -0700, Scott Waichler
 [EMAIL PROTECTED] wrote:
  I am trying to process text fields scanned in from a csv file that is
  output from the Windows database program FileMakerPro.  The characters
  onscreen look like regular text, but R does not like their underlying binary form.
  For example, one of text fields contains a name and a number, but
  R recognizes the number as something other than what it appears
  to be in plain text.  The character string Draszt  03 after being
  read into R using scan and = becomes Draszt 03 where the 3 is
  displayed in my R session as a superscript.  Here is the result pasted
  into this email I'm composing in emacs:  Draszt 0%/1€Œiso8859-15³
  Another clue for the knowledgable:  when I try to display the vector element
  causing trouble, I get
CHARSXP: Draszt 0%/1€Œiso8859-15³
  where again the superscipt part is just 3 in my R session.  I'm working in
  Linux, R version 1.9.1, 2004-06-21.  Your help will be much appreciated.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Testing for normality of residuals in a regression model

2004-10-16 Thread Federico Gherardini
Prof Brian Ripley wrote:
However, stats 901 or some such tells you that if the distributions have 
even slightly longer tails than the normal you can get much better 
estimates than OLS, and this happens even before a test of normality 
rejects on a sample size of thousands.

Robustness of efficiency is much more important than robustness of 
distribution, and I believe robustness concepts should be in stats 101.
(I was teaching them yesterday in the third lecture of a basic course, 
albeit a graduate course.)
   

This is a very interesting discussion. So you are basically saying that 
it's better to use robust regression methods, without having to worry 
too much about the distribution of residuals, instead of using standard 
methods and doing a lot of tests to check for normality? Did I get your 
point?

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


Re: [R] tree version 1.0-16

2004-10-16 Thread Martin Maechler
 ZKala == Kalaylioglu, Zeynep (IMS) [EMAIL PROTECTED]
 on Fri, 15 Oct 2004 15:52:11 -0400 writes:

ZKala Hi There is something weird going on with the tree
ZKala package version 1.0-16.  So I want to download an
ZKala updated tree package. I found that R website has
ZKala version 1.0-18. I want to try this one and see how
ZKala the tree algorithm is performing.  What is the best
ZKala way to download tree package version 1.0-18 which can
ZKala be found in index of src/contrib at
ZKala www.r-project.org?  So far I tried two different ways
ZKala none of which has worked for me: 1) I tried to
ZKala download it by running the command
ZKala install.packages(tree,C:\Program
ZKala Files\R\rw1081\library,http://cran.r-project.org/src/contrib,destdir=
ZKala C:\Program
ZKala http://cran.r-project.org/src/contrib,destdir=C:/Program
ZKala Files\R\rw1081\library,installWithVers=TRUE) But it
ZKala tries to connect to
ZKala http://cran.r-project.org/src/contrib/bin/windows/contrib/1.8/PACKAGES
ZKala http://cran.r-project.org/src/contrib/bin/windows/contrib/1.8/PACKAGES
ZKala instead of the URL I enter above.

yes, I see  that your R version is 'R (for windows) 1.8.1'
and that's probably why it tries to get package for that
version.

If you want to upgrade packages, I strongly recommend to first
upgrade R to the current version 2.0.0 (or maybe 2.0.0 patched)
-- and then follow the advice from James MacDonald.

Martin Maechler, ETH Zurich
 
ZKala 2) Also I tried to download it by copying the zip
ZKala file first tree_1.0-18.tar.gz
ZKala http://cran.r-project.org/src/contrib/tree_1.0-18.tar.gz
ZKala in my directory and then using the Packages-Install
ZKala package from local -zip files in the R menu.
 
ZKala How can I download this version of tree? Thanks.
 
ZKala Zeynep

ZKala  [[alternative HTML version deleted]]

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

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


RE: [R] combine many .csv files into a single file/data frame

2004-10-16 Thread Ted Harding
On 15-Oct-04 bogdan romocea wrote:
 I have a few hundred .csv files which I need to put
 together (full outer joins on a common variable) to do a
 factor analysis. Each file may contain anywhere from a few
 hundred to a few thousand rows. What would be the most
 efficient way to do this in R? Please include some sample
 code if applicable.

Sorry, the example I posted last night was written too hastily
and does not illustrate your precise query well. Here is a
better one, with explanation.

$ cat j1
1,a
1,b
2,c
2,d
2,e
3,f
3,g
4,h
4,i
5,j

$ cat j2
1,A
1,B
1,C
2,D
2,E
4,F
4,G
5,H
6,I
6,J

$ join -t , -a 1 -a 2 -o 0,1.2,2.2 j1 j2
1,a,A
1,a,B
1,a,C
1,b,A
1,b,B
1,b,C
2,c,D
2,c,E
2,d,D
2,d,E
2,e,D
2,e,E
3,f,
3,g,
4,h,F
4,h,G
4,i,F
4,i,G
5,j,H
6,,I
6,,J

Explanation of options:

-t ,Input and output field separator is , (for CSV)
-a 1Output a line for every line of j1 not matched in j2
-a 2Output a line for every line of j2 not matched in j1
-o 0,1.2,2.2  Output field format specification:
0 denotes the match (join) field (needed when using -a)
1.2 denotes field 2 from file 1 (j1)
2.2 denotes field 2 from file 2 (j2)
j1 and j2 are of course the two files to be joined.

Using the -a option gives you the full outer join which you want.

This command only works for two files at a time (and you must give
two). To join several files you would have to loop through them on
the lines of

$ join -t , -a 1 -a 2 -o 0,1.2,2.2 j1 j2  J

which creates a file J which is the full outer join of j1, j2.

Then

$ join -t , -a 1 -a 2 -o 0,1.2,2.2 J j3  J

and so on through j4, j5, ...

For your few hundred files this is best done with a loop like

$ for i in * ; do join -t , -a 1 -a 2 -o 0,1.2,2.2 J $i  J ; done

having first done it for j1, j2 as above and put these two file
out of sight in a different directory. J itself also needs to
be out of sight otherwise it will get joined to itself at some
stage. E.g. where J is written above it could in fact be
written as ../joins/J and similarly for ../joins/j1 and
../joins/j2.

E.g. first move j1  j2 to ../joins and then do

$ join -t , -a 1 -a 2 -o 0,1.2,2.2 ../joins/j1 ../joins/j2  ../joins/J

and then

$ for i in * ; do
join -t , -a 1 -a 2 -o 0,1.2,2.2 ../joins/J $i  ../joins/J
  done


Sorry for the previous sloppy response, and hoping the above
helps.

Best wishes,
Ted.




E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 16-Oct-04   Time: 10:39:05
-- XFMail --

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


[R] barplot

2004-10-16 Thread Sepp Gurgel
I have a table with two columns, one with types of blood (A, B, AB or 0) and
one with the factor (negative = -1 or positive = 1).

How can I combine those two columns so that 7 bars are plotted (A, B, AB, 0,
-A, -B and -0)?

--

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


[R] sapply and loop

2004-10-16 Thread Mayeul KAUFFMANN
Zhen,

how to count the exact time ?

system.time(base)
Returns CPU (and other) times that expr used.


If you only need seconds, you can also do

date();zz-sapply(ma, myfunction);date()

I do not know about how to reduce the time.
For very comlex iterations, I use for( ) myself, which maybe inneficient.

Mayeul KAUFFMANN
Université Pierre Mendès France
Grenoble
France

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


[R] Cox PH Warning Message

2004-10-16 Thread Neil Leonard
Hi,
Can anybody tell me what the message below means and how to overcome it.
Thanks,
Neil
Warning message:
X matrix deemed to be singular; variable 2 in: coxph(Surv(age_at_death, 
death) ~ project$pluralgp + project$yrborn +  .


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


Re: [R] 20,000 * 6 data values

2004-10-16 Thread Sean Davis
Sun,

There are hundreds using R for microarray analysis.  You probably want to
avail yourself of the bioconductor tools (http://www.bioconductor.org).
20,000 rows with 6 data values is a small data set, by microarray standards,
and is easily handled by R and the bioconductor tools.  I routinely analyze
a couple of hundred experiments with 40-50k rows, and most of the time, that
doesn't push R very hard (on my 2 processor, 4Gb machine, at least).

Sean

- Original Message -
From: Sun [EMAIL PROTECTED]
To: R-help mailing list [EMAIL PROTECTED]
Sent: Saturday, October 16, 2004 12:24 AM
Subject: [R] 20,000 * 6 data values


 Hello, Rusers:

 What is the maximum number of data R can handle? Or I have to use SAS? I
am
 trying to do some microarray data analysis. But I am totally new. Did
anyone
 use R to do microarray analysis?

 Many thanks,

 Sun

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


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


[R] Cox PH Warning Message

2004-10-16 Thread Mayeul KAUFFMANN
Hi,
Can anybody tell me what the message below means and how to overcome it.
Thanks,
Neil
Warning message:
X matrix deemed to be singular; variable 2 in: coxph(Surv(age_at_death,
death) ~ project$pluralgp + project$yrborn +  .

Your 2nd covariate (yrborn) is colinear to the other covariates (or nearly
colinear). R drops it, but warns you. The results are OK.

Mayeul KAUFFMANN
Université Pierre Mendès France
Grenoble
France

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


Re: [R] Cox PH Warning Message

2004-10-16 Thread Neil Leonard
This is the output. I think it means that there is a problem with 
project$pluralgpTriplet???

Neil
 fm.CPH
Call:
coxph(formula = Surv(age_at_death, death) ~ project$pluralgp +
project$yrborn + project$private + project$pcdead + project$mheight 
+
project$ga2 + project$apgcode + project$apgar5 + project$VLBWgp +
project$PEBW + project$LBWgp + project$LBWcat + project$totadm +
project$totlos + project$sex + teen + project$DS + project$pcsborn +
project$disadv + project$ecores + project$edoccu)

coef exp(coef) se(coef)   z   p
project$pluralgpTwin   -0.509203 0.601  0.74415 -0.6843 4.9e-01
project$pluralgpTriplet   NANA  0.0  NA  NA
project$yrborn1988-1992-0.083348 0.920  0.22553 -0.3696 7.1e-01
project$private 0.260465 1.298  0.12384  2.1032 3.5e-02
project$pcdead -0.058200 0.943  0.49418 -0.1178 9.1e-01
project$mheight 0.016361 1.016  0.01745  0.9378 3.5e-01
project$ga2 0.104246 1.110  0.10162  1.0258 3.0e-01
project$apgcode4-7 -0.266885 0.766  0.50211 -0.5315 6.0e-01
project$apgcode1-3 -1.704620 0.182  1.12545 -1.5146 1.3e-01
project$apgar5 -0.427139 0.652  0.14099 -3.0296 2.4e-03
project$VLBWgp=1500 grams  0.046203 1.047  0.65494  0.0705 9.4e-01
project$PEBW0.015297 1.015  0.01356  1.1281 2.6e-01
project$LBWgp=2500 grams  -0.257472 0.773  0.42496 -0.6059 5.4e-01
project$LBWcat -0.222823 0.800  0.23938 -0.9308 3.5e-01
project$totadm  0.005836 1.006  0.01536  0.3800 7.0e-01
project$totlos  0.007342 1.007  0.00176  4.1664 3.1e-05
project$sexFemale  -0.016431 0.984  0.22803 -0.0721 9.4e-01
teen0.286282 1.331  0.34807  0.8225 4.1e-01
project$DSDown syndrome 1.193727 3.299  0.27227  4.3844 1.2e-05
project$pcsborn-0.704743 0.494  0.75943 -0.9280 3.5e-01
project$disadv -0.000573 0.999  0.00250 -0.2296 8.2e-01
project$ecores -0.001588 0.998  0.00249 -0.6392 5.2e-01
project$edoccu  0.000590 1.001  0.00193  0.3054 7.6e-01
Likelihood ratio test=102  on 22 df, p=2.87e-12  n=2126 (1396 
observations deleted due to missing)

On 16/10/2004, at 6:32 PM, Mayeul KAUFFMANN wrote:

Hi,
Can anybody tell me what the message below means and how to overcome 
it.
Thanks,
Neil
Warning message:
X matrix deemed to be singular; variable 2 in: coxph(Surv(age_at_death,
death) ~ project$pluralgp + project$yrborn +  .

Your 2nd covariate (yrborn) is colinear to the other covariates (or 
nearly
colinear). R drops it, but warns you. The results are OK.

Mayeul KAUFFMANN
Université Pierre Mendès France
Grenoble
France

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


RE: [R] Testing for normality of residuals in a regression model

2004-10-16 Thread Philippe Grosjean
 Prof Brian Ripley wrote:
 
 However, stats 901 or some such tells you that if the distributions 
 have even slightly longer tails than the normal you can get much 
 better estimates than OLS, and this happens even before a test of 
 normality rejects on a sample size of thousands.
 
 Robustness of efficiency is much more important than robustness of 
 distribution, and I believe robustness concepts should be 
 in stats 101.
 (I was teaching them yesterday in the third lecture of a 
 basic course, 
 albeit a graduate course.)
 
 

Federico Gherardini answered:
 This is a very interesting discussion. So you are basically 
 saying that it's better to use robust regression methods, 
 without having to worry too much about the distribution of 
 residuals, instead of using standard methods and doing a lot 
 of tests to check for normality? Did I get your point?

My feeling is that symmetry is more important than, let's say kurtosis  0
in the error. Is this correct? Now the problem is: the lower number of
observations, the more severe an effect of non-normality (at least,
asymmetry?) could be on the regression AND at the same time, power of tests
to detect non normality drops. So, I can imagine easily situations where
non-normality is not detected, yet asymmetry is such that regression is
significantly biased... It is mainly a question of sample size from this
point of view... But not only:

Andy Liaw wrote:
 Also, I was told by someone very smart that fitting OLS to
 data with heteroscedastic errors can make the residuals look
 `more normal' than they really are...  Don't know how true
 that is, though. 

That very smart person is not me, but it happens that I experimented also a
little bit on this a while ago! Just experiment with artificial data, and
you will see what happens: residuals look often more normal that the error
distribution you introduced in your artificial data... Another consequence,
is a biased estimate of parameters. Indeed, both come together: parameters
are biased in a direction that lowers residuals sum of square, obviously,
but also in some circumstances, in a direction that make residuals looking
more normal... And that is not (how can it be?) taken into account in the
test of normality. That is, I believe, a second reason why non-normality of
error could not be detected, yet it has a major impact on the OLS
regression.

And I am pretty sure there are other reasons, like distribution of error
both in the dependent and in the independent variables, another violation of
the assumptions made for OLS...

Best regards,

Philippe

..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Pentagone
( ( ( ( (Academie Universitaire Wallonie-Bruxelles
 ) ) ) ) )   6, av du Champ de Mars, 7000 Mons, Belgium  
( ( ( ( (   
 ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.33.12
( ( ( ( (email: [EMAIL PROTECTED]
 ) ) ) ) )  
( ( ( ( (web:   http://www.umh.ac.be/~econum
 ) ) ) ) )
..

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


RE: [R] Testing for normality of residuals in a regression model

2004-10-16 Thread Prof Brian Ripley
I am assuming everyone is on R-help and doesn't want two copies so have 
trimmed the Cc: list to R-help.

On Sat, 16 Oct 2004, Philippe Grosjean wrote:

  Prof Brian Ripley wrote:

[ Other contributions previously excised here without comment. ]

  However, stats 901 or some such tells you that if the distributions 
  have even slightly longer tails than the normal you can get much 
  better estimates than OLS, and this happens even before a test of 
  normality rejects on a sample size of thousands.
  
  Robustness of efficiency is much more important than robustness of 
  distribution, and I believe robustness concepts should be 
  in stats 101.
  (I was teaching them yesterday in the third lecture of a  basic course, 
  albeit a graduate course.)
 
 Federico Gherardini answered:
  This is a very interesting discussion. So you are basically 
  saying that it's better to use robust regression methods, 
  without having to worry too much about the distribution of 
  residuals, instead of using standard methods and doing a lot 
  of tests to check for normality? Did I get your point?
 
 My feeling is that symmetry is more important than, let's say kurtosis  0
 in the error. Is this correct? Now the problem is: the lower number of
 observations, the more severe an effect of non-normality (at least,
 asymmetry?) could be on the regression AND at the same time, power of tests
 to detect non normality drops. So, I can imagine easily situations where
 non-normality is not detected, yet asymmetry is such that regression is
 significantly biased... 

Before you can even talk about bias you have to agree what it is you are
trying to estimate.  For asymmetric error distributions it is unlikely to
be the population mean, but if it is then least-squares linear regression
is unbiased provided only that the error distribution has a finite first
moment.  (Part of the so-called Gauss-Markov Theorem.  This seems to
suggest that Philippe's `easy imagination' is of impossible things.)

For contaminated normal distributions it is possibly the mean of the
uncontaminated normal component, and the latter seems the commonest aim of
mainstream robust methods, which do often assume symmetry.  (This may not
affect interpretation of coefficients other than the intercept.)  The
(non-linear) robust regression estimators may be biased for the population
mean but have a (much) smaller variability for long-tailed distributions.

There is a lot of careful discussion about this in the statistical
literature, and I don't believe that it is profitable for people to be
discussing this without knowing the literature, and probably not _here_
even then.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] hashing

2004-10-16 Thread Roger D. Peng
In a sense, yes.  Elements of named vectors can be accessed via their names and 
that (internally) uses hashing, I believe.

-roger
Søren Merser wrote:
is hashing implemented in R
regards søren
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

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


Re: [R] sapply and loop

2004-10-16 Thread Roger D. Peng
You can use system.time() to time your procedure.  There's no guarantee that 
sapply() will be faster than a for() loop, especially if you preallocate the 
matrices.

-roger
Zhen Pang wrote:
Dear all,
I am doing 200 times simulation. For each time, I generate a matrix and 
define some function on this matrix to get a 6 dimension vector as my 
results.

As the loop should be slow, I generate 200 matrice first, and save them 
into a list named ma,
then I define zz-sapply(ma, myfunction)

To my surprise, It almost costs me the same time to get my results if I 
directly use a loop from 1 to 200. Is it common? Can I improve any further?

Ps, how to count the exact time to finish my code?
Thanks.
Zhen
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

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


RE: [R] sapply and loop

2004-10-16 Thread Liaw, Andy
Without seeing what myfunction is, it's almost impossible to tell.

In addition to system.time(), you might want to profile your code.  e.g.,

Rprof()
zz - sapply(ma, myfunction)
Rprof(NULL)
summaryRprof()

HTH,
Andy

 From: Zhen Pang
 
 Dear all,
 
 I am doing 200 times simulation. For each time, I generate a 
 matrix and 
 define some function on this matrix to get a 6 dimension vector as my 
 results.
 
 As the loop should be slow, I generate 200 matrice first, and 
 save them into 
 a list named ma,
 then I define zz-sapply(ma, myfunction)
 
 To my surprise, It almost costs me the same time to get my 
 results if I 
 directly use a loop from 1 to 200. Is it common? Can I 
 improve any further?
 
 Ps, how to count the exact time to finish my code?
 
 Thanks.
 
 Zhen
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


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


RE: [R] sapply and loop

2004-10-16 Thread Zhen Pang
Below is my code. myfunction is the myfunction I mentioned in my last email.
p0-.2
rho0-.2
nl-200
simu-200
set.seed(135)
setwd(d:/r)
options(warn=1)
ns-rep(1,nl)
configuration-runif(nl)
frequency-c(0.0046,0.0057,0.0099,0.0139,0.0147,0.0148,0.0225,0.0321,0.0475,0.0766,0.1179,0.1529,0.1605,0.1424,0.0975,0.0542,0.0207,0.0086,0.0030)
for (i in 1:nl)
   {if (configuration[i]=frequency[1]) {ns[i]-1
} else {for (j in 2:length(frequency))
 {if (sum(frequency[1:(j-1)])configuration[i]  
configuration[i]=sum(frequency[1:j]))   {ns[i]-j}
  }
}
}

nu-unique(ns)
k-max(nu)
a-vector(simu,mode=list)
for (si in 1:simu)
{
print (si)
print (si)
data-c(0,0,0)
for (iu in 1:length(nu))
  {fr-length(ns[ns==nu[iu]])
   y-rep(0,fr)
   for (ju in 1:fr)
  
{y[ju]-rbinom(1,nu[iu],rbeta(1,(1-rho0)*p0/rho0,(1-rho0)*(1-p0)/rho0))
   }
   yu-sort(unique(y))
   yy-rep(0,length(yu))
   for (ku in 1:length(yu))
  {yy[ku]-length(y[y==yu[ku]])
   }
   ma-cbind(rep(nu[iu],length(yu)),yu,yy)
   data-rbind(data,ma)
   }
data-data[-1,]
a[[si]]-data
}

myfunction-function(data)
{
llb-function(theta)
{
s - apply(data, 1, function(data) {
n-data[1]; y-data[2] ; re-data[3]
	p-1/(1+exp(-theta[1]))
   t - exp(theta[2])
	s - log(choose(n,y))
	r-c(0:(n-1))
	s - s-sum(log(1+r*t))
	if (n-y-1=0)
	{
	r-c(0:(n-y-1))
	s - s+sum(log(1-p+r*t))
	}
   if (y-1=0)
   {r-c(0:(y-1))
	 s- s+sum(log(p+r*t))
	}
s*re
})
-sum(s)
}
est2-optim(c(log(p0/(1-p0)),log(rho0/(1-rho0))),llb,hessian=T,control = 
list(maxit=500))
est2$par
}

zz-sapply(a,myfunction)
If we move the myfucntion to the for(si in 1:simu) loop, results are the 
same and there are no time spare. Can you improve a little? Thanks.

Zhen

From: Liaw, Andy [EMAIL PROTECTED]
To: 'Zhen Pang' [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: [R] sapply and loop
Date: Sat, 16 Oct 2004 08:23:54 -0400
Without seeing what myfunction is, it's almost impossible to tell.
In addition to system.time(), you might want to profile your code.  e.g.,
Rprof()
zz - sapply(ma, myfunction)
Rprof(NULL)
summaryRprof()
HTH,
Andy
 From: Zhen Pang

 Dear all,

 I am doing 200 times simulation. For each time, I generate a
 matrix and
 define some function on this matrix to get a 6 dimension vector as my
 results.

 As the loop should be slow, I generate 200 matrice first, and
 save them into
 a list named ma,
 then I define zz-sapply(ma, myfunction)

 To my surprise, It almost costs me the same time to get my
 results if I
 directly use a loop from 1 to 200. Is it common? Can I
 improve any further?

 Ps, how to count the exact time to finish my code?

 Thanks.

 Zhen

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


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


Re: [R] tree version 1.0-16

2004-10-16 Thread Uwe Ligges
Martin Maechler wrote:
ZKala == Kalaylioglu, Zeynep (IMS) [EMAIL PROTECTED]
   on Fri, 15 Oct 2004 15:52:11 -0400 writes:

ZKala Hi There is something weird going on with the tree
ZKala package version 1.0-16.  So I want to download an
ZKala updated tree package. I found that R website has
ZKala version 1.0-18. I want to try this one and see how
ZKala the tree algorithm is performing.  What is the best
ZKala way to download tree package version 1.0-18 which can
ZKala be found in index of src/contrib at
ZKala www.r-project.org?  So far I tried two different ways
ZKala none of which has worked for me: 1) I tried to
ZKala download it by running the command
ZKala install.packages(tree,C:\Program
ZKala Files\R\rw1081\library,http://cran.r-project.org/src/contrib,destdir=
ZKala C:\Program
ZKala http://cran.r-project.org/src/contrib,destdir=C:/Program
ZKala Files\R\rw1081\library,installWithVers=TRUE) But it
ZKala tries to connect to
ZKala http://cran.r-project.org/src/contrib/bin/windows/contrib/1.8/PACKAGES
ZKala http://cran.r-project.org/src/contrib/bin/windows/contrib/1.8/PACKAGES
ZKala instead of the URL I enter above.
yes, I see  that your R version is 'R (for windows) 1.8.1'
and that's probably why it tries to get package for that
version.
If you want to upgrade packages, I strongly recommend to first
upgrade R to the current version 2.0.0 (or maybe 2.0.0 patched)
-- and then follow the advice from James MacDonald.
Yes!
Let me add, that if you are going to stay with R-1.8.1 for some 
unbelievable reason, you can compile from sources (the one that ends 
with .tar.gz) yourself (follow .../src/gnuwin32/readme.packages). That 
might be much harder than upgrading, though - and we cannot promise that 
a recent package version works under outdated versions of R.

Uwe Ligges

Martin Maechler, ETH Zurich
 
ZKala 2) Also I tried to download it by copying the zip
ZKala file first tree_1.0-18.tar.gz
ZKala http://cran.r-project.org/src/contrib/tree_1.0-18.tar.gz
ZKala in my directory and then using the Packages-Install
ZKala package from local -zip files in the R menu.
 
ZKala How can I download this version of tree? Thanks.
 
ZKala Zeynep

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


Re: [R] barplot

2004-10-16 Thread Uwe Ligges
Sepp Gurgel wrote:
I have a table 
Do you mean a data.frame?
with two columns, one with types of blood (A, B, AB or 0) and
one with the factor (negative = -1 or positive = 1).
And from these you made a table?
  my.table - table(my.data.frame)

How can I combine those two columns so that 7 bars are plotted (A, B, AB, 0,
-A, -B and -0)?
Now you can say
  blood.id - outer(rownames(my.table), colnames(m.ytable),
paste, sep=)
  barplot(as.vector(my.table), names = blood.id)
Uwe Ligges

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


[R] Lazy loading... advices

2004-10-16 Thread Philippe Grosjean
Hello,

I am looking for more information about lazy loading introduced in R 2.0.0.
Doing
?lazyLoad
I got some and there is a 'see also' section that points to
'makeLazyLoading'... But I cannot reach this page.

My problem is: I recompiled a library that uses a lot of functions from
other libraries (of course I can give details if needed). I load it in my
computer: library(svGUI), and it takes something like 20 seconds to load. In
R 1.9.1 it took 3-4 seconds on the same machine (Windows XP). So, I try now
to understand the mechanism and to find a way to lower the loading time of
this library with lazy loading (its goal is to load faster, isn't, so I
probably do something wrong).

Any help or advice would be appreciated.

Here is a Rprof of library(svGUI) on my machine:

» summaryRprof()
$by.self
self.time self.pct total.time total.pct
file.exists  7.42 24.9   8.46  28.4
list.files   7.24 24.3   7.32  24.6
file 6.78 22.8   6.88  23.1
read.dcf 1.42  4.8   9.24  31.0
file.info0.54  1.8   0.82   2.8
lapply   0.52  1.7   8.96  30.1
inherits 0.34  1.1  28.76  96.5
names0.34  1.1   0.38   1.3
names-  0.30  1.0   0.42   1.4
paste0.30  1.0   0.66   2.2
close.connection 0.24  0.8   0.24   0.8
.Call0.20  0.7   0.20   0.7
apply0.20  0.7   0.58   1.9
.find.package0.18  0.6  18.14  60.9
[... More here]

$by.total
total.time total.pct self.time self.pct
library  29.70  99.7  0.00  0.0
try  29.64  99.5  0.10  0.3
f29.36  98.5  0.00  0.0
firstlib 29.36  98.5  0.00  0.0
Require  28.96  97.2  0.00  0.0
match28.80  96.6  0.08  0.3
inherits 28.76  96.5  0.34  1.1
is.factor28.76  96.5  0.00  0.0
%in% 28.60  96.0  0.00  0.0
installed.packages   28.60  96.0  0.00  0.0
unlist   21.46  72.0  0.08  0.3
packageDescription   21.22  71.2  0.10  0.3
system.file  19.18  64.4  0.08  0.3
.find.package18.14  60.9  0.18  0.6
guiInstall   11.82  39.7  0.00  0.0
read.dcf  9.24  31.0  1.42  4.8
lapply8.96  30.1  0.52  1.7
file.exists   8.46  28.4  7.42 24.9
FUN   7.82  26.2  0.02  0.1
list.files7.32  24.6  7.24 24.3
.packages 7.20  24.2  0.02  0.1
file  6.88  23.1  6.78 22.8
require   3.42  11.5  0.00  0.0
[... More here]

This is the description of my package (in the bundle SciViews):

Package: svGUI
Title: SciViews GUI API - Main GUI features
Description: Functions to communicate with a GUI client, to implement an
object browser, etc...
Bundle: SciViews
Version: 0.7-0
Date: 2004-10-10
Depends: utils, grDevices, graphics, stats, methods, tcltk, R2HTML, svMisc
Suggests: Hmisc, MASS, wxPython
Author: Philippe Grosjean  Eric Lecoutre
Maintainer: Philippe Grosjean [EMAIL PROTECTED]
BundleDescription: SciViews GUI API
  A series of packages to implement a full reusable GUI API for R.
License: GPL 2 or above
URL: http://www.sciviews.org/SciViews-R

Thank you.
Best,

Philippe Grosjean

..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Pentagone
( ( ( ( (Academie Universitaire Wallonie-Bruxelles
 ) ) ) ) )   6, av du Champ de Mars, 7000 Mons, Belgium  
( ( ( ( (   
 ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.33.12
( ( ( ( (email: [EMAIL PROTECTED]
 ) ) ) ) )  
( ( ( ( (web:   http://www.umh.ac.be/~econum
 ) ) ) ) )
..

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


[R] moving functions between namespaces

2004-10-16 Thread Faber Fedor
Hi all,

I'm a newbie wrt R but that's okay, since I don't do any programming
in R.  What I do need to do is to administrate the activites of an R
programmer, so my questions will be related to adminning R as opposed
to statistcal programming.  I hope that's okay with y'all. :-)

I've been through most of the docs that I could find (the PDFs,
StatsRUs, etc.) and I've found the answers to most of my questions,
but not to an important one: how do I move a function from one
namespace to another.

On the chance that I'm not using the right terminlogoy, here's my
situation: Programmer A has written a function foobar() which resides
in his namespace /home/progA/.RData.  I want to move foobar(), and
only foobar(), into the QA enviroment which means replicating foobar()
inside of /home/qa/.RData.

I've found that I can use sink() to copy foobar() to a file but 1) I
haven't found how to read it back in and 2) I figure you guys have a
more elegant way of doing this.

Any advice?

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


Re: [R] Lazy loading... advices

2004-10-16 Thread Douglas Bates
Philippe Grosjean wrote:
Hello,
I am looking for more information about lazy loading introduced in R 2.0.0.
Doing
?lazyLoad
I got some and there is a 'see also' section that points to
'makeLazyLoading'... But I cannot reach this page.
My problem is: I recompiled a library that uses a lot of functions from
other libraries (of course I can give details if needed). I load it in my
computer: library(svGUI), and it takes something like 20 seconds to load. In
R 1.9.1 it took 3-4 seconds on the same machine (Windows XP). So, I try now
to understand the mechanism and to find a way to lower the loading time of
this library with lazy loading (its goal is to load faster, isn't, so I
probably do something wrong).
Any help or advice would be appreciated.
Have you read the article about lazyLoad mechanism that Brian Ripley 
wrote for the latest R News issue?

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


Re: [R] moving functions between namespaces

2004-10-16 Thread Prof Brian Ripley
On Sat, 16 Oct 2004, Faber Fedor wrote:

 Hi all,
 
 I'm a newbie wrt R but that's okay, since I don't do any programming
 in R.  What I do need to do is to administrate the activites of an R
 programmer, so my questions will be related to adminning R as opposed
 to statistcal programming.  I hope that's okay with y'all. :-)
 
 I've been through most of the docs that I could find (the PDFs,
 StatsRUs, etc.) and I've found the answers to most of my questions,
 but not to an important one: how do I move a function from one
 namespace to another.
 
 On the chance that I'm not using the right terminlogoy, here's my

I think you mean `workspace', not `namespace', so the explanation was very 
helpful.

 situation: Programmer A has written a function foobar() which resides
 in his namespace /home/progA/.RData.  I want to move foobar(), and
 only foobar(), into the QA enviroment which means replicating foobar()
 inside of /home/qa/.RData.

 I've found that I can use sink() to copy foobar() to a file but 1) I
 haven't found how to read it back in and 2) I figure you guys have a
 more elegant way of doing this.

In /home/progA start R and run save(foobar, file=foobar.rda). End.

In /home/qa start R and run load(/home/progA/foobar.rda).

If this is more than once off, your programmer should write a package 
containing the useful functions: see `Writing R Extensions'.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] moving functions between namespaces

2004-10-16 Thread Douglas Bates
Faber Fedor wrote:
Hi all,
I'm a newbie wrt R but that's okay, since I don't do any programming
in R.  What I do need to do is to administrate the activites of an R
programmer, so my questions will be related to adminning R as opposed
to statistcal programming.  I hope that's okay with y'all. :-)
I've been through most of the docs that I could find (the PDFs,
StatsRUs, etc.) and I've found the answers to most of my questions,
but not to an important one: how do I move a function from one
namespace to another.
On the chance that I'm not using the right terminlogoy, here's my
situation: Programmer A has written a function foobar() which resides
in his namespace /home/progA/.RData.  I want to move foobar(), and
only foobar(), into the QA enviroment which means replicating foobar()
inside of /home/qa/.RData.
I've found that I can use sink() to copy foobar() to a file but 1) I
haven't found how to read it back in and 2) I figure you guys have a
more elegant way of doing this.
Any advice?
The term namespace now means something other than the way you use it 
but that's not important.

The simple way to do this is to have Programmer A start up R in 
/home/progA and save a copy of the function foobar to a file.

  save(foobar, file = /home/qa/foobar.rda)
(Depending on the size of the file Programmer A may wish to add the 
optional argument compress = TRUE in that call.)

Now start R in /home/qa and load the saved copy
  load(/home/qa/foobar.rda)
then exit R.
I'm tempted to write more about variations on this mechanism but I think 
I'll just stay with the simple answer.

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


Re: [R] Lazy loading... advices

2004-10-16 Thread Uwe Ligges
Philippe Grosjean wrote:
Hello,
I am looking for more information about lazy loading introduced in R 2.0.0.
Doing
?lazyLoad
I got some and there is a 'see also' section that points to
'makeLazyLoading'... But I cannot reach this page.
My problem is: I recompiled a library 
Philippe,
citing Doug Bates: Someone named Martin Maechler will shortly be 
sending you email regarding the distinction between 'library' and 
'package'. ;-)

[from:
  install.packages(fortunes)
  library(fortunes)
  fortune(library)
]
 that uses a lot of functions from
other libraries (of course I can give details if needed). I load it in my
computer: library(svGUI), and it takes something like 20 seconds to load. In
R 1.9.1 it took 3-4 seconds on the same machine (Windows XP). So, I try now
to understand the mechanism and to find a way to lower the loading time of
this library with lazy loading (its goal is to load faster, isn't, so I
probably do something wrong).
It might not always be faster. See Brian Ripley's article in the most 
recent R Newsletter. Probably you are using a lot of functions in the 
startup directly after the call to library() (in .First.lib() or 
.onLoad() or Hooks or whatever).
I think you want to specify LazyLoad: no in the package's DESCRIPTION 
file (cp. Writing R Extensions).

Uwe


Any help or advice would be appreciated.
Here is a Rprof of library(svGUI) on my machine:
» summaryRprof()
$by.self
self.time self.pct total.time total.pct
file.exists  7.42 24.9   8.46  28.4
list.files   7.24 24.3   7.32  24.6
file 6.78 22.8   6.88  23.1
read.dcf 1.42  4.8   9.24  31.0
file.info0.54  1.8   0.82   2.8
lapply   0.52  1.7   8.96  30.1
inherits 0.34  1.1  28.76  96.5
names0.34  1.1   0.38   1.3
names-  0.30  1.0   0.42   1.4
paste0.30  1.0   0.66   2.2
close.connection 0.24  0.8   0.24   0.8
.Call0.20  0.7   0.20   0.7
apply0.20  0.7   0.58   1.9
.find.package0.18  0.6  18.14  60.9
[... More here]
$by.total
total.time total.pct self.time self.pct
library  29.70  99.7  0.00  0.0
try  29.64  99.5  0.10  0.3
f29.36  98.5  0.00  0.0
firstlib 29.36  98.5  0.00  0.0
Require  28.96  97.2  0.00  0.0
match28.80  96.6  0.08  0.3
inherits 28.76  96.5  0.34  1.1
is.factor28.76  96.5  0.00  0.0
%in% 28.60  96.0  0.00  0.0
installed.packages   28.60  96.0  0.00  0.0
unlist   21.46  72.0  0.08  0.3
packageDescription   21.22  71.2  0.10  0.3
system.file  19.18  64.4  0.08  0.3
.find.package18.14  60.9  0.18  0.6
guiInstall   11.82  39.7  0.00  0.0
read.dcf  9.24  31.0  1.42  4.8
lapply8.96  30.1  0.52  1.7
file.exists   8.46  28.4  7.42 24.9
FUN   7.82  26.2  0.02  0.1
list.files7.32  24.6  7.24 24.3
.packages 7.20  24.2  0.02  0.1
file  6.88  23.1  6.78 22.8
require   3.42  11.5  0.00  0.0
[... More here]
This is the description of my package (in the bundle SciViews):
Package: svGUI
Title: SciViews GUI API - Main GUI features
Description: Functions to communicate with a GUI client, to implement an
object browser, etc...
Bundle: SciViews
Version: 0.7-0
Date: 2004-10-10
Depends: utils, grDevices, graphics, stats, methods, tcltk, R2HTML, svMisc
Suggests: Hmisc, MASS, wxPython
Author: Philippe Grosjean  Eric Lecoutre
Maintainer: Philippe Grosjean [EMAIL PROTECTED]
BundleDescription: SciViews GUI API
  A series of packages to implement a full reusable GUI API for R.
License: GPL 2 or above
URL: http://www.sciviews.org/SciViews-R
Thank you.
Best,
Philippe Grosjean
..°}))
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Pentagone
( ( ( ( (Academie Universitaire Wallonie-Bruxelles
 ) ) ) ) )   6, av du Champ de Mars, 7000 Mons, Belgium  
( ( ( ( (   
 ) ) ) ) )   phone: + 

RE: [R] power in a specific frequency band

2004-10-16 Thread Gabor Grothendieck


Unfortunately the documentation seems somewhat sparse 
but you can figure out what it is doing by looking at the code 
of spec.pgram or just pumping a sine wave through it and 
comparing that to a manually generated periodogram, which 
we do below:

 tt - 1:32 # time
 x - sin(2*pi*tt/8) # sine save with period 8, i.e. freq = .125
 x - x - mean(x)
 
 # Calculate the periodogram manually using the fft
 round(Mod(fft(x))^2/32, 3)
 [1] 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0
 
 # Now recalculate using spectrum
 sp - spectrum(x, taper = 0, detrend = FALSE)
 
 # Note the power concentrated at sp$freq[4]=.125 in sp$spec[4].
 # Note that the fft version returns the mean in element 1 so element 2
 # of the fft version corresponds to element 1 of the spectrum version.
 # Also in comparing we see that the spectrum version omits the symmetric 
 # completion of the first half.
 round(sp$spec,2)
 [1] 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0
 sp$freq
 [1] 0.03125 0.06250 0.09375 0.12500 0.15625 0.18750 0.21875 0.25000 0.28125
[10] 0.31250 0.34375 0.37500 0.40625 0.43750 0.46875 0.5
 1/sp$freq
 [1] 32.00 16.00 10.67  8.00  6.40  5.33  4.571429
 [8]  4.00  3.56  3.20  2.909091  2.67  2.461538  2.285714
[15]  2.13  2.00
 
 # sum of squares vs. sum of periodogram values.
 # Note that power defined as sum of squares of demeaned series
 # equals twice sum of periodogram values returned by spectrum 
 # (since spec.pgram does not return the half that is the same 
 # by symmetry)
 sum(x*x)
[1] 16
 sum(sp$spec)
[1] 8



Date:   Fri, 15 Oct 2004 19:55:40 -0400 
From:   Giuseppe Pagnoni [EMAIL PROTECTED]
To:   [EMAIL PROTECTED] 
Subject:   [R] power in a specific frequency band 

 
Dear R users

I have a really simple question (hoping for a really simple answer :-):

Having estimated the spectral density of a time series x (heart rate 
data) with:

x.pgram - spectrum(x,method=pgram)

I would like to compute the power in a specific energy band.

Assuming that frequency(x)=4 (Hz), and that I am interested in the band 
between f1 and f2, is the power in the band simply the following?

sum(x.pgram$spec[(x.pgram$freq  f1/frequency(x))  (x.pgram$freq = 
f2/frequency(x))])

If it is so, are the returned units the same units as the original time 
series, but squared (if x is bpm, then the power is in bpm^2)?

I own a copy of Venables and Ripley (MASS 2003), but I was not able to 
extract this information from the time series chapter


thanks for any help
(please cc to my e-mail, if possible)


giuseppe





Giuseppe Pagnoni
Dept. Psychiatry and Behavioral Sciences
Emory University
1639 Pierce Drive, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233

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


[R] returning parameter values by CoCo

2004-10-16 Thread assuncao . senra

Hello,
as anyone used CoCo?
I used 'backward' function to find a loglinear model for my data, wich I did. 
Now I´m trying to get the estimates of the parameters of the model. I 
tried 'returnExpression' but I can´t understand the output. Besides the same 
model I get the value TRUE.
Can someone explain me?
Thanks in advance.
Assunção

__
Email gratuito com 2 000 MB
Espaço para guardar 20 anos de correio
http://www.portugalmail.pt/2000mb

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


Re: [R] Lazy loading... advices

2004-10-16 Thread Martin Maechler
 UweL == Uwe Ligges [EMAIL PROTECTED]
 on Sat, 16 Oct 2004 18:31:29 +0200 writes:

UweL Philippe Grosjean wrote:
 Hello,
 
 I am looking for more information about lazy loading
 introduced in R 2.0.0.  Doing ?lazyLoad I got some and
 there is a 'see also' section that points to
 'makeLazyLoading'... But I cannot reach this page.
 
 My problem is: I recompiled a library

UweL Philippe,

UweL citing Doug Bates: Someone named Martin Maechler will
UweL shortly be sending you email regarding the distinction
UweL between 'library' and 'package'. ;-)

of course, now I have to  

Note that library(package) attaches and loads a *package* from
one of possibly several libraries { = the directories listed,
e.g., by .libPaths() !} 

 that uses a lot of functions from other libraries (of
 course I can give details if needed). I load it in my
 computer: library(svGUI), and it takes something like 20
 seconds to load. In R 1.9.1 it took 3-4 seconds on the
 same machine (Windows XP). So, I try now to understand
 the mechanism and to find a way to lower the loading time
 of this library with lazy loading (its goal is to load
 faster, isn't, so I probably do something wrong).

UweL It might not always be faster. See Brian Ripley's
UweL article in the most recent R Newsletter. Probably you
UweL are using a lot of functions in the startup directly
UweL after the call to library() (in .First.lib() or
UweL .onLoad() or Hooks or whatever).  I think you want to
UweL specify LazyLoad: no in the package's DESCRIPTION
UweL file (cp. Writing R Extensions).

I'm pretty sure the increased startup time comes from the very
long 'Depends:' field in Philippe's package.
I'd bet that -- after reading Brian's article -- Philippe will
find that he can make the 'Depends' much smaller, e.g., by
moving entries to 'Suggests'.

Martin

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


[R] Plotcorr: colour the ellipses to emphasize the differences

2004-10-16 Thread Gorjanc Gregor
Hello R users!

I began with R and I must say that it is really nice. I have data with a lot of 
variables
and have a problem to extract the pattern from correlation matrix. So I tried with 
plotcorr
and it went fine. While I was reading the help page of this function, I found that 
ellipse
display can be even better with use of different colors (the code is bellow). However 
I have
a problem to understand the process of generating the colors. The function cm.colors() 
with argument 11 produces scale of colors with 11 points. What is the meaning of [5*xc 
+ 6])? If I ommit this part from the code, I see that ellipses bellow diagonal do not 
have the same color as above the diagonal. In given example numbers 5 and 6 are given 
(I think so) since there are 11 variables in dataset mtcars. 

How can one use this setup for other datasets? For example I have a dataset with 15 
variables.

I would also like to know if it is possible to use some other scale of colors instead 
of cm.colors, rainbow, heat.colors, terrain.colors, topo.colors. I would like to have 
positive correlations in blue and nagative ones in red spectrum of colors. Is it 
possible?

Thank you!

# Colour the ellipses to emphasize the differences
corr.mtcars - cor(mtcars)
ord - order(corr.mtcars[1,])
xc - corr.mtcars[ord, ord]
plotcorr( xc, col=cm.colors(11)[5*xc + 6])


With regards, Lep pozdrav
Gregor GORJANC

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


[R] how to draw a multivariate function

2004-10-16 Thread Sun
Hi, Rusers:

Thanks for answering my last questions. I am frustrated in plotting a trinomial pmf 
function 

f(x,y | n, pa, pb) = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* 
pa^x * pb^y * ((1-pa-pb)^(n-x-y))

obviously it is a bivariate function of x and y. But I have put a lot of time on this.

**
x - seq(0, n, len = n/2+1) # for now I set it to n/2 to control x+y = n
y - seq(0, n, len = n/2+1)
f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x * pb^y * 
((1-pa-pb)^(n-x-y))
wireframe(f ~ x * y, shade = TRUE)
**

well, but it plots nothing out.

I wonder if you could help me? Seems R is hard to learn without your help.

Many thanks,

Sun
[[alternative HTML version deleted]]

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


Re: [R] how to draw a multivariate function

2004-10-16 Thread Spencer Graves
 Have you studied the documentation for wireframe including the 
examples?  See also the contour plot examples in Venables and Ripley 
(2002) Modern Applied Statistics with S, 4th ed. (Springer). 

 It might help if you write your function as follows: 

f - function(x,y ,n, pa, pb) (factorial(n)/
(factorial(x) * factorial(y) * factorial(n-x-y))*
 pa^x * pb^y * ((1-pa-pb)^(n-x-y)))
 I hope this fills in enough gaps that you will be able to complete 
the remaining steps. 

 Good luck.  spencer graves
Sun wrote:
Hi, Rusers:
Thanks for answering my last questions. I am frustrated in plotting a trinomial pmf function 

f(x,y | n, pa, pb) = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* 
pa^x * pb^y * ((1-pa-pb)^(n-x-y))
obviously it is a bivariate function of x and y. But I have put a lot of time on this.
**
x - seq(0, n, len = n/2+1) # for now I set it to n/2 to control x+y = n
y - seq(0, n, len = n/2+1)
f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x * pb^y * 
((1-pa-pb)^(n-x-y))
wireframe(f ~ x * y, shade = TRUE)
**
well, but it plots nothing out.
I wonder if you could help me? Seems R is hard to learn without your help.
Many thanks,
Sun
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

--
Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to draw a multivariate function

2004-10-16 Thread Sun
Hi, All:

Thanks. Here is the code

n = 30
lamdaa = 4
lamdab = 1.5

pa = lamdaa/n
pb = lamdab/n

x - seq(0, n/2, len = n/2+1)
y - seq(0, n/2, len = n/2+1)
f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x *
pb^y * ((1-pa-pb)^(n-x-y))
wireframe(f ~ x * y, shade = TRUE)

The above cannot show anything.
Just le t you know that now I changed to cloud, it can display something :)
cloud(f ~ x * y, shade = TRUE)

I have questions:

1.
what does x*y mean here? I don't think it is a vector dot multiplication. I
guess it will creat all rows of x and y for all possible combinations? Why
wireframe cannot show here?

2.
How to show the value on the cloud plot? I have no idea of how much the data
value is from the plot.

3. Where can I get resources of R? The help file seems not very helpful to
me. For example, the lm () function, its weighted least square option does
not say clearly the weight = standard deviation. It said it is to minimize
sum w*error^2, which mislead us to think it takes variance. I have to ask
experienced people. And everytime the answer depends on luck.

Thanks,

- Original Message - 
From: Andrew Ward [EMAIL PROTECTED]
To: Sun [EMAIL PROTECTED]
Sent: Saturday, October 16, 2004 10:15 PM
Subject: RE: [R] how to draw a multivariate function


 Dear Sun,

 Could you please provide an example that can be run
 by readers of the list? What you've given is
 missing at least n and pa.

 Regards,

 Andrew C. Ward,[EMAIL PROTECTED]
 Senior Analyst (Quantitative), Tel: +61 7 3864 0439
 Queensland Studies Authority,  Fax: +61 7 3229 3318
 295 Ann Street,
 Brisbane Qld 4000, Australia

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Sun
 Sent: Sunday, 17 October 2004 12:59 PM
 To: R-help mailing list
 Subject: [R] how to draw a multivariate function


 Hi, Rusers:

 Thanks for answering my last questions. I am frustrated in plotting a
trinomial pmf function

 f(x,y | n, pa, pb) = factorial(n)/ (factorial(x) * factorial(y) *
factorial (n-x-y))* pa^x * pb^y * ((1-pa-pb)^(n-x-y))

 obviously it is a bivariate function of x and y. But I have put a lot of
time on this.

 **
 x - seq(0, n, len = n/2+1) # for now I set it to n/2 to control x+y = n
 y - seq(0, n, len = n/2+1)
 f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x
* pb^y * ((1-pa-pb)^(n-x-y))
 wireframe(f ~ x * y, shade = TRUE)
 **

 well, but it plots nothing out.

 I wonder if you could help me? Seems R is hard to learn without your help.

 Many thanks,

 Sun
 [[alternative HTML version deleted]]

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
 ~~
 This email (including any attached files) is for the intended
 recipient(s) only. If you received this email by mistake, please,
 as a courtesy, tell the sender, then delete this email.

 The views and opinions are the originator's and do not necessarily
 reflect those of the Queensland Studies Authority. All reasonable
 precautions have been taken to ensure that this email contained no
 viruses at the time it was sent.




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


Re: [R] how to draw a multivariate function

2004-10-16 Thread Sun
Thanks, Spencer. Turing it into a function seems really to make difference.

Well but I don't know what is the difference between

data1 = cbind (x, y, f(x,y))
cloud(data1)

and

cloud(f(x,y) ~ x *y)?

They draw different plots. I don't know which one is correct. I am really
confused.

Here are codes:
n = 30
lamdaa = 4
lamdab = 1.5

pa = lamdaa/n
pb = lamdab/n

x - seq(0, n/2, len = n/2+1)
y - seq(0, n/2, len = n/2+1)
f - function(x,y) (factorial(n)/
 (factorial(x) * factorial(y) * factorial(n-x-y))*
  pa^x * pb^y * ((1-pa-pb)^(n-x-y)))

data1 = cbind (x, y, f(x,y))
cloud(data1)

cloud(f(x,y) ~ x *y)



Thanks a lot
- Original Message - 
From: Spencer Graves [EMAIL PROTECTED]
To: Sun [EMAIL PROTECTED]
Cc: R-help mailing list [EMAIL PROTECTED]
Sent: Saturday, October 16, 2004 11:06 PM
Subject: Re: [R] how to draw a multivariate function


   Have you studied the documentation for wireframe including the
 examples?  See also the contour plot examples in Venables and Ripley
 (2002) Modern Applied Statistics with S, 4th ed. (Springer).

   It might help if you write your function as follows:

 f - function(x,y ,n, pa, pb) (factorial(n)/
  (factorial(x) * factorial(y) * factorial(n-x-y))*
   pa^x * pb^y * ((1-pa-pb)^(n-x-y)))

   I hope this fills in enough gaps that you will be able to complete
 the remaining steps.

   Good luck.  spencer graves

 Sun wrote:

 Hi, Rusers:
 
 Thanks for answering my last questions. I am frustrated in plotting a
trinomial pmf function
 
 f(x,y | n, pa, pb) = factorial(n)/ (factorial(x) * factorial(y) *
factorial (n-x-y))* pa^x * pb^y * ((1-pa-pb)^(n-x-y))
 
 obviously it is a bivariate function of x and y. But I have put a lot of
time on this.
 
 **
 x - seq(0, n, len = n/2+1) # for now I set it to n/2 to control x+y = n
 y - seq(0, n, len = n/2+1)
 f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))* pa^x
* pb^y * ((1-pa-pb)^(n-x-y))
 wireframe(f ~ x * y, shade = TRUE)
 **
 
 well, but it plots nothing out.
 
 I wonder if you could help me? Seems R is hard to learn without your
help.
 
 Many thanks,
 
 Sun
  [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
 
 

 -- 
 Spencer Graves, PhD, Senior Development Engineer
 O:  (408)938-4420;  mobile:  (408)655-4567




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


Re: [R] how to draw a multivariate function

2004-10-16 Thread Deepayan Sarkar
On Saturday 16 October 2004 23:12, Sun wrote:
 Hi, All:

 Thanks. Here is the code

 n = 30
 lamdaa = 4
 lamdab = 1.5

 pa = lamdaa/n
 pb = lamdab/n

 x - seq(0, n/2, len = n/2+1)
 y - seq(0, n/2, len = n/2+1)

Have you looked at what values of x and y these produce? They include 
non-integer values. Are you sure you want that?

 f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))*
 pa^x * pb^y * ((1-pa-pb)^(n-x-y))
 wireframe(f ~ x * y, shade = TRUE)

 The above cannot show anything.
 Just le t you know that now I changed to cloud, it can display
 something :) cloud(f ~ x * y, shade = TRUE)

 I have questions:

 1.
 what does x*y mean here? I don't think it is a vector dot
 multiplication. I guess it will creat all rows of x and y for all
 possible combinations? Why wireframe cannot show here?

Why guess instead of reading the documentation and looking at the 
examples? There's a very relevant example in the help page for 
wireframe.

You clearly want to evaluate 'f' at all combinations of x and y, yet you 
seem to be evaluating it only along the diagonal (x = y). The correct 
way to do this is (as studying the examples should have suggested to 
you):

g - expand.grid(x = seq(0, n), y = seq(0, n))
g$z - dtrinom(g$x, g$y)
wireframe(z ~ x * y, data = g, shade = TRUE)

where dtrinom could be defined as 

dtrinom - function(x, y)
{
ifelse(x + y  n,
   NA,
   factorial(n)/ (factorial(x) * 
   factorial(y) * factorial (n-x-y))*
   pa^x * pb^y * ((1-pa-pb)^(n-x-y)))
}

although I would suggest working on the log scale for numerical 
stability:

dtrinom - function(x, y)
{
ifelse(x + y  n,
   NA,
   exp((lfactorial(n) - lfactorial(x) -
lfactorial(y) - lfactorial(n-x-y)) + 
   x * log(pa) +  y * log(pb) +
   (n-x-y) * log(1-pa-pb)))
}


 2.
 How to show the value on the cloud plot? I have no idea of how much
 the data value is from the plot.

Read the documentation for the 'scales' argument.

 3. Where can I get resources of R? The help file seems not very
 helpful to me. For example, the lm () function, its weighted least
 square option does not say clearly the weight = standard deviation.
 It said it is to minimize sum w*error^2, which mislead us to think it
 takes variance. I have to ask experienced people. And everytime the
 answer depends on luck.

It's too bad you feel that way. Statistics, and in particular linear 
modeling, is a non-trivial subject, and R documentation is not supposed 
to serve as a textbook. If you don't understand what minimizing 
'sum(w*e^2)' means, you really do need help from 'experienced people'. 
Alternatively, look at the references listed in the help page for lm.

Hope that helps,

Deepayan



 Thanks,

 - Original Message -
 From: Andrew Ward [EMAIL PROTECTED]
 To: Sun [EMAIL PROTECTED]
 Sent: Saturday, October 16, 2004 10:15 PM
 Subject: RE: [R] how to draw a multivariate function

  Dear Sun,
 
  Could you please provide an example that can be run
  by readers of the list? What you've given is
  missing at least n and pa.

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


Re: [R] how to draw a multivariate function

2004-10-16 Thread Sun
Hi, Thanks. But minimizing
 'sum(w*e^2)'

means w is the variance instead of the standard deviation. However, the
truth is that R takes standard deviation. R will square it!

R-help document is not that to be proud of. It is not very clear or helpful
sometimes.


- Original Message - 
From: Deepayan Sarkar [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: Sun [EMAIL PROTECTED]; Andrew Ward [EMAIL PROTECTED]
Sent: Sunday, October 17, 2004 12:04 AM
Subject: Re: [R] how to draw a multivariate function


 On Saturday 16 October 2004 23:12, Sun wrote:
  Hi, All:
 
  Thanks. Here is the code
 
  n = 30
  lamdaa = 4
  lamdab = 1.5
 
  pa = lamdaa/n
  pb = lamdab/n
 
  x - seq(0, n/2, len = n/2+1)
  y - seq(0, n/2, len = n/2+1)

 Have you looked at what values of x and y these produce? They include
 non-integer values. Are you sure you want that?

  f = factorial(n)/ (factorial(x) * factorial(y) * factorial (n-x-y))*
  pa^x * pb^y * ((1-pa-pb)^(n-x-y))
  wireframe(f ~ x * y, shade = TRUE)
 
  The above cannot show anything.
  Just le t you know that now I changed to cloud, it can display
  something :) cloud(f ~ x * y, shade = TRUE)
 
  I have questions:
 
  1.
  what does x*y mean here? I don't think it is a vector dot
  multiplication. I guess it will creat all rows of x and y for all
  possible combinations? Why wireframe cannot show here?

 Why guess instead of reading the documentation and looking at the
 examples? There's a very relevant example in the help page for
 wireframe.

 You clearly want to evaluate 'f' at all combinations of x and y, yet you
 seem to be evaluating it only along the diagonal (x = y). The correct
 way to do this is (as studying the examples should have suggested to
 you):

 g - expand.grid(x = seq(0, n), y = seq(0, n))
 g$z - dtrinom(g$x, g$y)
 wireframe(z ~ x * y, data = g, shade = TRUE)

 where dtrinom could be defined as

 dtrinom - function(x, y)
 {
 ifelse(x + y  n,
NA,
factorial(n)/ (factorial(x) *
factorial(y) * factorial (n-x-y))*
pa^x * pb^y * ((1-pa-pb)^(n-x-y)))
 }

 although I would suggest working on the log scale for numerical
 stability:

 dtrinom - function(x, y)
 {
 ifelse(x + y  n,
NA,
exp((lfactorial(n) - lfactorial(x) -
 lfactorial(y) - lfactorial(n-x-y)) +
x * log(pa) +  y * log(pb) +
(n-x-y) * log(1-pa-pb)))
 }


  2.
  How to show the value on the cloud plot? I have no idea of how much
  the data value is from the plot.

 Read the documentation for the 'scales' argument.

  3. Where can I get resources of R? The help file seems not very
  helpful to me. For example, the lm () function, its weighted least
  square option does not say clearly the weight = standard deviation.
  It said it is to minimize sum w*error^2, which mislead us to think it
  takes variance. I have to ask experienced people. And everytime the
  answer depends on luck.

 It's too bad you feel that way. Statistics, and in particular linear
 modeling, is a non-trivial subject, and R documentation is not supposed
 to serve as a textbook. If you don't understand what minimizing
 'sum(w*e^2)' means, you really do need help from 'experienced people'.
 Alternatively, look at the references listed in the help page for lm.

 Hope that helps,

 Deepayan


 
  Thanks,
 
  - Original Message -
  From: Andrew Ward [EMAIL PROTECTED]
  To: Sun [EMAIL PROTECTED]
  Sent: Saturday, October 16, 2004 10:15 PM
  Subject: RE: [R] how to draw a multivariate function
 
   Dear Sun,
  
   Could you please provide an example that can be run
   by readers of the list? What you've given is
   missing at least n and pa.

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


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


Re: [R] problem with axis labels

2004-10-16 Thread Martin Maechler
 Paul == Paul Stansell [EMAIL PROTECTED]
 on Sat, 16 Oct 2004 19:19:42 +0100 (BST) writes:

Paul Dear R users,

Paul Below are some R commands which produce a y-axis label
Paul that is not wholly in the viewing area of the eps file
Paul (or the x11 window).

yes, that has almost nothing to do with the specific device

   label-expression(italic(A)==union(italic(H)[italic(i)],i==1,4))
   postscript(labelBug.eps,onefile=F,height=5,width=5,pointsize=12)
   plot(1,1,xlab=label,ylab=label) 
   dev.off()

Paul I have tried experimenting with the postscript
Paul bounding box, and using such R commands as
Paul over(phantom(0),...) but I make the whole y-label
Paul visible.

Paul Does anyone have any suggestions for how I may fix this. 

yes. You have to use a larger left margin (i.e. margin # 2),
see the 'mar' section in  help(par),
and also re-read the part on graphics in the Introduction to R
manual.

The following will look better {independently of the device,
postscript, X11, windows,...}:

  label - expression(italic(A) == union(italic(H)[italic(i)],i==1,4))
  op - par(mar = .1 + c(5,5,4,1))
  plot(1,1, xlab=label, ylab=label) 
  par(op)# to reset the graphics settings to the defaults

Martin

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