Re: [R] R Book Advice Needed

2007-06-14 Thread Alain Reymond
Cody,

I plan to use it in life sciences. We use of course basic descriptive
statistics but also classification using ACP and CAH (French
abbreviation for Principal Component Analysis and Hierarchical Cluster
Analysis). We also use logistic regression for classifying some results
of clinical laboratory analyses.

In fact, I have been a user of SPSS for - quite - a long time. The price
of the licences are increasing and it becomes a problem for us (many
thousand of euros). I am the only user and don't work with the programs
on a daily basis. So - I confess - I am investigating R. And I am more
and more convinced by the possibilities it offers.

Regards.

Alain

[EMAIL PROTECTED] a écrit :
 Alain,

 Can you tell us what you plan to use R for?

 Regards,
 -Cody

 [EMAIL PROTECTED] a écrit :
   
 I am new to using R and would appreciate some advice on
 which books to start with to get up to speed on using R.
 ...cut...
 
-- 
Alain Reymond
CEIA
Bruxelles

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Annotating trellis graphics

2007-06-14 Thread Alan S Barnett
I'm using xyplot to generate a trellis plot with each panel containing a
scatterplot and a best fit line.  Is it possible to write the slope of
the best fit line in each panel?
-- 
Alan S Barnett [EMAIL PROTECTED]
NIMH/CBDB

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Panel data

2007-06-14 Thread Stefan Grosse
Panel data is that you have e.g. several subjects 
(=individuals,firms,households) being tracked over a certain time (meaning 
there are repeated observations). One could roughly say that it is a 
collection of (quite similiar) time series. This makes the analysis better 
than pooling the whole set but it needs certain econometric tools. 

An example would be estimating wage elasticities.

Time series analysis usually just involves one subject (interest rates, share 
prices etc.) over some time.

Standard books on panel data analysis are also Baltagi: econometric analysis 
of panel data and Wooldridge: econometric analysis of cross sectional and 
panel data. Both are not introductionary texts since you do not know the 
difference between time series and panel data maybe you should start with an 
introductionary econometrics book like Wooldridge introductory econometrics 
or Verbeek: modern econometrics.

Stefan

on Thursday 14 June 2007 07:33:05 Megh Dal wrote:
MD  Then what is the difference between panel data and time series data? You
 said panel data is data on same subject being tracked over time. But time
 series data also do the same. Please correct me if I am wrong. MD 

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Panel data

2007-06-14 Thread Prof Brian Ripley
On Wed, 13 Jun 2007, Megh Dal wrote:

 Then what is the difference between panel data and time series data? You 
 said panel data is data on same subject being tracked over time. But 
 time series data also do the same. Please correct me if I am wrong.

Panel data is about several subjects being tracked over time, so gives a 
series of related time series.  It also known as 'longitudinal data' or 
'repeated measures' (perhaps with slightly different emphases).

If the observation times were the same for all subjects a vector AR 
(presumably the one of several senses of 'VAR' being used) could be used, 
but conventional analyses are via mixed/GEE models (and in simple cases 
these reduce to a nested anova).

There are examples in MASS and in Diggle, Hegarty, Liang and Zeger (cited 
there).


 - Original Message 
 From: Leeds, Mark (IED) [EMAIL PROTECTED]
 To: Megh Dal [EMAIL PROTECTED]
 Sent: Wednesday, June 13, 2007 8:30:18 PM
 Subject: RE: [R] Panel data


 not as far as I know. Panel data is quite specific in that it's the
 same subject being tracked over time.
 A VAR doesn't take advantage of this and doesn't make that assumption
 and I don't think it's applicable to
 Your problem. I think there is a book by
 Hsaio on panel data and possibly another one by Arellano ( spelling )
 but I'm not sure what's available in R for doing panel
 data estimation. I've never done it. Maybe do a search for panel data
 on the search engine and something may come up ?



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Megh Dal
 Sent: Tuesday, June 12, 2007 12:12 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Panel data

 Dear all R users,

 I have a small doubt about panel data analysis. My basic understanding
 on Panel data is a type of data that is collected over time and
 subjects. Vector Autoregressive Model (VAR) model used on this type of
 data. Therefore can I say that, one of statistical tools used for
 analysis of panel data is VAR model? If you clarify my doubt I will be
 very grateful.

 Thanks and regards,
 Megh





 
 
 Looking for earth-friendly autos?
 Browse Top Cars by Green Rating at Yahoo! Autos' Green Center.

[[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

 This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] extractor rows from a matrix

2007-06-14 Thread billycorg

thanks for the answer..but i don't find what i'm looking for!

now i'm trying to expose better my problem:
i have:

ht= a 1096rows x 3 columns matrix 
 
i'd like a function like this:
 
d[i]=rbind(ht[i,]) for (i in 1:length(ht))

but this don't work :(
can anyone seriously help  me?
-- 
View this message in context: 
http://www.nabble.com/extractor-rows-from-a-matrix-tf3913088.html#a4923
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Responding to a posting in the digest

2007-06-14 Thread Moshe Olshansky
Is there a convenient way to respond to a particular
posting which is a part of the digest?  
I mean something that will automatically quote the
original message, subject, etc.

Thank you!

Moshe Olshansky
[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Formatted Data File Question for Clustering -Quickie Project

2007-06-14 Thread Vladimir Eremeev

The R Data Import/Export guide was mentioned already, it contains
everything you should know about data exchange between R and other software.

In case it says nothing about dates, try as.Date() and strftime().
For your example below,
  as.Date(1/31/1994,format=%m/%d/%Y)
works.


ngottlieb wrote:
 
 I am trying to learn how to format Ascii data files for scan or read
 into R.
 
 Precisely for a quickie project, I found some code (at end of this
 email) to do exactly what I need:
 To cluster and graph a dendrogram from package (stats).
 
 I am stuck on how to format a text file to run the script.
 I looked at the dataset USArrests (which would be replaced by my data
 and labels) using UltraEdit. That data appears to be in binary format
 and I would simply like a readable ASCII text file.
 
 How can I:
 A) format this data to a file for the script below? 
 B) I would like to use squared Euclidean distance, can hclust support
 this?
 
 Thanks,
 Neil Gottlieb
 
 Here is sub-set example of my data set, return series to cluster: 13
 cases by 36 observations):
 Month   Convertible Arbitrage   Dedicated Short BiasEmerging
 Markets   
 1/31/1994 0.004   -0.016  0.105   
 2/28/1994 0.002   0.020   -0.011  
 3/31/1994 -0.010  0.072   -0.046  
 
 [skip]
 

-- 
View this message in context: 
http://www.nabble.com/Formatted-Data-File-Question-for-Clustering--Quickie-Project-tf3915926.html#a5436
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Read Windows-like .INI files into R data structure?

2007-06-14 Thread Christophe Pallier
On 6/14/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 Here is yet another solution.  This is the simplest so far.
 Lines.raw is as before and the output is a 3 column character
 matrix.

section - 
 f - function(x) {
 if (length(x) == 1) section - gsub([\\[\\]], , x)
 if (length(x) = 1) return()
 return(c(x, section))
 }
 # Lines - readLines(myfile.ini)
 Lines - readLines(textConnection(Lines.raw))
 do.call(rbind, lapply(strsplit(Lines, =), f))



The corresponding awk code fits in one line '/\[/{a=$1;next}{print
$1,$2,a}'.

With the example.ini:

$ awk -F= '/\[/{a=$1;next}{print $1,$2,a}' example.ini
var1 value1 [Section1]
var2 value2 [Section1]
A value3 [Section2]
B value4 [Section2]

The output can then be imported in R with read.table.

I know, I am not playing by the rules here... :)
But with programming languages, like with human languages, it pays to be bi
or tri-lingual (or polyglot, if one can).

I also realise that under Windows, it means using the command line,
something that  not so many people are comfortable with nowadays.

One reason people insist on using only one language to do everything may be
due to the awkwardness and limitations of the default scripting language
under Windows (DOS). Having everything done inside one single R script can
seem simpler. But a divide-and-conquer approach, with a few small scripts,
can actually work better in some complex cases.

I tend to do as much as possible in R but for all serious data analysis
tasks, I use Makefile to glue the various stages of processing. Data
preprocessing stages (performed with R or other tools) create files that are
then processed with R. One advantage is that preprocessing is performed only
when raw input data change; but the most important, is that when I come back
years later, I can follow the exact flow of transformations.
Again, make  (like awk  or R) is not without limits and idiosyncrasies. If
someone has a simpler solution, I am interested to hear about it.

Christophe





-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Read Windows-like .INI files into R data structure?

2007-06-14 Thread Christophe Pallier
Ah! I forgot to mention that it is possible to call awk from R:

a - system(awk -F'=' '/\\[/{a=$1;next}{print $1,$2,a}' example.ini,
intern=T)
z - textConnection(a)
read.table(z)


Christophe


On 6/14/07, Christophe Pallier [EMAIL PROTECTED] wrote:

 On 6/14/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 
  Here is yet another solution.  This is the simplest so far.
  Lines.raw is as before and the output is a 3 column character
  matrix.

 section - 
  f - function(x) {
  if (length(x) == 1) section - gsub([\\[\\]], , x)
  if (length(x) = 1) return()
  return(c(x, section))
  }
  # Lines - readLines(myfile.ini)
  Lines - readLines(textConnection(Lines.raw))
  do.call(rbind, lapply(strsplit(Lines, =), f))



 The corresponding awk code fits in one line '/\[/{a=$1;next}{print
 $1,$2,a}'.

 With the example.ini:

 $ awk -F= '/\[/{a=$1;next}{print $1,$2,a}' example.ini
 var1 value1 [Section1]
 var2 value2 [Section1]
 A value3 [Section2]
 B value4 [Section2]

 The output can then be imported in R with read.table.

 I know, I am not playing by the rules here... :)
 But with programming languages, like with human languages, it pays to be
 bi or tri-lingual (or polyglot, if one can).

 I also realise that under Windows, it means using the command line,
 something that  not so many people are comfortable with nowadays.

 One reason people insist on using only one language to do everything may
 be due to the awkwardness and limitations of the default scripting language
 under Windows (DOS). Having everything done inside one single R script can
 seem simpler. But a divide-and-conquer approach, with a few small scripts,
 can actually work better in some complex cases.

 I tend to do as much as possible in R but for all serious data analysis
 tasks, I use Makefile to glue the various stages of processing. Data
 preprocessing stages (performed with R or other tools) create files that are
 then processed with R. One advantage is that preprocessing is performed only
 when raw input data change; but the most important, is that when I come back
 years later, I can follow the exact flow of transformations.
 Again, make  (like awk  or R) is not without limits and idiosyncrasies.
 If someone has a simpler solution, I am interested to hear about it.

 Christophe





 --
 Christophe Pallier ( http://www.pallier.org)




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ARIMA with more than one seasonality period

2007-06-14 Thread Paulo Tanimoto
Dear R community,

I have a project with electricity load forecasting, and I got hourly
data for system load.  If you haven't worked with electricity before,
seasonality comes in many flavors: a daily pattern, with a peak at
around 7pm; a weekly pattern, in which we use more electricity on
weekdays in comparison to weekends; a winter-summer pattern, with air
conditioning and heaters playing an important role, etc.

In SAS, I could specify an ARIMA with multiple seasonality terms, say
(1,0,1) with period=24, and (1,0,1) with period=168 (I don't remember
the orders I was using).  This is how many studies I found on IEEE
were modeling electricity load and it worked pretty well with the data
I have.

However, I can't seem to find how to do that in R.  I've read the help
files a few times, but to no avail. Is it possible?  I hope I'm
missing something straightforward.

Thank you,

Paulo Tanimoto
University of Arizona

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] extractor rows from a matrix

2007-06-14 Thread Petr Klasterecky
billycorg napsal(a):
 thanks for the answer..but i don't find what i'm looking for!
 
 now i'm trying to expose better my problem:
 i have:
 
 ht= a 1096rows x 3 columns matrix 
  
 i'd like a function like this:
  
 d[i]=rbind(ht[i,]) for (i in 1:length(ht))
 
 but this don't work :(
 can anyone seriously help  me?

The problem is that people actually are trying to seriously help you, 
but it is really difficult from your queries...

Please specify what you expect to be your output - a vector where you 
just paste the rows of of the original matrix one by one?
If so, you can do
d - t(ht)
dim(d) - NULL

or (a 'dirty' way)
d - c(t(ht))

It is not at all clear what your statement should do. For example, what 
is length(ht) with ht being a matrix? For R it is the total number of 
elements, but did you mean this or the number of rows/columns??

The suggestion to read R-Intro is the best advice you got here.

Petr

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] make sample() faster

2007-06-14 Thread Rainer M. Krug
Hi

I have a simulation which is relatively slow. I used Rprofile() and 
identified the calls to sample() as the culprit is sample():

  summaryRprof(Documents/PostDoc/Aloe_Pillansii/R/create.out)
$by.self
   self.time self.pct total.time total.pct
sample   1.30 44.2   1.52  51.7
ifelse   0.46 15.6   2.44  83.0
.
.
.

I am using sample() as follow:
result - sample(
  x=d.growth.seedling$growth,
  size=1,
  prob=d.growth.seedling$p,
  replace
  )

d.growth.seedling$p and d.growth.seedling$growth have a length of 1024 
and are calculated initially by using density().

My question: is there any way to make this faster, i.e. replace sample() 
as I use it with another faster algorithm (if necessary implemented in C)?

Thanks in advance,

Rainer

-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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
and provide commented, minimal, self-contained, reproducible code.


[R] Difference between prcomp and cmdscale

2007-06-14 Thread michael watson \(IAH-C\)
I'm looking for someone to explain the difference between these
procedures.  The function prcomp() does principal components anaylsis,
and the function cmdscale() does classical multi-dimensional scaling
(also called principal coordinates analysis).

My confusion stems from the fact that they give very similar results:

my.d - matrix(rnorm(50), ncol=5)
rownames(my.d) - paste(c, 1:10, sep=)
# prcomp
prc - prcomp(my.d)
# cmdscale
mds - cmdscale(dist(my.d))
cor(prc$x[,1], mds[,1]) # produces 1 or -1
cor(prc$x[,2], mds[,2]) # produces 1 or -1

Presumably, under the defaults for these commands in R, they carry out
the same (or very similar) procedures?

Thanks
Mick

The information contained in this message may be confidentia...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to set degrees of freedom in cor.test?

2007-06-14 Thread Florence Dufour

Hello,

I want to compute a correlation test but I do not want to use the
degrees of freedom that are calculated by default but I want to set a
particular number of degrees of freedom.
I looked in the manual, different other functions but I did not found
how to do it

Thanks in advance for your answers

Yours




Florence Dufour
PhD Student
AZTI Tecnalia - Spain

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Responding to a posting in the digest

2007-06-14 Thread Ted Harding
On 14-Jun-07 07:26:26, Moshe Olshansky wrote:
 Is there a convenient way to respond to a particular
 posting which is a part of the digest?  
 I mean something that will automatically quote the
 original message, subject, etc.
 
 Thank you!
 
 Moshe Olshansky
 [EMAIL PROTECTED]

This will depend on two things.

1. Whether the mail software you use has the capability;
2. Whether the digest format would permit it anyway.

Regarding (2), if you are receiving R-help in traditional
digest format (all the messages, each with its principal
headers, as one single long message-body), then the only
way to respond to a particular message is to start to
compose a new message and copy what you need from the digest.

While I've never reveived R-help in digest format myself,
according to Martin Maechler:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59429.html

  Please open the URL at the end of every message
 https://stat.ethz.ch/mailman/listinfo/r-help
  go to the bottom and log in -- clicking the
  [Unsubscribe or Edit Options] field. You need your
  mailing list password sooner or later. The one you
  get sent every 1st of the month; or you can have it
  sent to you again.

  Then you are in a page entitled
 R-help Membership Configuration for foo@bar
  Scroll down to the section
 Your R-help Subscription
  where the 3rd entry is entitled
 Get MIME or Plain Text Digests?
  and now you want MIME. 

In MIME digest format, each message with its own main headers
is a separate MIME attachment, and suitable mail software can
bring any message up on its own, You can then reply in the
normal way.

However (and here is where I'm ignorant as a result of never
having received R-help as digest), your reply may not continue
the thread -- since this depends on message-identifier headers
being present which allow threading software to trace which
messages are replies to which message. The JISCMAIL MIME digest
for the AllStat mailing list only includes a Message-ID for the
digest as a whole, i.e. the ID for the entire digest message.
Message-IDs for the individual messages in the digest (as would
be seen by people who received them singly) are absent: you only
get the likes of

  Date:DoW, DD Mon  HH:MM:SS TZ
  From:Sender (person who sent the message to the list)
  Subject: Subject of individual message
  MIME-Version: 1.0
  Content-Type: text/plain; charset=iso-8859-1
  Content-Transfer-Encoding: quoted-printable

and no Message ID for the original message from Sender. So any
reply to this component message is not identifiable as belonging
to its thread.

I don't know whether R-help's 'mailman'  provides such headers
(Martin??). If it does, then your reply could include an
In-Reply-To: which identifies the thread. Otherwise it can't.

As to (1), you will probably get several suggestions for suitable
mail software. My own (see below) opens an AllStat digest in a window
with attachment tags displayed, one for Tablf of Contents,
one for each message. Clicking on one of these opens a new window
with the message attached to that tag displayed, and now the usual
reply/forward etc mail sunctions can be applied to that message.
But it will reply only to the address given in the From: header
(i.e. the original sender, as above), not to the AllStat list
(so you have to enter that address by hand, if you want to reply
to the list).

In principle, mailer software could also identify the address of
the list from which the digest has been sent, as well as the sender
of the original message, so you could get the option to reply to
either or both. But my XFMail does not, and only offers the
original sender. Whether other mailer software can do this is
for others to comment on!

Hoping this helps,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 14-Jun-07   Time: 09:53:58
-- 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] A Question about R

2007-06-14 Thread M. P. Papadatos

Hi,

This might help you:

https://stat.ethz.ch/pipermail/r-help/2000-February/009984.html

Martin

On 11 Jun 2007, at 20:50, [EMAIL PROTECTED] wrote:


Hi Sir/Madam,

I'm a researcher in university of Guelph, Canada and now considering
using R to do some data analysis. I'm wondering whether there is a
library available in R that includes algorithms for archetypal
analysis? This is a method quite similar to principal components
analysis that is designed to find archetypes or pure types from
multidimensional data.

Any help from you is greatly appreciated.

Thanks
Juan

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

and provide commented, minimal, self-contained, reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using odesolve to produce non-negative solutions

2007-06-14 Thread Thomas Petzoldt
Dear Jeremy,

a few notes about your model: The equations of your derivatives are 
designed in a way that can lead to negative state variables with certain 
parameter combinations. In order to avoid this, you are using if 
constructions which are intended to correct this. This method is 
however (as far as I have learned from theory and own experience ;-) a 
bad idea and should be strictly avoided.

This trick may violate assumptions of the ODE solvers and in many cases 
also mass-balances (or similar).

Instead of this, processes should be modeled in a way that avoids 
crossing zero, e.g. exponential decay (x, k  0):

dx = - k * x  (1)

and not a linear decay like

dx = -k   (2)

which by its nature can lead to negative state values.

Case (1) can be managed almost perfectly by lsoda with his automatic 
internal time step algorithm. hmax is intended for non-autonomous models 
to ensure that external signals are not skipped by the automatism, which 
may be appropriate in your case because p seems to contain time 
dependent functions.

As far as I can see, your equations belong to type (1) and should not 
need any of the if and for constructs, as long as your parameters (which 
are not given in your post) do have the correct sign and range (for 
example, vax = 1, death = 0  etc.).

If you perform optimization, you must ensure that parameters stay in the 
plausible range is met using transformations of the parameters or 
constraints in the optimization procedure.

Thomas

PS: another question, what is the purpose of the state variable N?
I guess it can be derived from the other states.


Jeremy Goldhaber-Fiebert wrote:
 Hello,
 
 I am using odesolve to simulate a group of people moving through time
 and transmitting infections to one another.
 
 In Matlab, there is a NonNegative option which tells the Matlab
 solver to keep the vector elements of the ODE solution non-negative
 at all times. What is the right way to do this in R?
 
 Thanks, Jeremy

[... code deleted, see original post ...]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ML, REML and several random effects

2007-06-14 Thread Gregor
Arnaud Mosnier arnaud_mosnier at UQAR.QC.CA writes:
 Hello everyone,
 
 Hope that my question could have interest for more than one people here.
 I know that in order to compare mixed models with different fixed effect 
 I need to use ML method.
 But ... what about comparing models with the same fixed effects and 
 different random effects ?

Likelihood ratio test on REML likelihood

Gregor

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] extractor rows from a matrix

2007-06-14 Thread Petr Klasterecky
Well, you cannot have a vector of vectors, you need a list of vectors. 
With mean() and sum() it worked probably because these produce a single 
number as their output. Also, the rbind() function won't help here, that 
is for merging vector into a matrix. Once again, reading R-Intro is the 
best advice I can give you.

# creating an ampty list of length 1096:
d - list()
length(d) - 1096

# Filling the list with rows
for(i in (1:1096)){
d[[i]] - ht[i,]
}

Note the double bracketing when indexing lists: d[[1]]

Please respond to the entire list next time, I only read these messages 
occasionally.

Petr


vincenzo napsal(a):
 thank you a lot for the answer
  
 i don't expect one vector..
 but 1096 vector.
  
 example: ht=
123
 1  345
 2  458
 3
 4
 .
 .
 .
 1096 
  
 i'd like 1096 vector like these:
 d[1]= 345
 d[2]= 458
 ...
  
 i'm trying now with this:
 for(i in 1:1096) d[i]=(rbind(ht[i,])) 
 but it doesn't work :(
 it works with function like mean,sum.. but not with rbind
 what can i do?
  
  
  
 /---Messaggio originale---/
  
 /*Da:*/ Petr Klasterecky mailto:[EMAIL PROTECTED]
 /*Data:*/ 06/14/07 10:07:33
 /*A:*/ billycorg mailto:[EMAIL PROTECTED]
 /*Cc:*/ r-help@stat.math.ethz.ch mailto:r-help@stat.math.ethz.ch
 /*Oggetto:*/ Re: [R] extractor rows from a matrix
  
 billycorg napsal(a):
   thanks for the answer..but i don't find what i'm looking for!
  
   now i'm trying to expose better my problem:
   i have:
  
   ht= a 1096rows x 3 columns matrix
  
   i'd like a function like this:
  
   d[i]=rbind(ht[i,]) for (i in 1:length(ht))
  
   but this don't work :(
   can anyone seriously help  me?
  
 The problem is that people actually are trying to seriously help you,
 but it is really difficult from your queries...
  
 Please specify what you expect to be your output - a vector where you
 just paste the rows of of the original matrix one by one?
 If so, you can do
 d - t(ht)
 dim(d) - NULL
  
 or (a 'dirty' way)
 d - c(t(ht))
  
 It is not at all clear what your statement should do. For example, what
 is length(ht) with ht being a matrix? For R it is the total number of
 elements, but did you mean this or the number of rows/columns??
  
 The suggestion to read R-Intro is the best advice you got here.
  
 Petr
  
 --
 Petr Klasterecky
 Dept. of Probability and Statistics
 Charles University in Prague
 Czech Republic
  
 __ Informazione NOD32 2328 (20070613) __
  
 Questo messaggio  è stato controllato dal Sistema Antivirus NOD32
 http://www.nod32.it http://www.nod32.it/
  
  
   
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] installing packages

2007-06-14 Thread raymond chiruka
hie 
  
  how do l install R packages .L'm using windows xp.plus is there a  dipository 
for the packages that one can browse to find out what  packages are available.
  thanks.
  
 
-
Be a PS3 game guru.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] besselK

2007-06-14 Thread ivivi mwaniki
Assistance,
besselK- complex number problem
 Im a student  intrested in using R in my learning and research work in option 
pricing however i have a problem with besselK function In R.
 Would you assit me in computing the besselK of third kind of a complex number 
in R.
 Any code or suggestion will be highly appriceiated
 eg
 besselK(2,10)  works well.. but
 besselK(2,10i) doesnt work !!
 
 im supprised it works in MATLAB but NOT in R.
 rgds
 ivivi mwaniki
 student kenya

 
-
Don't pick lemons.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Research assistant in biostatistics in Copenhagen

2007-06-14 Thread Christian Ritz
The Statistics Group at the Department of Natural Sciences, Faculty of Life 
Sciences, 
University of Copenhagen, is looking for a research assistant with R skills.

For details see: http://www.matfys.kvl.dk/~torbenm/eu

Please note that the deadline for applications is June 22 2007.



Christian

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] pretty report

2007-06-14 Thread Gavin Kelly
At 5:01 PM -0400 6/12/07, Weiwei Shi wrote:
Dear Listers:

I have a couple of data frames to report and each corresponds to
different condtions, e.g. conditions=c(10, 15, 20, 25). In this
examples, four data frames need to be exported in a pretty report.

I knew Perl has some module for exporting data to Excel and after
googling, I found R does not.

Weiwei,

If you (or the users who are opening your reports) are going to using
a version of excel that supports the new Office XML formats, you can
write multi-sheeted workbooks as below: simply give spreadsheetML a
named list of dataframes.  You can add attributes to the components to
add things such as comments, subheadings that span multiple columns,
hyperlinks and named data-ranges.

If you can't guarantee that the opener won't have a modern Excel (I
don't believe Mac versions are yet at this stage), then you will need
to have a windows box to open the file, and save as 'proper' excel.
Below is a visual basic macro I have set up in a watched directory to
do this on the fly.  I use the program filenotify to watch the
directory.

If any of the package developers want to incorporate this function,
then please do get in touch.  It's probably not worth a package of
it's own, but I think the ability to have multi-sheeted excel books,
with the extra bits of formatting mentioned above might be useful.
I'ts fairly straightforward to add extra styling (colours, typefaces,
etc).

Regards - Gavin

###  The R function, and a demo
spreadsheetML - function(dat, fname, style=NULL) {
  if (is.data.frame(dat))
dat - list(Sheet1=dat)
  if (is.null(names(dat)))
names(dat) - paste(Sheet,1:length(dat), sep=)
  names(dat)[names(dat)==] - paste(Sheet,1:length(dat),
sep=)[names(dat)==]
  x - xmlOutputDOM(Workbook, nameSpace=ss,
nsURI=list(
  o=urn:schemas-microsoft-com:office:office,
  x=urn:schemas-microsoft-com:office:excel,
  ss=urn:schemas-microsoft-com:office:spreadsheet,
  html=http://www.w3.org/TR/REC-html40;))
  if (!is.null(style))
x$addNode(style)
### Annotate any named Ranges
  if (any(!is.null(lapply(dat, attr, range {
x$addTag(Names, close=FALSE)
for (sheet in names(dat)) {
  rngs - attr(dat[[sheet]],range)
  offset - ifelse(is.null(attr(dat[[sheet]],subhead)), 1, 2)
  for (i in names(rngs)) {
refersTo - sprintf(=%s!R%iC%i:R%iC%i,
sheet,
rngs[[i]]$rowStart+offset,
rngs[[i]]$colStart,
rngs[[i]]$rowEnd+offset,
rngs[[i]]$colEnd)
x$addTag(NamedRange, attrs=c(ss:Name=i,
 ss:RefersTo=refersTo))
  }
}
x$closeTag() #Names
  }
  for (sheet in 1:length(dat)) {
## For each dataframe, construct a worksheet
x$addTag(Worksheet, attrs=c(ss:Name=names(dat)[[sheet]]), close=FALSE)
x$addTag(Table,close=FALSE)
x$addTag(Row, close=FALSE)
## If there's a subheader, expand it, and remove entries from
relevant header
headRow - colnames(dat[[sheet]])
if (!is.null(subhead - attr(dat[[sheet]],subhead))) {
  subHeadRow - rep(, length(headRow))
  for (i in names(subhead)) {
start - match(i, headRow)
subHeadRow[start:(start+length(subhead[[i]])-1)] -
  subhead[[i]]
headRow[(start+1):(start+length(subhead[[i]])-1)] - 
  }
}
## Create Header Row, with comments
for (i in headRow) {
  x$addTag(Cell, close=FALSE)
  x$addTag(Data,i , attrs=c(ss:Type=String))
  if (!is.null(comment - attr(dat[[sheet]],xlComment)[[i]])) {
if (is.character(comment)) {
  x$addTag(Comment, attrs=c(ss:Author=BaBS), close=FALSE)
  x$addTag(Data, comment)
  x$closeTag() #Comment
}
  }
  x$closeTag() # Header entry
}
x$closeTag() # Header Row
## Create Sub-Header row, with comments
if (!is.null(subhead)) {
  x$addTag(Row, close=FALSE)
  for (i in 1:length(subHeadRow)) {
x$addTag(Cell, close=FALSE)
x$addTag(Data,subHeadRow[i] , attrs=c(ss:Type=String))
if (is.list(comment - attr(dat[[sheet]],xlComment)[[headRow[i]]])) {
  if (!is.null(comment - comment[[subHeadRow[i]]])) {
x$addTag(Comment, attrs=c(ss:Author=BaBS), close=FALSE)
x$addTag(Data, comment)
x$closeTag() #Comment
  }
}
x$closeTag()
  }
  x$closeTag() # subHeader Row
}
coltypes - rep(String, ncol(dat[[sheet]]))
coltypes[sapply(dat[[sheet]], is.numeric)] - Number
href - attributes(dat[[sheet]])$href
## Enter the data row-wise
for (i in 1:nrow(dat[[sheet]])) {
  x$addTag(Row, close=FALSE)
  for (j in 1:ncol(dat[[sheet]])) {
## Go through the row, expanding any hyperlinks
cellAttr - NULL
if (!is.na(ind - 

Re: [R] installing packages

2007-06-14 Thread John Kane
Menu  Packages  Install Packages 
works well for me.
--- raymond chiruka [EMAIL PROTECTED] wrote:

 hie 
   
   how do l install R packages .L'm using windows
 xp.plus is there a  dipository for the packages that
 one can browse to find out what  packages are
 available.
   thanks.
   
  
 -
 Be a PS3 game guru.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] extractor rows from a matrix

2007-06-14 Thread John Kane
I think I understand what you want.  Try

htt  data.frame(ht)
unlist (htt)


--- billycorg [EMAIL PROTECTED] wrote:

 
 thanks for the answer..but i don't find what i'm
 looking for!
 
 now i'm trying to expose better my problem:
 i have:
 
 ht= a 1096rows x 3 columns matrix 
  
 i'd like a function like this:
  
 d[i]=rbind(ht[i,]) for (i in 1:length(ht))
 
 but this don't work :(
 can anyone seriously help  me?
 -- 
 View this message in context:

http://www.nabble.com/extractor-rows-from-a-matrix-tf3913088.html#a4923
 Sent from the R help mailing list archive at
 Nabble.com.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Dates in Windows

2007-06-14 Thread Tom McCallum
Hi everyone,

When using R on Linux I can do the following:

 x - as.Date(01/04/2007, %d/%m/%Y);
 x
[1] 2007-04-01
 print(format(x, %s));
[1] 1175385600

When using R in Windows XP though the format %s does nothing but return  
a blank string.  How can I convert a date to the number of seconds since  
1970 in Windows?

Cheers

Tom

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Responding to a posting in the digest

2007-06-14 Thread Michael Dewey
At 08:26 14/06/2007, Moshe Olshansky wrote:
Is there a convenient way to respond to a particular
posting which is a part of the digest?
I mean something that will automatically quote the
original message, subject, etc.

Yes, if you use appropriate mailing software. I use Eudora, receive 
the emails in MIME format and the responses do get properly threaded 
as far as I can see from the mailing list archives.

Thank you!

Moshe Olshansky
[EMAIL PROTECTED]

Michael Dewey
http://www.aghmed.fsnet.co.uk

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] make sample() faster

2007-06-14 Thread Prof Brian Ripley
I think the problem is not sample (which is written in C), but that you 
are calling it with size=1.  Taking one sample with probabilities from a 
large discrete distribution is necessarily slow, but you can take a large 
sample for little more cost.

On Thu, 14 Jun 2007, Rainer M. Krug wrote:

 Hi

 I have a simulation which is relatively slow. I used Rprofile() and
 identified the calls to sample() as the culprit is sample():

  summaryRprof(Documents/PostDoc/Aloe_Pillansii/R/create.out)
 $by.self
   self.time self.pct total.time total.pct
 sample   1.30 44.2   1.52  51.7
 ifelse   0.46 15.6   2.44  83.0
 .
 .
 .

 I am using sample() as follow:
 result - sample(
  x=d.growth.seedling$growth,
  size=1,
  prob=d.growth.seedling$p,
  replace
  )

 d.growth.seedling$p and d.growth.seedling$growth have a length of 1024
 and are calculated initially by using density().

 My question: is there any way to make this faster, i.e. replace sample()
 as I use it with another faster algorithm (if necessary implemented in C)?

 Thanks in advance,

 Rainer



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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dates in Windows

2007-06-14 Thread Prof Brian Ripley
%s is of course not documented on ?strftime: it is a glibc extension and 
marked as such on my Linux man page.

But as.numeric(x) gives you the number of days, and
as.numeric(as.POSIXct(x)) gives you the number of seconds, equal to
86400*as.numeric(x).

[Why are you including empty commands at the end of every R line?
It is not necessary and makes the code harder to read.]


On Thu, 14 Jun 2007, Tom McCallum wrote:

 Hi everyone,

 When using R on Linux I can do the following:

 x - as.Date(01/04/2007, %d/%m/%Y);
 x
 [1] 2007-04-01
 print(format(x, %s));
 [1] 1175385600

 When using R in Windows XP though the format %s does nothing but return
 a blank string.  How can I convert a date to the number of seconds since
 1970 in Windows?

 Cheers

 Tom

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] extractor rows from a matrix

2007-06-14 Thread billycorg

Petr, it works!!!
thank you a lot!!!

Vincenzo


Petr Klasterecky wrote:
 
 Well, you cannot have a vector of vectors, you need a list of vectors. 
 With mean() and sum() it worked probably because these produce a single 
 number as their output. Also, the rbind() function won't help here, that 
 is for merging vector into a matrix. Once again, reading R-Intro is the 
 best advice I can give you.
 
 # creating an ampty list of length 1096:
 d - list()
 length(d) - 1096
 
 # Filling the list with rows
 for(i in (1:1096)){
 d[[i]] - ht[i,]
 }
 
 Note the double bracketing when indexing lists: d[[1]]
 
 Please respond to the entire list next time, I only read these messages 
 occasionally.
 
 Petr
 
 
 vincenzo napsal(a):
 thank you a lot for the answer
  
 i don't expect one vector..
 but 1096 vector.
  
 example: ht=
123
 1  345
 2  458
 3
 4
 .
 .
 .
 1096 
  
 i'd like 1096 vector like these:
 d[1]= 345
 d[2]= 458
 ...
  
 i'm trying now with this:
 for(i in 1:1096) d[i]=(rbind(ht[i,])) 
 but it doesn't work :(
 it works with function like mean,sum.. but not with rbind
 what can i do?
  
  
  
 /---Messaggio originale---/
  
 /*Da:*/ Petr Klasterecky mailto:[EMAIL PROTECTED]
 /*Data:*/ 06/14/07 10:07:33
 /*A:*/ billycorg mailto:[EMAIL PROTECTED]
 /*Cc:*/ r-help@stat.math.ethz.ch mailto:r-help@stat.math.ethz.ch
 /*Oggetto:*/ Re: [R] extractor rows from a matrix
  
 billycorg napsal(a):
   thanks for the answer..but i don't find what i'm looking for!
  
   now i'm trying to expose better my problem:
   i have:
  
   ht= a 1096rows x 3 columns matrix
  
   i'd like a function like this:
  
   d[i]=rbind(ht[i,]) for (i in 1:length(ht))
  
   but this don't work :(
   can anyone seriously help  me?
  
 The problem is that people actually are trying to seriously help you,
 but it is really difficult from your queries...
  
 Please specify what you expect to be your output - a vector where you
 just paste the rows of of the original matrix one by one?
 If so, you can do
 d - t(ht)
 dim(d) - NULL
  
 or (a 'dirty' way)
 d - c(t(ht))
  
 It is not at all clear what your statement should do. For example, what
 is length(ht) with ht being a matrix? For R it is the total number of
 elements, but did you mean this or the number of rows/columns??
  
 The suggestion to read R-Intro is the best advice you got here.
  
 Petr
  
 --
 Petr Klasterecky
 Dept. of Probability and Statistics
 Charles University in Prague
 Czech Republic
  
 __ Informazione NOD32 2328 (20070613) __
  
 Questo messaggio  è stato controllato dal Sistema Antivirus NOD32
 http://www.nod32.it http://www.nod32.it/
  
  
  
 
 
 -- 
 Petr Klasterecky
 Dept. of Probability and Statistics
 Charles University in Prague
 Czech Republic
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/extractor-rows-from-a-matrix-tf3913088.html#a7324
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] besselK

2007-06-14 Thread Robin Hankin
Hello

AFAIK, R has no capability for evaluating Bessel functions for  
complex arguments.

Bessel functions for complex arguments are difficult to evaluate  
numerically.
Some Bessel functions require cut lines or consideration of Riemann  
surfaces.

The GSL library (for which the gsl package is an R wrapper) does
not include such functionality although the issue has arisen
on the GSL email list a couple of times over the last few years.

Writing R functionality for Bessel functions (and in particular
the Airy function) is on my List of Things To Do, but
don't hold your breath  . . .

best wishes


Robin




On 14 Jun 2007, at 10:31, ivivi mwaniki wrote:

 Assistance,
 besselK- complex number problem
  Im a student  intrested in using R in my learning and research  
 work in option pricing however i have a problem with besselK  
 function In R.
  Would you assit me in computing the besselK of third kind of a  
 complex number in R.
  Any code or suggestion will be highly appriceiated
  eg
  besselK(2,10)  works well.. but
  besselK(2,10i) doesnt work !!

  im supprised it works in MATLAB but NOT in R.
  rgds
  ivivi mwaniki
  student kenya


 -
 Don't pick lemons.

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting- 
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] function with xyplot

2007-06-14 Thread Diego Gruber
Hi,

I'm a new user trying to switch from SAS, so sorry for the beginner's
question: Suppose I have a dataframe DF that contains variables X,Y,Z. I am
trying to write a function like this:

myplot - function(varname){xyplot(varname ~ Y, group = Z, data = DF)}.

The problem is then how to enter X into my function. If I write myplot(X)
I get an error because the argument is a string and xyplot can make nothing
out of it. If I write myplot(X) I also get an error that tells me the object
X does not exist.

Thanks for your help,

Diego

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Wilcoxon test on data matrix

2007-06-14 Thread Booman, M
Dear everyone,
I am trying to do a Wilcoxon one-sided test on my gene expression data.
These are the data i have in R:
data.matrix (matrix, numeric) containing all gene expression data (42 
rows=genes,  42 columns=tumors), no column header or row names
data.cl (vector, numeric) consisting of 42 0's and 1's to indicate class 0 or 
class 1 for each column in data.matrix

I want to do a Wilcoxon one-sided test on the data from class 0 versus the data 
from class 1, for each row (gene) of the data set.
My first try:

#to make separate matrices for both classes:
data.matrix.0 - data.matrix[,data.cl==0] 
data.matrix.1 - data.matrix[,data.cl==1]

# to run the wilcox.test function for each row:
rawp - apply(data.matrix.0, 1, wilcox.test, y=data.matrix.1, 
alternative=less)


The result of printing rawp is:
$`1`

Wilcoxon rank sum test with continuity correction

data:  newX[, i] and data.matrix.1 
W = 7585, p-value = 1
alternative hypothesis: true location shift is less than 0 


$`2`

Wilcoxon rank sum test with continuity correction

data:  newX[, i] and data.matrix.1 
W = 6700, p-value = 0.9983
alternative hypothesis: true location shift is less than 0 


Etcetera for each row of the data matrix. 
I can get the p value for one row (gene) using:
rawp.1 - rawp$'1'$p.value

But how can I get these p-values in one list? I have tried:
rawp - NULL
for (i in 1:42) {
a - paste(', i, ', sep=)
rawp - rbind(rawp, test$a$p.value)
 }

but that doesn't work (no errors but rawp stays NULL)

There must be an easier way to do a wilcoxon analysis on a matrix!
I'd appreciate your help with this...

Marije


De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de 
geadresseerde(n). Anderen dan de geadresseerde mogen geen gebruik maken van dit 
bericht, het openbaar maken of op enige wijze verspreiden of vermenigvuldigen. 
Het UMCG kan niet aansprakelijk gesteld worden voor een incomplete aankomst of 
vertraging van dit verzonden bericht.

The contents of this message are confidential and only intended for the eyes of 
the addressee(s). Others than the addressee(s) are not allowed to use this 
message, to make it public or to distribute or multiply this message in any 
way. The UMCG cannot be held responsible for incomplete reception or delay of 
this transferred message.
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Generating artificial datasets with a specific correlation coefficient.

2007-06-14 Thread James R. Milks
Thanks to all who responded to my request.  I'll probably use the  
corgen function in ecodist, as suggested by Sarah Goslee (below), as  
I just need examples of correlated vectors.

Thanks again.

Jim Milks

Graduate Student
Environmental Sciences Ph.D. Program
136 Biological Sciences
Wright State University
3640 Colonel Glenn Hwy
Dayton, OH 45435

Begin forwarded message:

 From: Sarah Goslee [EMAIL PROTECTED]
 Date: June 12, 2007 5:37:36 PM EDT
 To: James Milks [EMAIL PROTECTED]
 Subject: Re: [R] Generating artificial datasets with a specific  
 correlation coefficient.

 If you don't need anything fancy, just two vectors x and y
 such that cor(x, y) = 0.30 then the corgen function in
 ecodist (current version available from CRAN) does just that.

 Sarah

 On 6/12/07, James Milks [EMAIL PROTECTED] wrote:
 I need to create artificial datasets with specific correlation
 coefficients (i.e. a dataset that returns r = 0.30, etc.) as examples
 for a lab I am teaching this summer.  Is there a way to do that in R?

 Thanks.

 Jim Milks

 Graduate Student
 Environmental Sciences Ph.D. Program
 136 Biological Sciences
 Wright State University
 3640 Colonel Glenn Hwy
 Dayton, OH 45435




 -- 
 Sarah Goslee
 http://www.functionaldiversity.org


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] function with xyplot

2007-06-14 Thread John Kane
You need to reference the data.frame or append it.  

myplot(DF$X) should work
or 
append(DF)
myplot(X)
--- Diego Gruber [EMAIL PROTECTED] wrote:

 Hi,
 
 I'm a new user trying to switch from SAS, so sorry
 for the beginner's
 question: Suppose I have a dataframe DF that
 contains variables X,Y,Z. I am
 trying to write a function like this:
 
 myplot - function(varname){xyplot(varname ~ Y,
 group = Z, data = DF)}.
 
 The problem is then how to enter X into my function.
 If I write myplot(X)
 I get an error because the argument is a string and
 xyplot can make nothing
 out of it. If I write myplot(X) I also get an error
 that tells me the object
 X does not exist.
 
 Thanks for your help,
 
 Diego
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] test if files in current folder

2007-06-14 Thread Vladimir Eremeev



runner wrote:
 
 I want to test if the files are already in my current folder before I
 download or copy from somewhere else. What's in my mind is to check if a
 file is open-able in current folder. Is there a way to do this, like in
 Perl: 
 if (open()) { do sth}?
 
 To put it another way, how to extract all file names in a folder to an
 array or list? 
 

?files
?dir

BTW, Perl has nice -X functions, which allow file testing without explicit
opening:
 http://perldoc.perl.org/functions/-X.html
-- 
View this message in context: 
http://www.nabble.com/test-if-files-in-current-folder-tf3919587.html#a8347
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Wilcoxon test on data matrix

2007-06-14 Thread Christophe Pallier
   wilcox.test(data.matrix[i,] ~ data.cl)$p.value

will return the p.value for row 'i'.

With a loop:

   pv = rep(0,42)
   for (i in 1:42) { pv[i]=wilcox.test(data.matrix[i,] ~ data.cl)$p.value }

Is this what you wanted?

Christophe




On 6/14/07, Booman, M [EMAIL PROTECTED] wrote:

 Dear everyone,
 I am trying to do a Wilcoxon one-sided test on my gene expression data.
 These are the data i have in R:
 data.matrix (matrix, numeric) containing all gene expression data (42
 rows=genes,  42 columns=tumors), no column header or row names
 data.cl (vector, numeric) consisting of 42 0's and 1's to indicate class 0
 or class 1 for each column in data.matrix

 I want to do a Wilcoxon one-sided test on the data from class 0 versus the
 data from class 1, for each row (gene) of the data set.
 My first try:

 #to make separate matrices for both classes:
 data.matrix.0 - data.matrix[,data.cl==0]
 data.matrix.1 - data.matrix[,data.cl==1]

 # to run the wilcox.test function for each row:
 rawp - apply(data.matrix.0, 1, wilcox.test, y=data.matrix.1,
 alternative=less)


 The result of printing rawp is:
 $`1`

 Wilcoxon rank sum test with continuity correction

 data:  newX[, i] and data.matrix.1
 W = 7585, p-value = 1
 alternative hypothesis: true location shift is less than 0


 $`2`

 Wilcoxon rank sum test with continuity correction

 data:  newX[, i] and data.matrix.1
 W = 6700, p-value = 0.9983
 alternative hypothesis: true location shift is less than 0


 Etcetera for each row of the data matrix.
 I can get the p value for one row (gene) using:
 rawp.1 - rawp$'1'$p.value

 But how can I get these p-values in one list? I have tried:
 rawp - NULL
 for (i in 1:42) {
 a - paste(', i, ', sep=)
 rawp - rbind(rawp, test$a$p.value)
 }

 but that doesn't work (no errors but rawp stays NULL)

 There must be an easier way to do a wilcoxon analysis on a matrix!
 I'd appreciate your help with this...

 Marije


 De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de
 geadresseerde(n). Anderen dan de geadresseerde mogen geen gebruik maken van
 dit bericht, het openbaar maken of op enige wijze verspreiden of
 vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een
 incomplete aankomst of vertraging van dit verzonden bericht.

 The contents of this message are confidential and only intended for the
 eyes of the addressee(s). Others than the addressee(s) are not allowed to
 use this message, to make it public or to distribute or multiply this
 message in any way. The UMCG cannot be held responsible for incomplete
 reception or delay of this transferred message.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Tools For Preparing Data For Analysis

2007-06-14 Thread Ted Harding
As a tangent to this thread, there is a very relevant
article in the latest issue of the RSS magazine Significance,
which I have just received:

  Dr Fisher's Casebook
  The trouble with data

Significance, Vol 4 (2007) Issue 2.

Full current contents at

http://www.blackwell-synergy.com/toc/sign/4/2

but unfortunately you can only read any of it by paying
money to Blackwell (unless you're an RSS member).

Best wishes to all,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 14-Jun-07   Time: 12:24:46
-- 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
and provide commented, minimal, self-contained, reproducible code.


[R] building packages under windows

2007-06-14 Thread Cinzia Viroli

I tried to check or build a package under windows xp but I got the error

the package can not be installed

(without any details in the install.out file)

I work with R-2.5.0, Miktex 2.5.0, and I have installed the unix tools.zip, 
Perl and Microsoft HTML Workshop.
The path environment is ok.

Have someone else encountered the same problem?

Thank you,
Cinzia










Cinzia Viroli
Dipartimento di Scienze Statistiche Paolo Fortunati
Via delle Belle Arti 41
40126 Bologna
Italy
Ph.  +39 051 2098250
Fax  +39 051 232153

home: www2.stat.unibo.it/viroli


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difference between prcomp and cmdscale

2007-06-14 Thread Mark Difford

Michael,

Why should that confuse you?  Have you tried reading some of the literature
on these methods?  There's plenty about them on the Net (Wiki's often a
goodish place to start)---and even in R, if you're prepared to look ;).

BestR,
Mark.


michael watson (IAH-C) wrote:
 
 I'm looking for someone to explain the difference between these
 procedures.  The function prcomp() does principal components anaylsis,
 and the function cmdscale() does classical multi-dimensional scaling
 (also called principal coordinates analysis).
 
 My confusion stems from the fact that they give very similar results:
 
 my.d - matrix(rnorm(50), ncol=5)
 rownames(my.d) - paste(c, 1:10, sep=)
 # prcomp
 prc - prcomp(my.d)
 # cmdscale
 mds - cmdscale(dist(my.d))
 cor(prc$x[,1], mds[,1]) # produces 1 or -1
 cor(prc$x[,2], mds[,2]) # produces 1 or -1
 
 Presumably, under the defaults for these commands in R, they carry out
 the same (or very similar) procedures?
 
 Thanks
 Mick
 
 The information contained in this message may be confidentia...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Difference-between-prcomp-and-cmdscale-tf3920408.html#a8602
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difference between prcomp and cmdscale

2007-06-14 Thread Prof Brian Ripley
On Thu, 14 Jun 2007, michael watson (IAH-C) wrote:

 I'm looking for someone to explain the difference between these
 procedures.  The function prcomp() does principal components anaylsis,
 and the function cmdscale() does classical multi-dimensional scaling
 (also called principal coordinates analysis).

 My confusion stems from the fact that they give very similar results:

 my.d - matrix(rnorm(50), ncol=5)
 rownames(my.d) - paste(c, 1:10, sep=)
 # prcomp
 prc - prcomp(my.d)
 # cmdscale
 mds - cmdscale(dist(my.d))
 cor(prc$x[,1], mds[,1]) # produces 1 or -1
 cor(prc$x[,2], mds[,2]) # produces 1 or -1

 Presumably, under the defaults for these commands in R, they carry out
 the same (or very similar) procedures?

For Eucldean distance, the same.  The point being that classical MDS on 
Euclidean distances is just PCA on the reconstucted configuration, but 
that MDS is not restricted to a data matrix.

The relationship is explained in MASS, for example.

 Thanks
 Mick


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] building packages under windows

2007-06-14 Thread Prof Brian Ripley
If you try

Rcmd INSTALL mypackage

you will get the error messages on the terminal.  I've never not seen them 
in the mypackage.Rcheck/00install.out file, but then I used the correct 
name.

On Thu, 14 Jun 2007, Cinzia Viroli wrote:


 I tried to check or build a package under windows xp but I got the error

 the package can not be installed

 (without any details in the install.out file)

 I work with R-2.5.0, Miktex 2.5.0, and I have installed the unix tools.zip,
 Perl and Microsoft HTML Workshop.
 The path environment is ok.

 Have someone else encountered the same problem?

 Thank you,
 Cinzia









 
 Cinzia Viroli
 Dipartimento di Scienze Statistiche Paolo Fortunati
 Via delle Belle Arti 41
 40126 Bologna
 Italy
 Ph.  +39 051 2098250
 Fax  +39 051 232153

 home: www2.stat.unibo.it/viroli
 

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] make sample() faster

2007-06-14 Thread Rainer M. Krug
Thanks for the info - so the solution would (likely) be to draw several 
samples and use these whenever I need a new one.

tHANKS, i'LL TRY IT OUT,

rAINER

P.S: somebody said once that the caps-lock key is the most useless key 
on the keyboard and he is right...


Prof Brian Ripley wrote:
 I think the problem is not sample (which is written in C), but that you 
 are calling it with size=1.  Taking one sample with probabilities from a 
 large discrete distribution is necessarily slow, but you can take a large 
 sample for little more cost.
 
 On Thu, 14 Jun 2007, Rainer M. Krug wrote:
 
 Hi

 I have a simulation which is relatively slow. I used Rprofile() and
 identified the calls to sample() as the culprit is sample():

 summaryRprof(Documents/PostDoc/Aloe_Pillansii/R/create.out)
 $by.self
   self.time self.pct total.time total.pct
 sample   1.30 44.2   1.52  51.7
 ifelse   0.46 15.6   2.44  83.0
 .
 .
 .

 I am using sample() as follow:
 result - sample(
  x=d.growth.seedling$growth,
  size=1,
  prob=d.growth.seedling$p,
  replace
  )

 d.growth.seedling$p and d.growth.seedling$growth have a length of 1024
 and are calculated initially by using density().

 My question: is there any way to make this faster, i.e. replace sample()
 as I use it with another faster algorithm (if necessary implemented in C)?

 Thanks in advance,

 Rainer


 


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] test if files in current folder

2007-06-14 Thread Prof Brian Ripley
On Thu, 14 Jun 2007, Vladimir Eremeev wrote:




 runner wrote:

 I want to test if the files are already in my current folder before I
 download or copy from somewhere else. What's in my mind is to check if a
 file is open-able in current folder. Is there a way to do this, like in
 Perl:
 if (open()) { do sth}?

 To put it another way, how to extract all file names in a folder to an
 array or list?


 ?files
 ?dir

 BTW, Perl has nice -X functions, which allow file testing without explicit
 opening:
 http://perldoc.perl.org/functions/-X.html

which are based on those in 'test' and most Unix shells, as is R's 
file.test() in package 'utils'.

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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Preserving dates in Excel.

2007-06-14 Thread Patnaik, Tirthankar
Hi,
Quick question: Say I have a date variable in a data frame or
matrix, and I'd like to preserve the date format when using write.table.
However, when I export the data, I get the generic number underlying the
date, not the date per se, and a number such as 11323, 11324, etc are
not meaningful in Excel. Is there any way I can preserve the format of a
date on writing into a text-file?

TIA and best,
-Tir

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitted Value Pareto Distribution

2007-06-14 Thread livia

Thank you very much and that is exactly what I am looking for. Another
question would be how can I test the goodness of fit for the Pareto
distribution?



J. Hosking wrote:
 
 livia wrote:
 I would like to fit a Pareto Distribution and I am using the following
 codes. 
 
 I thought the fitted (fit1) should be the fitted value for the data, is
 it
 correct? As the result of the fitted turns out to be a single value for
 all. 
 
 fit=vglm(ycf1 ~ 1, pareto1(location=alpha), trace=TRUE, crit=c) 
 fitted(fit) 
 
 The result is 
 fitted(fit)
 [,1]
  [1,] 0.07752694
  [2,] 0.07752694
  [3,] 0.07752694
  [4,] 0.07752694
  [5,] 0.07752694
  [6,] 0.07752694
  [7,] 0.07752694
  [8,] 0.07752694
  [9,] 0.07752694
 [10,] 0.07752694
 [11,] 0.07752694
 [12,] 0.07752694
 [13,] 0.07752694
 
 Could anybody give me some advice? 
 
 
 I don't have whatever package function 'vglm' comes from (did you
 follow the instructions in the last two lines of your post?), but you
 can fit a GPD and get fitted values for it by some such approach as
 this:
 
library(POT)
threshold - 0  # probably
para - fitgpd(ycf1, threshold, method=pwmu)$param
ycf1.fit - qgpd( ppoints(ycf1, a=0.44), threshold, para[1], para[2])
 
 Note that the above code contains my own preferences for fitting
 method and plotting positions: yours may differ.
 
 
 J. R. M. Hosking
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Fitted-Value-Pareto-Distribution-tf3914151.html#a9224
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with hist()

2007-06-14 Thread Mario Dejung
Hey everybody,
I try to make a graph with two different plots.


First I make a boxplot of my data. It is a collection off correlation
values of different pictures. For example:

0.23445 pica
0.34456 pica
0.45663 pica
0.98822 picb
0.12223 picc
0.34443 picc
etc.

Ok, I make this boxplot and I get for every picture the boxes. After this
I want to know, how many correlations per picture exist.
So I make a new vector y - as.numeric(data$picture)

So I get for my example something like this:

y
[1] 1 1 1 1 1 1 1 1 1 1
[11] 1 1 1 1 1 1 1 1 2 2
...
[16881] 59 59 59 60 60 60 60 60 60 60

After this I make something like this

boxplot(cor ~ pic)
par(new = TRUE)
hist(y, nclass = 60)

But there is my problem. I have 60 pictures, so I get 60 different
boxplots, and I want the hist behind the boxes. But it makes only 59
histbars.

What can I do? I tried also
hist(y, 1:60) # same effect
and
hist(y, 1:61)
this give me 60 places, but only 59 bars. the last bar is 0.

I hope anyone can help me.

Regards Mario

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Preserving dates in Excel.

2007-06-14 Thread Peter Dalgaard
Patnaik, Tirthankar wrote:
 Hi,
   Quick question: Say I have a date variable in a data frame or
 matrix, and I'd like to preserve the date format when using write.table.
 However, when I export the data, I get the generic number underlying the
 date, not the date per se, and a number such as 11323, 11324, etc are
 not meaningful in Excel. Is there any way I can preserve the format of a
 date on writing into a text-file?

   
Er, what is exactly the problem here?

 d - data.frame(date=as.Date(2007-6-1)+1:5, x=rnorm(5))
 d
date x
1 2007-06-02  0.7987635130
2 2007-06-03 -0.7381623316
3 2007-06-04 -1.3626708691
4 2007-06-05  0.0007668082
5 2007-06-06  0.6719088533
 write.table(d)
date x
1 2007-06-02 0.798763513018864
2 2007-06-03 -0.738162331606612
3 2007-06-04 -1.36267086906438
4 2007-06-05 0.000766808196322155
5 2007-06-06 0.671908853312511
 write.csv(d)
,date,x
1,2007-06-02,0.798763513018864
2,2007-06-03,-0.738162331606612
3,2007-06-04,-1.36267086906438
4,2007-06-05,0.000766808196322155
5,2007-06-06,0.671908853312511


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] function with xyplot

2007-06-14 Thread Diego Gruber
Thanks a lot for your suggestions. Referencing the dataset solved the
problem. I had actually tried it before but since I was also subsetting the
datset within the function (something I didn't mention in my question) the
objects were not of the same length and that caused me trouble. Your comment
made me realize that.

Thanks Hadley for pointing me out to ggplot2, looks like a very complete
graphics package and if it simplifies the programming it must be extremely
useful. I'll make sure to take a closer look at it.

Best regards,

Diego

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Preserving dates in Excel.

2007-06-14 Thread Prof Brian Ripley
On Thu, 14 Jun 2007, Patnaik, Tirthankar  wrote:

 Hi,
   Quick question: Say I have a date variable in a data frame or
 matrix,

Which? It matters: see the help page.

 and I'd like to preserve the date format when using write.table.
 However, when I export the data, I get the generic number underlying the
 date, not the date per se, and a number such as 11323, 11324, etc are
 not meaningful in Excel. Is there any way I can preserve the format of a
 date on writing into a text-file?

Yes, see the help page and use a data frame.  E.g.

 write.table(data.frame(x=.leap.seconds[1:3]), )
x
1 1972-07-01 01:00:00
2 1973-01-01 00:00:00
3 1974-01-01 00:00:00


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difference between prcomp and cmdscale

2007-06-14 Thread michael watson \(IAH-C\)
Hi Mark

I think Brian Ripley answered this most effectively and succinctly.  I
did actually do quite a bit of googling and searching of the R help
before posting, and whilst there is quite a lot on each topic
individually, I failed to find articles that compare and contrast PCA
and MDS.  If you know of any, of course I would be happy to read them.

Many thanks
Mick

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Difford
Sent: 14 June 2007 12:49
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Difference between prcomp and cmdscale


Michael,

Why should that confuse you?  Have you tried reading some of the
literature
on these methods?  There's plenty about them on the Net (Wiki's often a
goodish place to start)---and even in R, if you're prepared to look ;).

BestR,
Mark.


michael watson (IAH-C) wrote:
 
 I'm looking for someone to explain the difference between these
 procedures.  The function prcomp() does principal components anaylsis,
 and the function cmdscale() does classical multi-dimensional scaling
 (also called principal coordinates analysis).
 
 My confusion stems from the fact that they give very similar results:
 
 my.d - matrix(rnorm(50), ncol=5)
 rownames(my.d) - paste(c, 1:10, sep=)
 # prcomp
 prc - prcomp(my.d)
 # cmdscale
 mds - cmdscale(dist(my.d))
 cor(prc$x[,1], mds[,1]) # produces 1 or -1
 cor(prc$x[,2], mds[,2]) # produces 1 or -1
 
 Presumably, under the defaults for these commands in R, they carry out
 the same (or very similar) procedures?
 
 Thanks
 Mick
 
 The information contained in this message may be\ confiden...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] scatterplots: (equal axes and overlay)

2007-06-14 Thread Matthias von Rad
Hi,
I am doing lots of scatterplots for my dissertation and to make the
comparable, I would like to have equal x- amd - y axis. Can I specify
their scale?
Another question adresses overlay scatterplots. Having prae and post
measures for each case, is it possible to have them in one graph with
symbols or colors for prae and post.
So
scatterplot(bdiprae,mocoprae) and
scatterplot(bdipost,mocopost) in one graph (for example green for prae
and red for post?)
thanks a lot in advance
Matthias

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] building packages under windows

2007-06-14 Thread Cinzia Viroli

Thank you for your suggestion. I tried WITH different packages and also I 
tried to INSTALL the package OC from CRAN and I got the message

installing to 'c:PROGRA~1/r/R-25~1.0/library'

*** Installation of oc failed ***

Removing 'c:/PROGRA~1/r/R-25~1.0/library/oc'

my path for R is 'c:/program files/R/R-2.5.0'

Is space allowed?

Thanks
Cinzia

At 13.56 14/06/2007, you wrote:
If you try

Rcmd INSTALL mypackage

you will get the error messages on the terminal.  I've never not seen them 
in the mypackage.Rcheck/00install.out file, but then I used the correct name.

On Thu, 14 Jun 2007, Cinzia Viroli wrote:


I tried to check or build a package under windows xp but I got the error

the package can not be installed

(without any details in the install.out file)

I work with R-2.5.0, Miktex 2.5.0, and I have installed the unix tools.zip,
Perl and Microsoft HTML Workshop.
The path environment is ok.

Have someone else encountered the same problem?

Thank you,
Cinzia










Cinzia Viroli
Dipartimento di Scienze Statistiche Paolo Fortunati
Via delle Belle Arti 41
40126 Bologna
Italy
Ph.  +39 051 2098250
Fax  +39 051 232153

home: www2.stat.unibo.it/viroli


 [[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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



Cinzia Viroli
Dipartimento di Scienze Statistiche Paolo Fortunati
Via delle Belle Arti 41
40126 Bologna
Italy
Ph.  +39 051 2098250
Fax  +39 051 232153

home: www2.stat.unibo.it/viroli


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Preserving dates in Excel.

2007-06-14 Thread Patnaik, Tirthankar
Hi Peter, Prof. Ripley,

You're right--I just realized I was exporting a matrix, after 
converting the data-frame using data.matrix, where the date characteristics are 
lost.

 
Basically a function I was running converted the dataframe to a matrix 
first--something I'd forgotten.

 z1 - data.matrix(head(Banks.Index.daily[,1:5]))
Warning message:
class information lost from one or more columns in: 
data.matrix(head(Banks.Index.daily[, 1:5])) 
 z1
Date   SBI.BO HDFC.BO KTKM.BO YESB.BO
2001-01-01 11323 102944.3 64134.8  3576.4  NA
2001-01-02 11324 108812.5 64390.9  3606.2  NA
2001-01-03 11325 114101.8 65909.5  3528.2  NA
2001-01-04 11326 112180.8 65266.3  3691.2  NA
2001-01-05 11327 113365.0 69286.3  3700.3  NA
2001-01-08 11330 112180.8 70292.8  3682.0  NA
 write.table(z1)
Date SBI.BO HDFC.BO KTKM.BO YESB.BO
2001-01-01 11323 102944.3 64134.8 3576.4 NA
2001-01-02 11324 108812.5 64390.9 3606.2 NA
2001-01-03 11325 114101.8 65909.5 3528.2 NA
2001-01-04 11326 112180.8 65266.3 3691.2 NA
2001-01-05 11327 113365 69286.3 3700.3 NA
2001-01-08 11330 112180.8 70292.8 3682 NA
 

Apologies for the inconvenience.

Best,
-Tir


 -Original Message-
 From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 14, 2007 6:07 PM
 To: Patnaik, Tirthankar [GWM-CIR]
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Preserving dates in Excel.
 
 Patnaik, Tirthankar wrote:
  Hi,
  Quick question: Say I have a date variable in a data 
 frame or matrix, 
  and I'd like to preserve the date format when using write.table.
  However, when I export the data, I get the generic number 
 underlying 
  the date, not the date per se, and a number such as 11323, 
 11324, etc 
  are not meaningful in Excel. Is there any way I can preserve the 
  format of a date on writing into a text-file?
 

 Er, what is exactly the problem here?
 
  d - data.frame(date=as.Date(2007-6-1)+1:5, x=rnorm(5)) d
 date x
 1 2007-06-02  0.7987635130
 2 2007-06-03 -0.7381623316
 3 2007-06-04 -1.3626708691
 4 2007-06-05  0.0007668082
 5 2007-06-06  0.6719088533
  write.table(d)
 date x
 1 2007-06-02 0.798763513018864
 2 2007-06-03 -0.738162331606612
 3 2007-06-04 -1.36267086906438
 4 2007-06-05 0.000766808196322155
 5 2007-06-06 0.671908853312511
  write.csv(d)
 ,date,x
 1,2007-06-02,0.798763513018864
 2,2007-06-03,-0.738162331606612
 3,2007-06-04,-1.36267086906438
 4,2007-06-05,0.000766808196322155
 5,2007-06-06,0.671908853312511
 
 
 -- 
O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  
 (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: 
 (+45) 35327907
 
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] nlsList problems: control option does not effect output and strange environment search

2007-06-14 Thread Theis, Winfried
Dear R-helpers,
 
I'm using R 2.5.0 under Windows and am trying to use nlsList from nlme
3.1-80 with the selfstart function for the four parametric logistic
function. My first test went well, but now I'm trying to do some more
sophisticated things and it does not work anymore. 
 
I simulate my data from a five parametric logistic function like this:

Y-as.data.frame(apply(params,1,function(x){
Y-x[1]+(x[2]/(1+x[3]*exp(-1*x[4]*(1:240-x[5])))^(1/x[3]))+rnorm(240,0,s
derror) 
return(Y)}))

params contains different parameters for 200 persons in 4 groups. Next I
sample for each person five observations one at the start, one at the
end and three randomly in between. Now I get the following error
messages:
testnlslist2-nlsList(SSfpl,groupedData(Y~Time|group, datset))
Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal, data =
xy,  : 
step factor 0.000488281 reduced below 'minFactor' of 0.000976562
Error in nls(formula = formula, data = data, control = control) : 
singular gradient

For the first error it could be that this is due to the fact that this
group is simulated as a kind of placebo and therefore it may be hard to
fit. To solve this I tried to specify controls like this:
testnlslist2-nlsList(SSfpl,groupedData(Y~Time|group,
datset),control=nls.control(minFactor=1/4096))

but it led to the same error as the first. So it looks like the control
parameter is not evaluated. Any other ideas how to get the function
running? 

The second strange thing I encountered is that nlsList does not seem to
analyse the environment from which it is called. I did try to use it
within a function in apply and I got the error that the dataset I gave
was not found, but the function grouped.data worked well within the
function. Any idea what I could have done wrong?

Regards,
Winfried Theis

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difference between prcomp and cmdscale

2007-06-14 Thread Sarah Goslee
On 6/14/07, michael watson (IAH-C) [EMAIL PROTECTED] wrote:

 ... I failed to find articles that compare and contrast PCA
 and MDS.  If you know of any, of course I would be happy to read them.

There's an excellent non-R discussion of a wide range of ordination methods
at http://ordination.okstate.edu/ (Mike Palmer's work).

If you look under distance-based ordination (like MDS/PCO),
you find:
Special case: for Euclidean distance, PCoA = PCA.

and much other useful information. He also gives an extensive list of
references from the literature, if you'd like something more rigorous.
For an overview text, I'm partial to _Numerical Ecology_ by Legendre
and Legendre (1998) because of its readability, but there are many
more good texts.

Sarah
-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Using subset() in a user-defined function

2007-06-14 Thread Tobin, Jared
Hello,

I'm having a problem with using subset() inside a function I'm writing.
Ignoring everything else in the function, the problem can be illustrated
by (where master.frame is the data frame I'm using):


function1 - function(arg1=, arg2=, arg3=){

temp.frame - subset(master.frame, a == arg1  b == arg2  c ==
arg3)

}


This works fine if the user specifies all arguments, but if any one or
more of the arguments isn't specified, say arg1 for example, the subset
is empty because subset() goes looking for values of a ==  in
master.frame, and there are none.  I want it to work such that if an
argument is not specified, it is not included in what subset() goes
looking for.  So if I were to input:

function1(arg2=5, arg3=6)

then in function1, the subset command will look like

temp.frame - subset(master.frame, b == 5  c == 6)


Any suggestions would be much appreciated.

Thanks,

--

jared tobin, student research assistant
dept. of fisheries and oceans
[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difference between prcomp and cmdscale

2007-06-14 Thread Mark Difford

Hi Michael,

Doubtless Professor Ripley did; but it helps to put your back into it.  Long
ago Gower (1966) drew attention to the links between PCA and classical
scaling.  It took me a few seconds to find this:

http://www.garfield.library.upenn.edu/classics1980/A1980JJ0821.pdf

Of course, I knew about Gower.  But I knew about Gower because I had done
the _basic_ research on these methods.  And that was my point.  In a later
paper Gower argued that classical scaling extended, and was more powerful
than, PCA.

However, classical scaling operates on [a matrix of] similarities between
observations/individuals/rows, whereas PCA operates on [a matrix of]
similarities between variables/descriptors/columns.  This means that in
classical scaling the axes cannot be interpreted; often one does  a PCA to
get at these.

HTH, bestR,
Mark.


michael watson (IAH-C) wrote:
 
 Hi Mark
 
 I think Brian Ripley answered this most effectively and succinctly.  I
 did actually do quite a bit of googling and searching of the R help
 before posting, and whilst there is quite a lot on each topic
 individually, I failed to find articles that compare and contrast PCA
 and MDS.  If you know of any, of course I would be happy to read them.
 
 Many thanks
 Mick
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Mark Difford
 Sent: 14 June 2007 12:49
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] Difference between prcomp and cmdscale
 
 
 Michael,
 
 Why should that confuse you?  Have you tried reading some of the
 literature
 on these methods?  There's plenty about them on the Net (Wiki's often a
 goodish place to start)---and even in R, if you're prepared to look ;).
 
 BestR,
 Mark.
 
 
 michael watson (IAH-C) wrote:
 
 I'm looking for someone to explain the difference between these
 procedures.  The function prcomp() does principal components anaylsis,
 and the function cmdscale() does classical multi-dimensional scaling
 (also called principal coordinates analysis).
 
 My confusion stems from the fact that they give very similar results:
 
 my.d - matrix(rnorm(50), ncol=5)
 rownames(my.d) - paste(c, 1:10, sep=)
 # prcomp
 prc - prcomp(my.d)
 # cmdscale
 mds - cmdscale(dist(my.d))
 cor(prc$x[,1], mds[,1]) # produces 1 or -1
 cor(prc$x[,2], mds[,2]) # produces 1 or -1
 
 Presumably, under the defaults for these commands in R, they carry out
 the same (or very similar) procedures?
 
 Thanks
 Mick
 
 The information contained in this message may be\ confiden...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Difference-between-prcomp-and-cmdscale-tf3920408.html#a11120608
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Confidence interval for coefficient of variation

2007-06-14 Thread Kevin Wright
This is a function I coded a few years ago to calculate a confidence
interval for a coefficient of variation.  The code is based on a paper
by Mark Vangel in The American Statistician.  I have not used the
function much, but it could be useful for comparing cv's from
different groups.

Kevin Wright


confint.cv - function(x,alpha=.05, method=modmckay){
  # Calculate the confidence interval of the cv of the vector x
  # Author: Kevin Wright
  # See: Vangel, Mark.  Confidence Intervals for a Normal Coefficient
  # of Variation. American Statistician, Vol 15, No1, p. 21--26.
  # x - c(326,302,307,299,329)
  # confint.cv(x,.05,modmckay)

  x - na.omit(x)
  v - length(x)-1
  mu - mean(x)
  sigma - sqrt(var(x))
  k - sigma/mu
  # CV  .33 may give poor results, so warn the user
  if(k.33) warning(Confidence interval may be very approximate.)

  method - casefold(method) # In case we see McKay

  if(method==mckay){
# McKay method.  See equation 15.
t1 - qchisq(1-alpha/2,v)/v
t2 - qchisq(alpha/2,v)/v
u1 - v*t1
u2 - v*t2
lower - k/sqrt(( u1/(v+1) -1)*k*k + u1/v)
upper - k/sqrt(( u2/(v+1) -1)*k*k + u2/v)
  } else if (method==naive){
# Naive method.  See equation 17.
t1 - qchisq(1-alpha/2,v)/v
t2 - qchisq(alpha/2,v)/v
lower - k/sqrt(t1)
upper - k/sqrt(t2)
  } else {
# Modified McKay method. See equation 16.
u1 - qchisq(1-alpha/2,v)
u2 - qchisq(alpha/2,v)
lower - k/sqrt(( (u1+2)/(v+1) -1)*k*k + u1/v)
upper - k/sqrt(( (u2+2)/(v+1) -1)*k*k + u2/v)
  }
  ci - c(lower,upper)
  attr(ci,CV) - k
  attr(ci,alpha) - alpha
  return(ci)
}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] besselK

2007-06-14 Thread Ben Bolker
Robin Hankin r.hankin at noc.soton.ac.uk writes:

 
 Hello
 
 AFAIK, R has no capability for evaluating Bessel functions for  
 complex arguments.
 
 Bessel functions for complex arguments are difficult to evaluate  
 numerically.
 Some Bessel functions require cut lines or consideration of Riemann  
 surfaces.
 
 The GSL library (for which the gsl package is an R wrapper) does
 not include such functionality although the issue has arisen
 on the GSL email list a couple of times over the last few years.
 
 Writing R functionality for Bessel functions (and in particular
 the Airy function) is on my List of Things To Do, but
 don't hold your breath  . . .
 
 best wishes
 
 Robin
 
 On 14 Jun 2007, at 10:31, ivivi mwaniki wrote:
 
  Assistance,
  besselK- complex number problem
   Im a student  intrested in using R in my learning and research  
  work in option pricing however i have a problem with besselK  
  function In R.
   Would you assit me in computing the besselK of third kind of a  
  complex number in R.
   Any code or suggestion will be highly appriceiated
   eg
   besselK(2,10)  works well.. but
   besselK(2,10i) doesnt work !!
 
   im supprised it works in MATLAB but NOT in R.
   rgds
   ivivi mwaniki
   student kenya
 
 

   I have some code for complex Bessel functions which consists
of R wrappers for C++ code: the licensing a little obscure -- the code is
ultimately from Computation of Special Functions, Zhang and Jin, John Wiley
and Sons, 1996.  The FORTRAN routines are available from
http://jin.ece.uiuc.edu/routines/routines.html ; Chris Bond
http://www.crbond.com/math.htm has made a C++ translation
available.  Both versions are copyrighted: Zhang and Jin
say we give permission to the user who downloads these routines to incorporate
any of these routines into his or her programs provided that the copyright is
acknowledged.  The code seems to work for my purposes, but hasn't
been thoroughly tested.

  I can send my crude versions to anyone who would like it.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using subset() in a user-defined function

2007-06-14 Thread Duncan Murdoch
On 6/14/2007 9:38 AM, Tobin, Jared wrote:
 Hello,
 
 I'm having a problem with using subset() inside a function I'm writing.
 Ignoring everything else in the function, the problem can be illustrated
 by (where master.frame is the data frame I'm using):
 
 
 function1 - function(arg1=, arg2=, arg3=){
 
   temp.frame - subset(master.frame, a == arg1  b == arg2  c ==
 arg3)
 
 }
 
 
 This works fine if the user specifies all arguments, but if any one or
 more of the arguments isn't specified, say arg1 for example, the subset
 is empty because subset() goes looking for values of a ==  in
 master.frame, and there are none.  I want it to work such that if an
 argument is not specified, it is not included in what subset() goes
 looking for.  So if I were to input:
 
 function1(arg2=5, arg3=6)
 
 then in function1, the subset command will look like
 
   temp.frame - subset(master.frame, b == 5  c == 6)
 
 
 Any suggestions would be much appreciated.

Code it like this:

subset(master.frame, (missing(arg1) | a == arg1) 
  (missing(arg2) | b == arg2) 
  (missing(arg3) | c == arg3))

I haven't tried this, and I forget what happens in subset() if you pass 
it a subset of the wrong length, so it might fail if all args are 
missing, but otherwise I think it should work.  It does depend on 
defaults for the args existing and not causing errors in the equality 
tests (it's not using shortcut evaluation).

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem with hist()

2007-06-14 Thread Uwe Ligges


Mario Dejung wrote:
 Hey everybody,
 I try to make a graph with two different plots.
 
 
 First I make a boxplot of my data. It is a collection off correlation
 values of different pictures. For example:
 
 0.23445 pica
 0.34456 pica
 0.45663 pica
 0.98822 picb
 0.12223 picc
 0.34443 picc
 etc.
 
 Ok, I make this boxplot and I get for every picture the boxes. After this
 I want to know, how many correlations per picture exist.
 So I make a new vector y - as.numeric(data$picture)
 
 So I get for my example something like this:
 
 y
 [1] 1 1 1 1 1 1 1 1 1 1
 [11] 1 1 1 1 1 1 1 1 2 2
 ...
 [16881] 59 59 59 60 60 60 60 60 60 60
 
 After this I make something like this
 
 boxplot(cor ~ pic)
 par(new = TRUE)
 hist(y, nclass = 60)
 
 But there is my problem. I have 60 pictures, so I get 60 different
 boxplots, and I want the hist behind the boxes. But it makes only 59
 histbars.
 
 What can I do? I tried also
 hist(y, 1:60) # same effect
 and
 hist(y, 1:61)
 this give me 60 places, but only 59 bars. the last bar is 0.


In fact, I am pretty sure you really want to have a barplot() rather 
than a histogram. If you really want to use hist(), then perhaps hist(y, 
0:60).

Uwe Ligges



 I hope anyone can help me.
 
 Regards Mario
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] scatterplots: (equal axes and overlay)

2007-06-14 Thread Roland Rau
Hi Matthias,

please see below for some code example.

Matthias von Rad wrote:
 Hi,
 I am doing lots of scatterplots for my dissertation and to make the
 comparable, I would like to have equal x- amd - y axis. Can I specify
 their scale?
 Another question adresses overlay scatterplots. Having prae and post
 measures for each case, is it possible to have them in one graph with
 symbols or colors for prae and post.

### first we create some hypothetical data

pre.x - runif(n=100, min=0, max=10)
pre.y - 1.5+2*pre.x+rnorm(n=length(pre.x), mean=pre.x, sd=1)

post.x - runif(n=100, min=0, max=10)
post.y - 20-3*post.x+rnorm(n=length(post.x), mean=post.x, sd=1)


## let's construct a plot from scratch, using type=n to have an
## empty plotting area
plot(x=1,y=1, type=n, xlim=c(0,10), ylim=c(0,20), axes=FALSE,
  xlab=My X-Labels, ylab=My Y-Labels)
axis(side=1, at=seq(from=0, to=10, by=2.5))
axis(side=2, at=seq(from=0, to=20, by=5))
points(x=pre.x, y=pre.y, col=green, pch=19)
points(x=post.x, y=post.y, col=red, pch=19)

### and this makes it easy to find out which 'pch'-number plots which
### symbol:
plot(x=0:25, y=0:25, pch=0:25)


I hope this helps.

Best,
Roland

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] names() after library(RDCOMClient) problem(?)

2007-06-14 Thread Vorlow Constantinos
Hello,

Try example(names) in R 2.5.0 after  library(RDCOMClient) and you get

 example(names)

names # print the names attribute of the islands data set
names names(islands)
Error in names(islands) : no applicable method for names
 


Is this normal? Any way round it???

Best regards,

Costas

 
--
Costas Vorlow
Research Economist
Eurobank EFG
Division of Research  Forecasting

---
( tel: +30-210-3337273 (ext 17273)
7   fax: +30-210-3337687




P Think before you print.

Disclaimer:
This e-mail is confidential. If you are not the intended recipient, you should 
not copy it, re-transmit it, use it or disclose its contents, but should return 
it to the sender immediately and delete the copy from your system.
EFG Eurobank Ergasias S.A. is not responsible for, nor endorses, any opinion, 
recommendation, conclusion, solicitation, offer or agreement or any information 
contained in this communication.
EFG Eurobank Ergasias S.A. cannot accept any responsibility for the accuracy or 
completeness of this message as it has been transmitted over a public network. 
If you suspect that the message may have been intercepted or amended, please 
call the sender.


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] system(R CMD BATCH ...) on UNIX-alikes

2007-06-14 Thread Meinhard Ploner
If I start from R (in emacs) a new R batch job using

system(R CMD BATCH --no-save --quiet Rin.txt Rout.txt,

 intern=FALSE, ignore.stderr=TRUE, wait=FALSE,  
input=NULL)

the job runs fine and smooth.
However, when, for any reason, I press later ctrl+C in the calling R,  
it not only kills the loop or whatever in the emacs/R, but it kills  
me the called batch job, too.

Why? Can I avoid that?

Best regards
Meinhard

PS system





: MacOS 10.4.9 Intel, R 2.5.0




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problems with na.rm=T

2007-06-14 Thread Lucke, Joseph F
Suddenly (e.g. yesterday) all my functions that have na.rm= as a
parameter (e.g., mean(), sd(), range(), etc.) have been reporting
warnings with na.rm=T. The message is Warning message: the condition
has length  1 and only the first element will be used in: if (na.rm) x
- x[!is.na(x)] .   This has never happened before.  I don't recall
having done anything that might generate this message.  How do I fix
this?
Joe

Joseph F. Lucke, PhD
Biostatistician
Center for Clinical Research and Evidence-based Medicine
Department of Pediatrics
School of Medicine
University of Texas Health Science Center at Houston
Voice: 713-500-5651
Email: [EMAIL PROTECTED]
Postal Mail: PO Box 20708, Houston, TX 77225-0708
 
 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using subset() in a user-defined function

2007-06-14 Thread Tobin, Jared
Thanks for the quick response, Duncan.

The given code doesn't seem to work, and possibly due to this reason I
found in the online help for missing() (if I understand it correctly):

Currently missing() can only be used in the immediate body of the
function that defines the argument, not in the body of a nested function
or a local call. This may change in the future.

So as I understand it, missing() cannot refer to the arguments of
function1 if it is used in an argument of subset()?  It seems to remain
a promising function for this situation regardless, but I'm not sure how
I could implement it into the subset() arguments offhand.

--

jared tobin, student research assistant
dept. of fisheries and oceans
[EMAIL PROTECTED]

-Original Message-
From: Duncan Murdoch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 14, 2007 11:28 AM
To: Tobin, Jared
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Using subset() in a user-defined function

On 6/14/2007 9:38 AM, Tobin, Jared wrote:
 Hello,
 
 I'm having a problem with using subset() inside a function I'm
writing.
 Ignoring everything else in the function, the problem can be 
 illustrated by (where master.frame is the data frame I'm using):
 
 
 function1 - function(arg1=, arg2=, arg3=){
 
   temp.frame - subset(master.frame, a == arg1  b == arg2  c ==
 arg3)
 
 }
 
 
 This works fine if the user specifies all arguments, but if any one or

 more of the arguments isn't specified, say arg1 for example, the 
 subset is empty because subset() goes looking for values of a ==  in

 master.frame, and there are none.  I want it to work such that if an 
 argument is not specified, it is not included in what subset() goes 
 looking for.  So if I were to input:
 
 function1(arg2=5, arg3=6)
 
 then in function1, the subset command will look like
 
   temp.frame - subset(master.frame, b == 5  c == 6)
 
 
 Any suggestions would be much appreciated.

Code it like this:

subset(master.frame, (missing(arg1) | a == arg1) 
  (missing(arg2) | b == arg2) 
  (missing(arg3) | c == arg3))

I haven't tried this, and I forget what happens in subset() if you pass
it a subset of the wrong length, so it might fail if all args are
missing, but otherwise I think it should work.  It does depend on
defaults for the args existing and not causing errors in the equality
tests (it's not using shortcut evaluation).

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with na.rm=T

2007-06-14 Thread Duncan Murdoch
On 6/14/2007 10:32 AM, Lucke, Joseph F wrote:
 Suddenly (e.g. yesterday) all my functions that have na.rm= as a
 parameter (e.g., mean(), sd(), range(), etc.) have been reporting
 warnings with na.rm=T. The message is Warning message: the condition
 has length  1 and only the first element will be used in: if (na.rm) x
 - x[!is.na(x)] .   This has never happened before.  I don't recall
 having done anything that might generate this message.  How do I fix
 this?

I imagine you have created a variable T of length greater than 1.  Use 
TRUE (which is a reserved word, so you can't create such a variable). 
Don't keep big workspaces full of stuff you don't know about, create a 
new empty one in each session.

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
and provide commented, minimal, self-contained, reproducible code.


[R] R programming question

2007-06-14 Thread Nelson, Gary (FWE)
Dear All.,

I've created R-code for which a user will be asked to choose between 2
analyses.  I've written one function for each type of analysis.  Within
each function, the users is prompted to enter information.  An example
is:
 
cat(Enter value for lower Linf :\n)
 L1-scan(n=1)
 cat(Enter value for upper Linf :\n)
 L2-scan(n=1)
 cat(Enter Linf interval :\n)
 int_L-scan(n=1)
 cat(Enter value for lower K :\n)
 K1-scan(n=1)
 cat(Enter value for upper K :\n)
 K2-scan(n=1)
 cat(Enter K interval :\n)
 int_K-scan(n=1)

I thought I could evaluate and run the appropriate function at the end
of the program by:

if(event==1) explore() else evaluate()


If I run the whole program and either explore() or evaluate() is run,
the first four prompted entries are skipped over.  The console output
for event==1 is TRUE looks like:

 if(event==1) explore() else evaluate()
Enter value for lower Linf :
1: 
Read 0 items
Enter value for upper Linf :
1: 
Read 0 items
Enter Linf interval :
1:
Read 0 items
Enter value for lower K :
1: 
Read 0 items
Enter value for upper K :
1:

I then tried another way.  I created

runcase-ifelse(event==1,explore,evaluate)

At the bottom of the program I used:

eval(call(x=runcase))

But I still get the same problem.

Any suggestions?
 

Thanks for your help

Gary A. Nelson, Ph.D
Massachusetts Division of Marine Fisheries
30 Emerson Avenue
Gloucester, MA 01930
Phone: (978) 282-0308 x114
Fax: (617) 727-3337
Email: [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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with na.rm=T

2007-06-14 Thread Peter Dalgaard
Lucke, Joseph F wrote:
 Suddenly (e.g. yesterday) all my functions that have na.rm= as a
 parameter (e.g., mean(), sd(), range(), etc.) have been reporting
 warnings with na.rm=T. The message is Warning message: the condition
 has length  1 and only the first element will be used in: if (na.rm) x
 - x[!is.na(x)] .   This has never happened before.  I don't recall
 having done anything that might generate this message.  How do I fix
 this?
   

Rename the object that you suddenly called T...

(And notice that some people will advise you to use na.rm=TRUE to avoid
this)

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] simulate null hypothesis

2007-06-14 Thread Weiwei Shi
Hi, there:

This is a bit off-topic but I try to do it in R so I put it here:

I have 31 samples from a population of genes, and each sample contains
a pair of gene lists, with different lengths and the intersection
between the two lists also varies. I want to test my hypothesis by
creating a null hypothesis for this population. Since the distribution
for the length and the distribution for the intersection size do not
follow any known distribution, I think I need to use sample with
replacement to simulate those parameters. And use the parameters to
permutate genes; but I am not very sure if it is alll right.

BTW, is there any general package or I just need sample() to do
that? (just tried to make my question on-topic:)

thanks,

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ARIMA with more than one seasonality period

2007-06-14 Thread sj
Paulo,

I have run into similar problems when wanting to work with multiple
seasonality. You are probably already familiar with the work by James Taylor
in this area. I contacted him and he was kind enough to share some of his
(Gauss) code, and I have tried to implement it in R, but due to my lack of
programming skill I don't really trust the results and it is very slow. I
will try to get it to the point where it could be useful for others.

best,

Spencer



On 6/14/07, Paulo Tanimoto [EMAIL PROTECTED] wrote:

 Dear R community,

 I have a project with electricity load forecasting, and I got hourly
 data for system load.  If you haven't worked with electricity before,
 seasonality comes in many flavors: a daily pattern, with a peak at
 around 7pm; a weekly pattern, in which we use more electricity on
 weekdays in comparison to weekends; a winter-summer pattern, with air
 conditioning and heaters playing an important role, etc.

 In SAS, I could specify an ARIMA with multiple seasonality terms, say
 (1,0,1) with period=24, and (1,0,1) with period=168 (I don't remember
 the orders I was using).  This is how many studies I found on IEEE
 were modeling electricity load and it worked pretty well with the data
 I have.

 However, I can't seem to find how to do that in R.  I've read the help
 files a few times, but to no avail. Is it possible?  I hope I'm
 missing something straightforward.

 Thank you,

 Paulo Tanimoto
 University of Arizona

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with na.rm=T

2007-06-14 Thread Lucke, Joseph F
Brilliant!  Yesterday, I created a table called T.  Dumb. Removing it
solves the problem.  Thanks. 

-Original Message-
From: Duncan Murdoch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 14, 2007 10:01 AM
To: Lucke, Joseph F
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Problems with na.rm=T

On 6/14/2007 10:32 AM, Lucke, Joseph F wrote:
 Suddenly (e.g. yesterday) all my functions that have na.rm= as a 
 parameter (e.g., mean(), sd(), range(), etc.) have been reporting 
 warnings with na.rm=T. The message is Warning message: the 
 condition has length  1 and only the first element will be used in:
if (na.rm) x
 - x[!is.na(x)] .   This has never happened before.  I don't recall
 having done anything that might generate this message.  How do I fix 
 this?

I imagine you have created a variable T of length greater than 1.  Use
TRUE (which is a reserved word, so you can't create such a variable). 
Don't keep big workspaces full of stuff you don't know about, create a
new empty one in each session.

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT]Web-Based Data Brushing

2007-06-14 Thread Greg Snow
There is the TkBrush function in the TeachingDemos package for R.  It is not 
web based.

-Original Message-
From: Roy Mendelssohn [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch r-help@stat.math.ethz.ch
Sent: 6/12/07 10:26 AM
Subject: [R] [OT]Web-Based Data Brushing

I apologize for the off-topic post, but my Google search did not turn  
up much and I thought people on this list my have knowledge of this.   
I am looking for examples of  data brushing  (i.e. dynmaic linked  
plots) either on a web site, or in a web-based application, such as  
an AJAX app.  Even better if there is a way to do this in R.

Thanks for any help.

-Roy M.

**
The contents of this message do not reflect any position of the U.S.  
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division 
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: [EMAIL PROTECTED] (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with na.rm=T

2007-06-14 Thread Barry Rowlingson
Lucke, Joseph F wrote:
 Suddenly (e.g. yesterday) all my functions that have na.rm= as a
 parameter (e.g., mean(), sd(), range(), etc.) have been reporting
 warnings with na.rm=T. The message is Warning message: the condition
 has length  1 and only the first element will be used in: if (na.rm) x
 - x[!is.na(x)] .   This has never happened before.  I don't recall
 having done anything that might generate this message.  How do I fix

  Do you have something called 'T':

  T=c(1,2,3,4)
  mean(x,na.rm=T)
[1] 2
Warning message:
the condition has length  1 and only the first element will be used in: 
if (na.rm) x - x[!is.na(x)]

  You should always use 'TRUE' for true and 'FALSE' for false. R makes 
it harder to shoot yourself in the foot that way:

  TRUE=c(1,2,3)
Error in TRUE = c(1, 2, 3) : invalid (do_set) left-hand side to assignment

help(TRUE) helps:

Details:

  'TRUE' and 'FALSE' are part of the R language, where 'T' and 'F'
  are global variables set to these. All four are 'logical(1)'
  vectors.

Barry

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using subset() in a user-defined function

2007-06-14 Thread Tobin, Jared
I should mention the idea I worked on yesterday was cat()ing together
the appropriate condition strings and then ideally printing that entire
concatenated string into the subset argument.  However, as far as I
know, cat() only prints directly on the console and cannot be used to
substitute input text into a function, so I scrapped that idea.

Just figured I'd mention that in case there does happen to be a way to
do such a thing, and someone knows of a way offhand.

--

jared tobin, student research assistant
dept. of fisheries and oceans
[EMAIL PROTECTED]

-Original Message-
From: Tobin, Jared 
Sent: Thursday, June 14, 2007 12:28 PM
To: 'Duncan Murdoch'
Cc: r-help@stat.math.ethz.ch
Subject: RE: [R] Using subset() in a user-defined function

Thanks for the quick response, Duncan.

The given code doesn't seem to work, and possibly due to this reason I
found in the online help for missing() (if I understand it correctly):

Currently missing() can only be used in the immediate body of the
function that defines the argument, not in the body of a nested function
or a local call. This may change in the future.

So as I understand it, missing() cannot refer to the arguments of
function1 if it is used in an argument of subset()?  It seems to remain
a promising function for this situation regardless, but I'm not sure how
I could implement it into the subset() arguments offhand.

--

jared tobin, student research assistant
dept. of fisheries and oceans
[EMAIL PROTECTED]

-Original Message-
From: Duncan Murdoch [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 14, 2007 11:28 AM
To: Tobin, Jared
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Using subset() in a user-defined function

On 6/14/2007 9:38 AM, Tobin, Jared wrote:
 Hello,
 
 I'm having a problem with using subset() inside a function I'm
writing.
 Ignoring everything else in the function, the problem can be 
 illustrated by (where master.frame is the data frame I'm using):
 
 
 function1 - function(arg1=, arg2=, arg3=){
 
   temp.frame - subset(master.frame, a == arg1  b == arg2  c ==
 arg3)
 
 }
 
 
 This works fine if the user specifies all arguments, but if any one or

 more of the arguments isn't specified, say arg1 for example, the 
 subset is empty because subset() goes looking for values of a ==  in

 master.frame, and there are none.  I want it to work such that if an 
 argument is not specified, it is not included in what subset() goes 
 looking for.  So if I were to input:
 
 function1(arg2=5, arg3=6)
 
 then in function1, the subset command will look like
 
   temp.frame - subset(master.frame, b == 5  c == 6)
 
 
 Any suggestions would be much appreciated.

Code it like this:

subset(master.frame, (missing(arg1) | a == arg1) 
  (missing(arg2) | b == arg2) 
  (missing(arg3) | c == arg3))

I haven't tried this, and I forget what happens in subset() if you pass
it a subset of the wrong length, so it might fail if all args are
missing, but otherwise I think it should work.  It does depend on
defaults for the args existing and not causing errors in the equality
tests (it's not using shortcut evaluation).

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using subset() in a user-defined function

2007-06-14 Thread Duncan Murdoch
On 6/14/2007 10:57 AM, Tobin, Jared wrote:
 Thanks for the quick response, Duncan.
 
 The given code doesn't seem to work, and possibly due to this reason I
 found in the online help for missing() (if I understand it correctly):
 
 Currently missing() can only be used in the immediate body of the
 function that defines the argument, not in the body of a nested function
 or a local call. This may change in the future.
 
 So as I understand it, missing() cannot refer to the arguments of
 function1 if it is used in an argument of subset()?  It seems to remain
 a promising function for this situation regardless, but I'm not sure how
 I could implement it into the subset() arguments offhand.

Right, I had forgotten that subset uses nonstandard evaluation.  You 
could evaluate add some variables to hold it, e.g.

mysubset - function(arg1=, arg2=, arg3=) {
   miss1 - missing(arg1)
   miss2 - missing(arg2)
   miss3 - missing(arg3)

   subset(master.frame, (miss1 | a == arg1) 
  (miss2 | b == arg2) 
  (miss3 | c == arg3))
}

This time I did test it as I should have last time, so I can tell you 
that if all args are missing you'll get the full master.frame.

Duncan Murdoch
 
 --
 
 jared tobin, student research assistant
 dept. of fisheries and oceans
 [EMAIL PROTECTED]
 
 -Original Message-
 From: Duncan Murdoch [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 14, 2007 11:28 AM
 To: Tobin, Jared
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Using subset() in a user-defined function
 
 On 6/14/2007 9:38 AM, Tobin, Jared wrote:
 Hello,
 
 I'm having a problem with using subset() inside a function I'm
 writing.
 Ignoring everything else in the function, the problem can be 
 illustrated by (where master.frame is the data frame I'm using):
 
 
 function1 - function(arg1=, arg2=, arg3=){
 
  temp.frame - subset(master.frame, a == arg1  b == arg2  c ==
 arg3)
 
 }
 
 
 This works fine if the user specifies all arguments, but if any one or
 
 more of the arguments isn't specified, say arg1 for example, the 
 subset is empty because subset() goes looking for values of a ==  in
 
 master.frame, and there are none.  I want it to work such that if an 
 argument is not specified, it is not included in what subset() goes 
 looking for.  So if I were to input:
 
 function1(arg2=5, arg3=6)
 
 then in function1, the subset command will look like
 
  temp.frame - subset(master.frame, b == 5  c == 6)
 
 
 Any suggestions would be much appreciated.
 
 Code it like this:
 
 subset(master.frame, (missing(arg1) | a == arg1) 
   (missing(arg2) | b == arg2) 
   (missing(arg3) | c == arg3))
 
 I haven't tried this, and I forget what happens in subset() if you pass
 it a subset of the wrong length, so it might fail if all args are
 missing, but otherwise I think it should work.  It does depend on
 defaults for the args existing and not causing errors in the equality
 tests (it's not using shortcut evaluation).
 
 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
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Goodness of fit- Pareto distribution

2007-06-14 Thread livia

Hello, I have fitted a Pareto Distribution for some data,  I would appreciate
if anyone can tell me how to evaluate the goodness of fit for the
distribution. What I do now is rather subjective. I just compare the
emprcical density distribution and the fitted density distribution.


-- 
View this message in context: 
http://www.nabble.com/Goodness-of-fit--Pareto-distribution-tf3922663.html#a11123100
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ievent.wait

2007-06-14 Thread Greg Snow
I don't know iPlot well enough to tell about that.  I was not sure if
you needed to use iPlot, or just wanted to connect the points and
thought that iPlot might be an answer.  I suggested locator with
type='l' as a possibility if traditional graphics would work for you.

If you have other reasons that require you to use iPlot, then someone
with more knowledge of iPlot will need to help you.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of ryestone
 Sent: Wednesday, June 13, 2007 12:09 PM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] ievent.wait
 
 
 With locator( ) does it only work in a regular R plot or can 
 I use it with iPlot?
 I am having difficulty getting it to be used with Iplots, it 
 just calls up a new screen when the function is called.
 
 Stone.
 
 
 Sundar Dorai-Raj wrote:
  
  Hi, Greg,
  
  type = 'b' won't work according to ?locator. Try type = 'o'.
  
  HTH,x
  
  --sundar
  
  Greg Snow said the following on 6/13/2007 7:27 AM:
  Does
  
  locator(type='l')
  
  (or type  ='b')
  
  Work for you?
  
  -Original Message-
  From: ryestone [EMAIL PROTECTED]
  To: r-help@stat.math.ethz.ch r-help@stat.math.ethz.ch
  Sent: 6/8/07 10:19 AM
  Subject: [R] ievent.wait
  
  
  I am working on a plot and would be like to click on a few 
 points and 
  then have a line connect them. Could anyone help me with this or 
  advise me in a direction that would suit this. I know I would be 
  using ievent.wait in iplot but not sure about this.
  
  thank you.
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
  
 
 --
 View this message in context: 
 http://www.nabble.com/ievent.wait-tf3891095.html#a11105384
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R vs. Splus in Pharma/Devices Industry

2007-06-14 Thread Greg Snow
But sweave is expanding.  There is a driver for HTML sweaving in the
R2HTML package and the odfWeave package allows you to sweave with open
office docs (which can be converted to/from MS word).  I personally like
using LaTeX and the original sweave, but I work with people who want
everything in MS word or similar, so for them I will create a template
file in open office, odfWeave that, convert to MS word and send that to
them.

I think the offset is more that S-PLUS 8 is supposed to implement many
of the things that R does now (I don't know which, I'm waiting for my
copy of 8), so soon it may be possible to sweave in both.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 [EMAIL PROTECTED]
 Sent: Wednesday, June 13, 2007 4:07 PM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] R vs. Splus in Pharma/Devices Industry
 
 
 I should have also noted that Sweave is available for use 
 with R.  This is offset, however, by the fact that I will 
 probably never be able to convince anyone to use Latex.  This 
 is a pity as I often find myself admiring reports done in 
 Latex as opposed to the ones I have worked on in MS Word.
 
 Cody Hamilton, PhD
 Edwards Lifesciences
 
 As always, I am speaking for myself and not necessarily for 
 Edwards Lifesciences.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] connecting to DB2 database

2007-06-14 Thread Aydemir, Zava \(FID\)
Hi,
 
i am trying to connect to a DB2 server using the DBI library.
 
getData - function()

{

driver - dbDriver(DB2)

conn - dbConnect(driver,server,uname,pword)

data - dbSendquery(conn, select etc.)

}

 

When I run the function, i get the error

 

 data -  getData()
Error in do.call(as.character(drvName), list(...)) : 
could not find function DB2

 
 
 
Can anyone help me here?
 
Thank you
 
Zava


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] names() after library(RDCOMClient) problem(?)

2007-06-14 Thread Duncan Temple Lang

Hi Costas.


  On my Windows setup, I don't get this error message.
What version of RDCOMClient are you using - i.e.
the output of
   packageDescription(RDCOMClient)

and also what else is loaded into the R session, i.e.

   sessionInfo()

  D.


Vorlow Constantinos wrote:
 Hello,
 
 Try example(names) in R 2.5.0 after  library(RDCOMClient) and you get
 
  example(names)
 
 names # print the names attribute of the islands data set
 names names(islands)
 Error in names(islands) : no applicable method for names
  
 
 
 Is this normal? Any way round it???
 
 Best regards,
 
 Costas
 
  
 --
 Costas Vorlow
 Research Economist
 Eurobank EFG
 Division of Research  Forecasting
 
 ---
 ( tel: +30-210-3337273 (ext 17273)
 7   fax: +30-210-3337687
 
 
 
 
 P Think before you print.
 
 Disclaimer:
 This e-mail is confidential. If you are not the intended recipient, you 
 should not copy it, re-transmit it, use it or disclose its contents, but 
 should return it to the sender immediately and delete the copy from your 
 system.
 EFG Eurobank Ergasias S.A. is not responsible for, nor endorses, any opinion, 
 recommendation, conclusion, solicitation, offer or agreement or any 
 information contained in this communication.
 EFG Eurobank Ergasias S.A. cannot accept any responsibility for the accuracy 
 or completeness of this message as it has been transmitted over a public 
 network. If you suspect that the message may have been intercepted or 
 amended, please call the sender.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R programming question

2007-06-14 Thread Charles C. Berry

Gary,

You are asked to

PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

when posting.

You have not provided such code, and until you do I doubt we can help.

When I wrap your lines in a dummy function:

foo - function(){
cat(Enter value for lower Linf :\n)
L1-scan(n=1)
cat(Enter value for upper Linf :\n)
L2-scan(n=1)
cat(Enter Linf interval :\n)
int_L-scan(n=1)
cat(Enter value for lower K :\n)
K1-scan(n=1)
cat(Enter value for upper K :\n)
K2-scan(n=1)
cat(Enter K interval :\n)
int_K-scan(n=1)
list(L1,L2,int_L,K1,K2,int_K)
   }

and run it as you claim

event - 1

if (event == 1 ) foo() else bar()

it prompts for all input and prints the expected result.

 sessionInfo()
R version 2.5.0 (2007-04-23)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods 
base



Chuck

On Thu, 14 Jun 2007, Nelson, Gary (FWE) wrote:

 Dear All.,

 I've created R-code for which a user will be asked to choose between 2
 analyses.  I've written one function for each type of analysis.  Within
 each function, the users is prompted to enter information.  An example
 is:

 cat(Enter value for lower Linf :\n)
 L1-scan(n=1)
 cat(Enter value for upper Linf :\n)
 L2-scan(n=1)
 cat(Enter Linf interval :\n)
 int_L-scan(n=1)
 cat(Enter value for lower K :\n)
 K1-scan(n=1)
 cat(Enter value for upper K :\n)
 K2-scan(n=1)
 cat(Enter K interval :\n)
 int_K-scan(n=1)

 I thought I could evaluate and run the appropriate function at the end
 of the program by:

 if(event==1) explore() else evaluate()


 If I run the whole program and either explore() or evaluate() is run,
 the first four prompted entries are skipped over.  The console output
 for event==1 is TRUE looks like:

 if(event==1) explore() else evaluate()
 Enter value for lower Linf :
 1:
 Read 0 items
 Enter value for upper Linf :
 1:
 Read 0 items
 Enter Linf interval :
 1:
 Read 0 items
 Enter value for lower K :
 1:
 Read 0 items
 Enter value for upper K :
 1:

 I then tried another way.  I created

 runcase-ifelse(event==1,explore,evaluate)

 At the bottom of the program I used:

 eval(call(x=runcase))

 But I still get the same problem.

 Any suggestions?


 Thanks for your help

 Gary A. Nelson, Ph.D
 Massachusetts Division of Marine Fisheries
 30 Emerson Avenue
 Gloucester, MA 01930
 Phone: (978) 282-0308 x114
 Fax: (617) 727-3337
 Email: [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
 and provide commented, minimal, self-contained, reproducible code.


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Confusion with sapply

2007-06-14 Thread Patnaik, Tirthankar
Thanks Gabor, this is cool!

Best,
-Tir 

 -Original Message-
 From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, June 13, 2007 6:53 PM
 To: Patnaik, Tirthankar [GWM-CIR]
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Confusion with sapply
 
 Try this. It takes a Date class date and in the first line 
 month.day.year converts unclass(x) to chron.  In the last 
 line of the function we convert back to Date class.  Its 
 already vectorized so sapply is unneeded:
 
 library(chron)
 f - function(x) with(month.day.year(unclass(x)), {
   month - ifelse(month == 6 | month == 9, 3, month)
   year - ifelse(month == 12, year + 1, year)
   as.Date(paste(year, month, day, sep = -))
 })
 
 Running the last line gives:
 
  # test
  f(seq(Sys.Date(), length = 12, by = month))
  [1] 2007-03-13 2007-07-13 2007-08-13 2007-03-13 2007-10-13
  [6] 2007-11-13 2008-12-13 2008-01-13 2008-02-13 2008-03-13
 [11] 2008-04-13 2008-05-13
 
 
 On 6/13/07, Patnaik, Tirthankar [EMAIL PROTECTED] wrote:
  Hi,
   I have some confusion in applying a function over a column.
 
  Here's my function. I just need to shift non-March 
 month-ends to March 
  month-ends. Initially I tried seq.dates, but one cannot give a 
  negative increment (decrement) here.
 
  
 return(as.Date(seq.dates(format(xdate,%m/%d/%Y),by=months,len=4)[4
  ])
  )
 
  Hence this simple function:
 
   mydate - as.Date(2006-01-01)
  
   # Function to shift non-March company-reporting dates to March.
   Set2March - function(xdate){
  + # Combines non-March months into March months:
  + # Dec2006 - Mar2007
  + # Mar2006 - Mar2006
  + # Jun2006 - Mar2006
  + # Sep2006 - Mar2006
  + # VERY Specific code.
  + Month - format(xdate,%m)
  + wDate - month.day.year(julian(xdate))
  + if (Month==12){
  + wDate$year - wDate$year + 1
  + wDate$month - 3
  + }else
  + if (Month==06){
  + wDate$month - 3
  + }else
  + if (Month==09){
  + wDate$month - 3
  + wDate$day - wDate$day + 1
  + }else warning (No Changes made to the month, since 
 month is not
  one of (6,9,12))
  + cDate - 
 chron(paste(wDate$month,wDate$day,wDate$year,sep=/))
  + return(as.Date(as.yearmon(as.Date(cDate,%m/%d/%y)),frac=1))
  + }
   Set2March(as.Date(2006-06-30))
  [1] 2006-03-31
   Set2March(mydate)
  [1] 2006-01-31
  Warning message:
  No Changes made to the month, since month is not one of (6,9,12) in:
  Set2March(mydate)
  
 
  Works well when I use it on a single date. Then I try it on 
 a vector:
 
 
   dc - seq(as.Date(2006-01-01),len=10, by=month) dc
   [1] 2006-01-01 2006-02-01 2006-03-01 2006-04-01 
 2006-05-01
  2006-06-01 2006-07-01 2006-08-01
   [9] 2006-09-01 2006-10-01
 
 
   sapply(as.vector(dc),Set2March)
  Error in prettyNum(.Internal(format(x, trim, digits, 
 nsmall, width, 3,
  :
 unimplemented type 'character' in 'asLogical'
  
 
  What am I missing here? Shouldn't the function work with the sapply 
  working on each entry?
 
 
  TIA and best,
  -Tir
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] connecting to DB2 database

2007-06-14 Thread Prof Brian Ripley
On Thu, 14 Jun 2007, Aydemir, Zava (FID) wrote:

 i am trying to connect to a DB2 server using the DBI library.

The DBI *package* does not allow you to connect to anything by itself. 
For that you need a driver package, currently available for MySQL, ORACLE 
and SQLite (only, AFAIK).

There are ODBC drivers for DB2 (on several platforms) so perhaps 
you could use RODBC: perhaps also RJDBC.


 getData - function()

 {

driver - dbDriver(DB2)

conn - dbConnect(driver,server,uname,pword)

data - dbSendquery(conn, select etc.)

 }



 When I run the function, i get the error



 data -  getData()
 Error in do.call(as.character(drvName), list(...)) :
could not find function DB2




 Can anyone help me here?

 Thank you

 Zava
 

 This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] clustalW

2007-06-14 Thread jeremy . mazet
Hello,

I try to make directly with R a multiple alignment querying CLUSTAL W, do 
you know how can I do this?

Thanks 


Jérémy Mazet

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] besselK- complex number problem any help is welcome

2007-06-14 Thread ivivi mwaniki
Assistance,
 Im a student  intrested in using R in my learning and research work in option 
pricing however i have a problem with besselK function In R.
 Would you assit me in computing the besselK of third kind of a complex number 
in R.
 Any code or suggestion will be highly appriceiated
 eg
 besselK(2,10)  works well.. but
 besselK(2,10i) doesnt work !!
 
 im supprised it works in MATLAB but NOT in R.
 rgds
 ivivi mwaniki
 student
school of mathematics   
 nairobi university
 kenya 
   
-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] JGR, Java and Kubuntu 7.04 ...

2007-06-14 Thread John Logsdon
R-ists

Yet again Java rears its ugly head.  

I have Kubuntu 7.04 running the Kubuntu-repository version of R 2.4.1-1.  
Yes it isn't the  very latest version but this is not the issue here.  

I want a Windows-like environment and everyone is talking about JGR.

I downloaded it and installed it along with rJava.  Both compile and install 
satisfactorily.

But when I come to run it:

  library('JGR')

 Loading required package: rJava
 Error in dyn.load(x, as.logical(local), as.logical(now)) :
 unable to load shared library
 '/usr/local/lib/R/site-library/rJava/libs/rJava.so':
 /usr/local/lib/R/site-library/rJava/libs/rJava.so: undefined symbol:
 JNI_GetCreatedJavaVMs Error: .onLoad failed in 'loadNamespace' for 'rJava'
 Error: package 'rJava' could not be loaded


When I first tried to run it without Java being installed, I got a message 
saying that JDK wasn't installed but mentioned 1.4.2.  The version of Java 
actually installed as the latest from the Ubuntu repository is Sun 1.5.0.11.  
I don't see the point in installing old versions of Java just for one 
application because the language, or at least the writing, should be 
backwards compatible.  

In all aspects I have seen Kubuntu is a very impressive in checking 
compatibility.  Unfortunately this is frequently not the case with Java.  I 
steer clear of Java as much as possible.  

Can anyone suggest what I should do?  Use Windows perhaps?  Run Windows in a 
kvm virtual machine just to run R?  Put my head in a bucket of cold water?  
Is there an alternative IDE?  Is there a later JGR somewhere that is not yet 
on CRAN?

TIA

-- 
Best wishes

John

John Logsdon   Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Normal and Poisson tail area expectations in R

2007-06-14 Thread Charles C. Berry


Ravi,

This looks simple to me.

km_G - function(lambda,k)
lambda*ppois(k-1,lambda,lower=FALSE) -
k*ppois(k,lambda,lower=FALSE)

Am I confused here?

Chuck



On Wed, 13 Jun 2007, Ravi Varadhan wrote:


 More interesting is the Poisson convolution. I don't know if there is an
 analytic solution to this.  I looked at Jolley's Summation of Series and
 Abramowitz and Stegun, but no help there.  It seems that discrete FFT
 technique should work. Does anyone know the answer?

 Ravi.
 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



 
 

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of kavindra malik
 Sent: Wednesday, June 13, 2007 5:45 PM
 To: Charles C. Berry
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Normal and Poisson tail area expectations in R

 Thank you very much. This solves the problem I was trying to solve. I am new
 to R and am learning. A great lesson in the power of R...

 Charles C. Berry [EMAIL PROTECTED] wrote: On Wed, 13 Jun 2007,
 kavindra malik wrote:

 I am interested in R functions for the following integrals / sums
 (expressed best I can in text)  -

 Normal: G_u(k) =  Integration_{Lower limit=k}^{Upper limit=infinity} [(u
 -k) f(u) d(u)], where where u is N(0,1), and f(u) is the density function.

 Poisson: G(lambda,k) = Sum_{Lower limit=k}^{Upper limit=infinity} [(x-k)
 p(x, lambda)] where P(x,lambda) is the Poisson prob function with parameter
 lambda.

 The Normal expression is very commonly used in inventory management to
 determine safety stocks (and its tabular values can be found in some
 texts) - and I am also looking for Poisson and/or Gamma as that'd fit
 the situation better.

 I am wondering if there are standard functions in R that might allow me to
 get these values, instead of needing to do the numerical integration, etc.
 myself.

 Not that I know of, but it is not difficult to do the integration:

 k - 1.1 # for example
 integrate(function(x) (x-k)*dnorm(x),lower=k,upper=Inf)
 0.06861951 with absolute error  5.5e-07


 see

  ?integrate
  ?qnorm
  ?qpois
  ?qgamma

Thank you very much.



 -
 Sucker-punch spam with award-winning protection.

  [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 Charles C. Berry(858) 534-2098
 Dept of Family/Preventive
 Medicine
 E mailto:[EMAIL PROTECTED] UC San Diego
 http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901





 -


   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] random effects in logistic regression (lmer)-- identification question

2007-06-14 Thread Paul Johnson
Hello R users!

I've been experimenting with lmer to estimate a  mixed model with a
dichotomous dependent variable.  The goal is to fit a hierarchical
model in which we compare the effect of individual and city-level
variables.  I've run up against a conceptual problem that I expect one
of you can clear up for me.

The question is about random effects in the context of a model fit
with a binomial family and logit link.  Unlike an ordinary linear
regression, there is no way to estimate an individual level random
error in the linear predictor

z_i = a + b*x_i + e_i

because the variance of e_i is unidentified.  The standard deviation
of the logistic is pi*s/3, and we assume s=1, so the standard
deviation is assumed to be pi/3 (just a bit bigger than 1, if you are
comparing against the Standard Normal).  The logistic fitting process
sets the variance of the error and the parameters a and b are
rescaled accordingly.

As a result, there is an implicit individual-level random effect
within a logistic model.  There is a good explanation of this issue in
Tony Lancaster's textbook An Introduction to Modern Bayesian
Econometrics.

So we usually end up thinking about a linear predictor in a logistic
regression like so

z_i = a + b*x_i

Random effects can be estimated for groups or clusters of
observations.  If j is a grouping variable, then we estimate

z_i = a + b*x_i + u_j

The variance component here is, as far as I understand, measured on
the same scale as the logistic distribution's standard deviation.

Currently, I'm working on a project in which there are observations
collected in many cities, represented by a variable PLACE.  We are
comparing the effect of several variables on a response for each of
the values of a RACE variable.  RACE is dichotomized into White and
Nonwhite by the people who collect the data.

For Nonwhites only, we can estimate the effect of individual level
predictors (x) on the output (y).

fm1 - lmer( y ~ x + (1 | PLACE), data=dat, , family=binomial, subset=
Race %in% c(Nonwhite))

The random effect in this model indicates the variance caused by a
Nonwhite's location on the response variable.

Random effects:
 Groups  NameVariance Std.Dev.
 PLACE (Intercept) 0.047326 0.21754

Suppose I estimate models for the 2 races in a combined model like this:

fm1 - lmer( y ~ -1 + Race / (x) + (-1 + Race | PLACE), data=dat,
family=binomial)

This gives fixed effects estimates that are pretty easy for
nonstatisticians to understand.  One can look and see the effect of a
variable x on people of different races.

But the random effect is a bit hard to understand.  Since the Race
variable is dichotomous, My aim was to see if the variance of the
random effect is different for the 2 racial categories. Here are the
estimates:

Random effects:
 Groups  Name  Variance  Std.Dev. Corr
 PLACE RACE_ALLWhite  0.0095429 0.097688
 RACE_ALLNonwhite 0.1286597 0.358692 1.000

I can't quite grasp what the correlation means.  I BELIEVE the
variance values indicate that the experiences of whites are
homogeneous across cities, because the variance is negligible for
them, while the experiences of Nonwhites are much more city-dependent.

What does it mean when the correlation is 1.0?  The correlation takes
on that value when there are no city-level variables in this model, so
I GUESS that it means that all city-level variation is attributed to
the random effect. What do you think?

If i put in some city level predictors, then the estimates of the
variance components change--they essentially disappear to the minimum
values--and the correlation is not 1.0 anymore.

Random effects:
 Groups  Name  Variance Std.Dev.   Corr
 PLACE  RACEWhite5e-102.2361e-05
  RACENonwhite   5e-102.2361e-05 0.001

This indicates that, after adding in the city level variables, the
unaccounted for city-level  variation is very small.  Correct?

Now, back to the idea that there is always an implicit individual
level random effect in a logistic regression. Is it meaningful to ask
is that individual level random effect different for people of
different races?  If so, How can I estimate that?  If e_i is the
implicit random error, can I ask for another random effect for
Nonwhites only, say u_iN, in a model like so:

z_i = a + b*x_i + e_i + u_iN

Suppose the unique respondent number is ID and we create a new variable

NonwhiteID = 0 for Nonwhites
 = ID for Nonwhites

Here's my idea about how to check to see if the individual level
variance component for Nonwhites is different from the baseline of
Whites by fitting this:

fm1 - lmer( y ~ -1 + Race / (x) + (-1 + Race | PLACE) + (1 |
NonwhiteID), data=dat, family=binomial)

Here, again, I leave out the city-level variables.

Random effects:
 Groups  Name  Variance   Std.Dev.   Corr
 NonwhiteID (Intercept)   5.e-10 2.2361e-05
 PLACE RACEWhite   1.0575e-02 1.0283e-01
 RACENonwhite1.2880e-01 

Re: [R] Normal and Poisson tail area expectations in R

2007-06-14 Thread Ravi Varadhan
Perfect, Chuck.  I got a closed-form solution after some algebraic labor,
but your solution is simple and elegant.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: Charles C. Berry [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 14, 2007 1:36 PM
To: Ravi Varadhan
Cc: 'kavindra malik'; r-help@stat.math.ethz.ch
Subject: RE: [R] Normal and Poisson tail area expectations in R



Ravi,

This looks simple to me.

km_G - function(lambda,k)
lambda*ppois(k-1,lambda,lower=FALSE) -
k*ppois(k,lambda,lower=FALSE)

Am I confused here?

Chuck



On Wed, 13 Jun 2007, Ravi Varadhan wrote:


 More interesting is the Poisson convolution. I don't know if there is an
 analytic solution to this.  I looked at Jolley's Summation of Series and
 Abramowitz and Stegun, but no help there.  It seems that discrete FFT
 technique should work. Does anyone know the answer?

 Ravi.


 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html





 

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of kavindra malik
 Sent: Wednesday, June 13, 2007 5:45 PM
 To: Charles C. Berry
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Normal and Poisson tail area expectations in R

 Thank you very much. This solves the problem I was trying to solve. I am
new
 to R and am learning. A great lesson in the power of R...

 Charles C. Berry [EMAIL PROTECTED] wrote: On Wed, 13 Jun 2007,
 kavindra malik wrote:

 I am interested in R functions for the following integrals / sums
 (expressed best I can in text)  -

 Normal: G_u(k) =  Integration_{Lower limit=k}^{Upper limit=infinity} [(u
 -k) f(u) d(u)], where where u is N(0,1), and f(u) is the density function.

 Poisson: G(lambda,k) = Sum_{Lower limit=k}^{Upper limit=infinity} [(x-k)
 p(x, lambda)] where P(x,lambda) is the Poisson prob function with
parameter
 lambda.

 The Normal expression is very commonly used in inventory management to
 determine safety stocks (and its tabular values can be found in some
 texts) - and I am also looking for Poisson and/or Gamma as that'd fit
 the situation better.

 I am wondering if there are standard functions in R that might allow me
to
 get these values, instead of needing to do the numerical integration, etc.
 myself.

 Not that I know of, but it is not difficult to do the integration:

 k - 1.1 # for example
 integrate(function(x) (x-k)*dnorm(x),lower=k,upper=Inf)
 0.06861951 with absolute error  5.5e-07


 see

  ?integrate
  ?qnorm
  ?qpois
  ?qgamma

Thank you very much.



 -
 Sucker-punch spam with award-winning protection.

  [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 Charles C. Berry(858) 534-2098
 Dept of Family/Preventive
 Medicine
 E mailto:[EMAIL PROTECTED] UC San Diego
 http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901





 -


   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Charles C. Berry(858) 534-2098
 Dept of Family/Preventive
Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

[R] how to fit y=m*x

2007-06-14 Thread genomenet
Hi There,

I have a set of data (xi,yi).I want to fit them with the equation
y=mx. 

note: in the above equation, there is no intercept.

I don't know how to use common software such as R , matlab, sas, or
spss to do this kind of regression.

Does anyone know how to do this?

I know it is easy to use least square method to do this by
programming. But I want to find if there exists some common software
which can do this. 

Thank you very much.

Van

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to fit y=m*x

2007-06-14 Thread Ndoye Souleymane
Hi,

try : ln(y~x)


From: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject: [R] how to fit y=m*x
Date: Thu, 14 Jun 2007 11:25:54 -0700

Hi There,

I have a set of data (xi,yi).I want to fit them with the equation
y=mx.

note: in the above equation, there is no intercept.

I don't know how to use common software such as R , matlab, sas, or
spss to do this kind of regression.

Does anyone know how to do this?

I know it is easy to use least square method to do this by
programming. But I want to find if there exists some common software
which can do this.

Thank you very much.

Van

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

_
Découvrez le Blog heroic Fantaisy d'Eragon!

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to fit y=m*x

2007-06-14 Thread Andrew Robinson
Probably

lm(y ~ x - 1)

will be better.  y~x doesn't remove the intercept, and ln() is a typo
(I hope!)

Andrew

On Thu, Jun 14, 2007 at 06:33:02PM +, Ndoye Souleymane wrote:
 Hi,
 
 try : ln(y~x)
 
 
 From: [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: r-help@stat.math.ethz.ch
 Subject: [R] how to fit y=m*x
 Date: Thu, 14 Jun 2007 11:25:54 -0700
 
 Hi There,
 
 I have a set of data (xi,yi).I want to fit them with the equation
 y=mx.
 
 note: in the above equation, there is no intercept.
 
 I don't know how to use common software such as R , matlab, sas, or
 spss to do this kind of regression.
 
 Does anyone know how to do this?
 
 I know it is easy to use least square method to do this by
 programming. But I want to find if there exists some common software
 which can do this.
 
 Thank you very much.
 
 Van
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 _
 D?couvrez le Blog heroic Fantaisy d'Eragon!
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Annotating trellis graphics

2007-06-14 Thread Deepayan Sarkar
On 6/13/07, Alan S Barnett [EMAIL PROTECTED] wrote:
 I'm using xyplot to generate a trellis plot with each panel containing a
 scatterplot and a best fit line.  Is it possible to write the slope of
 the best fit line in each panel?

Sure. The only question is, where (inside the panel) do you want it written?
Here are a couple of possibilities:

## writes the slope at a location that happens to be empty in both
## panels in this example

xyplot(len ~ dose | supp, ToothGrowth,
   panel = function(x, y, ...) {
   panel.xyplot(x, y, ...)
   fm - lm(y ~ x)
   panel.abline(reg = fm)
   slope - round(coef(fm)[2], 3)
   panel.text(1.5, 5, lab = slope)
   })


## needs the user to click on a suitable position for each panel

library(grid)

xyplot(len ~ dose | supp, ToothGrowth,
   panel = function(x, y, ...) {
   panel.xyplot(x, y, ...)
   fm - lm(y ~ x)
   panel.abline(reg = fm)
   slope - round(coef(fm)[2], 3)
   message(Click on desired location)
   panel.text(grid.locator(native), lab = slope)
   })

-Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to fit y=m*x

2007-06-14 Thread Christophe Pallier
summary(lm(y ~ x - 1))

Use google (R linear regression without intercept)
Read the posting guide.

There.


On 6/14/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hi There,

 I have a set of data (xi,yi).I want to fit them with the equation
 y=mx.

 note: in the above equation, there is no intercept.

 I don't know how to use common software such as R , matlab, sas, or
 spss to do this kind of regression.

 Does anyone know how to do this?

 I know it is easy to use least square method to do this by
 programming. But I want to find if there exists some common software
 which can do this.

 Thank you very much.

 Van

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Normal and Poisson tail area expectations in R

2007-06-14 Thread Ravi Varadhan
Inspired by Chuck's elegant solution to the Poisson tail area problem, here
is a simple solution to the normal tail area expectation that does not use
integrate().

Gu.k - function(k) {1/sqrt(2*pi) * exp(-k*k/2) - k * pnorm(k, lower=FALSE)}

 k - 1:10
 Gu.k(k)
 [1] 8.331547e-02 8.490703e-03 3.821543e-04 7.145258e-06 5.346166e-08
1.563570e-10 1.760326e-13 7.550262e-17 1.224779e-20 7.474560e-25

 sapply(k, function(k)integrate(function(x)
(x-k)*dnorm(x),lower=k,upper=Inf)$val)
 [1] 8.331547e-02 8.490702e-03 3.821543e-04 7.145259e-06 5.346163e-08
1.563570e-10 1.760326e-13 7.550262e-17 1.224779e-20 7.474560e-25


Ravi. 


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan
Sent: Thursday, June 14, 2007 2:08 PM
To: 'Charles C. Berry'
Cc: 'kavindra malik'; r-help@stat.math.ethz.ch
Subject: Re: [R] Normal and Poisson tail area expectations in R

Perfect, Chuck.  I got a closed-form solution after some algebraic labor,
but your solution is simple and elegant.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: Charles C. Berry [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 14, 2007 1:36 PM
To: Ravi Varadhan
Cc: 'kavindra malik'; r-help@stat.math.ethz.ch
Subject: RE: [R] Normal and Poisson tail area expectations in R



Ravi,

This looks simple to me.

km_G - function(lambda,k)
lambda*ppois(k-1,lambda,lower=FALSE) -
k*ppois(k,lambda,lower=FALSE)

Am I confused here?

Chuck



On Wed, 13 Jun 2007, Ravi Varadhan wrote:


 More interesting is the Poisson convolution. I don't know if there is an
 analytic solution to this.  I looked at Jolley's Summation of Series and
 Abramowitz and Stegun, but no help there.  It seems that discrete FFT
 technique should work. Does anyone know the answer?

 Ravi.


 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html





 

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of kavindra malik
 Sent: Wednesday, June 13, 2007 5:45 PM
 To: Charles C. Berry
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Normal and Poisson tail area expectations in R

 Thank you very much. This solves the problem I was trying to solve. I am
new
 to R and am learning. A great lesson in the power of R...

 Charles C. Berry [EMAIL PROTECTED] wrote: On Wed, 13 Jun 2007,
 kavindra malik wrote:

 I am interested in R functions for the following integrals / sums
 (expressed best I can in text)  -

 Normal: G_u(k) =  Integration_{Lower limit=k}^{Upper limit=infinity} [(u
 -k) f(u) d(u)], where where u is N(0,1), and f(u) is the density function.

 Poisson: G(lambda,k) = Sum_{Lower limit=k}^{Upper limit=infinity} [(x-k)
 p(x, lambda)] where P(x,lambda) is the Poisson prob function with
parameter
 lambda.

 The Normal expression is very commonly used in inventory management to
 determine safety stocks (and its tabular values can be found in some
 texts) - and I am also looking for Poisson and/or Gamma as that'd fit
 the situation better.

 I am wondering if there are standard functions in R that might allow me
to
 get these values, instead of needing to do the numerical integration, etc.
 myself.

 Not that I know of, but it is not difficult to do the integration:

 k - 1.1 # for example
 integrate(function(x) (x-k)*dnorm(x),lower=k,upper=Inf)
 0.06861951 with absolute error  5.5e-07


 see

  ?integrate
  ?qnorm
  ?qpois
  ?qgamma

Thank you very much.



 -
 Sucker-punch spam with award-winning protection.

  [[alternative HTML version deleted]]

 __
 

[R] question about formula for lm

2007-06-14 Thread Pedro Mardones
Dear all;

Is there any way to make this to work?:

.x-rnorm(50,10,3)
.y-.x+rnorm(50,0,1)

X-data.frame(.x,.y)
colnames(X)-c(Xvar,Yvar)

Ytext-Yvar

lm(Ytext~Xvar,data=X) # doesn't run

lm(Yvar~Xvar,data=X) # does run

The main idea is to use Ytext as input in a function, so you just type
Yvar and the model should fit
Also, I need to avoid the expression X$Yvar~X$Xvar

Thanks for any idea

PM

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Course: 2-day Short R/S-Plus at JSM - Salt Lake City July - August 2007

2007-06-14 Thread elvis Miller
Greetings!
 
XLSolutions Will schedule a series of 2-day R/S-plus courses during JSM
in Salt Lake City. Please email us your interest and dates that work 
best for you from  July 26th - August 3rd.
 
www.xlsolutions-corp.com/courselist.htm 
 
Payment due AFTER the class
 Email us for group discounts. 
 Email Sue Turner: [EMAIL PROTECTED] 
 Phone: 206-686-1578 
 Visit us: www.xlsolutions-corp.com/courselist.htm 
 Please let us know if you and your colleagues are interested in these
 classes to take advantage of group discount. Register now to secure
your 
 seat! 
 
 Cheers, 
 Elvis Miller, PhD 
 Manager Training. 
 XLSolutions Corporation 
 206 686 1578 
 www.xlsolutions-corp.com

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] question about formula for lm

2007-06-14 Thread Thomas Petzoldt
Why not using:

lm(X[[Ytext]]~Xvar,data=X)


ThPe


Pedro Mardones wrote:
 Dear all;
 
 Is there any way to make this to work?:
 
 .x-rnorm(50,10,3)
 .y-.x+rnorm(50,0,1)
 
 X-data.frame(.x,.y)
 colnames(X)-c(Xvar,Yvar)
 
 Ytext-Yvar
 
 lm(Ytext~Xvar,data=X) # doesn't run
 
 lm(Yvar~Xvar,data=X) # does run
 
 The main idea is to use Ytext as input in a function, so you just type
 Yvar and the model should fit
 Also, I need to avoid the expression X$Yvar~X$Xvar
 
 Thanks for any idea
 
 PM
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >