Re: [R] converting character strings to numbers

2007-06-15 Thread Prof Brian Ripley
There is no support for 'thousands separators' in R's input/conversion 
routines, mainly because C has no support either (not even for output in 
the C standard).  We could of course add our own layer, but as far as I am 
aware this is the first time this has come up.

On Thu, 14 Jun 2007, Andrew J Tyre wrote:

 I have a comma delimited text file in which many columns of numbers are
 also quoted and have commas as well as decimals. I was surprised to find
 read.csv() didn't import this seamlessly, even after messing around with
 the colClasses argument. I did find a solution to convert the character
 strings after reading them in, but wonder if there isn't a better one I
 overlooked.

 test = c(10,522.5,11,768.9,11,354.3)
 as.numeric(test) # fails
 as.numeric(gsub(,,,test)) # works

 Any suggestions? Or is this as good as it gets? I'm not complaining ...
 just curious!

 Drew Tyre

 School of Natural Resources
 University of Nebraska-Lincoln
 416 Hardin Hall, East Campus
 Lincoln, NE 68583-0974
 phone: +1 402 472 4054 fax: +1 402 472 2946
 email: [EMAIL PROTECTED]
 http://snr.unl.edu/tyre
   [[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] problem with hist()

2007-06-15 Thread Mario Dejung


 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

Ok, it seems you are right, but I'm a beginner in R, so maybe you can help
me a little bit more.

When I use the hist function, it automatically uses the frequency of the
different numbers, so I will get normally 60 bars.

When I use the barplot function, then I have to count the frequency of the
numbers. Is there a function who can do this, or should I write a function
on my own.

Sorry, I'm sure it is a stupid question, but maybe someone can give me a
good reference for answers, because I am a beginner :-)

Thanks to everyone
Mario



 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] problem with hist()

2007-06-15 Thread hadley wickham
On 6/14/07, Mario Dejung [EMAIL PROTECTED] 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.

 I hope anyone can help me.

What does the y axis represent?  It will be counts for the histogram,
and correlations for the boxplots.  These aren't comparable, so you're
probably better off making two separate graphics.

Hadley

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


Mario Dejung wrote:

 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

 Ok, it seems you are right, but I'm a beginner in R, so maybe you can help
 me a little bit more.
 
 When I use the hist function, it automatically uses the frequency of the
 different numbers, so I will get normally 60 bars.
 
 When I use the barplot function, then I have to count the frequency of the
 numbers. Is there a function who can do this, or should I write a function
 on my own.

You are looking for table().


 Sorry, I'm sure it is a stupid question, but maybe someone can give me a
 good reference for answers, because I am a beginner :-)

There are several manuals, books and the mailing list archives.

Uwe Ligges



 Thanks to everyone
 Mario
 

 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.


[R] interpretation of F-statistics in GAMs

2007-06-15 Thread robert . ptacnik





dear listers,
I use gam (from mgcv) for evaluation of shape and strength of relationships
between a response variable and several predictors.
How can I interpret the 'F' values viven in the GAM summary? Is it
appropriate to treat them in a similar manner as the T-statistics in a
linear model, i.e. larger values mean that this variable has a stronger
impact than a variable with smaller F?
When I run my analysis for two different response varables (but identical
predictors), is there a way to compare the F values among tests (like to
standardize them by teh sum of F within each test?) I append two summaries
below.
Thanks in advance,
Robert


### example 1 ###

Family: gaussian
Link function: identity

Formula:
dep[sel, i] ~ s(date, k = 3) + s(depth, k = kn) + s(temp, k = kn) +
s(light, k = kn) + s(PO4, k = kn) + s(DIN, k = kn) + s(prop.agpla,
k = kn)

Parametric coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   5.1048 0.0384   132.9   2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Approximate significance of smooth terms:
edf Est.rank  F  p-value
s(date)   1.6692 12.161 1.07e-05 ***
s(depth)  1.6712 36.125 4.85e-14 ***
s(temp)   1.9272  6.686  0.00156 **
s(light)  1.8862 12.604 7.20e-06 ***
s(PO4)1.6762  3.237  0.04143 *
s(DIN)1.0001 38.428 3.41e-09 ***
s(prop.agpla) 1.4052 15.987 3.79e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

R-sq.(adj) =  0.687   Deviance explained = 70.5%
GCV score = 0.31995   Scale est. = 0.30076   n = 204

### example 2 ###
Family: gaussian
Link function: identity

Formula:
dep[sel, i] ~ s(date, k = 3) + s(depth, k = kn) + s(temp, k = kn) +
s(light, k = kn) + s(PO4, k = kn) + s(DIN, k = kn) + s(prop.agpla,
k = kn)

Parametric coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)  7.135880.05549   128.6   2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Approximate significance of smooth terms:
edf Est.rank  F  p-value
s(date)   1.9442 15.997 3.67e-07 ***
s(depth)  1.8762 25.427 1.52e-10 ***
s(temp)   1.0001  2.866   0.0921 .
s(light)  1.7512  4.212   0.0162 *
s(PO4)1.9502 10.632 4.14e-05 ***
s(DIN)1.8052 10.745 3.73e-05 ***
s(prop.agpla) 1.7152  2.674   0.0715 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

 R-sq.(adj) =  0.479   Deviance explained = 50.9%
GCV score = 0.6863   Scale est. = 0.64348   n = 209

__
R-help@stat.math.ethz.ch 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] arturo invites you to join Zorpia

2007-06-15 Thread arturo

   
Hi r-help!
Your friend arturo from  , just invited you to  online photo albums and 
journals at Zorpia.com.



So what is Zorpia?
It is an online community that allows you to upload unlimited amount of photos, 
write journals and make friends. We also have a variety of skins in store for 
you so that you can customize your homepage freely.

Join now for free! Please click the following link to join Zorpia:
http://signup2.zorpia.com/signup?invitation_key=20070657c3fd0889d8d1e73b6d8a00c8referral=arturitocoral

This message was delivered with the arturo's initiation.

If you wish to discontinue receiving invitations from us, please click the 
following link:
http://signup2.zorpia.com/email/optout/r-help@stat.math.ethz.ch


[[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] problem with hist()

2007-06-15 Thread hadley wickham
On 6/15/07, Mario Dejung [EMAIL PROTECTED] wrote:
  On 6/14/07, Mario Dejung [EMAIL PROTECTED] 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.
 
  I hope anyone can help me.
 
  What does the y axis represent?  It will be counts for the histogram,
  and correlations for the boxplots.  These aren't comparable, so you're
  probably better off making two separate graphics.
 
  Hadley
 
 The boxplots show only the median, min, max, etc of the different
 pictures, but I want to know, how many entry's are in this plot. Now I
 have done this by the hist function, and when I use different colors, you
 can see, for the first picture there are about 130 entry, but for the 8th
 picture, there are only 40 entry's...
 Doesn't make this sense?

I think your plot would be more clear if you used two graphics - one
showing the spread, and one showing the number of points (you might
also want to look at notched boxplots).  In the graphic you attached
the bars of the barchart (not histogram! - that's for continuous data)
distract the eye from the boxplots.  You might also want to try
ordering the x axis by mean or number of observations as this will
make it easier to see trends in the data.

The confusion with the barchart arises because there are really two
quite different types of barcharts.  One type is basically the same as
a dotchart, but you draw bars instead of dots - this is the default in
R.  The other type is the categorical analog of the histogram, and
this is the default in ggplot2
(http://had.co.nz/ggplot2/geom_bar.html), allow the next version will
automatically work out which version you want.

Hadley

__
R-help@stat.math.ethz.ch 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] package with fortran 90 subroutines under windows xp

2007-06-15 Thread Cinzia Viroli
Hello,
I work under windows xp and I am trying to build a R package with a 
subroutine written in fortran 90.
I have installed all the updated tools and I am working with R-2.4.0 or 
R-2.5.0.

When I check a package with a subroutine in fortran 77 (and extension f) 
everything is ok.
When I try to build the same package with a subroutine in fortran 90 (with 
extension f90) the following warning appears:

Subdirectory 'src' contains no source files

and the package can not be built.

The funny thing is that I have successfully built the same package with 
fortran 90 last March and everything was good.

I can not imagine what is the problem, could do you help me?






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

home: www2.stat.unibo.it/viroli

__
R-help@stat.math.ethz.ch 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 matrix, list and other..

2007-06-15 Thread billycorg

hi

can anyone help me to solve these problems?

i have:
1) d matrix with 1096 rows;
for example, 
d[2]=
   [,1]   [,2]  [,3]
[1,] 0.1192566 0.000 0.000
[2,] 0.000 0.1065938 0.000
[3,] 0.000 0.000 0.103

if I
class (d[2]) = list 
solve(d[2]) = error!!!

2) e list with 1096 rows;
for example
e[2]2=
[[1]]
[1] -1.0892216 -0.7304947 -1.2883680

d[2]%*%t(e[2])
this is the error: requires numeric matrix/vector arguments

i've tried to coerce e to a matrix, but it's doesn't work...

in the end.. i'd like this:
for (i in (1:1096)) {solve(d[i])*t(e[i])}

help me, please :)

Vincenzo
-- 
View this message in context: 
http://www.nabble.com/problems-with-matrix%2C-list-and-other..-tf3926701.html#a11135888
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] gpclib problem

2007-06-15 Thread Leonardo Lami
Hi all,
I am trying to test the new adehabitat package but I have a problem with
a linked library, gpclib.

When I try do install it I have this output:

install.packages(gpclib, dependencies=TRUE,
repos=http://cran.cnr.berkeley.edu/;)
Avviso in install.packages(gpclib, dependencies = TRUE, repos =
http://cran.cnr.berkeley.edu/;) :
argument 'lib' is missing: using /usr/local/lib/R/site-library
dependency ''gpclib'' is not available

I have the same problem in other repository.


Leonardo

__
R-help@stat.math.ethz.ch 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] back-transform predictors for x-axis in plot -- mgcv package

2007-06-15 Thread hadley wickham
Hi Suzan,

You can do sort of backtransformation inside of ggplot2
(http://had.co.nz/ggplot2).

library(ggplot2)

# Create the base scatterplot with y and x axes transformed by logging,
# and then back transformed by exponentiating
(base - qplot(carat, price, data=diamonds) + scale_x_log10() +
scale_y_log10() + coord_trans(y=pow10, x=pow10))

base + geom_smooth(method=lm)

library(mgcv)
base + geom_smooth(method=gam, formula = y ~ s(x, bs=cr))
base + geom_smooth(method=gam, formula = y ~ s(x, bs=cr), fill=grey50)

# cf.

qplot(carat, price, data=diamonds) + geom_smooth(method=lm)
qplot(carat, price, data=diamonds) + geom_smooth(method=gam, formula
= y ~ s(x, bs=cr), fill=grey50)


Regards,

Hadley

On 6/14/07, Suzan Pool [EMAIL PROTECTED] wrote:
 My question is related to plot( ) in the mgcv package.  Before modelling
 the data, a few predictors were transformed to normalize them.
 Therefore, the x-axes in the plots show transformed predictor values.
 How do I back-transform the predictors so that the plots are easier to
 interpret?

 Thanks in advance,
 Suzan

 --
 Suzan Pool
 Oregon State University
 Cooperative Institute for Marine Resources Studies
 c/o NOAA Fisheries
 520 Heceta Place
 P.O. Box 155
 Hammond, OR  97121

 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 Phone:  503-861-1818 x36 TTY
 Voice to TTY:  711
 Fax:  503-861-2589

 __
 R-help@stat.math.ethz.ch 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] JGR, Java and Kubuntu 7.04 ...

2007-06-15 Thread Stefan Grosse
You could download the latest R (2.5.0) directly from CRAN, this just as
a side remark, You find instructions here:
http://cran.au.r-project.org/bin/linux/ubuntu/README

With java you should make sure that you have the Java 5 JDK installed. 
I dont know how it is with Ubuntu but on fedora I have to set the java
alternative (sun java installation does not change the default java
there). Which java is installed you can check with java -version there
you see it it is properly installed and a R CMD javareconf also
indicates if your java is configured correctly. Additionally on Fedora I
had to set JAVA_HOME to the JDK directory manually.

Stefan

 Original Message  
Subject: [R] JGR, Java and Kubuntu 7.04 ...
From: John Logsdon [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Date: 14.06.2007 19:16
 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



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

2007-06-15 Thread Prof Brian Ripley
On Fri, 15 Jun 2007, Leonardo Lami wrote:

 Hi all,
 I am trying to test the new adehabitat package but I have a problem with
 a linked library, gpclib.

 When I try do install it I have this output:

 install.packages(gpclib, dependencies=TRUE,
 repos=http://cran.cnr.berkeley.edu/;)
 Avviso in install.packages(gpclib, dependencies = TRUE, repos =
 http://cran.cnr.berkeley.edu/;) :
 argument 'lib' is missing: using /usr/local/lib/R/site-library
 dependency ''gpclib'' is not available

 I have the same problem in other repository.

You haven't told us your OS or R version (or what the 'other repository' 
was).  The files are there

http://cran.cnr.berkeley.edu/src/contrib/Descriptions/gpclib.html

so a guess is that you have failed to update your R.

 Leonardo

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

Please do as this asks.


-- 
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] package with fortran 90 subroutines under windows xp

2007-06-15 Thread Duncan Murdoch
On 12/06/2007 9:41 AM, Cinzia Viroli wrote:
 Hello,
 I work under windows xp and I am trying to build a R package with a 
 subroutine written in fortran 90.
 I have installed all the updated tools and I am working with R-2.4.0 or 
 R-2.5.0.
 
 When I check a package with a subroutine in fortran 77 (and extension f) 
 everything is ok.
 When I try to build the same package with a subroutine in fortran 90 (with 
 extension f90) the following warning appears:
 
 Subdirectory 'src' contains no source files
 
 and the package can not be built.
 
 The funny thing is that I have successfully built the same package with 
 fortran 90 last March and everything was good.
 
 I can not imagine what is the problem, could do you help me?

The current Windows tools don't support Fortran 9x, just Fortran 77.  If 
you have your own Fortran 90 compiler, you can enter it into MkRules 
(either by enabling the GCC4 macro, or entering it directly in the F95 
macro).

But you should have got an error about the compiler not existing, not an 
error about no source files.

Are you sure you named the file *.f90?  I get a check warning about no 
source files if I name the file test.F90, but not for test.f90.

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] Loop for test statistic

2007-06-15 Thread livia

I would like to obtain the statistic of A2 for ycf between the value 0.0032
and 0.09, and I am using the following codes. 

while (0.0032 ycf 0.09) {
A2 - A2_GOFlaio(ycf, dist=GEV)[1]
print(A2)
}

Could anyone give me some advice as it does not work.

Many thanks.
-- 
View this message in context: 
http://www.nabble.com/Loop-for-test-statistic-tf3927249.html#a11137549
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] Grahpics problem

2007-06-15 Thread Wachtel, Mitchell
To the group:

 

A marvelous thing is combining graphs with the par function, but there
remains an issue. What if you wish to put a title on top of the set of
graphs or a general x or y axis label? How does one do this?


With kindest regards.

 

Mitchell S. Wachtel, MD


[[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] connecting to DB2 database

2007-06-15 Thread David James
Hi,

On 6/14/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 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.

RJDBC also uses the DBI interface.

Regards,

--
David



  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-help@stat.math.ethz.ch 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] JGR, Java and Kubuntu 7.04 ...

2007-06-15 Thread Dirk Eddelbuettel

On 15 June 2007 at 12:32, Stefan Grosse wrote:
| You could download the latest R (2.5.0) directly from CRAN, this just as
| a side remark, You find instructions here:
| http://cran.au.r-project.org/bin/linux/ubuntu/README

Yes indeed, thanks for our fearless backporters.
 
| With java you should make sure that you have the Java 5 JDK installed. 
| I dont know how it is with Ubuntu but on fedora I have to set the java
| alternative (sun java installation does not change the default java
| there). Which java is installed you can check with java -version there
| you see it it is properly installed and a R CMD javareconf also
| indicates if your java is configured correctly. Additionally on Fedora I
| had to set JAVA_HOME to the JDK directory manually.

It all worked -- I don't run Java much myself, but I think starting with
the previous Ubuntu release and the actual Sun packages directly acessible
via apt-get, it worked.

However, with the current packages in my Kubuntu setup at work, I do get a
segfault once JGR is up and loaded.   I suspect, as Stefan said here, that
this is due to the Java 6 packages in Ubuntu.  As I said, sun-java5-jdk seems
to have work along with 'sudo R CMD javareconf', Simon's powerful Java
parameter setter for R.

In any event, we should carry this over to r-sig-debian.

Dirk

| 
| Stefan
| 
|  Original Message  
| Subject: [R] JGR, Java and Kubuntu 7.04 ...
| From: John Logsdon [EMAIL PROTECTED]
| To: r-help@stat.math.ethz.ch
| Date: 14.06.2007 19:16
|  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
| 
| 
| 
| __
| R-help@stat.math.ethz.ch 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.

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
R-help@stat.math.ethz.ch 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 matrix, list and other..

2007-06-15 Thread Petr Klasterecky
You only got what you deserved when not reading the manual...
R-Intro, Chapters 5 and 6, page 26 in particular.
http://cran.r-project.org/doc/manuals/R-intro.pdf

Petr


billycorg napsal(a):
 hi
 
 can anyone help me to solve these problems?
 
 i have:
 1) d matrix with 1096 rows;
 for example, 
 d[2]=
[,1]   [,2]  [,3]
 [1,] 0.1192566 0.000 0.000
 [2,] 0.000 0.1065938 0.000
 [3,] 0.000 0.000 0.103
 
 if I
 class (d[2]) = list 
 solve(d[2]) = error!!!
 
 2) e list with 1096 rows;
 for example
 e[2]2=
 [[1]]
 [1] -1.0892216 -0.7304947 -1.2883680
 
 d[2]%*%t(e[2])
 this is the error: requires numeric matrix/vector arguments
 
 i've tried to coerce e to a matrix, but it's doesn't work...
 
 in the end.. i'd like this:
 for (i in (1:1096)) {solve(d[i])*t(e[i])}
 
 help me, please :)
 
 Vincenzo

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


Re: [R] Loop for test statistic

2007-06-15 Thread Petr Klasterecky
Please read the posting guide. How shall we know what ycf, and A2 are?
In general, the condition should be something like (.0032ycf  ycf.09) 
Also make sure that the initial value of ycf actually fits between the 
limits (or assign something to A2 outside the loop) and that ycf is 
changed inside the loop (to prevent looping forever).

Petr

livia napsal(a):
 I would like to obtain the statistic of A2 for ycf between the value 0.0032
 and 0.09, and I am using the following codes. 
 
 while (0.0032 ycf 0.09) {
 A2 - A2_GOFlaio(ycf, dist=GEV)[1]
 print(A2)
 }
 
 Could anyone give me some advice as it does not work.
 
 Many thanks.

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


Re: [R] Grahpics problem

2007-06-15 Thread Duncan Murdoch
On 6/15/2007 8:13 AM, Wachtel, Mitchell wrote:
 To the group:
 
  
 
 A marvelous thing is combining graphs with the par function, but there
 remains an issue. What if you wish to put a title on top of the set of
 graphs or a general x or y axis label? How does one do this?

Use mtext() to write to the outer margins, but remember first to create 
some space there.  For example,

  par(oma=c(0,0,2,0),mfrow=c(2,2))
  plot(1)
  plot(2)
  plot(3)
  plot(4)
  mtext(Main title, side=3, outer=TRUE)

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] Grahpics problem

2007-06-15 Thread Petr Klasterecky
RSiteSearch(common title)

Petr

Wachtel, Mitchell napsal(a):
 To the group:
 
  
 
 A marvelous thing is combining graphs with the par function, but there
 remains an issue. What if you wish to put a title on top of the set of
 graphs or a general x or y axis label? How does one do this?
 
 
 With kindest regards.
 
  
 
 Mitchell S. Wachtel, MD
 
 
   [[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.
 

-- 
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] Problem with workspace loading after languageR use

2007-06-15 Thread Pfister
Hello R,

To analyze multi-level data, I started learning and using lmer. So far 
so wonderful. I then found some useful functions in package languageR. 
But then the following problem ocurred: Whenever I load and use the 
languageR package, then save the workspace - or quit R with saving the 
workspace - I am unable to reload that workspace in a later session. 
That is, R doesn't start at all when I try to start it by clicking the 
workspace file.
Loading languageR before loading the workspace doesn't help, but yields 
the message:

Error in load(D:\\statistics\\MultilevelAnalysis\\.RData) :
 could not find function findPackageEnv

Thus, the saved workspace remains inaccessible. I not 100% certain that 
languageR is the scapegoat, but my trial-and-error experiments indicate 
it is.

My system is Win XP Home/Professional:

  sessionInfo()
R version 2.5.0 Patched (2007-04-24 r41305)
i386-pc-mingw32
locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252
attached base packages:
[1] splines   stats graphics  grDevices utils
[6] datasets  methods   base
other attached packages:
   languageR   rpartMASS  Designsurvival
   0.23.1-367.2-342.0-12  2.31
   Hmisc   e1071   class cluster   zipfR
 3.3-21.5-167.2-341.11.7 0.6-0
lme4coda  Matrix lattice
0.99875-10.11-2 0.99875-20.15-8


thanks for any helpful suggestions!

best
Rüdiger


-- 
Hans-Rüdiger Pfister
Professor of Business Psychology
University of Lüneburg
Faculty for Business Administration, Behavioral Sciences and Law
Institute of Experimental Industrial Psychology (LueneLab)
Wilschenbrucher Weg 84
D-21335 Lüneburg, Germany
+49-(0)4131 677 7759
[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] method of rpart when response variable is binary?

2007-06-15 Thread ronggui
Dear all,

I would like to model the relationship between y and x. y is binary
variable, and x is a count variable which may be possion-distribution.

I think it is better to divide x into intervals and change it to a
factor before calling glm(y~x,data=dat,family=binomail).

I try to use rpart. As y is binary, I use class method and get the
following result.
 rpart(y~x,data=dat,method=class)
n=778 (22 observations deleted due to missingness)

node), split, n, loss, yval, (yprob)
  * denotes terminal node

1) root 778 67 0 (0.91388175 0.08611825) *


If with the default method, I get such a result.

 rpart(y~x,data=dat)
n=778 (22 observations deleted due to missingness)

node), split, n, deviance, yval
  * denotes terminal node

1) root 778 61.230080 0.08611825
  2) x 19.5 750 53.514670 0.0773
4) x 1.25 390 17.169230 0.04615385 *
5) x=1.25 360 35.60 0.1110 *
  3) x=19.5 28  6.107143 0.32142860 *

If I use 1.25 and 19.5 as the cutting points, change x into factor by
x2 - cut(q34b,breaks=c(0,1.25,19.5,200),right=F)

The coef in y~x2 is significant and makes sense.

My problem is: is it OK use the default method in rpart when response
varibale is binary one?  Thanks.


-- 
Ronggui Huang
Department of Sociology
Fudan University, Shanghai, China

__
R-help@stat.math.ethz.ch 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] Need Help with Dendrogram and DataFrame Leaf names

2007-06-15 Thread ngottlieb
I having problem with dendrogram leaf names when I read a tab delimited
file into dataframe;

I have a text file, tab delimited, using read.table into a data frame as
follows:
  test1-read.table(c:\\R\\data\\Tremont4.txt, header=TRUE, sep=\t)

When I do this the test1 data frame is picking up my first column
names as
part of the data and not the case names, the leafs are the numbers on
the left 1-13
As opposed to the text names to the right. 

Example Output from displaying dataframe:
 test1
 row.names X1.31.2004 X2.29.2004 X3.31.2004 X4.30.2004
X5.31.2004 X6.30.2004 X7.31.2004 X8.31.2004 X9.30.2004 X10.31.2004
1 ConvertibleArbitrage  0.014  0.003  0.004  0.005
-0.013 -0.008 -0.002  0.003 -0.001  -0.003
2   DedicatedShortBias -0.017  0.003 -0.026  0.042
0.008 -0.013  0.081  0.013 -0.019  -0.018
3  EmergingMarkets  0.025  0.014  0.018 -0.033
-0.018  0.009 -0.001  0.018  0.023   0.024
4MarketNeutral  0.008  0.008 -0.001 -0.003
0.002  0.008  0.003  0.021  0.005   0.000
5  EventDriven  0.022  0.010  0.005  0.005
0.001  0.010  0.000  0.005  0.013   0.012
6   Distressed  0.024  0.009  0.006  0.007
0.003  0.011  0.005  0.006  0.012   0.019
7  EventdriveMultiStrategy  0.020  0.011  0.003  0.005
-0.001  0.009 -0.003  0.004  0.014   0.007
8RiskArbitrage  0.008  0.005  0.007 -0.006
0.004  0.003 -0.015  0.002  0.006   0.009
9 FixedIncomeArbitrage  0.012  0.009 -0.005  0.013
0.006  0.007  0.007 -0.004 -0.008   0.011
10 GlobalMacro  0.015  0.012  0.010  0.001
0.001  0.005  0.008 -0.008 -0.005   0.012
11 LongShortEquity  0.020  0.018  0.002 -0.014
-0.004  0.007 -0.014  0.001  0.024   0.014
12  ManagedFutures  0.011  0.069 -0.009 -0.065
-0.011 -0.028 -0.020 -0.015  0.020   0.048
13  Multi-Strategy  0.016  0.004  0.004  0.003
-0.001  0.001 -0.003  0.004  0.006   0.006

Input file looks like this:
row.names   1/31/2004 2/29/2004 3/31/2004
4/30/2004   5/31/2004   6/30/2004   7/31/2004
8/31/2004
ConvertibleArbitrage0.0140.003  0.004  0.005-0.013
-0.008  -0.002  0.003
DedicatedShortBias  -0.017   0.003  -0.026  0.042  0.008
-0.013  0.081 0.013
EmergingMarkets   0.0250.0140.018-0.033
-0.0180.009  -0.001   0.018
MarketNeutral 0.0080.008-0.001  -0.003  0.002
0.008 0.003   0.021
Etc...

Would appreciate why the read.table into dataframe sees the text as part
of the data oand
Not the observation names and is making the numbers the leaf names and
observation names.


Thanks for any help,
Neil Gottlieb


 
 
This information is being sent at the recipient's request or...{{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] method of rpart when response variable is binary?

2007-06-15 Thread Prof Brian Ripley
On Fri, 15 Jun 2007, ronggui wrote:

 Dear all,

 I would like to model the relationship between y and x. y is binary
 variable, and x is a count variable which may be possion-distribution.

 I think it is better to divide x into intervals and change it to a
 factor before calling glm(y~x,data=dat,family=binomail).

 I try to use rpart. As y is binary, I use class method and get the
 following result.
 rpart(y~x,data=dat,method=class)
 n=778 (22 observations deleted due to missingness)

 node), split, n, loss, yval, (yprob)
  * denotes terminal node

 1) root 778 67 0 (0.91388175 0.08611825) *


 If with the default method, I get such a result.

 rpart(y~x,data=dat)
 n=778 (22 observations deleted due to missingness)

 node), split, n, deviance, yval
  * denotes terminal node

 1) root 778 61.230080 0.08611825
  2) x 19.5 750 53.514670 0.0773
4) x 1.25 390 17.169230 0.04615385 *
5) x=1.25 360 35.60 0.1110 *
  3) x=19.5 28  6.107143 0.32142860 *

 If I use 1.25 and 19.5 as the cutting points, change x into factor by
 x2 - cut(q34b,breaks=c(0,1.25,19.5,200),right=F)

 The coef in y~x2 is significant and makes sense.

 My problem is: is it OK use the default method in rpart when response
 varibale is binary one?  Thanks.

Not unless you want a least-squares fit.  Note that you have only 8.6% of 
one class, and for such an unbalanced classification problem you are 
unlikely to do better than declaring class 1 for all examples.

-- 
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] importing .dta files

2007-06-15 Thread Thomas Lumley
On Fri, 15 Jun 2007, Chris Linton wrote:

 I'm trying to read in a Stata file but I've never used this function (
 read.dta).  It's the only one that seems to come close to working, but I
 keep getting this error:

 data-read.dta(C:/Documents and
 Settings/Chris/Desktop/S4412/catestscores.dta)
 Error in read.dta(C:/Documents and
 Settings/Chris/Desktop/S4412/catestscores.dta,  :
a binary read error occurred


 There's little chance the data is corrupt considering it came from my
 professor and he used the data earlier.  So, either I'm doing something
 wrong or R just doesn't like to read in Stata files.  If it's a problem with
 R, how can I easily convert the file without purchasing Stata?


R does read Stata files -- I use this facility frequently.  It's hard to 
tell why it isn't working in your case, since we don't know anything about 
the file, your version of R, version of Stata, etc (we can guess you are 
on windows from the file name).

The error message implies that the file was found, and that it started 
with the right sequence of bytes to be a Stata .dta file, but that 
something (probably the end of the file) prevented R from reading what it 
was expecting to read.

This is why (in the absence of any further information) the natural 
suspicion is that the file is corrupt.  It is possible that we have 
misunderstood some unusual possibility in the Stata file format -- this 
has happened once before -- but it is fairly well documented.  In any 
case, there is not much that can be done without more information.


-thomas

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


[R] Coefficients and Covariances in MNP

2007-06-15 Thread Ozlem Ipekci
Hi everyone,
I use the MNP package to fit my data.  I can interpret the coefficients and
covariance.  I cannot put them into the original model which is
Wi=Sum(bXij) over j,
Yi(Wi)=0 if max(Wi)0, j if max(Wi)=Wij0

j=3 here, 3 choice alternatives, Clio, Punto, Polo
I don't  know how to put the coefficients and covariances into W, to
construct W for each j.
The coefficients and covariances are below.
I f anyone help me on this, I would appreciate.
ozlem.

Call:
mnp(formula = choice ~ 1, data = rowdata3, choiceX = list(Punto =
PricePunto,
Clio = PriceClio, Polo = PricePolo), cXnames = price, base = Polo,
n.draws = 100, verbose = TRUE)


Coefficients:
   mean std.dev.2.5%97.5%
(Intercept):Clio -1.45590.6889-2.7017 -0.387
(Intercept):Punto  -0.19890.7180-2.2192  0.893
price   10.0865   5.1486 0.8549  23.030

Covariances:
mean std.dev.2.5%97.5%
Clio:Clio1.0.1.  1.000
Clio:Punto -0.9458   0.7644   -2.1816  0.449
Punto:Punto  2.59802.53120.4339  9.281

Base category: Polo
Number of alternatives: 3
Number of observations: 12
Number of estimated parameters: 5
Number of stored MCMC draws: 100

[[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] Problem with workspace loading after languageR use

2007-06-15 Thread Prof Brian Ripley
The problem would appear to be something missing in R.  From what I can 
see you have saved a reference to a package environment in your workspace. 
When load() tries to resolve this, it calls findPackageEnv and that does 
not exist in current R (or any recent version I looked at).


I think adding the following to your new session before load() will help

findPackageEnv - function(info)
   as.environment(paste(package, info, sep=:))

will work, but if not try

findPackageEnv - function(info) .GlobalEnv

If you send me the problematic workspace (or reproduction instructions) I 
can take a closer look.



On Fri, 15 Jun 2007, Pfister wrote:


Hello R,

To analyze multi-level data, I started learning and using lmer. So far
so wonderful. I then found some useful functions in package languageR.
But then the following problem ocurred: Whenever I load and use the
languageR package, then save the workspace - or quit R with saving the
workspace - I am unable to reload that workspace in a later session.
That is, R doesn't start at all when I try to start it by clicking the
workspace file.
Loading languageR before loading the workspace doesn't help, but yields
the message:

Error in load(D:\\statistics\\MultilevelAnalysis\\.RData) :
could not find function findPackageEnv

Thus, the saved workspace remains inaccessible. I not 100% certain that
languageR is the scapegoat, but my trial-and-error experiments indicate
it is.

My system is Win XP Home/Professional:

 sessionInfo()
R version 2.5.0 Patched (2007-04-24 r41305)
i386-pc-mingw32
locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252
attached base packages:
[1] splines   stats graphics  grDevices utils
[6] datasets  methods   base
other attached packages:
  languageR   rpartMASS  Designsurvival
  0.23.1-367.2-342.0-12  2.31
  Hmisc   e1071   class cluster   zipfR
3.3-21.5-167.2-341.11.7 0.6-0
   lme4coda  Matrix lattice
0.99875-10.11-2 0.99875-20.15-8


thanks for any helpful suggestions!

best
Rüdiger





--
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] mixed model for analysing microarray data

2007-06-15 Thread Jack
Dear R users, 

We are trying to analyse microarray data. The experiment compares two 
conditions (light vs. dark). we would like to use a mixed-model ANOVA but we 
don't know much about it. could you please help?
the experiment test the effect of light on a tissue and compare tissues 
maintained in light or dark (fixed effect).
In each condition, Two RNA samples were used (random effect?) for each 
condition, and each sample was measured twice (random effect? nested in 
sample?), or maybe the replicate factor is not required?

Any help will be appreciated (particularly on how to assign the random 
factor(s) )

for a given gene the data look like that:

light  RNA  replicate  reading
y 1 1  1.67
y 1 2  1.56
y 2 1  1.60
y 2 2  1.34
n 1 1  1.67
n 1 2  1.56
n 2 1  1.60
n 2 2  1.34




***
This email was sent via http://www.AnonymousSpeech.com,  
the worlds leading a href=http://www.anonymousspeech.comanonymous email/a 
provider.
Paid memberships do not show this footer 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] method of rpart when response variable is binary?

2007-06-15 Thread Wensui Liu
you might use default setting if you use as.factor(y)~x in rpart(), I think.

On 6/15/07, ronggui [EMAIL PROTECTED] wrote:
 Dear all,

 I would like to model the relationship between y and x. y is binary
 variable, and x is a count variable which may be possion-distribution.

 I think it is better to divide x into intervals and change it to a
 factor before calling glm(y~x,data=dat,family=binomail).

 I try to use rpart. As y is binary, I use class method and get the
 following result.
  rpart(y~x,data=dat,method=class)
 n=778 (22 observations deleted due to missingness)

 node), split, n, loss, yval, (yprob)
   * denotes terminal node

 1) root 778 67 0 (0.91388175 0.08611825) *


 If with the default method, I get such a result.

  rpart(y~x,data=dat)
 n=778 (22 observations deleted due to missingness)

 node), split, n, deviance, yval
   * denotes terminal node

 1) root 778 61.230080 0.08611825
   2) x 19.5 750 53.514670 0.0773
 4) x 1.25 390 17.169230 0.04615385 *
 5) x=1.25 360 35.60 0.1110 *
   3) x=19.5 28  6.107143 0.32142860 *

 If I use 1.25 and 19.5 as the cutting points, change x into factor by
 x2 - cut(q34b,breaks=c(0,1.25,19.5,200),right=F)

 The coef in y~x2 is significant and makes sense.

 My problem is: is it OK use the default method in rpart when response
 varibale is binary one?  Thanks.


 --
 Ronggui Huang
 Department of Sociology
 Fudan University, Shanghai, China

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



-- 
WenSui Liu
A lousy statistician who happens to know a little programming
(http://spaces.msn.com/statcompute/blog)

__
R-help@stat.math.ethz.ch 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] Error: bad value ? what is that?

2007-06-15 Thread Jose
Peter Dalgaard p.dalgaard at biostat.ku.dk writes:

 
 Jose Quesada wrote:
  Hi,
 
  I'm finding a very strange error.
  For no good reason my R console (Rgui.exe, R 2.5.0, under win XP) stops  
  producing anything meaningful, and just returns:
  Error: bad value
  to _whatever_ I enter. It starts doing this after a while, not immediately  
  when launched.
 
  I have to restart R when this happens.
  No idea why. I didn't change anything in the R config that I remenber.
 
  Any thoughts?
 
  Thanks.
 

 Hmm that message comes from deep down inside SETCAR() and friends. I 
 can't see other reasons for it than memory corruption. Are you running 
 some rogue C code? Is the machine flaky in other respects?
 
 __
 R-help at stat.math.ethz.ch 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.
 
 

Thanks Peter,

Interesting; I upgraded my laptop to 2 gigs. and from that point on, it 
sometimes fauls to hibernate (just hangs). Maybe this is related? I installed 
an XP patch to solve hibernation problems with laptops over 2 gigs...

Maybe it didn't work?

-Jose
Re: Rogue c code: I was running library(Matrix), which is a pretty complicated 
piece of code and surely has c 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] [OT] 'gv' and fractional points

2007-06-15 Thread Ted Harding
Hi Folks,

This is off-topic R-wise, but it may be close to
the heart of many R-users, so I think it may be
the best place to ask!

Users of 'gv' (the front end to ghostscript) will
be aware of the little window which gives you the
x-y coordinates (in points = 1/72 inch) of the position
of the cross-hair mouse cursor. These coordinates
are those of the corresponding position on the printed
page, relative to some origin.

I have often used this to extract numerical values
for data from graphs in Postscript files (also PDF
files, after you have converted them to PS). Then
(veering back on topic ... ) you can submit the
numerical data to R and try your own analyses on
these data, and compare with what the article does.

However, this little window only gives the numbers
in whole points. Say a smallish graphic may print
out 3 inches wide or high. Then you get precision
of 1/216 per 3 inches or 0.4% of full scale. This
can be adequate on many occasions, but can be on
the coarse side on other occasions.

Even for a 6-inch-wide/high graph, you only get down
to 0.2% of full scale.

If it were possible to induce 'gv' to display these
coordinates in tenths of a point, then much greater
precision (as adequate as one can expect to hope for
when, in effect, measuring off the graph) could be
obtained.

Does anyone know:
a) Whether it is possible to persuade 'gv' to give
   this display in fractional points (my own search
   of the documentation has not revealed anything);
b) Of any alternative to 'gv' as PS viewer which would
   provide this capability?

With thanks, and best wishes to all,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 16:13:21
-- 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] registration density profiles : FDA

2007-06-15 Thread Bellanger Lise
Hello,


   I would like to use  fda library to compare sampled curves that 
are density profiles. But I encounter some problems to register my data :
I know that I must use a registration function to align functions in 
order to have important features found in each curve occur at roughly 
the same argument value, prior to do subsequent analysis ( PCA and 
cluster analysis).   But I do not know which function (if there exists 
one) allows me  to synchronize density profiles : could help me please ?

   Thank you by advance

   Best regards

 Lise Bellanger

-- 
Lise Bellanger, 
Université de Nantes
Département de Mathématiques, Laboratoire Jean Leray UMR CNRS 6629 
2, Rue de la Houssinière BP 92208 - F-44322 Nantes Cedex 03 
Tél. : (33|0) 2 51 12 59 00 (ou 43) - Fax : (33|0) 2 51 12 59 12 
E-Mail : [EMAIL PROTECTED]
URL : http://www.math.sciences.univ-nantes.fr/

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


Re: [R] Problem with workspace loading after languageR use

2007-06-15 Thread Pfister
Dear Brian,

thanks a lot for your advice.

Prof Brian Ripley wrote:
 On Fri, 15 Jun 2007, Prof Brian Ripley wrote:
 

 I think adding the following to your new session before load() will help

 findPackageEnv - function(info)
   as.environment(paste(package, info, sep=:))

this does not work.

 
 more likely
 
 findPackageEnv - function(info) as.environment(info)

this works, if I load the languageR library before.

 
 is correct.

 will work, but if not try

 findPackageEnv - function(info) .GlobalEnv

this works unconditionally. Including that line in a local .RProfile 
file, basically solves the problem.


 If you send me the problematic workspace (or reproduction 
 instructions) I can take a closer look.

A typical session would look like this (using example data from Hox(2002)):

# from Hox (2002)
hoxpop - 
read.table(http://www.ruediger-pfister.de/download/popular.dat;, 
header=TRUE)
hoxpop$PUPIL - factor(hoxpop$PUPIL)
hoxpop$SCHOOL - factor(hoxpop$SCHOOL)
hoxpop$SEX - factor(hoxpop$SEX)

# load languageR
library(languageR)

# do some analyses ...

# save the workspace
save.image(D:\\statistics\\MultilevelAnalysis\\lm.RData)


After quitting R, the workspace lm.RData will not reload.
(this workspace can be downloaded here: 
http://www.ruediger-pfister.de/Downloads/lmRData.zip)


best
Rüdiger





 On Fri, 15 Jun 2007, Pfister wrote:

 Hello R,

 To analyze multi-level data, I started learning and using lmer. So far
 so wonderful. I then found some useful functions in package languageR.
 But then the following problem ocurred: Whenever I load and use the
 languageR package, then save the workspace - or quit R with saving the
 workspace - I am unable to reload that workspace in a later session.
 That is, R doesn't start at all when I try to start it by clicking the
 workspace file.
 Loading languageR before loading the workspace doesn't help, but yields
 the message:

 Error in load(D:\\statistics\\MultilevelAnalysis\\.RData) :
 could not find function findPackageEnv

 Thus, the saved workspace remains inaccessible. I not 100% certain that
 languageR is the scapegoat, but my trial-and-error experiments indicate
 it is.

 My system is Win XP Home/Professional:

  sessionInfo()
 R version 2.5.0 Patched (2007-04-24 r41305)
 i386-pc-mingw32
 locale:
 LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252
  

 attached base packages:
 [1] splines   stats graphics  grDevices utils
 [6] datasets  methods   base
 other attached packages:
   languageR   rpartMASS  Designsurvival
   0.23.1-367.2-342.0-12  2.31
   Hmisc   e1071   class cluster   zipfR
 3.3-21.5-167.2-341.11.7 0.6-0
lme4coda  Matrix lattice
 0.99875-10.11-2 0.99875-20.15-8


 thanks for any helpful suggestions!

 best
 Rüdiger





 

-- 
Hans-Rüdiger Pfister
Professor of Business Psychology
University of Lüneburg
Faculty for Business Administration, Behavioral Sciences and Law
Institute of Experimental Industrial Psychology (LueneLab)
Wilschenbrucher Weg 84
D-21335 Lüneburg, Germany
+49-(0)4131 677 7759
[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] how to compute a garch model with t innovations ?

2007-06-15 Thread Benoit Chemineau
Hi, dear R users,

I'm a new user of R and especially in time series modelling. I would like to
know how to compute arch/garch model using innovations that are not normally
distributed (Student / swew-Student distriibuted).
The *garch*  function in the time series fits a Generalized Autoregressive
Conditional Heteroscedastic GARCH(p, q) time series model to the data by
computing the maximum-likelihood estimates of the conditionally normal
model.

What function/package should I use ?

Thanks !

[[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] R vs. Splus in Pharma/Devices Industry

2007-06-15 Thread Greg Snow
I am happy to say nice things about odfWeave.  Before it was released I
was looking at the RTF spec to see if I could write an RTF driver for
sweave.  But the task was a bit daunting and I doubt that I would have
had time for it.  So, I was (and still am) exited when odfWeave came
out.  It is a big time saver for  me and I have shown it to several
other people as well.

I have looked at ooconvert, but unfortunately the current version is
limited to *nix, and I am currently in a MS windows world.  I tried
getting it to run under cygwin at one point, but did not succeed at the
time.  Once it is available more generally, I will just set up Makefiles
so that I can automatically produce either .doc or .pdf documents from
my templates and data.

Thanks for the great package,

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

 -Original Message-
 From: Kuhn, Max [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 14, 2007 3:11 PM
 To: Greg Snow; [EMAIL PROTECTED]; r-help@stat.math.ethz.ch
 Subject: RE: [R] R vs. Splus in Pharma/Devices Industry
 
 Greg,
 
 Thanks for the kind words about odfWeave.
 
  These reports are usually put out as internal webpages for various 
  people in the organization to look at, so we could either go the 
  odfWeave approach and generate pdf files (not as automated 
 as I would
  like)
 
 I agree that automating the conversion should be easier. My 
 wish would be that the OO binary had a flag to convert from 
 one format to another.
 
 On Linux, there is a bash script that uses the open office 
 binaries to do the conversion at the command line by Nathan Coulter at
 
http://sourceforge.net/projects/ooconvert/
 
 Also, there is a Java class called jooconvert out there (if memory
 serves) that has similar functionality.
 
 Max
 
 
 
 --
 LEGAL NOTICE
 Unless expressly stated otherwise, this message is 
 confidential and may be privileged.  It is intended for the 
 addressee(s) only.  Access to this E-mail by anyone else is 
 unauthorized.  If you are not an addressee, any disclosure or 
 copying of the contents of this E-mail or any action taken 
 (or not taken) in reliance on it is unauthorized and may be 
 unlawful.  If you are not an addressee, please inform the 
 sender immediately.


__
R-help@stat.math.ethz.ch 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] 'gv' and fractional points

2007-06-15 Thread hadley wickham
This doesn't answer your original question, and isn't much help unless
you're on a mac, but there's a nice looking program that makes this
kind of graph scraping really easy:
http://www.arizona-software.ch/applications/graphclick/en/

Hadley

On 6/15/07, Ted Harding [EMAIL PROTECTED] wrote:
 Hi Folks,

 This is off-topic R-wise, but it may be close to
 the heart of many R-users, so I think it may be
 the best place to ask!

 Users of 'gv' (the front end to ghostscript) will
 be aware of the little window which gives you the
 x-y coordinates (in points = 1/72 inch) of the position
 of the cross-hair mouse cursor. These coordinates
 are those of the corresponding position on the printed
 page, relative to some origin.

 I have often used this to extract numerical values
 for data from graphs in Postscript files (also PDF
 files, after you have converted them to PS). Then
 (veering back on topic ... ) you can submit the
 numerical data to R and try your own analyses on
 these data, and compare with what the article does.

 However, this little window only gives the numbers
 in whole points. Say a smallish graphic may print
 out 3 inches wide or high. Then you get precision
 of 1/216 per 3 inches or 0.4% of full scale. This
 can be adequate on many occasions, but can be on
 the coarse side on other occasions.

 Even for a 6-inch-wide/high graph, you only get down
 to 0.2% of full scale.

 If it were possible to induce 'gv' to display these
 coordinates in tenths of a point, then much greater
 precision (as adequate as one can expect to hope for
 when, in effect, measuring off the graph) could be
 obtained.

 Does anyone know:
 a) Whether it is possible to persuade 'gv' to give
this display in fractional points (my own search
of the documentation has not revealed anything);
 b) Of any alternative to 'gv' as PS viewer which would
provide this capability?

 With thanks, and best wishes to all,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 15-Jun-07   Time: 16:13:21
 -- 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-help@stat.math.ethz.ch 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] model.frame: how does one use it?

2007-06-15 Thread Dirk Eddelbuettel

Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
In short, the issue has to do with how rpart evaluates a formula and
supporting arguments, in particular 'weights'.  

A simple contrived example is

-
library(rpart)

## using data from help(rpart), set up simple example
myformula - formula(Kyphosis ~ Age + Number + Start)
mydata - kyphosis
myweight - abs(rnorm(nrow(mydata)))

goodFunction - function(mydata, myformula, myweight) {
  hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
  prev - hyp
}
goodFunction(mydata, myformula, myweight)
cat(Ok\n)

## now remove myweight and try to compute it inside a function
rm(myweight)

badFunction - function(mydata, myformula) {
  myweight - abs(rnorm(nrow(mydata)))
  mf - model.frame(myformula, mydata, myweight)
  print(head(df))
  hyp - rpart(myformula,
   data=mf,
   weights=myweight,
   method=class)
  prev - hyp
}
badFunction(mydata, myformula)
cat(Done\n)
-

Here goodFunction works, but only because myweight (with useless random
weights, but that is not the point here) is found from the calling
environment. 

badFunction fails after we remove myweight from there:

:~ cat /tmp/philipp.R | R --slave
Ok
Error in eval(expr, envir, enclos) : object myweight not found
Execution halted
:~

As I was able to replicate it, I reported this to the package maintainer.  It
turns out that seemingly all is well as this is supposed to work this way,
and I got a friendly pointer to study model.frame and its help page.  

Now I am stuck as I can't make sense of model.frame -- see badFunction
above. I would greatly appreciate any help in making rpart work with a local
argument weights so that I can tell Philipp that there is no bug.  :)

Regards, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
R-help@stat.math.ethz.ch 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] subscript out of bounds error in lda

2007-06-15 Thread Silvia Lomascolo

I work with Windows, R version 2.4.1

I'm trying to do a discriminant analysis and, in trying to figure out how to
do it following the example from R help, I'm getting an error that says
'subscript out of bounds'.  I don't know what this means and how to solve it
(I'm very new with R)

I'm doing everything in this made-up test matrix:

   group var1 var2 var3
1  13   556
2  14   667
3  15   558
4  14   667
5  13   446
6  14   555
7  25   889
8  24   998
9  28   889
10 29   768
11 28   669
12 29   99   10
13 2   10  1009

I write:

data.tb-read.table('locationHere.txt', header=T)
data.df-as.data.frame (data.tb)
   
train-sample (1:63, 30)

   
table (data.df$group[train])
 
data.disc-lda(group~., data.tb, subset = train)
 
data.disc   
 
predict (data.disc, data.df[-train,])$class  

This is where I get the message:

Error in `[.data.frame`(data.df, -train, ) : 
subscript out of bounds

Can anyone, please help me figure out what this is about? Thanks!

Silvia.
-- 
View this message in context: 
http://www.nabble.com/subscript-out-of-bounds-error-in-lda-tf3928773.html#a11142304
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] A question about logical controls and function arguements

2007-06-15 Thread Jason Q McClintic
Dear R-help subscribers,

I'm trying to write a function to generate data simulating the image
created by a point radiation source in a plane on a screen where there
is filter with a single circular aperture in it between the source and
the screen.

Following some guides (including Intro to R and some I found online) and
examples I have specified the function (full code below question) with
several arguments with the form:

option=c(option1,option2)

For instance, I want filter to either be FALSE to tell the function
there is no filter or an ordered triplet describing the location and
radius of the area radiation is not blocked by the filter. There are
several others along similar lines.

When I source the function into R, it parses fine, but when attempting
to run it with

data.spect-spect.data(source.p=r,filter=c(0,0,1),file.out=FALSE)

the following warning is returned:

Warning messages:
1: the condition has length  1 and only the first element will be used
in: if (filter == FALSE) {
2: the condition has length  1 and only the first element will be used
in: if (filter == FALSE) {

The code this is referencing is about 1/3 from the bottom of the function.

I'm not sure how to correct this. I tried ifelse in one case and it
doesn't work at all. Searching the archives for function arguments
didn't yield anything about the kind of arguments that are causing the
trouble.

I also want to get the matrix of generated data out, and have tried
data.spect$final.sample (following an example I found online), but it
returns null. I also attempted to use data.spect$initial.sample, but
this returned null as well.

I'm still very new to writing my own functions, and any and all help
would be appreciated.

There are notes about what different options are supposed to do at the
end of the appended code.

Thanks in advance,

Jason Q McClintic
--
Jason Q McClintic
[EMAIL PROTECTED]
[EMAIL PROTECTED]

spect.data-function(num.points=50,fixed=FALSE,source.p=c(r,c(0,0)),
   source.mean=0,source.sd=1,filter=c(FALSE,c(0,0,1)),
   heights=c(0.5,0.5),
   file.out=c(FALSE,/home/jqmcclintic/Desktop/spect.data)){
##Determine Start Point
if (source.p==r)
{source-c(rnorm(1,source.mean,source.sd),rnorm(1,source.mean,source.sd))}
else {source-source.p}
cat(The location of the source is: ,source,\n)
##Generate the data
remainder-num.points
initial.sample-c(1,1)
##finds intersection points with the screen
intersect.screen.at-function(x,h){
t-h[1]/(2*cos(x))
x.intercept-t*sin(x[,2])*cos(x[,1])
y.intercept-t*sin(x[,2])*sin(x[,1])
}
##finds intersection points with the collecting plate
intersect.plate.at-function(x,h){
t-h[2]/(2*cos(x))
x.intercept-t*sin(x[,2])*cos(x[,1])
y.intercept-t*sin(x[,2])*sin(x[,1])
}
##determines if the intersection point is inside or outside the hole in
the screen. x is the matrix of intersection points and s is the location
and radius of the hole in the screen. 1 for yes, 0 for no.
passes.through-function(x,s){
distance-sqrt(((x[,1]-s[1])^2)+((x[,2]-s[2])^2))
through-ifelse(distances[3],1,0)
}
##Build the sample
while (remainder0){
##Generate n random vectors uniformly distributed over S2
theta-runif(remainder,0,6.2831853)
phi-runif(remainder,0,1.5707963)
theta.phi-cbind(theta,phi)
initial.sample-rbind(initial.sample,theta.phi)
##Call intersect.screen.at
intersects.screen-intersect.screen.at(initial.sample,heights)
##Call intersect.plate.at
intersects.plate-if(filter==FALSE)
{intersect.screen.at(initial.sample,heights)} else {
intersect.plate.at(initial.sample,heights)
}
##Does it intersect inside or outside the hole?

intersect.hole-if(filter==FALSE){array(1,dim=length(initial.sample))}
else{passes.through(intersects.screen,filter)}
##Remove points that do not pass throught the hole. By design, 
if
there is no filter, all pass through the hole.
initial.sample-cbind(initial.sample,intersect.hole)
initial.sample-subset(initial.sample,initial.sample[,3]==1)
##Reset remainder
remainder-if(fixed==FALSE) {0} else {
num.points-length(initial.sample)
}
}
write(initial.sample)
##remove the top row of the initial sample since it is non-random.
final.sample-initial.sample[-1,]
##print the final sample to a csv file for archival purposes

Re: [R] Problem with workspace loading after languageR use

2007-06-15 Thread Prof Brian Ripley
Thank you for the example: it has enabled me to test a more comprehensive 
fix for R-patched (soon to be 2.5.1).


You should have got a warning when saving along the lines of

Warning message:
'package:languageR' may not be available when loading in: save(list = 
ls(envir = .GlobalEnv, all.names = TRUE), file = outfile,


The problem is indeed in package languageR, which is creating classes and 
methods in your workspace rather than in its package.  It really should 
not be doing so (it uses setMethod in .First.lib), and I am Cc:ing the 
maintainer in the hope that he will stop doing so.


I also find it hard to believe that

Depends: R (= 2.4.0), methods, lattice, Matrix, coda, lme4, zipfR, 
cluster, e1071, Design, Hmisc, MASS, rpart


is totally necessary, and suggest that Suggests: is used.



On Fri, 15 Jun 2007, Pfister wrote:


Dear Brian,

thanks a lot for your advice.

Prof Brian Ripley wrote:

On Fri, 15 Jun 2007, Prof Brian Ripley wrote:



I think adding the following to your new session before load() will help

findPackageEnv - function(info)
  as.environment(paste(package, info, sep=:))


this does not work.



more likely

findPackageEnv - function(info) as.environment(info)


this works, if I load the languageR library before.



is correct.


will work, but if not try

findPackageEnv - function(info) .GlobalEnv


this works unconditionally. Including that line in a local .RProfile file, 
basically solves the problem.




If you send me the problematic workspace (or reproduction instructions) I 
can take a closer look.


A typical session would look like this (using example data from Hox(2002)):

# from Hox (2002)
hoxpop - read.table(http://www.ruediger-pfister.de/download/popular.dat;, 
header=TRUE)

hoxpop$PUPIL - factor(hoxpop$PUPIL)
hoxpop$SCHOOL - factor(hoxpop$SCHOOL)
hoxpop$SEX - factor(hoxpop$SEX)

# load languageR
library(languageR)

# do some analyses ...

# save the workspace
save.image(D:\\statistics\\MultilevelAnalysis\\lm.RData)


After quitting R, the workspace lm.RData will not reload.
(this workspace can be downloaded here: 
http://www.ruediger-pfister.de/Downloads/lmRData.zip)



best
Rüdiger






On Fri, 15 Jun 2007, Pfister wrote:


Hello R,

To analyze multi-level data, I started learning and using lmer. So far
so wonderful. I then found some useful functions in package languageR.
But then the following problem ocurred: Whenever I load and use the
languageR package, then save the workspace - or quit R with saving the
workspace - I am unable to reload that workspace in a later session.
That is, R doesn't start at all when I try to start it by clicking the
workspace file.
Loading languageR before loading the workspace doesn't help, but yields
the message:

Error in load(D:\\statistics\\MultilevelAnalysis\\.RData) :
could not find function findPackageEnv

Thus, the saved workspace remains inaccessible. I not 100% certain that
languageR is the scapegoat, but my trial-and-error experiments indicate
it is.

My system is Win XP Home/Professional:

 sessionInfo()
R version 2.5.0 Patched (2007-04-24 r41305)
i386-pc-mingw32
locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252 
attached base packages:

[1] splines   stats graphics  grDevices utils
[6] datasets  methods   base
other attached packages:
  languageR   rpartMASS  Designsurvival
  0.23.1-367.2-342.0-12  2.31
  Hmisc   e1071   class cluster   zipfR
3.3-21.5-167.2-341.11.7 0.6-0
   lme4coda  Matrix lattice
0.99875-10.11-2 0.99875-20.15-8


thanks for any helpful suggestions!

best
Rüdiger













--
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] A question about logical controls and function arguements

2007-06-15 Thread Jason Q McClintic
Sir,

I freely admit my ignorance as to the subtleties of specifying arguments.

Let me make sure I understand your suggestion: create a variable filter
which takes 1 or 0 (filter or not) and another called, say,
filter.location which is the ordered triplet.

It does add to the number of options, but would seem to simplify the
underlying code. It appears I may have attempted to code above my skill
level.

Thanks for the assistance,

Jason Q McClintic
--
Jason Q McClintic
[EMAIL PROTECTED]
[EMAIL PROTECTED]

jim holtman wrote:
 You are trying to use 'filter' in two ways.  Your code is testing for a
 single value (FALSE), and that is all that == can do (single value),
 but you are pass in a vector (c(0,0,1)) which has three values, on the
 first of which can be tested by the ==.
  
 So you might want to consider having another parameter which says
 whether or not to use filter.
 
  
 On 6/15/07, *Jason Q McClintic* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Dear R-help subscribers,
 
 I'm trying to write a function to generate data simulating the image
 created by a point radiation source in a plane on a screen where there
 is filter with a single circular aperture in it between the source and
 the screen.
 
 Following some guides (including Intro to R and some I found online)
 and
 examples I have specified the function (full code below question) with
 several arguments with the form:
 
 option=c(option1,option2)
 
 For instance, I want filter to either be FALSE to tell the function
 there is no filter or an ordered triplet describing the location and
 radius of the area radiation is not blocked by the filter. There are
 several others along similar lines.
 
 When I source the function into R, it parses fine, but when attempting
 to run it with
 
 data.spect-spect.data(source.p=r,filter=c(0,0,1),file.out=FALSE)
 
 the following warning is returned:
 
 Warning messages:
 1: the condition has length  1 and only the first element will be used
. in: if (filter == FALSE) {
. 2: the condition has length  1 and only the first element will
be used
 in: if (filter == FALSE) {
.
 The code this is referencing is about 1/3 from the bottom of the
 function.
 
 I'm not sure how to correct this. I tried ifelse in one case and it
 doesn't work at all. Searching the archives for function arguments
 didn't yield anything about the kind of arguments that are causing the
 trouble.
 I also want to get the matrix of generated data out, and have tried
 data.spect$final.sample (following an example I found online), but it
 returns null. I also attempted to use data.spect$initial.sample , but
 this returned null as well.
 
 I'm still very new to writing my own functions, and any and all help
 would be appreciated.
 
 There are notes about what different options are supposed to do at the
. end of the appended code.
 
 Thanks in advance,
 
 Jason Q McClintic
 --
 Jason Q McClintic
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 
 spect.data-function(num.points=50,fixed=FALSE,source.p=c(r,c(0,0)),
   source.mean=0,source.sd=1,filter=c(FALSE,c(0,0,1)),
   heights=c(0.5,0.5),
   file.out=c (FALSE,/home/jqmcclintic/Desktop/spect.data)){
##Determine Start Point
if (source.p==r)
 {source-c(rnorm(1,source.mean,source.sd http://source.sd
 ),rnorm(1,source.mean,source.sd http://source.sd))}
 else {source-source.p}
cat(The location of the source is: ,source,\n)
##Generate the data
remainder- num.points
initial.sample-c(1,1)
##finds intersection points with the screen
intersect.screen.at
 http://intersect.screen.at-function(x,h){
t-h[1]/(2*cos(x))
x.intercept-t*sin(x[,2])*cos(x[,1])
y.intercept-t*sin(x[,2])*sin(x[,1])
}
##finds intersection points with the collecting plate
intersect.plate.at
 http://intersect.plate.at-function(x,h){
t-h[2]/(2*cos(x))
x.intercept-t*sin(x[,2])*cos(x[,1])
y.intercept -t*sin(x[,2])*sin(x[,1])
.}
##determines if the intersection point is inside or outside
 the hole in
 the screen. x is the matrix of intersection points and s is the location
 and radius of the hole in the screen. 1 for yes, 0 for no.
passes.through-function(x,s){
distance-sqrt(((x[,1]-s[1])^2)+((x[,2]-s[2])^2))
through-ifelse(distances[3],1,0)
}
##Build the sample
while (remainder0){
##Generate n 

[R] Registration density profiles using FDA (Functional Data Analysis)

2007-06-15 Thread Bellanger Lise
Hello,


  I would like to use  fda (Functional data analysis) library  to 
compare sampled curves that are density profiles. But I encounter some 
problems to register my data as functional data.
I know that I must use a registration function to align functions in 
order to have important features found in each curve occur at roughly 
the same argument value, prior to do subsequent analysis ( PCA and 
cluster analysis).   But I do not know which function (if there exists 
one) allows me  to synchronize density profiles : could help me please ?

  Thank you by advance

  Best regards

Lise Bellanger

-- 
Lise Bellanger, 
Université de Nantes
Département de Mathématiques, Laboratoire Jean Leray UMR CNRS 6629 
2, Rue de la Houssinière BP 92208 - F-44322 Nantes Cedex 03 
Tél. : (33|0) 2 51 12 59 00 (ou 43) - Fax : (33|0) 2 51 12 59 12 
E-Mail : [EMAIL PROTECTED]
URL : http://www.math.sciences.univ-nantes.fr/

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


Re: [R] subscript out of bounds error in lda

2007-06-15 Thread Prof Brian Ripley
On Fri, 15 Jun 2007, Silvia Lomascolo wrote:


 I work with Windows, R version 2.4.1

 I'm trying to do a discriminant analysis and, in trying to figure out how to
 do it following the example from R help, I'm getting an error that says
 'subscript out of bounds'.  I don't know what this means and how to solve it
 (I'm very new with R)

 I'm doing everything in this made-up test matrix:

   group var1 var2 var3
 1  13   556
 2  14   667
 3  15   558
 4  14   667
 5  13   446
 6  14   555
 7  25   889
 8  24   998
 9  28   889
 10 29   768
 11 28   669
 12 29   99   10
 13 2   10  1009

 I write:

 data.tb-read.table('locationHere.txt', header=T)
 data.df-as.data.frame (data.tb)

Wny call as.data.frame on a data frame?

 train-sample (1:63, 30)

Why sample from 1:63 with 13 rows?

 table (data.df$group[train])
 data.disc-lda(group~., data.tb, subset = train)
 data.disc
 predict (data.disc, data.df[-train,])$class

 This is where I get the message:

 Error in `[.data.frame`(data.df, -train, ) :
subscript out of bounds

traceback() is your friend:

 traceback()
8: `[.data.frame`(data.df, -train, )
7: data.df[-train, ]
6: inherits(x, data.frame)
5: is.data.frame(data)
4: model.frame.default(Terms, newdata, na.action = na.pass, xlev = 
object$xlevels)
3: model.frame(Terms, newdata, na.action = na.pass, xlev = object$xlevels)
2: predict.lda(data.disc, data.df[-train, ])
1: predict(data.disc, data.df[-train, ])


So, let's take a look at the top lines.

 train
  [1] 46 42 30 13 27 63 19 47  3 52 62 16 26  4 61 23 59 44 40 38 25 55 50 
10 43
[26]  2  8 31  7 11
 nrow(data.df)
[1] 13

So, you are asking for number 46 out of 13 rows.  Now perhaps you didn't 
show us all the problem, but hopefully this helps you find the error.  If 
not, the bottom of every R-help message says

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] problems with matrix, list and other..

2007-06-15 Thread billycorg

thank you!
it works with:
E=list()
length(E)=1096
for(i in (2:1096)){E[[i]]=crossprod(solve(d[[i]]),cbind(e[[i]]))}




Petr Klasterecky wrote:
 
 You only got what you deserved when not reading the manual...
 R-Intro, Chapters 5 and 6, page 26 in particular.
 http://cran.r-project.org/doc/manuals/R-intro.pdf
 
 Petr
 
 
 billycorg napsal(a):
 hi
 
 can anyone help me to solve these problems?
 
 i have:
 1) d matrix with 1096 rows;
 for example, 
 d[2]=
[,1]   [,2]  [,3]
 [1,] 0.1192566 0.000 0.000
 [2,] 0.000 0.1065938 0.000
 [3,] 0.000 0.000 0.103
 
 if I
 class (d[2]) = list 
 solve(d[2]) = error!!!
 
 2) e list with 1096 rows;
 for example
 e[2]2=
 [[1]]
 [1] -1.0892216 -0.7304947 -1.2883680
 
 d[2]%*%t(e[2])
 this is the error: requires numeric matrix/vector arguments
 
 i've tried to coerce e to a matrix, but it's doesn't work...
 
 in the end.. i'd like this:
 for (i in (1:1096)) {solve(d[i])*t(e[i])}
 
 help me, please :)
 
 Vincenzo
 
 -- 
 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/problems-with-matrix%2C-list-and-other..-tf3926701.html#a11144182
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] text display using expression or not

2007-06-15 Thread Sarah Goslee
Hello,

I imagine that I'm missing something straightforward, but a run thru
the help files didn't turn up an answer.

I noticed while formatting some figures for publication that text
enclosed in expression() and used for a title displays differently
than a string, regardless of the par options. On both postscript()
and x11() devices, the regular text is heavier than the expression text.

Here's an example. The real thing used expression() to
produce superscripts, but I boiled this down to the simplest possible
case.

par(mfrow=c(2,1))
plot(1:10, 1:10, main=Figure A)
plot(1:10, 1:10, main=expression(Figure B))

Is there some straightforward way to make them match, other
than putting expression() around all strings?


I'm currently using R 2.5.0 on Fedora core 5.

Thanks,
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] complex contrasts and logistic regression

2007-06-15 Thread Nicholas Lewin-Koh
Hi,
I am doing a retrospective analysis on a cohort from a designed trial,
and I am fitting
the model

fit-glmD(survived ~ Covariate*Therapy + confounder,myDat,X=TRUE,
Y=TRUE, family=binomial()) 

My covariate has three levels (A,B and C) and therapy has two
(treated and control), confounder is a continuous variable.
Also patients were randomized to treatment in the trial, but Covariate
is something that is measured
posthoc and can vary in the population.
 
I am trying to wrap my head around how to calculate a few quantities
from the model
and get reasonable confidence intervals for them, namely I would like to
test

H0: gamma=0, where gamma is the regression coefficient of the odds
ratios of surviving
 under treatment vs control at each level of Covariate
 (adjusted for the confounder)

and I would like to get the odds of surviving at each level of Covariate
under treatment and control
for each level of covariate adjusted for the confounder. I have looked
at contrast in the Design 
library but I don't think it gives me the right quantity, for instance 

contrast(fit,list(covariate=A, Therapy=Treated,
confounder=median(myDat$confounder), X=TRUE)
( A is the baseline level of Covariate) 

gives me beta0 + beta_Treated + beta_confounder*68  

Is this correctly interpreted as the conditional odds of dying? 
As to the 1st contrast I am not sure how to get it, would it be using
type = 'average' with some weights 
in contrast? The answers are probably staring me in the face, i am just
not seeing them today.

Nicholas

__
R-help@stat.math.ethz.ch 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-15 Thread Kuhn, Max
Greg,

 I have looked at ooconvert, but unfortunately the current version is
 limited to *nix, and I am currently in a MS windows world.  I tried
 getting it to run under cygwin at one point, but did not succeed at
the
 time.  Once it is available more generally, I will just set up
Makefiles
 so that I can automatically produce either .doc or .pdf documents from
 my templates and data.

I found the Java tool at

   http://www.artofsolving.com/opensource/jodconverter

(they changed the name). I just tried it on my Windows machine and it
worked. You have to start a headless soffice process (see the readme
file) and then it is a simple command line away.

Max

--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{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] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread new ruser
I have an array such as:

x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 ,  test=77)

I wish to remove values where both the name and the value are identical.

eg. i wish to end up with:
x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)
 
What is the best way to do this?

   
-
Park yourself in front of a world of choices in alternative vehicles.

[[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] [OT] 'gv' and fractional points

2007-06-15 Thread Deepayan Sarkar
On 6/15/07, Ted Harding [EMAIL PROTECTED] wrote:
 Hi Folks,

 This is off-topic R-wise, but it may be close to
 the heart of many R-users, so I think it may be
 the best place to ask!

 Users of 'gv' (the front end to ghostscript) will
 be aware of the little window which gives you the
 x-y coordinates (in points = 1/72 inch) of the position
 of the cross-hair mouse cursor. These coordinates
 are those of the corresponding position on the printed
 page, relative to some origin.

 I have often used this to extract numerical values
 for data from graphs in Postscript files (also PDF
 files, after you have converted them to PS). Then
 (veering back on topic ... ) you can submit the
 numerical data to R and try your own analyses on
 these data, and compare with what the article does.

 However, this little window only gives the numbers
 in whole points. Say a smallish graphic may print
 out 3 inches wide or high. Then you get precision
 of 1/216 per 3 inches or 0.4% of full scale. This
 can be adequate on many occasions, but can be on
 the coarse side on other occasions.

If you are mostly concerned about small figures, one possibility is

1. zoom out to a level where you're happy with the pixel resolution
2. do a screen capture using 'import'
3. use gimp (which has the same feature, with more units)

gimp can also load PS files directly, with a user supplied zoom factor
at load time, but only one page at a time, AFAICT.

-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] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread jim holtman
try this:

 x[!(duplicated(names(x))duplicated(x))]
  sum   min   max count count  test
   77 4 9 5 877



On 6/15/07, new ruser [EMAIL PROTECTED] wrote:

 I have an array such as:

 x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 ,  test=77)

 I wish to remove values where both the name and the value are identical.

 eg. i wish to end up with:
 x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)

 What is the best way to do this?


 -
 Park yourself in front of a world of choices in alternative vehicles.

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread Marc Schwartz
On Fri, 2007-06-15 at 11:19 -0700, new ruser wrote:
 I have an array such as:
 
 x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 ,  test=77)
 
 I wish to remove values where both the name and the value are identical.
 
 eg. i wish to end up with:
 x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)
  
 What is the best way to do this?

Not sure if this is the best way, but since you need to compare both the
values and their name attributes for 'uniqueness':

 x[!(duplicated(x)  duplicated(names(x)))]
  sum   min   max count count  test 
   77 4 9 5 877 


What is being done is to first compare the values for duplicates. Note
that the second value is identified as the duplicate, not the first:

 duplicated(x)
[1] FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE  TRUE

and then compare the names for duplicates:

 duplicated(names(x))
[1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE


Then compare the two logical vectors and get the indices where BOTH are
TRUE:

 (duplicated(x)  duplicated(names(x)))
[1] FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE


Now, negate the relation:

 !(duplicated(x)  duplicated(names(x)))
[1]  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE


and return the values in 'x' that satisfy the logical indices:

 x[!(duplicated(x)  duplicated(names(x)))]
  sum   min   max count count  test 
   77 4 9 5 877 



See ?duplicated.  You might also want to look
at ?unique, ?identical, ?all.equal and ?isTRUE.

Note that the above example will likely fail if any of the values are
floats:

 duplicated(c(0.5 - 0.4, 0.1))
[1] FALSE FALSE

in which case, you would need to use a looping structure where the value
comparisons use isTrue(all.equal(...)) instead.


HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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 vs. Splus in Pharma/Devices Industry

2007-06-15 Thread Nicholas Lewin-Koh
Hi,
I just saw this thread. This issue, and the larger scale issue of open
source in industry
is being addressed. One has to realize that the behemoth that is the
clinical aperatus
of the pharma industry is very conservative and very slow to change. In
many cases 
switching to R would meean changing a great many processes all based on
legacy code. One
of the big issues is that the industry demands consistency not
necessarily correctness.

All that said there are a great many areas where R could be used that
would not impact
regulatory submission, data security etc. Many in pharma are quietly
working on this,
but steps are small and incremental. Development takes time in industry
because of the amount of
documentation necessary. All this impacts the free nature of R and
cost and risk (From the industries
perspective) need to be justified. 

Probably when the statistical community is using Z big pharma will be
ready to use
R. %P

Nicholas

__
R-help@stat.math.ethz.ch 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 plot two graphics in one window

2007-06-15 Thread Miguel Caro

Hello ,
Maybe this question you answered before, but i couldnt find something
indicated in the mailing list.

I wish to plot two graphics  in one window, for example y=sinx and y=exp(x)
in the same windows, (the same interval for x).

Thanks .

Miguel.
-- 
View this message in context: 
http://www.nabble.com/how-to-plot-two-graphics-in-one-window-tf3929594.html#a11145186
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] model.frame: how does one use it?

2007-06-15 Thread Deepayan Sarkar
On 6/15/07, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:

 Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
 In short, the issue has to do with how rpart evaluates a formula and
 supporting arguments, in particular 'weights'.

 A simple contrived example is

 -
 library(rpart)

 ## using data from help(rpart), set up simple example
 myformula - formula(Kyphosis ~ Age + Number + Start)
 mydata - kyphosis
 myweight - abs(rnorm(nrow(mydata)))

 goodFunction - function(mydata, myformula, myweight) {
   hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
   prev - hyp
 }
 goodFunction(mydata, myformula, myweight)
 cat(Ok\n)

 ## now remove myweight and try to compute it inside a function
 rm(myweight)

 badFunction - function(mydata, myformula) {
   myweight - abs(rnorm(nrow(mydata)))
   mf - model.frame(myformula, mydata, myweight)
   print(head(df))
   hyp - rpart(myformula,
data=mf,
weights=myweight,
method=class)
   prev - hyp
 }
 badFunction(mydata, myformula)
 cat(Done\n)
 -

 Here goodFunction works, but only because myweight (with useless random
 weights, but that is not the point here) is found from the calling
 environment.

 badFunction fails after we remove myweight from there:

 :~ cat /tmp/philipp.R | R --slave
 Ok
 Error in eval(expr, envir, enclos) : object myweight not found
 Execution halted
 :~

 As I was able to replicate it, I reported this to the package maintainer.  It
 turns out that seemingly all is well as this is supposed to work this way,
 and I got a friendly pointer to study model.frame and its help page.

 Now I am stuck as I can't make sense of model.frame -- see badFunction
 above. I would greatly appreciate any help in making rpart work with a local
 argument weights so that I can tell Philipp that there is no bug.  :)

I don't know if ?model.frame is the best place page to look. There's a
more detailed description at

http://developer.r-project.org/nonstandard-eval.pdf

but here are the non-standard evaluation rules as I understand them:
given a name in either (1) the formula or (2) ``special'' arguments like
'weights' in this case, or 'subset', try to find the name

1. in 'data'
2. failing that, in environment(formula)
3. failing that, in the enclosing environment, and so on.

By 'name', I mean a symbol, such as 'Age' or 'myweight'.  So
basically, everything is as you would expect if the name is visible in
data, but if not, the search starts in the environment of the formula,
not the environment where the function call is being made (which is
the standard evaulation behaviour).  This is a feature, not a bug
(things would be a lot more confusing if it were the other way round).


With this in mind, either of the following might do what you want:

badFunction - function(mydata, myformula) {
mydata$myweight - abs(rnorm(nrow(mydata)))
hyp -
rpart(myformula,
  data=mydata,
  weights=myweight,
  method=class)
prev - hyp
}


badFunction - function(mydata, myformula) {
myweight - abs(rnorm(nrow(mydata)))
environment(myformula) - environment()
hyp -
rpart(myformula,
  data=mydata,
  weights=myweight,
  method=class)
prev - hyp
}

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


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

2007-06-15 Thread Cody_Hamilton

Nicholas,

You're making me depressed!

Cody Hamilton, PhD
Edwards Lifesciences

Hi,
I just saw this thread. This issue, and the larger scale issue of open
source in industry
is being addressed. One has to realize that the behemoth that is the
clinical aperatus
of the pharma industry is very conservative and very slow to change. In
many cases
switching to R would meean changing a great many processes all based on
legacy code. One
of the big issues is that the industry demands consistency not
necessarily correctness.

All that said there are a great many areas where R could be used that
would not impact
regulatory submission, data security etc. Many in pharma are quietly
working on this,
but steps are small and incremental. Development takes time in industry
because of the amount of
documentation necessary. All this impacts the free nature of R and
cost and risk (From the industries
perspective) need to be justified.

Probably when the statistical community is using Z big pharma will be
ready to use
R. %P

Nicholas

__
R-help@stat.math.ethz.ch 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] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread Patrick Burns
In case it matters, the given solution has a problem if the
data look like:

x - c(sum=77, test=99, sum=99)

By the description all three elements should be kept, but
the duplicated solution throws out the last element.  A more
complicated solution is:

unique(data.frame(x, names(x)))

(and then put the vector back together again).

Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)

jim holtman wrote:

try this:

  

x[!(duplicated(names(x))duplicated(x))]


  sum   min   max count count  test
   77 4 9 5 877



On 6/15/07, new ruser [EMAIL PROTECTED] wrote:
  

I have an array such as:

x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 ,  test=77)

I wish to remove values where both the name and the value are identical.

eg. i wish to end up with:
x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)

What is the best way to do this?


-
Park yourself in front of a world of choices in alternative vehicles.

   [[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 vs. Splus in Pharma/Devices Industry

2007-06-15 Thread Douglas Bates
On 6/15/07, Nicholas Lewin-Koh [EMAIL PROTECTED] wrote:
 Hi,
 I just saw this thread. This issue, and the larger scale issue of open
 source in industry
 is being addressed. One has to realize that the behemoth that is the
 clinical aperatus
 of the pharma industry is very conservative and very slow to change. In
 many cases
 switching to R would meean changing a great many processes all based on
 legacy code. One
 of the big issues is that the industry demands consistency not
 necessarily correctness.

 All that said there are a great many areas where R could be used that
 would not impact
 regulatory submission, data security etc. Many in pharma are quietly
 working on this,
 but steps are small and incremental. Development takes time in industry
 because of the amount of
 documentation necessary. All this impacts the free nature of R and
 cost and risk (From the industries
 perspective) need to be justified.

 Probably when the statistical community is using Z big pharma will be
 ready to use
 R. %P

I think you mean A, not Z.  First there was S, then there was R.

__
R-help@stat.math.ethz.ch 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] model.frame: how does one use it?

2007-06-15 Thread Marc Schwartz
On Fri, 2007-06-15 at 10:47 -0500, Dirk Eddelbuettel wrote: 
 Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
 In short, the issue has to do with how rpart evaluates a formula and
 supporting arguments, in particular 'weights'.  
 
 A simple contrived example is
 
 -
 library(rpart)
 
 ## using data from help(rpart), set up simple example
 myformula - formula(Kyphosis ~ Age + Number + Start)
 mydata - kyphosis
 myweight - abs(rnorm(nrow(mydata)))
 
 goodFunction - function(mydata, myformula, myweight) {
   hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
   prev - hyp
 }
 goodFunction(mydata, myformula, myweight)
 cat(Ok\n)
 
 ## now remove myweight and try to compute it inside a function
 rm(myweight)
 
 badFunction - function(mydata, myformula) {
   myweight - abs(rnorm(nrow(mydata)))
   mf - model.frame(myformula, mydata, myweight)
   print(head(df))
   hyp - rpart(myformula,
data=mf,
weights=myweight,
method=class)
   prev - hyp
 }
 badFunction(mydata, myformula)
 cat(Done\n)
 -
 
 Here goodFunction works, but only because myweight (with useless random
 weights, but that is not the point here) is found from the calling
 environment. 
 
 badFunction fails after we remove myweight from there:
 
 :~ cat /tmp/philipp.R | R --slave
 Ok
 Error in eval(expr, envir, enclos) : object myweight not found
 Execution halted
 :~
 
 As I was able to replicate it, I reported this to the package maintainer.  It
 turns out that seemingly all is well as this is supposed to work this way,
 and I got a friendly pointer to study model.frame and its help page.  
 
 Now I am stuck as I can't make sense of model.frame -- see badFunction
 above. I would greatly appreciate any help in making rpart work with a local
 argument weights so that I can tell Philipp that there is no bug.  :)
 
 Regards, Dirk


Dirk,

As you note, the issue is the non-standard evaluation of the arguments
in model.frame()  The key section of the Details in ?model.frame is:


All the variables in formula, subset and in ... are looked for first in
data and then in the environment of formula (see the help for formula()
for further details) and collected into a data frame. Then the subset
expression is evaluated, and it is is used as a row index to the data
frame. Then the na.action function is applied to the data frame (and may
well add attributes). The levels of any factors in the data frame are
adjusted according to the drop.unused.levels and xlev arguments.


Note that even with your goodFunction(), if 'myweight' is created within
the environment of the function and not in the global environment, it
still fails:

library(rpart)
myformula - formula(Kyphosis ~ Age + Number + Start)
mydata - kyphosis

goodFunction - function(mydata, myformula) {
 myweight - abs(rnorm(nrow(mydata)))
 hyp - rpart(myformula, data=mydata,
  weights=myweight, method=class)
 prev - hyp
}


 goodFunction(mydata, myformula)
Error in eval(expr, envir, enclos) : object myweight not found


However, now let's do this:


library(rpart)
myformula - formula(Kyphosis ~ Age + Number + Start)
mydata - kyphosis
myweight - abs(rnorm(nrow(mydata)))

goodFunction - function(mydata, myformula) {
 hyp - rpart(myformula, data=mydata,
  weights=myweight, method=class)
 prev - hyp
}

 goodFunction(mydata, myformula)
 

It works, because 'myweight' is found in the global environment, which
is where the formula is created.


Now, final example, try this:


library(rpart)
goodFunction - function() {
 myformula - formula(Kyphosis ~ Age + Number +
  Start)
 mydata - kyphosis
 myweight - abs(rnorm(nrow(mydata)))

 hyp - rpart(myformula, data=mydata,
  weights=myweight, method=class)
 prev - hyp
}

 goodFunction()
 

It works because the formula is created within the environment of the
function and hence, 'myweight', which is created there as well, is
found.

There was a (non) bug filed on a related matter dealing with the
evaluation of 'subset':

http://bugs.r-project.org/cgi-bin/R/feature%26FAQ?id=3671

and you might find this document on Non-Standard Evaluation helpful:

http://developer.r-project.org/nonstandard-eval.pdf

HTH,

Marc

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

Re: [R] [OT] 'gv' and fractional points

2007-06-15 Thread Ted Harding
On 15-Jun-07 16:29:53, Ted Harding wrote:
 [...]
 However, as a follow-up, I've since found that one can (somewhat
 tediously) do what I was asking with the GIMP.

As well as the awkwardness of doing it the GIMP way, I've
discovered another disadvantage.

I'd previously tried it on a rather small image (175x70 points,
= 2.43x0.97 inches).

I then tried it on a full A4 page. Even at a GIMP Scale
factor of 300, this leads to a 50MB temporary file being
created. At 1000, this would rise to some 550MB, as I found
out after this attempt filled up the limited spare space
I have on the disk drive in question ...

No doubt Scale=300 (as opposed to the default of 100) may be
ample for most purposes, but the overhead is still unpleasant!

Hence I'm once again hankering after something which will display
a PS file as efficiently as 'gv', but will report the cursor
position in fractions of a point!

Best wishes to all,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 19:18:48
-- XFMail --


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 20:33:19
-- 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] how to plot two graphics in one window

2007-06-15 Thread John Kane
?points

x - 1:10
plot(exp(x),col=red, type =o)
points(sin(x), col=blue)


--- Miguel Caro [EMAIL PROTECTED] wrote:

 
 Hello ,
 Maybe this question you answered before, but i
 couldnt find something
 indicated in the mailing list.
 
 I wish to plot two graphics  in one window, for
 example y=sinx and y=exp(x)
 in the same windows, (the same interval for x).
 
 Thanks .
 
 Miguel.
 -- 
 View this message in context:

http://www.nabble.com/how-to-plot-two-graphics-in-one-window-tf3929594.html#a11145186
 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] how to plot two graphics in one window

2007-06-15 Thread Miguel Caro

Hi,
I answer myself

plot(x,y,type=l)
par(new=TRUE)
plot(x,yy,type=l)

Thanks all!



Miguel Caro wrote:
 
 Hello ,
 Maybe this question you answered before, but i couldnt find something
 indicated in the mailing list.
 
 I wish to plot two graphics  in one window, for example y=sinx and
 y=exp(x) in the same windows, (the same interval for x).
 
 Thanks .
 
 Miguel.
 

-- 
View this message in context: 
http://www.nabble.com/how-to-plot-two-graphics-in-one-window-tf3929594.html#a11146479
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] model.frame: how does one use it?

2007-06-15 Thread hadley wickham
On 6/15/07, Deepayan Sarkar [EMAIL PROTECTED] wrote:
 On 6/15/07, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:
 
  Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
  In short, the issue has to do with how rpart evaluates a formula and
  supporting arguments, in particular 'weights'.
 
  A simple contrived example is
 
  -
  library(rpart)
 
  ## using data from help(rpart), set up simple example
  myformula - formula(Kyphosis ~ Age + Number + Start)
  mydata - kyphosis
  myweight - abs(rnorm(nrow(mydata)))
 
  goodFunction - function(mydata, myformula, myweight) {
hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
prev - hyp
  }
  goodFunction(mydata, myformula, myweight)
  cat(Ok\n)
 
  ## now remove myweight and try to compute it inside a function
  rm(myweight)
 
  badFunction - function(mydata, myformula) {
myweight - abs(rnorm(nrow(mydata)))
mf - model.frame(myformula, mydata, myweight)
print(head(df))
hyp - rpart(myformula,
 data=mf,
 weights=myweight,
 method=class)
prev - hyp
  }
  badFunction(mydata, myformula)
  cat(Done\n)
  -
 
  Here goodFunction works, but only because myweight (with useless random
  weights, but that is not the point here) is found from the calling
  environment.
 
  badFunction fails after we remove myweight from there:
 
  :~ cat /tmp/philipp.R | R --slave
  Ok
  Error in eval(expr, envir, enclos) : object myweight not found
  Execution halted
  :~
 
  As I was able to replicate it, I reported this to the package maintainer.  
  It
  turns out that seemingly all is well as this is supposed to work this way,
  and I got a friendly pointer to study model.frame and its help page.
 
  Now I am stuck as I can't make sense of model.frame -- see badFunction
  above. I would greatly appreciate any help in making rpart work with a local
  argument weights so that I can tell Philipp that there is no bug.  :)

 I don't know if ?model.frame is the best place page to look. There's a
 more detailed description at

 http://developer.r-project.org/nonstandard-eval.pdf

 but here are the non-standard evaluation rules as I understand them:
 given a name in either (1) the formula or (2) ``special'' arguments like
 'weights' in this case, or 'subset', try to find the name

 1. in 'data'
 2. failing that, in environment(formula)
 3. failing that, in the enclosing environment, and so on.

 By 'name', I mean a symbol, such as 'Age' or 'myweight'.  So
 basically, everything is as you would expect if the name is visible in
 data, but if not, the search starts in the environment of the formula,
 not the environment where the function call is being made (which is
 the standard evaulation behaviour).  This is a feature, not a bug
 (things would be a lot more confusing if it were the other way round).

Could you give an example?  It's always seemed confusing to me and I
don't see why looking in the environment of the formula helps.

Hadley

__
R-help@stat.math.ethz.ch 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] 'gv' and fractional points

2007-06-15 Thread Ted Harding
On 15-Jun-07 15:56:58, hadley wickham wrote:
 This doesn't answer your original question, and isn't much help unless
 you're on a mac, but there's a nice looking program that makes this
 kind of graph scraping really easy:
 http://www.arizona-software.ch/applications/graphclick/en/
 
 Hadley

Thanks, Hadley! But (as you implicitly surmise) I don't use a Mac
(just non-psychedelic Linux).

However, as a follow-up, I've since found that one can (somewhat
tediously) do what I was asking with the GIMP.

If you start the GIMP on a PostScript file, you initially get a
Load PostScript window which asks you to choose (amongst other
things the resolution, initially 100. If you wind this up
to say 1000, then you get 10 times the positional precision
in the numbers shown as below.

When the image is displayed, there is again a little window
which gives you the GIMP coordinates of the mouse position.
With increased Resolution, the numerical values vary
correspondingly more rapidly with position.

The tedious aspect (compared with 'gv') is that to get better
visual resolution you need to zoom the image. This enlarges the
whole image, with the result that you have to pan around to
locate different parts, and you can get lost in a graph with
lots of widely-spread points.

With 'gv', on the other hand, you can select any small part
to view in zoom in a sub-window, which is much easier to cope
with; and you also get a rubber-band rectangle which enables
you to readily align points here with points there -- e.g. if
you want to read off a curve the y-value corresponding to say
x=5.0.

However, this is at least a partial answer to my own question!

Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 17:29:49
-- XFMail --


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 20:32:59
-- 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] how to plot two graphics in one window

2007-06-15 Thread Alex Tsoi
I hope this could help:

http://tolstoy.newcastle.edu.au/R/e2/help/07/02/11127.html

Alex-


On 6/15/07, Miguel Caro [EMAIL PROTECTED] wrote:


 Hello ,
 Maybe this question you answered before, but i couldnt find something
 indicated in the mailing list.

 I wish to plot two graphics  in one window, for example y=sinx and
 y=exp(x)
 in the same windows, (the same interval for x).

 Thanks .

 Miguel.
 --
 View this message in context:
 http://www.nabble.com/how-to-plot-two-graphics-in-one-window-tf3929594.html#a11145186
 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.




-- 
Medical University of South Carolina

[[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] text display using expression or not

2007-06-15 Thread Mark Difford

Hi Sarah,

You will kick yourself (perhaps?).  Try:

?par   ## sub: font.main ( font, just above)

## Example
par(mfrow=c(2,1))
plot(1:10, 1:10, main=Figure A, font.main=1)
plot(1:10, 1:10, main=expression(Figure B))

Regards,
Mark.


Sarah Goslee wrote:
 
 Hello,
 
 I imagine that I'm missing something straightforward, but a run thru
 the help files didn't turn up an answer.
 
 I noticed while formatting some figures for publication that text
 enclosed in expression() and used for a title displays differently
 than a string, regardless of the par options. On both postscript()
 and x11() devices, the regular text is heavier than the expression text.
 
 Here's an example. The real thing used expression() to
 produce superscripts, but I boiled this down to the simplest possible
 case.
 
 par(mfrow=c(2,1))
 plot(1:10, 1:10, main=Figure A)
 plot(1:10, 1:10, main=expression(Figure B))
 
 Is there some straightforward way to make them match, other
 than putting expression() around all strings?
 
 
 I'm currently using R 2.5.0 on Fedora core 5.
 
 Thanks,
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/text-display-using-expression-or-not-tf3929372.html#a11146488
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] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread Peter Dalgaard
Patrick Burns wrote:
 In case it matters, the given solution has a problem if the
 data look like:

 x - c(sum=77, test=99, sum=99)

 By the description all three elements should be kept, but
 the duplicated solution throws out the last element.  A more
 complicated solution is:

 unique(data.frame(x, names(x)))

 (and then put the vector back together again).

   
Yes, I was about to say the same.

x[!duplicated(cbind(x,names(x)))]

looks like it might cut the mustard.

__
R-help@stat.math.ethz.ch 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] removing values from a vector, where both the value and its name are the same?

2007-06-15 Thread Marc Schwartz
Good catch Patrick.  I am guilty of the same error.

Regards,

Marc

On Fri, 2007-06-15 at 20:25 +0100, Patrick Burns wrote:
 In case it matters, the given solution has a problem if the
 data look like:
 
 x - c(sum=77, test=99, sum=99)
 
 By the description all three elements should be kept, but
 the duplicated solution throws out the last element.  A more
 complicated solution is:
 
 unique(data.frame(x, names(x)))
 
 (and then put the vector back together again).
 
 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)
 
 jim holtman wrote:
 
 try this:
 
   
 
 x[!(duplicated(names(x))duplicated(x))]
 
 
   sum   min   max count count  test
77 4 9 5 877
 
 
 
 On 6/15/07, new ruser [EMAIL PROTECTED] wrote:
   
 
 I have an array such as:
 
 x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 ,  test=77)
 
 I wish to remove values where both the name and the value are identical.
 
 eg. i wish to end up with:
 x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)
 
 What is the best way to do this?
 
 
 -
 Park yourself in front of a world of choices in alternative vehicles.
 
[[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.

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

--- Douglas Bates [EMAIL PROTECTED] wrote:

 On 6/15/07, Nicholas Lewin-Koh [EMAIL PROTECTED]
 wrote:
  Hi,
  I just saw this thread. This issue, and the larger
 scale issue of open
  source in industry
  is being addressed. One has to realize that the
 behemoth that is the
  clinical aperatus
  of the pharma industry is very conservative and
 very slow to change. In
  many cases
  switching to R would meean changing a great many
 processes all based on
  legacy code. One
  of the big issues is that the industry demands
 consistency not
  necessarily correctness.
 
  All that said there are a great many areas where R
 could be used that
  would not impact
  regulatory submission, data security etc. Many in
 pharma are quietly
  working on this,
  but steps are small and incremental. Development
 takes time in industry
  because of the amount of
  documentation necessary. All this impacts the
 free nature of R and
  cost and risk (From the industries
  perspective) need to be justified.
 
  Probably when the statistical community is using Z
 big pharma will be
  ready to use
  R. %P
 
 I think you mean A, not Z.  First there was S, then
 there was R.

We're regressing 

__
R-help@stat.math.ethz.ch 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] 'gv' and fractional points

2007-06-15 Thread Gabor Grothendieck
Check out the engauge digitizer:

http://digitizer.sourceforge.net/

On 6/15/07, Ted Harding [EMAIL PROTECTED] wrote:
 Hi Folks,

 This is off-topic R-wise, but it may be close to
 the heart of many R-users, so I think it may be
 the best place to ask!

 Users of 'gv' (the front end to ghostscript) will
 be aware of the little window which gives you the
 x-y coordinates (in points = 1/72 inch) of the position
 of the cross-hair mouse cursor. These coordinates
 are those of the corresponding position on the printed
 page, relative to some origin.

 I have often used this to extract numerical values
 for data from graphs in Postscript files (also PDF
 files, after you have converted them to PS). Then
 (veering back on topic ... ) you can submit the
 numerical data to R and try your own analyses on
 these data, and compare with what the article does.

 However, this little window only gives the numbers
 in whole points. Say a smallish graphic may print
 out 3 inches wide or high. Then you get precision
 of 1/216 per 3 inches or 0.4% of full scale. This
 can be adequate on many occasions, but can be on
 the coarse side on other occasions.

 Even for a 6-inch-wide/high graph, you only get down
 to 0.2% of full scale.

 If it were possible to induce 'gv' to display these
 coordinates in tenths of a point, then much greater
 precision (as adequate as one can expect to hope for
 when, in effect, measuring off the graph) could be
 obtained.

 Does anyone know:
 a) Whether it is possible to persuade 'gv' to give
   this display in fractional points (my own search
   of the documentation has not revealed anything);
 b) Of any alternative to 'gv' as PS viewer which would
   provide this capability?

 With thanks, and best wishes to all,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 15-Jun-07   Time: 16:13:21
 -- 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-help@stat.math.ethz.ch 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] model.frame: how does one use it?

2007-06-15 Thread Deepayan Sarkar
On 6/15/07, hadley wickham [EMAIL PROTECTED] wrote:
 On 6/15/07, Deepayan Sarkar [EMAIL PROTECTED] wrote:

[...]

  By 'name', I mean a symbol, such as 'Age' or 'myweight'.  So
  basically, everything is as you would expect if the name is visible in
  data, but if not, the search starts in the environment of the formula,
  not the environment where the function call is being made (which is
  the standard evaulation behaviour).  This is a feature, not a bug
  (things would be a lot more confusing if it were the other way round).

 Could you give an example?  It's always seemed confusing to me and I
 don't see why looking in the environment of the formula helps.

Good question. I remember being convinced that it was a good idea, but
no longer remember why. This is the best I can come up with right now:


## stupid function that fits a model on a random subsample

lmsub - function(formula, data, p = 0.7)
{
n - nrow(data)
newdata - data[sample(round(n * p)), ]
lm(formula, newdata)
}

mydata - data.frame(x = 1:100, y = rnorm(100))

n - 2

lmsub(y ~ poly(x, n), data = mydata)

I don't think the use of the name 'n' is unusual in either case, and
we definitely wouldn't want the one inside 'lmsub' to be used for the
formula.

-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] model.frame: how does one use it?

2007-06-15 Thread Dirk Eddelbuettel

Hi Mark,

Thanks for the reply.

On 15 June 2007 at 14:33, Marc Schwartz wrote:
| On Fri, 2007-06-15 at 10:47 -0500, Dirk Eddelbuettel wrote: 
|  Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
|  In short, the issue has to do with how rpart evaluates a formula and
|  supporting arguments, in particular 'weights'.  
|  
|  A simple contrived example is
|  
|  
-
|  library(rpart)
|  
|  ## using data from help(rpart), set up simple example
|  myformula - formula(Kyphosis ~ Age + Number + Start)
|  mydata - kyphosis
|  myweight - abs(rnorm(nrow(mydata)))
|  
|  goodFunction - function(mydata, myformula, myweight) {
|hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
|prev - hyp
|  }
|  goodFunction(mydata, myformula, myweight)
|  cat(Ok\n)
|  
|  ## now remove myweight and try to compute it inside a function
|  rm(myweight)
|  
|  badFunction - function(mydata, myformula) {
|myweight - abs(rnorm(nrow(mydata)))
|mf - model.frame(myformula, mydata, myweight)
|print(head(df))
|hyp - rpart(myformula,
| data=mf,
| weights=myweight,
| method=class)
|prev - hyp
|  }
|  badFunction(mydata, myformula)
|  cat(Done\n)
|  
-
|  
|  Here goodFunction works, but only because myweight (with useless random
|  weights, but that is not the point here) is found from the calling
|  environment. 
|  
|  badFunction fails after we remove myweight from there:
|  
|  :~ cat /tmp/philipp.R | R --slave
|  Ok
|  Error in eval(expr, envir, enclos) : object myweight not found
|  Execution halted
|  :~
|  
|  As I was able to replicate it, I reported this to the package maintainer.  
It
|  turns out that seemingly all is well as this is supposed to work this way,
|  and I got a friendly pointer to study model.frame and its help page.  
|  
|  Now I am stuck as I can't make sense of model.frame -- see badFunction
|  above. I would greatly appreciate any help in making rpart work with a local
|  argument weights so that I can tell Philipp that there is no bug.  :)
|  
|  Regards, Dirk
| 
| 
| Dirk,
| 
| As you note, the issue is the non-standard evaluation of the arguments
| in model.frame()  The key section of the Details in ?model.frame is:
| 
| 
| All the variables in formula, subset and in ... are looked for first in
| data and then in the environment of formula (see the help for formula()
| for further details) and collected into a data frame. Then the subset
| expression is evaluated, and it is is used as a row index to the data
| frame. Then the na.action function is applied to the data frame (and may
| well add attributes). The levels of any factors in the data frame are
| adjusted according to the drop.unused.levels and xlev arguments.
| 
| 
| Note that even with your goodFunction(), if 'myweight' is created within
| the environment of the function and not in the global environment, it
| still fails:
| 
| library(rpart)
| myformula - formula(Kyphosis ~ Age + Number + Start)
| mydata - kyphosis
| 
| goodFunction - function(mydata, myformula) {
|  myweight - abs(rnorm(nrow(mydata)))
|  hyp - rpart(myformula, data=mydata,
|   weights=myweight, method=class)
|  prev - hyp
| }
| 
| 
|  goodFunction(mydata, myformula)
| Error in eval(expr, envir, enclos) : object myweight not found
| 
| 
| However, now let's do this:
| 
| 
| library(rpart)
| myformula - formula(Kyphosis ~ Age + Number + Start)
| mydata - kyphosis
| myweight - abs(rnorm(nrow(mydata)))
| 
| goodFunction - function(mydata, myformula) {
|  hyp - rpart(myformula, data=mydata,
|   weights=myweight, method=class)
|  prev - hyp
| }
| 
|  goodFunction(mydata, myformula)
|  
| 
| It works, because 'myweight' is found in the global environment, which
| is where the formula is created.

Well,yes, but doesn't this just recreate the working example I showed above?
It works 'because we get lucky' with the data in the outer global env.

| Now, final example, try this:
| 
| 
| library(rpart)
| goodFunction - function() {
|  myformula - formula(Kyphosis ~ Age + Number +
|   Start)
|  mydata - kyphosis
|  myweight - abs(rnorm(nrow(mydata)))
| 
|  hyp - rpart(myformula, data=mydata,
|   weights=myweight, method=class)
|  prev - hyp
| }
| 
|  goodFunction()
|  
| 
| It works because the formula is created within the environment of the
| function and hence, 

Re: [R] [OT] 'gv' and fractional points

2007-06-15 Thread Paul Murrell
Hi

If I understand correctly, this is something that the 'grImport' package
might be very useful for.  You can import the PostScript image into R,
which means that you can draw the image, but you also have the locations
of everything that is drawn as numeric values so you should be able
(probably after a bit of transformation) to extract the values to very
good accuracy.  If you can provide me with an example file, I'd be happy
to play around and see if I could get this to work.

Paul


(Ted Harding) wrote:
 On 15-Jun-07 16:29:53, Ted Harding wrote:
 [...]
 However, as a follow-up, I've since found that one can (somewhat
 tediously) do what I was asking with the GIMP.
 
 As well as the awkwardness of doing it the GIMP way, I've
 discovered another disadvantage.
 
 I'd previously tried it on a rather small image (175x70 points,
 = 2.43x0.97 inches).
 
 I then tried it on a full A4 page. Even at a GIMP Scale
 factor of 300, this leads to a 50MB temporary file being
 created. At 1000, this would rise to some 550MB, as I found
 out after this attempt filled up the limited spare space
 I have on the disk drive in question ...
 
 No doubt Scale=300 (as opposed to the default of 100) may be
 ample for most purposes, but the overhead is still unpleasant!
 
 Hence I'm once again hankering after something which will display
 a PS file as efficiently as 'gv', but will report the cursor
 position in fractions of a point!
 
 Best wishes to all,
 Ted.
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 15-Jun-07   Time: 19:18:48
 -- XFMail --
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 15-Jun-07   Time: 20:33:19
 -- 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.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

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


[R] Upgraded FC4 to FC5 - unable to start device X11 in R

2007-06-15 Thread Li-Jung Liang
Hi,

I upgraded my system from FC4 to FC5.  So now I have R version 2.5.0 
(2007-04-23).
But I ran into a problem with starting device X11 (message below).

  X11()
can't find X11 font
Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
else gamma,  :
unable to start device X11

Any idea?

Thanks,
L.

-- 
Li-Jung Liang, Ph.D.
Department of Biostatistics
UCLA School of Public Health
Los Angeles, CA 90095-1772

__
R-help@stat.math.ethz.ch 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] model.frame: how does one use it?

2007-06-15 Thread Philipp Benner

Thanks for your explanation!

 With this in mind, either of the following might do what you want:
 
 badFunction - function(mydata, myformula) {
mydata$myweight - abs(rnorm(nrow(mydata)))
hyp -
rpart(myformula,
  data=mydata,
  weights=myweight,
  method=class)
prev - hyp
 }
 
 
 badFunction - function(mydata, myformula) {
myweight - abs(rnorm(nrow(mydata)))
environment(myformula) - environment()
hyp -
rpart(myformula,
  data=mydata,
  weights=myweight,
  method=class)
prev - hyp
 }

OK, this is what I have now:

adaboostBad - function(formula, data) {
  ## local definition of the weight vector (won't work because pima.formula is 
not defined within this function)
  w - abs(rnorm(nrow(data)))
  rpart(formula, data=data, weights=w)
}

adaboostGood - function(formula, data) {
  ## create weight vector in the data object
  data$w - abs(rnorm(nrow(data)))
  rpart(formula, data=data, weights=w)
}

adaboostBest - function(formula, data) {
  ## associate the current environment (this function's one) with the object 
`formula'
  environment(formula) - environment()
  w - abs(rnorm(nrow(data)))
  rpart(formula, data=data, weights=w)
}

As far as I understand this non-standard evaluation stuff, adaboostGood() and 
adaboostBest()
are the only two possibilities to call rpart() with weight vectors. Now suppose 
that I don't
know what `data' contains and suppose further that it already contains a column 
called `w'.
adaboostGood() would overwrite that column with new data which is then used as 
weight vector
and as training data for rpart(). adaboostBest() would just use the wrong data 
as weight
vector as it finds data$w before the real weight vector. So, in both cases I 
have to check for
`names(data) == w` and stop if TRUE? Or is there a better way?

Regards

-- 
Philipp Benner

__
R-help@stat.math.ethz.ch 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] model.frame: how does one use it?

2007-06-15 Thread Marc Schwartz
On Fri, 2007-06-15 at 15:34 -0500, Dirk Eddelbuettel wrote:
 Hi Mark,
 
 Thanks for the reply.
 
 On 15 June 2007 at 14:33, Marc Schwartz wrote:
 | On Fri, 2007-06-15 at 10:47 -0500, Dirk Eddelbuettel wrote: 
 |  Philipp Benner reported a Debian bug report against r-cran-rpart aka 
 rpart.
 |  In short, the issue has to do with how rpart evaluates a formula and
 |  supporting arguments, in particular 'weights'.  
 |  
 |  A simple contrived example is
 |  
 |  
 -
 |  library(rpart)
 |  
 |  ## using data from help(rpart), set up simple example
 |  myformula - formula(Kyphosis ~ Age + Number + Start)
 |  mydata - kyphosis
 |  myweight - abs(rnorm(nrow(mydata)))
 |  
 |  goodFunction - function(mydata, myformula, myweight) {
 |hyp - rpart(myformula, data=mydata, weights=myweight, method=class)
 |prev - hyp
 |  }
 |  goodFunction(mydata, myformula, myweight)
 |  cat(Ok\n)
 |  

snip

 | 
 | However, now let's do this:
 | 
 | 
 | library(rpart)
 | myformula - formula(Kyphosis ~ Age + Number + Start)
 | mydata - kyphosis
 | myweight - abs(rnorm(nrow(mydata)))
 | 
 | goodFunction - function(mydata, myformula) {
 |  hyp - rpart(myformula, data=mydata,
 |   weights=myweight, method=class)
 |  prev - hyp
 | }
 | 
 |  goodFunction(mydata, myformula)
 |  
 | 
 | It works, because 'myweight' is found in the global environment, which
 | is where the formula is created.
 
 Well,yes, but doesn't this just recreate the working example I showed above?
 It works 'because we get lucky' with the data in the outer global env.

Technically, it is not the same, as I was trying to emphasize that there
was no need to pass 'myweight' as an argument to the function to
facilitate successful location/evaluation within the function.

We don't get lucky here. The behavior is by design and consistent with
the documentation, which is that 'myweight' in the call to rpart() is
evaluated within the environment of the formula in this case. The
formula is created in the global environment, so 'myweight' is found
there. Hence, no need to pass it as an argument.

A review of the code for rpart() will reveal code similar to that which
is used in most R modeling functions, relative to the evaluation of the
formula, associated args and the creation of the model frame.

One exception to the above, is that in other modeling functions, one
could forgo passing the formula and just pass the entire data frame,
where the presumption is that the first column is the response variable
and the remaining columns would be the independent terms. I don't see
that supported in rpart().

 
 | Now, final example, try this:
 | 
 | 
 | library(rpart)
 | goodFunction - function() {
 |  myformula - formula(Kyphosis ~ Age + Number +
 |   Start)
 |  mydata - kyphosis
 |  myweight - abs(rnorm(nrow(mydata)))
 | 
 |  hyp - rpart(myformula, data=mydata,
 |   weights=myweight, method=class)
 |  prev - hyp
 | }
 | 
 |  goodFunction()
 |  
 | 
 | It works because the formula is created within the environment of the
 | function and hence, 'myweight', which is created there as well, is
 | found.
 
 That works because we force it to be local. BDR claims that my 'badFunction'
 (derived from Philipp's original bug report) above can be made to work
 provide you use model.frame.  I asked about model.frame -- and you were kind
 enough do answer, but you dodged the question.
 
 So let me try again:  How can rpart be called inside a function using a
 local weight variable as I do above ?   Either it can, and the BDR is right
 and there is no bug, or one cannot, and then mere mortals like myself must
 consider rpart to be buggy as it does not support all its argument in at
 least some conceivable calling situations. 
 
 Is that a fair question?
 
 Regards,  Dirk

Yep, entirely fair. 

Without knowing what specific approach Prof. Ripley had in mind, I am
envisioning a couple of possibilities, but here is one:

library(rpart)

myformula - formula(Kyphosis ~ Age + Number + Start)
mydata - kyphosis

badFunction - function(mydata, myformula) {
  mydata$myweight - abs(rnorm(nrow(mydata)))
  rpart(myformula, data = mydata, weights = myweight, method = class)
}

badFunction(mydata, myformula)


Basically, there are 3 places in which 'myweights' could be found:

1. Formula environment

2. Data frame environment

3. Global environment


In this case, we add the weights as a new column within the function to
the 'mydata' data frame, so that it will be found in the call to
rpart(), based upon location number 2 above.

Does that help?

Regards,

Marc


[R] rect() does not work

2007-06-15 Thread scott flemming
I have typed the following commands:

x - c(1:10)
y - x
plot(x,y)
rect(2,2,4,4)

I am expecting a rectangular box, however, nothing occurs.

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


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

2007-06-15 Thread Ted Harding
On 15-Jun-07 19:30:45, Douglas Bates wrote:
 On 6/15/07, Nicholas Lewin-Koh [EMAIL PROTECTED] wrote:
 Hi,
 
 Probably when the statistical community is using Z big pharma will be
 ready to use
 R. %P
 
 I think you mean A, not Z.  First there was S, then there was R.

And, furthermore, A is further from R than Z is, which seems fitting.
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jun-07   Time: 23:57:13
-- 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] model.frame: how does one use it?

2007-06-15 Thread Deepayan Sarkar
On 6/15/07, Philipp Benner [EMAIL PROTECTED] wrote:

 Thanks for your explanation!

  With this in mind, either of the following might do what you want:
 
  badFunction - function(mydata, myformula) {
 mydata$myweight - abs(rnorm(nrow(mydata)))
 hyp -
 rpart(myformula,
   data=mydata,
   weights=myweight,
   method=class)
 prev - hyp
  }
 
 
  badFunction - function(mydata, myformula) {
 myweight - abs(rnorm(nrow(mydata)))
 environment(myformula) - environment()
 hyp -
 rpart(myformula,
   data=mydata,
   weights=myweight,
   method=class)
 prev - hyp
  }

 OK, this is what I have now:

 adaboostBad - function(formula, data) {
   ## local definition of the weight vector (won't work because pima.formula 
 is not defined within this function)
   w - abs(rnorm(nrow(data)))
   rpart(formula, data=data, weights=w)
 }

 adaboostGood - function(formula, data) {
   ## create weight vector in the data object
   data$w - abs(rnorm(nrow(data)))
   rpart(formula, data=data, weights=w)
 }

 adaboostBest - function(formula, data) {
   ## associate the current environment (this function's one) with the object 
 `formula'
   environment(formula) - environment()
   w - abs(rnorm(nrow(data)))
   rpart(formula, data=data, weights=w)
 }



 As far as I understand this non-standard evaluation stuff,
 adaboostGood() and adaboostBest() are the only two possibilities to
 call rpart() with weight vectors. Now suppose that I don't know what
 `data' contains and suppose further that it already contains a
 column called `w'.  adaboostGood() would overwrite that column with
 new data which is then used as weight vector and as training data
 for rpart(). adaboostBest() would just use the wrong data as weight
 vector as it finds data$w before the real weight vector. So, in both
 cases I have to check for `names(data) == w` and stop if TRUE? Or
 is there a better way?

Well, that depends on what you want to happen when there is a column
called 'w' in data.  I don't see a situation where it makes sense to
use data$w as weights ('w' is just a name you happen to choose inside
adaboostBest), so I would just go with adaboostGood.

In case you are worried about overwriting the original data, that may
not be happening in the sense you are thinking.  When you say

data$w - abs(rnorm(nrow(data)))

inside adaboostGood, that modifies a local copy of the data argument,
not the original (R argument semantics are call by value, not call by
reference).  You are losing data$w in the local copy in your function,
but why would you care if you are not using it anyway.

Of course, if your formula contains a reference to 'w' then you will
get wrong results, so checking for a unique name is always safer.
In addition, use an obfuscated name like '.__myWeights' instead
of 'w', and the check will be almost always irrelevant.

-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] rect() does not work

2007-06-15 Thread Marc Schwartz
On Fri, 2007-06-15 at 16:22 -0700, scott flemming wrote:
 I have typed the following commands:
 
 x - c(1:10)
 y - x
 plot(x,y)
 rect(2,2,4,4)
 
 I am expecting a rectangular box, however, nothing occurs.

What version of R?  What OS?

No problems here using R version 2.5.0 Patched (2007-06-05 r41831) on
F7.

You might want to check and see what par(lty) and par(lwd) return,
in case they have been set to values resulting in lines that you would
not be able to see.

BTW, the c() is not required in creating 'x':

 x - 1:10
 x
 [1]  1  2  3  4  5  6  7  8  9 10


Marc Schwartz

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

2007-06-15 Thread owenman

Hi Hadley,
I tried your suggestion, using ggplot2, but I am still having a problem. The
final plot lacks the figure legend -- which it had before I added the 
scale_fill_identity()  bit.  Can  you see what I am doing wrong?  
(By the way, all I am trying to do is make the figure monochrome friendly. 
Is there an easy way to prepare ggplot graphics for a monochrom device?)
Thanks,Owen

 y$color = factor(y$Fnd)
 y$color = c(black,darkgray,lightgray,white) 
 y
  Fnd locusFreq color
1  signeg A 0.087248322 black
2 neg A 0.711409396  darkgray
3 pos A 0.201342282 lightgray
4  sigpos A 0.0 white
5  signeg C 0.320754717 black
6 neg C 0.603773585  darkgray
7 pos C 0.075471698 lightgray
8  sigpos C 0.0 white
9  signeg B 0.157534247 black
10neg B 0.732876712  darkgray
11pos B 0.109589041 lightgray
12 sigpos B 0.0 white

 p = ggplot(y, aes(x=locus, y=Freq, fill=color)) +
 geom_bar(position=fill) + scale_fill_identity() 
 p



hadley wrote:
 
 
 Hi Dieter,
 
 You can do this with ggplot2 (http://had.co.nz/ggplot2) as follows:
 
 library(ggplot2)
 
 barley1 - subset(barley, site==Grand Rapids  variety %in%
 c(Velvet,Peatland))
 barley1[] - lapply(barley1, [, drop=TRUE)
 
 qplot(variety, yield, data=barley1, geom=bar, stat=identity,
 fill=factor(year))
 
 barley1$fill - c(red,green,blue,gray)
 qplot(variety, yield, data=barley1, geom=bar, stat=identity,
 fill=fill) + scale_fill_identity()
 
 See http://had.co.nz/ggplot2/scale_identity.html and
 http://had.co.nz/ggplot2/position_stack.html for more details.
 
 Hadley
 
 

-- 
View this message in context: 
http://www.nabble.com/Stacked-barchart-color-tf3909162.html#a11149419
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] R vs. Splus in Pharma/Devices Industry

2007-06-15 Thread Ted Harding
On 15-Jun-07 19:43:55, John Kane wrote:
 --- Douglas Bates [EMAIL PROTECTED] wrote:
 On 6/15/07, Nicholas Lewin-Koh [EMAIL PROTECTED]
 wrote:
  [...]
 I think you mean A, not Z.  First there was S, then
 there was R.
 
 We're regressing 

But not to mediocrity! [1]
Ted.

[1] Practical Regression and Anova using R
Julian J. Faraway (July 2002), page 15.

http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 16-Jun-07   Time: 00:43:39
-- 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] Upgraded FC4 to FC5 - unable to start device X11 in R

2007-06-15 Thread Marc Schwartz
On Fri, 2007-06-15 at 13:50 -0700, Li-Jung Liang wrote:
 Hi,
 
 I upgraded my system from FC4 to FC5.  So now I have R version 2.5.0 
 (2007-04-23).
 But I ran into a problem with starting device X11 (message below).
 
   X11()
 can't find X11 font
 Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
 else gamma,  :
 unable to start device X11
 
 Any idea?
 
 Thanks,
 L.

Sounds like either you did not install some font related RPMS during
your 'upgrade' or your xorg.conf file has perhaps become corrupted
relative to defining font paths.

Check as 'root':

 # yum list xorg-x11-fonts*

and see what it returns.

How did you install R?  Using the RPMS from CRAN or from Fedora Extras?

Also, note that FC5 will reach EOL (End of Life) on June 29, which means
that you will receive no further updates (security, bug fixes, etc)
after that date.  You should really consider upgrading to FC6. 

F7 just came out and I am running it, but I would recommend that typical
users wait a while before doing so to give it time to stabilize.

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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] 'gv' and fractional points

2007-06-15 Thread Ted Harding
On 15-Jun-07 20:08:05, Gabor Grothendieck wrote:
 Check out the engauge digitizer:
 
 http://digitizer.sourceforge.net/

Thanks, Gabor. This looks useful, as far as it goes.

However, it doesn't deal directly with PS, so one
would have to work to pixel resolution of screenshots
as displayed by say 'gv'.

In the case of an example such as the Fig 4 I mentioned
in a previous post, this would involve taking several
screenshots to tile over the entirety of the graph,
since the pixel accuracy or a screenshot of the entire
graph would be rather poor.

This would introduce the neccessity of keeing track of
points from screenshot to screenshot, and also each
screenshot would have its own coordinate system so these
would have to be reconciled before the final dataset
could be compiled.

But thanks -- this could well be worth a try in a different
kind of context (e.g. I have some screenshots of old maps
which I want to digitise ... ).

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 16-Jun-07   Time: 01:13:53
-- 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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
Hi everyone,

it's been a while I've been trying to save a plot created via  
lattice:::xyplot

if I have a file tst.R with the following code:

y - rnorm(100)
x - rnorm(100)
z - sample(letters[1:4], 100, rep=T)
library(lattice)
bitmap(tst.png)
xyplot(y~x|z)
dev.off()

and I source it, I get the tst.png file, which is a blank page.

If I copy and paste instead, I get the correct plot.

Any suggestion?

Thank you very much,

b

  sessionInfo()
R version 2.5.0 (2007-04-23)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE 
=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915 
;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASU 
REMENT=en_US.iso885915;LC_IDENTIFICATION=C

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

other attached packages:
lattice
0.15-4

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


Re: [R] plot via xyplot not being saved

2007-06-15 Thread deepayan . sarkar
On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 Hi everyone,

 it's been a while I've been trying to save a plot created via
 lattice:::xyplot

 if I have a file tst.R with the following code:

 y - rnorm(100)
 x - rnorm(100)
 z - sample(letters[1:4], 100, rep=T)
 library(lattice)
 bitmap(tst.png)
 xyplot(y~x|z)
 dev.off()

 and I source it, I get the tst.png file, which is a blank page.

 If I copy and paste instead, I get the correct plot.

 Any suggestion?

Use

source(..., echo = TRUE)

-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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
So, if those statements are inside a function, I have to make my  
function to have an 'echo' argument/functionality? eg.:

## begin test.R
test - function(n){
   y - rnorm(n)
   x - rnorm(n)
   z - sample(letters[1:4], n, rep=T)
   library(lattice)
   bitmap(tst.png)
   xyplot(y~x|z)
   dev.off()
}

test(100)
## end test.R

source(test.R, echo=T)

also fails in this case...

thanks a lot,

b


On Jun 15, 2007, at 8:53 PM, [EMAIL PROTECTED] wrote:

 On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 Hi everyone,

 it's been a while I've been trying to save a plot created via
 lattice:::xyplot

 if I have a file tst.R with the following code:

 y - rnorm(100)
 x - rnorm(100)
 z - sample(letters[1:4], 100, rep=T)
 library(lattice)
 bitmap(tst.png)
 xyplot(y~x|z)
 dev.off()

 and I source it, I get the tst.png file, which is a blank page.

 If I copy and paste instead, I get the correct plot.

 Any suggestion?

 Use

 source(..., echo = TRUE)

 -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] R vs. Splus in Pharma/Devices Industry

2007-06-15 Thread Marc Schwartz
On Sat, 2007-06-16 at 00:43 +0100, [EMAIL PROTECTED] wrote:
 On 15-Jun-07 19:43:55, John Kane wrote:
  --- Douglas Bates [EMAIL PROTECTED] wrote:
  On 6/15/07, Nicholas Lewin-Koh [EMAIL PROTECTED]
  wrote:
   [...]
  I think you mean A, not Z.  First there was S, then
  there was R.
  
  We're regressing 
 
 But not to mediocrity! [1]
 Ted.
 
 [1] Practical Regression and Anova using R
 Julian J. Faraway (July 2002), page 15.
 
 http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf


Which in turn is of course paraphrasing Galton's Regression Toward
Mediocrity in Hereditary Stature”. Journal of the Anthropological
Institute 15 : 246-63, 1886.

http://galton.org/essays/1880-1889/galton-1886-jaigi-regression-stature.pdf

:-)

Regards,

Marc

__
R-help@stat.math.ethz.ch 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] [Not R question]: Better fit for order probit model

2007-06-15 Thread adschai
Hi,

I have a model which tries to fit a set of data with 10-level ordered 
responses. Somehow, in my data, the majority of the observations are from level 
6-10 and leave only about 1-5% of total observations contributed to level 1-10. 
As a result, my model tends to perform badly on points that have lower level 
than 6. 

I would like to ask if there's any way to circumvent this problem or not. I was 
thinking of the followings ideas. But I am opened to any suggestions if you 
could please. 

1. Bootstrapping with small size of samples each time. Howevever, in each 
sample basket, I intentionally sample in such a way that there is a good mix 
between observations from each level. Then I have to do this many times. But I 
don't know how to obtain the true standard error of estimated parameters after 
all bootstrapping has been done. Is it going to be simply the average of all 
standard errors estimated each time?

2. Weighting points with level 1-6 more. But it's unclear to me how to put this 
weight back to maximum likelihood when estimating parameters. It's unlike OLS 
where your objective is to minimize error or, if you'd like, a penalty 
function. But MLE is obviously not a penalty function.

3. Do step-wise regression. I will segment the data into two regions, first 
points with response less than 6 and the rest with those above 6. The first 
step is a binary regression to determine if the point belongs to which of the 
two groups. Then in the second step, estimate ordered probit model for each 
group separately. The question here is then, why I am choosing 6 as a cutting 
point instead of others? 

Any suggestions would be really appreciated. Thank you.

- adschai

__
R-help@stat.math.ethz.ch 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] fSeries - Ox - ver: 240.10068 - Steps to make it work

2007-06-15 Thread Ian Gregory

-Bugs and fixes reported to Diethelm Wuertz.
-In the interim.  To make the Ox functions part of the fSeries package work 
please follow the following steps.

-
1.  Install R-project.
2.  Install fSeries.
3.  Download: http://www.core.ucl.ac.be/~laurent/[EMAIL 
PROTECTED]/site/xbdcons/garch42.zip  ([EMAIL PROTECTED] package for Ox)
4.  Download:  http://www.doornik.com/download/b736gw/oxcons.html  (Ox console)
5. Install Ox console to directory c:\ox
6. Copy: R-2.5.0\library\fSeries\ox\GarchOxModelling.ox 
c:\ox\ox\lib\GarchOxModelling.ox 
7. Load R-Project 
8. Run:
library(fSeries)
data(dem2gbp)
x = dem2gbp[, 1]
garchOxFit(~garch(1,1),x)
--
Causes the errors:
Error in paste(OXPATH, \\bin\\oxl.exe , OXPATH, \\lib\\GarchOxModelling.ox, 
 : 
object OXPATH not found
--

This can be fixed by setting the directory in R-Project to where Ox is 
installed.  ie. OXPATH=c:\ox\ox.
9. garchOxFit(~garch(1,1),x)

10.  Copy the [EMAIL PROTECTED] package files to c:\ox\ox\packages\Garch42

11.  Change the line in GarchOxModelling.ox: 
#import packages/Garch40/garch
to
#import packages/Garch42/garch


13.
garchOxFit(~garch(1,1),x)

Will give the following error:

--
Ox version 4.1 (Windows) (C) J.A. Doornik, 1994-2006
This version may be used for academic research and teaching only
Copyright for this package: S. Laurent and J.P. Peters, 2000-2006.
[EMAIL PROTECTED] package version 4.2, object created on  7-06-2007
-
Starting Values
===
Parameter  Starting Value
Cst(M)   0.01
Cst(V)   0.05
ARCH(Alpha1) 0.10
GARCH(Beta1) 0.80
-
Bounds
==

Parameter Lower Bound Upper Bound
Cst(M)-100.00  100.00
Cst(V)   0.00  100.00
ARCH(Alpha1) 0.001.00
GARCH(Beta1) 0.001.00
Runtime error: 'DoEstimation' wrong number of arguments
Runtime error occurred in main(207), call trace: 
c:/ox/Ox\lib\GarchOxModelling.ox (207): main
Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file 'OxResiduals.csv', reason 'No such file or directory' 
--

14.  This can be fixed by changing the line in GarchOxModelling.ox:
from  garchobj.DoEstimation(); to  
garchobj.DoEstimation();

15.
Running: 
garchOxFit(~garch(1,1),x)

Will give a 'typo' error is at the end of the estimation.  Which needs to be 
fixed by the developer
as it is compiled code.  
However, now the function works and can call Ox from R-Prooject to estimate 
models.



[1] garch(1, 1)

Ox version 4.1 (Windows) (C) J.A. Doornik, 1994-2006
This version may be used for academic research and teaching only
Copyright for this package: S. Laurent and J.P. Peters, 2000-2006.
[EMAIL PROTECTED] package version 4.2, object created on 11-06-2007
-
Starting Values
===
Parameter  Starting Value
Cst(M)   0.01
Cst(V)   0.05
ARCH(Alpha1) 0.10
GARCH(Beta1) 0.80
-
Bounds
==

Parameter Lower Bound Upper Bound
Cst(M)-100.00  100.00
Cst(V)   0.00  100.00
ARCH(Alpha1) 0.001.00
GARCH(Beta1) 0.001.00

Starting values
parameters
 0.01 0.05  0.1  0.8
Initial function =  -1312.86321151

Position after 5 SQPF iterations
parameters
0.0054353 0.038781  0.20486  0.60034
function value =  -1125.76603281  steplen = 0.03125

Position after 10 SQPF iterations
parameters
   -0.0088801 0.012371  0.17148  0.78507
function value =  -1106.89461928

Position after 14 SQPF iterations
Status: Strong convergence
parameters
   -0.0061830 0.010761  0.15341  0.80588
function value =  -1106.58656395
Ian - Doing output


 
 ** SPECIFICATIONS **
 
Dependent variable : X
Mean Equation : ARMA (0, 0) model.
No regressor in the mean
Variance Equation : GARCH (1, 1) model.
 No regressor in the variance
The distribution is a Gauss distribution.

Strong convergence using numerical derivatives
Log-likelihood = -1106.59
Please wait : Computing the Std Errors ...

 Maximum Likelihood Estimation (Std.Errors based 

Re: [R] [Not R question]: Better fit for order probit model

2007-06-15 Thread Robert A LaBudde
At 09:31 PM 6/15/2007, adschai wrote:
I have a model which tries to fit a set of data with 10-level 
ordered responses. Somehow, in my data, the majority of the 
observations are from level 6-10 and leave only about 1-5% of total 
observations contributed to level 1-10. As a result, my model tends 
to perform badly on points that have lower level than 6.

I would like to ask if there's any way to circumvent this problem or 
not. I was thinking of the followings ideas. But I am opened to any 
suggestions if you could please.

1. Bootstrapping with small size of samples each time. Howevever, in 
each sample basket, I intentionally sample in such a way that there 
is a good mix between observations from each level. Then I have to 
do this many times. But I don't know how to obtain the true standard 
error of estimated parameters after all bootstrapping has been done. 
Is it going to be simply the average of all standard errors 
estimated each time?

2. Weighting points with level 1-6 more. But it's unclear to me how 
to put this weight back to maximum likelihood when estimating 
parameters. It's unlike OLS where your objective is to minimize 
error or, if you'd like, a penalty function. But MLE is obviously 
not a penalty function.

3. Do step-wise regression. I will segment the data into two 
regions, first points with response less than 6 and the rest with 
those above 6. The first step is a binary regression to determine if 
the point belongs to which of the two groups. Then in the second 
step, estimate ordered probit model for each group separately. The 
question here is then, why I am choosing 6 as a cutting point 
instead of others?

Any suggestions would be really appreciated. Thank you.

You could do the obvious, and lump categories such as 1-6 or 1-7 
together to make a composite category.

You don't mention the size of your dataset. If there are 10,000 data, 
you might live with a 1% category. If you only have 100 data, you 
have too many categories.

Also, next time plan your study and training better so that next time 
your categories are fully utilized. And don't use so many categories. 
People have trouble even selecting responses on a 5-level scale.

Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

Vere scire est per causas scire

__
R-help@stat.math.ethz.ch 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] Upgraded FC4 to FC5 - unable to start device X11 in R

2007-06-15 Thread Patrick Connolly
On Fri, 15-Jun-2007 at 01:50PM -0700, Li-Jung Liang wrote:

| Hi,
| 
| I upgraded my system from FC4 to FC5.  So now I have R version 2.5.0 
| (2007-04-23).
| But I ran into a problem with starting device X11 (message below).
| 
|   X11()
| can't find X11 font
| Error in X11(display, width, height, pointsize, if (is.null(gamma)) 1 
| else gamma,  :
| unable to start device X11
| 
| Any idea?

Check what search() gives you.  Make sure package:grDevices is on that
list.

I ran into that problem myself.  I never figured out how come it used
to be there, but suddenly ceased to be.  The problem didn't appear
until R-2.5.0.  In the USER-VISIBLE CHANGES under 
CHANGES IN R VERSION 2.0.0,
I see this:

o   Package 'graphics' has been split into 'grDevices' (the graphics
devices shared between base and grid graphics) and 'graphics'
(base graphics).  Each of the 'graphics' and 'grid' packages
load 'grDevices' when they are attached.  Note that
ps.options() has been moved to grDevices and user hooks may
need to be updated.

My suspicion is that grDevices did not have to be specifically loaded
if graphics was one of your default packages loaded at startup.  Since
few others seem to have had the same experience, I'd hesitate to call
it a bug.  I've got round the problem by adding grDevices to the list
in my ~/.Rprofile file.

Others might have a better explanation, of course.

HTH


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] plot via xyplot not being saved

2007-06-15 Thread deepayan . sarkar
On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 So, if those statements are inside a function, I have to make my
 function to have an 'echo' argument/functionality? eg.:

 ## begin test.R
 test - function(n){
y - rnorm(n)
x - rnorm(n)
z - sample(letters[1:4], n, rep=T)
library(lattice)
bitmap(tst.png)
xyplot(y~x|z)
dev.off()
 }

 test(100)
 ## end test.R

 source(test.R, echo=T)

 also fails in this case...

Yes. The following will produce some output (the values of x + y and x
- y) if you type it out at the R prompt:

x - rnorm(10)
y - rnorm(10)
x + y
x - y

If you put that in a file and source it, nothing will get printed,
unless you have echo=TRUE. If you define

test - function(){
x - rnorm(10)
y - rnorm(10)
x + y
x - y
}

calling test() at the R prompt will only print x - y and not x + y, and so on.

This is all standard R behaviour. If you want something to be printed
irrespective of context, use print(), e.g.

print(x + y)

or

print(xyplot(y~x|z))

This is also mentioned in the R FAQ.

-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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
Thank you Deepayan,

I understand the behavior of not printing out the results inside the  
functions.

What I didn't know was that for xyplot() saving the plot actually  
meant save the result I see, which does not happen with plot(), in  
which case my function test() works just fine if I replaced xyplot()  
by plot().

Thank you very much,

b

On Jun 16, 2007, at 12:26 AM, [EMAIL PROTECTED] wrote:

 On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 So, if those statements are inside a function, I have to make my
 function to have an 'echo' argument/functionality? eg.:

 ## begin test.R
 test - function(n){
y - rnorm(n)
x - rnorm(n)
z - sample(letters[1:4], n, rep=T)
library(lattice)
bitmap(tst.png)
xyplot(y~x|z)
dev.off()
 }

 test(100)
 ## end test.R

 source(test.R, echo=T)

 also fails in this case...

 Yes. The following will produce some output (the values of x + y and x
 - y) if you type it out at the R prompt:

 x - rnorm(10)
 y - rnorm(10)
 x + y
 x - y

 If you put that in a file and source it, nothing will get printed,
 unless you have echo=TRUE. If you define

 test - function(){
x - rnorm(10)
y - rnorm(10)
x + y
x - y
 }

 calling test() at the R prompt will only print x - y and not x + y,  
 and so on.

 This is all standard R behaviour. If you want something to be printed
 irrespective of context, use print(), e.g.

 print(x + y)

 or

 print(xyplot(y~x|z))

 This is also mentioned in the R FAQ.

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


[R] selecting cut-off in Logistic regression using ROCR package

2007-06-15 Thread Tirthadeep


Hi,

I am using logistic regression to classify a binary psychometric data. using
glm() and then predict.glm() i got the predicted odds ratio of the testing
data. Next i am going to plot ROC curve for the analysis of my study.

Now what i will do:

1. first select a cut-off (say 0.4) and classify the output of predict.glm()
into {0,1} segment and then use it to draw ROC curve using ROCR package 

OR

2. just use the predicted odds ratio in ROCR package to get error rate and
use the minimum error rate (as new cut-off) to draw new ROC curve.

waiting for reply.

with regards and thanks.

Tirtha.
-- 
View this message in context: 
http://www.nabble.com/selecting-cut-off-in-Logistic-regression-using-ROCR-package-tf3931603.html#a11151210
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.