[R] Non-parametric four-way interactions?

2006-07-26 Thread Paul Smith
Dear All

I am trying to study four-way interactions in an ANOVA problem.
However, qqnorm+qqline result

(at http://phhs80.googlepages.com/qqnorm.png)

is not promising regarding the normality of data (960 observations).
The result of Shapiro-Wilk test is also not encouraging:

W = 0.9174, p-value  2.2e-16

(I am aware of the fact that normality tests tend to reject normality
for large samples.)

By the way, the histogram is at:

http://phhs80.googlepages.com/hist.png

To circumvent the problem, I looked for non-parametric tests, but I
found nothing, but the article:

http://www.pgia.ac.lk/socs/asasl/journal_papers/PDFformat/g.bakeerathanpaper-2.pdf

Finally, my question is: has R got implemented functions to use
non-parametric tests to avoid the fulfillment of the normality
assumption required to study four-way interactions?

Thanks in advance,

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.


Re: [R] Non-parametric four-way interactions?

2006-07-27 Thread Paul Smith
On 7/27/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
  I am trying to study four-way interactions in an ANOVA problem.
  However, qqnorm+qqline result
 
  (at http://phhs80.googlepages.com/qqnorm.png)
 
  is not promising regarding the normality of data (960 observations).
  The result of Shapiro-Wilk test is also not encouraging:
 
  W = 0.9174, p-value  2.2e-16
 
  (I am aware of the fact that normality tests tend to reject normality
  for large samples.)
 
  By the way, the histogram is at:
 
  http://phhs80.googlepages.com/hist.png
 
  To circumvent the problem, I looked for non-parametric tests, but I
  found nothing, but the article:
 
  http://www.pgia.ac.lk/socs/asasl/journal_papers/PDFformat/g.bakeerathanpaper-2.pdf
 
  Finally, my question is: has R got implemented functions to use
  non-parametric tests to avoid the fulfillment of the normality
  assumption required to study four-way interactions?

 Yes, although I seldom want to look at 4th order interactions.  You can
 fit a proportional odds model for an ordinal response which is a
 generalization of the Wilcoxon/Kruskal-Wallis approach, and allows one
 to have N-1 intercepts in the model when there are N data points (i.e.,
 it works even with no ties in the data).  However if N is large the
 matrix operations will be prohibitive and you might reduce Y to 100-tile
 groups.  The PO model uses only the ranks of Y so is monotonic
 transformation invariant.

 library(Design)  # also requires library(Hmisc)
 f - lrm(y ~ a*b*c*d)
 f
 anova(f)

 Also see the polr function in VR

Thanks, Frank. It is very encouraging to learn that, even without
normality, I can still study my four-way interactions. I am also aware
of transformations that may work in some non-normal cases, and I have
tried some of them, but with no success.

I am not familiar with the solutions that you suggest, and I would
like to learn how they work theoretically, in some book or on the
Internet. In particular, I would like to see, regarding power, how the
non-parametric suggested approach compares with the classical ANOVA
approach. Could you please indicate some references to help me with
that?

Again, thanks in advance.

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.


Re: [R] Non-parametric four-way interactions?

2006-07-28 Thread Paul Smith
On 7/27/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
 Tony Lachenbruch has written some about this, also see my book (it's web
 page is biostat.mc.vanderbilt.edu/rms).  I don't know about the power of
 interaction tests, but for main effect tests in the absence of
 interaction, the Wilcoxon test (a special case of PO model) has
 efficiency of 3/pi compared to the t-test if normality holds.

 Other approaches: Cox PH model, avas, ace.  My book covers these too.

Thanks, Frank, for the useful information.

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] Syntax of Levene's test

2006-08-02 Thread Paul Smith
Dear All

I am trying to use Levene's test (of package car), but I do not
understand quite well how to use it. '?levene.test' does not
unfortunately provide any example. My data are in a data frame and
correspond to 4 factors plus response. Could someone please give me an
example about how to use the command

levene.test(y, group)

?

Thanks in advance,

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.


Re: [R] Syntax of Levene's test

2006-08-02 Thread Paul Smith
On 8/2/06, John Fox [EMAIL PROTECTED] wrote:
 The argument y is the response variable and group is a factor defining
 groups (as ?levene.test says). If you have more than one factor, then you
 can use interaction() to create from them a factor with levels given by the
 product set of the levels of the individual factors. Here's an example

  library(car)
  data(Moore)
  attach(Moore)
  levene.test(conformity, interaction(fcategory, partner.status))
 Levene's Test for Homogeneity of Variance
   Df F value Pr(F)
 group  5  1.4694 0.2219
   39
  levels(interaction(fcategory, partner.status))
 [1] high.high   low.highmedium.high high.lowlow.low
 [6] medium.low
  levels(fcategory)
 [1] high   lowmedium
  levels(partner.status)
 [1] high low

 I'll add a couple of examples to the help page.

Thanks, John. Now, I understand how to use levene.test. There is only
a question remaining: is the null hypothesis corresponding to
homogeneity of variances, i.e., should one conclude that

Levene's Test for Homogeneity of Variance
   Df F valuePr(F)
group  95  3.5919  2.2e-16 ***
  864

tell us that the hypothesis that the variances are equal is (highly)
significant?

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.


Re: [R] Syntax of Levene's test

2006-08-02 Thread Paul Smith
On 8/3/06, John Fox [EMAIL PROTECTED] wrote:
 Levene's test tests the null hypothesis that the variance are equal, so a
 small p-value suggests that they are not. Looking at your output, it seems
 odd that you have as many as 96 groups.

Thanks again, John. I have 4 factors with 3, 4, 4 and 2 levels
(resulting in 96 groups), respectively. For each combination of the 4
factors, I have 10 observations.

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] Looking for transformation to overcome heterogeneity of variances

2006-08-03 Thread Paul Smith
Dear All

My data consists in 96 groups, each one with 10 observations. Levene's
test suggests that the variances are not equal, and therefore I have
tried to apply the classical transformations to have homocedasticity
in order to be able to use ANOVA. Unfortunately, no transformation
that I have used transforms my data into data with homocedasticity.
The histogram of variances is at

http://phhs80.googlepages.com/hist1.png

Is someone able to suggest to me a transformation to overcome the
problem of heterocedasticity?

Thanks in advance,

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.


Re: [R] Looking for transformation to overcome heterogeneity of variances

2006-08-03 Thread Paul Smith
On 03 Aug 2006 15:45:10 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote:
  My data consists in 96 groups, each one with 10 observations. Levene's
  test suggests that the variances are not equal, and therefore I have
  tried to apply the classical transformations to have homocedasticity
  in order to be able to use ANOVA. Unfortunately, no transformation
  that I have used transforms my data into data with homocedasticity.
  The histogram of variances is at
 
  http://phhs80.googlepages.com/hist1.png
 
  Is someone able to suggest to me a transformation to overcome the
  problem of heterocedasticity?

 Not based on that information. Try the following instead:

 fit - lm(y~g)
 par(mfrow=c(2,2)); plot(fit)

Thanks, Peter. By 'g', you mean

factor1* factor2*factor3*factor4

?

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.


Re: [R] Looking for transformation to overcome heterogeneity of variances

2006-08-03 Thread Paul Smith
On 03 Aug 2006 16:32:38 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote:
My data consists in 96 groups, each one with 10 observations. Levene's
test suggests that the variances are not equal, and therefore I have
tried to apply the classical transformations to have homocedasticity
in order to be able to use ANOVA. Unfortunately, no transformation
that I have used transforms my data into data with homocedasticity.
The histogram of variances is at
   
http://phhs80.googlepages.com/hist1.png
   
Is someone able to suggest to me a transformation to overcome the
problem of heterocedasticity?
  
   Not based on that information. Try the following instead:
  
   fit - lm(y~g)
   par(mfrow=c(2,2)); plot(fit)
 
  Thanks, Peter. By 'g', you mean
 
  factor1* factor2*factor3*factor4

 If that defines your 96 groups, yes.

Thanks, Peter. The result of

 fit - lm(tardiness ~ interaction(factor1,factor2,factor3,factor4))
 par(mfrow=c(2,2)); plot(fit)
Warning message:
X11 used font size 8 when 7 was requested


is at

http://phhs80.googlepages.com/2transform1.png

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.


Re: [R] Looking for transformation to overcome heterogeneity of variances

2006-08-04 Thread Paul Smith
Thanks to all contributors for the fruitfulness of this discussion. I
am speculating about a simpler solution: to use a non-parametric
approach. To avoid the requirement of having normal residuals, Frank
Harrell has suggested here the following non-parametric procedure:

library(Design)  # also requires library(Hmisc)
f - lrm(y ~ a*b*c*d)
f
anova(f)

Could someone please tell me whether that also works when there is no
homoscedasticity? What are the assumptions of that method?

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.


Re: [R] How to export data to Excel Spreadsheet?

2006-08-07 Thread Paul Smith
On 8/7/06, Xin [EMAIL PROTECTED] wrote:
I try to export my output's data to Excel spreadsheet. My outputs are:

  comb3
[,1] [,2] [,3]
   [1,] a  b  c
   [2,] a  b  d
   [3,] a  b  e
   [4,] a  b  f
   [5,] a  b  g

See

? write.table
? write.csv

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.


Re: [R] Vector Join

2006-08-13 Thread Paul Smith
On 8/13/06, Michael Zatorsky [EMAIL PROTECTED] wrote:
 I'm working on producing a simple cumulative frequency
 distribution.

 Thanks to the help of the good people on this list I
 now have four vectors that I'd like to join/relate
 into a table. e.g.


 v1 - myHistogram$breaks # classes
 v2 - myHistogram$counts # freqs
 v3 - cumsum(v2) # cumulative freq
 v4 - ((v3 / length(myData)) * 100)  # cumulative %


 What is the recommend approach to turning these into a
 single table with four columns?  ie effectively doing
 a relational join on row id?

 The goal is to ultimately have the data with one row
 per class in a format I can write out to a text file
 as:

   v1v2v3v4
   v1v2v3v4
   etc...

 Any advice will be appreciated.

An example follows:

 V1 - 1:4
 V2 - 3:6
 V3 - 2:5
 m - matrix(nrow=4,ncol=3)
 m
 [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]   NA   NA   NA
[3,]   NA   NA   NA
[4,]   NA   NA   NA
 m[,1] - V1
 m[,2] - V2
 m[,3] - V3
 m
 [,1] [,2] [,3]
[1,]132
[2,]243
[3,]354
[4,]465


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.


Re: [R] column to row

2006-08-14 Thread Paul Smith
On 8/14/06, yohannes alazar [EMAIL PROTECTED] wrote:
 I have a data in two columns and how can i convert it to one row . thank you
 in advance

 inpute

 1 2
 3 4
 5 6
 7 8
 9 1


 out put

 1 2 3 4 5 6 7 8 9 1

An example follows:

 input - matrix(1:10,5,2)
 input
 [,1] [,2]
[1,]16
[2,]27
[3,]38
[4,]49
[5,]5   10
 output - c(input[,1],input[,2])
 output
 [1]  1  2  3  4  5  6  7  8  9 10


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.


Re: [R] Autocompletion

2006-08-16 Thread Paul Smith
On 8/16/06, Óttar Ísberg [EMAIL PROTECTED] wrote:
 I may be guilty of not doing my homework, but still, I've searched. I'm a
 relative newcomer to R (my forte is at present MATLAB, but for various
 reasons I'm trying to get literate in R). My question is: Is there an
 autocompletion feature buried somewhere in R?

What do you mean precisely by 'autocompletion'? Are working on MS
Windows or on Linux?

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.


Re: [R] Autocompletion

2006-08-16 Thread Paul Smith
On 8/16/06, Óttar Ísberg [EMAIL PROTECTED] wrote:
 That was quick, and thanks. I'm afraid I wasn't precise enough. I'm using
 Windows XP and by autocompletion I mean typing the first few letters of a
 command and then have the system either complete the command or give you
 possible options, as in MATLAB or, for that matter, UNIX.

Regarding Windows XP, I do not know. However, on Linux, one presses
CTRL+R and R tries to complete the command with a command previously
used. Notwithstanding, I am sure that one can use the arrows keys on
Windows XP to invoke commands from a list of already used commands.
Try both ways.

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.


Re: [R] 4^2 factorial help

2006-08-18 Thread Paul Smith
On 8/18/06, Correia, L, Mr [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 To whom it may concern:

 I am trying a factorial design a system of mine that has two factors.
 Each factor was set at four different levels, with one replication for
 each of the combinations. My data is as follows:


A   B Response

 16002.5   0.0257

 26002.5   0.0254

 36005  0.0217

 46005  0.0204

 5600100.0191

 6600100.0210

 7600200.0133

 8600200.0139

 98002.5   0.0312

 10   800   2.5   0.0317

 11   800   5  0.0307

 12   800  5  0.0309

 13   800   100.0330

 14   800   100.0318

 15   800   200.0225

 16   800   200.0234

 17  1000  2.5   0.0350

 18  1000  2.5   0.0352

 19  1000  5  0.0373

 20  1000  5  0.0361

 21  1000 100.0432

 22  1000 100.0402

 23  1000 200.0297

 24  1000 200.0306

 25  1200  2.5   0.0324

 26  1200  2.5   0.0326

 27  1200  5  0.0353

 28  1200  5  0.0353

 29  1200 100.0453

 30  1200 100.0436

 31  1200 200.0348

 32  1200 200.0357



 I am able to enter my data into R and obtain an ANOVA table (which I
 have been able to verify as correct using an excel spreadsheet), using
 the following syntax:



 Factorial-data.frame(A=c(rep(c(600, 600, 600, 600, 800,
 800, 800, 800, 1000, 1000, 1000, 1000, 1200, 1200,
 1200, 1200), each=2)), B=c(rep(c(2.5, 5, 10, 20, 2.5, 5,
 10, 20, 2.5, 5, 10, 20, 2.5, 5, 10, 20), each=2)),
 Response = c(0.0257, 0.0254, 0.0217, 0.0204, 0.0191, 0.021, 0.0133,
 0.0139, 0.0312, 0.0317, 0.0307, 0.0309, 0.033, 0.0318, 0.0225, 0.0234,
 0.035, 0.0352, 0.0373, 0.0361, 0.0432, 0.0402, 0.0297, 0.0306, 0.0324,
 0.0326, 0.0353, 0.0353, 0.0453, 0.0436, 0.0348, 0.0357))



  anova(aov(Response~A*B, data=Factorial))



 However, this is as far as I am able to go. I would like to obtain the
 coefficients of my model, but am unable. I would also like to use other
 non-linear models as these factors are not linear. Also would like to
 add A^2 and B^2 into the ANOVA and modeling.

Try:

model - lm(Response~A*B, data=Factorial)
anova(model)

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.


Re: [R] Check values in colums matrix

2006-08-24 Thread Paul Smith
On 8/24/06, Muhammad Subianto [EMAIL PROTECTED] wrote:
 I have a dataset (20 columns  1000 rows) which
 some of columns have the same value and the others
 have different values.
 Here are some piece of my dataset:
 obj - cbind(c(1,1,1,4,0,0,1,4,-1),
  c(0,1,1,4,1,0,1,4,-1),
  c(1,1,1,4,2,0,1,4,-1),
  c(1,1,1,4,3,0,1,4,-1),
  c(1,1,1,4,6,0,1,5,-1),
  c(1,1,1,4,6,0,1,6,-1),
  c(1,1,1,4,6,0,1,7,-1),
  c(1,1,1,4,6,0,1,8,-1))
 obj.tr - t(obj)
 obj.tr
  obj.tr
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
 [1,]11140014   -1
 [2,]01141014   -1
 [3,]11142014   -1
 [4,]11143014   -1
 [5,]11146015   -1
 [6,]11146016   -1
 [7,]11146017   -1
 [8,]11146018   -1
 

 How can I do to check columns 2,3,4,6,7 and 9 have
 the same value, and columns 1,5 and 8 have different values.

Just try

all(obj.tr[,2]==obj.tr[1,2])

and so on for the other columns. See ? all.

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] Can R compute the expected value of a random variable?

2006-08-26 Thread Paul Smith
Dear All

Can R compute the expected value of a random variable?

Thanks in advance,

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.


Re: [R] Can R compute the expected value of a random variable?

2006-08-27 Thread Paul Smith
On 8/26/06, Mike Nielsen [EMAIL PROTECTED] wrote:
 Yes.

  Can R compute the expected value of a random variable?

Mike: thank you very much indeed for your so insightful and complete
answer. I have  meanwhile deepened my research and, as a consequence,
I have found the following solution, which seems to work fine:

 integrand - function(x){x*dlnorm(x,meanlog=2,sdlog=3)}
 integrate(integrand,-Inf, Inf)
665.146 with absolute error  0.046


There is also a package apt to calculate expected values: it is called
distrEx. (Thanks, Matthias.)

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.


Re: [R] Help on apply() function

2006-08-30 Thread Paul Smith
On 8/30/06, Mark Lyman [EMAIL PROTECTED] wrote:
  I have a problem with apply function. I have to two matrices of dimension of
  one column but n rows. I have to check whether one matrix is greater than
  other by going thru each row (ie) using if condition to check one matrix
  with another matrix.
 
  I like to use apply() function to this approach. That is apply function
  between two matrices. I searched for examples online but I couldn't find
  any.
 
  I don't know how to loop thru the matrices.

 You can use the functions all.equal with the function isTRUE (see ?all.equal) 
 to
 check if two objects are nearly equal (within a certain tolerance). Or you can
 use identical (see ?identical) to check if they are exactly the same. See the
 examples in the help for identical.

A possible solution could be:

 x - 1:5
 x
[1] 1 2 3 4 5
 y - 2:6
 y
[1] 2 3 4 5 6
 all((y-x)0)
[1] TRUE

The result TRUE means that each element of y is greater than the
homologous element in x.

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] Fitting Pareto distribution to some data

2006-09-03 Thread Paul Smith
Dear All

I am trying to fit Pareto distribution to some data. MASS package does
not support Pareto distribution. Is there some alternative way?

Thanks in advance,

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.


Re: [R] Fitting Pareto distribution to some data

2006-09-04 Thread Paul Smith
On 9/3/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
  I am trying to fit Pareto distribution to some data. MASS package does
  not support Pareto distribution. Is there some alternative way?

 Actually fitdistr{MASS} does if you supply the pdf for a Pareto.
 That is not in base R, but easy to write for yourself.

 It seems that Pareto and generalized Pareto is in several packages,
 including POT SoPhy VaR evd evir fExtremes lmomco.

Thanks, Prof Brian Ripley.

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.


Re: [R] Fitting Pareto distribution to some data

2006-09-04 Thread Paul Smith
On 9/4/06, William Asquith [EMAIL PROTECTED] wrote:
 Package lmomco fits generalized pareto (three parameter) using method
 of L-moments.  I suspect that other packages that Brian identified
 use method of moments or other.

That is excellent to learn that, William. Thanks.

Paul


 On Sep 3, 2006, at 10:55 AM, Paul Smith wrote:

  Dear All
 
  I am trying to fit Pareto distribution to some data. MASS package does
  not support Pareto distribution. Is there some alternative way?
 
  Thanks in advance,
 
  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-help@stat.math.ethz.ch 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] Gnuplot epslatex format also in R?

2006-09-12 Thread Paul Smith
Dear All

Is there some way of exporting R plots to epslatex, i.e., to a file
with the eps file and another one with the LaTeX commands
(representing the text in the plots), likewise Gnuplot does? If so,
could you please indicate it to me?

Thanks in advance,

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.


Re: [R] Gnuplot epslatex format also in R?

2006-09-12 Thread Paul Smith
On 9/12/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
  Is there some way of exporting R plots to epslatex, i.e., to a file
  with the eps file and another one with the LaTeX commands
  (representing the text in the plots), likewise Gnuplot does? If so,
  could you please indicate it to me?

 R has an xfig driver, and AFAIK you can do this from xfig.

Yes, your suggestion works! Thanks.

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.


Re: [R] extract a value from vector

2006-09-12 Thread Paul Smith
On 9/12/06, Ethan Johnsons [EMAIL PROTECTED] wrote:
 A quick question, please!

 How do you extract a certain value of vector?
 i.e. x = c(2,5,3,6,21,3,6,24, )

 How do you get the 1st one (which is 2); the 5th one (which is 21); etc?

Simple, Ethan:

x[1], x[5], ...

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.


Re: [R] Gnuplot epslatex format also in R?

2006-09-13 Thread Paul Smith
On 9/12/06, Anupam Tyagi [EMAIL PROTECTED] wrote:
  R has an xfig driver, and AFAIK you can do this from xfig.

 Is there an xfig port for Windows, without cygwin? If so, I will be thankful 
 for
 a pointer to the where it can be downloaded from. I have been looking for it 
 for
 some time. Anupam.

WinFIG, Anupam? Its site at

http://www.schmidt-web-berlin.de/WinFIG.htm

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] Classification trees and written conditions

2006-05-18 Thread Paul Smith
Dear All

When drawing a classification tree with

plot(mytree)
text(mytree)

the conditions are written just before the nodes branch. My question
is: can one be certain that those conditions refer to the left-side
branches? (The R documentation surprisingly lacks the information that
I am asking for.)

Thanks in advance,

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


Re: [R] Classification trees and written conditions

2006-05-18 Thread Paul Smith
On 5/18/06, Carlos Ortega [EMAIL PROTECTED] wrote:
 Are you referring to ?:
  - library(tree)
 -  library(rpart)

 On 5/18/06, Paul Smith [EMAIL PROTECTED] wrote:
 
 Dear All

 When drawing a classification tree with

 plot(mytree)
 text(mytree)

 the conditions are written just before the nodes branch. My question
 is: can one be certain that those conditions refer to the left-side
 branches? (The R documentation surprisingly lacks the information that
 I am asking for.)

Thanks, Carlos. I am referring to

ibrary(rpart)

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


Re: [R] Classification trees and written conditions

2006-05-18 Thread Paul Smith
On 5/18/06, Carlos Ortega [EMAIL PROTECTED] wrote:
 Yes, that is right.
 The conditions on top of the branches refer to the left-hand side.

Thanks, Carlos. Then, it should be explicitly said in ? text.rpart.

Paul

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


[R] Using R to illustrate the Central Limit Theorem

2005-04-21 Thread Paul Smith
Dear All

I am totally new to R and I would like to know whether R is able and
appropriate to illustrate to my students the Central Limit Theorem,
using for instance 100 independent variables with uniform distribution
and showing that their sum is a variable with an approximated normal
distribution.

Thanks in advance,

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


Re: [R] Using R to illustrate the Central Limit Theorem

2005-04-23 Thread Paul Smith
On 4/23/05, Matthias Kohl [EMAIL PROTECTED] wrote:
 here is another idea to illustrate the Central Limit Theorem which is
 based on our package distr.

Thanks to all for your numerous suggestions. Since I am just beginning
with R, it will take a while before I can fully digest your help.

Have a nice weekend!

Paul

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


[R] Restarting R without quitting R

2005-04-23 Thread Paul Smith
Dear All

Is there some way of restarting R, without quitting R? In other words,
I am looking for something like the commands reset (MuPAD) or restart
(Maple).

Thanks in advance,

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


Re: [R] Restarting R without quitting R

2005-04-23 Thread Paul Smith
On 4/23/05, Uwe Ligges [EMAIL PROTECTED] wrote:
  Is there some way of restarting R, without quitting R? In other words,
  I am looking for something like the commands reset (MuPAD) or restart
  (Maple).
 
 No, but of course you could write a function that fires up a new
 instance of R and quits the current one after that.

Thanks, Uwe.

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


Re: [R] good editor for R sources ?

2005-04-26 Thread Paul Smith
On 4/26/05, Uwe Ligges [EMAIL PROTECTED] wrote:
  (Sorry if the question has already been answered.)
  Could someone please suggest a good text editor for
  writing R sources ?
  (I know emacs exists ... but I find it a bit heavy).
  I use crimson (http://www.crimsoneditor.com) which is
  small and simple, but the R syntax seems not to be supported.
 
 See http://www.sciviews.org/_rgui/projects/Editors.html
 The page tells us that there is support for Crimson editor.

And for Linux, what do you recommend?

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


Re: [R] good editor for R sources ?

2005-04-26 Thread Paul Smith
On 4/26/05, Liaw, Andy [EMAIL PROTECTED] wrote:
(Sorry if the question has already been answered.)
Could someone please suggest a good text editor for
writing R sources ?
(I know emacs exists ... but I find it a bit heavy).
I use crimson (http://www.crimsoneditor.com) which is
small and simple, but the R syntax seems not to be supported.
  
   See http://www.sciviews.org/_rgui/projects/Editors.html
   The page tells us that there is support for Crimson editor.
 
  And for Linux, what do you recommend?
 
 Tere are suggestions on that page that Uwe mentioned above for Linux!
 First choice would be (X)Emacs/ESS.  Then there are also vim, kate,
 bluefish, ...

Thanks, Andy. Does somebody know how to install ess on xemacs?

Paul

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


[R] Density curve over a histogram

2005-04-27 Thread Paul Smith
Dear All

I would like to draw a picture with the density curve of a normal
distribution over a histogram of a set of random numbers extracted
from the same normal distribution. Is that possible?

Thanks in advance,

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


Re: [R] Density curve over a histogram

2005-04-27 Thread Paul Smith
On 4/27/05, Achim Zeileis [EMAIL PROTECTED] wrote:
  I would like to draw a picture with the density curve of a normal
  distribution over a histogram of a set of random numbers extracted
  from the same normal distribution. Is that possible?
 
 To quote Simon `Yoda' Blomberg: This is R. There is no if. Only how.
 (see fortune(Yoda))
 
 Try:
 
 R x - rnorm(100)
 R hist(x, freq = FALSE)
 R curve(dnorm, col = 2, add = TRUE)

Fantastic! Thanks a lot, Achim.

Paul

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


[R] User-defined random variable

2005-04-30 Thread Paul Smith
Dear All

I would like to know whether it is possible with R to define a
discrete random variable different from the ones already defined
inside R and generate random numbers from that user-defined
distribution.

Thanks in advance,

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


Re: [R] User-defined random variable

2005-05-02 Thread Paul Smith
On 5/1/05, Matthias Kohl [EMAIL PROTECTED] wrote:
 I would like to know whether it is possible with R to define a
 discrete random variable different from the ones already defined
 inside R and generate random numbers from that user-defined
 distribution.
 
 Yes. One generic way is to specify the quantile function (as in
 qpois() etc.) and do qfun(runif(N)).
 
 If the support discrete but also finite, you can also use sample(), e.g.
 
   sample(myset, N, replace = TRUE, prob = myprob)
 
 one can also use our R package distr to generate discrete random
 variables. The subsequent code provides a function which generates an
 object of class DiscreteDistribution based on a finite support supp.
 If prob is missing all elements in supp are equally weighted.

Thanks you for all your helpful replies to my question.

Paul

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


[R] Command to add two vectors

2005-05-03 Thread Paul Smith
Dear All

Is there some command to add two vectors?

Thanks in advance,

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


Re: [R] Command to add two vectors

2005-05-03 Thread Paul Smith
On 5/3/05, Josef Eschgfaeller [EMAIL PROTECTED] wrote:
  Is there some command to add two vectors?
 
 x+y

Thanks a lot, Josef.

Paul

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


[R] Density of the sum of two random variables

2005-05-04 Thread Paul Smith
Dear All

I would like to know whether it is possible with R to get the
mathematical expression of the density of a sum of two independent
continuous random variables.

Thanks in advance,

Paul

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


[R] Histogram for mixed random variables

2005-05-05 Thread Paul Smith
Dear All

I would like to get the histogram for the following model with
discrete and continuous random variables:

* with probability 1/3, a random number is drawn from the continuous
uniform distribution (min=0, max=1);
* with probability 2/3, a random number is drawn from a different
continuous uniform distribution (min=-1/2, max=1/2).

Any help would be most welcome.

Thanks in advance,

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


Re: [R] Density of the sum of two random variables

2005-05-05 Thread Paul Smith
On 5/5/05, Spencer Graves [EMAIL PROTECTED] wrote:
   Have you considered package distr?  It will do something similar 
 to
 what you request, I think;  it may or may not be adequate for your
 purposes.

Thanks, Spencer and Duncan. Maybe, the best choice is to use Maple or
MuPAD for that.

Paul

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


[R] Looking for greater floating-point precision

2006-11-16 Thread Paul Smith
Dear All

For my calculations, I am needing to use more floating-point precision
than the default one of R. Is that possible? And, if yes, how?

Thanks in advance,

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.


Re: [R] Looking for greater floating-point precision

2006-11-17 Thread Paul Smith
On 11/16/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
  For my calculations, I am needing to use more floating-point precision
  than the default one of R. Is that possible? And, if yes, how?

 See package gmp (but that will be slow and cumbersome for all but simple
 calculations).

 The real issue is that R already uses the maximum precision of the FPU for
 many common FPUs (but not all).  Since you have forgotten to tell us
 anything about your environment we don't know if that applies: there may
 be compiler options you can use to raise the precision.

 Please do study the posting guide: we are surprisingly good at
 mind-reading, but prefer to be told exactly what you want to do with R in
 what environment and why you are 'needing' something.

Thanks, Gabor and Prof. Ripley. After some research, I conclude that
the problem occurring to me cannot be removed for any finite
floating-point precision. (I do need infinite floating-point
precision.) The problematic operation is the successive multiplication
of reals between 0 and 1; after a certain number of multiplications,
significant rounding errors occur.

I did read the posting guide, but I could not anticipate the relevance
of indicating the environment that I am using: Fedora Core 6 (Linux)
running on a Pentium Dual Core and R 2.4.0.

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] Ryacas not working properly

2006-11-18 Thread Paul Smith
Dear All

I have just installed the package Ryacas, but getting the following:

 library(Ryacas)
Loading required package: XML
 yacas(1/2 * 3/4)
[1] Starting Yacas!
Error in socketConnection(host = 127.0.0.1, port = 9734, server = FALSE,  :
unable to open connection
In addition: Warning message:
127.0.0.1:9734 cannot be opened
 /usr/lib/R/library/Ryacas/yacdir/R.ys(1) : File not found


I am using Fedora Core 6 (Linux), R 2.4.0 and Yacas 1.0.62.

Any ideas?

Thanks in advance,

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Checkout the INSTALLATION - UNIX and TROUBLESHOOTING
 sections of the home page:
 http://code.google.com/p/ryacas/
 
  I have just installed the package Ryacas, but getting the following:
 
   library(Ryacas)
  Loading required package: XML
   yacas(1/2 * 3/4)
  [1] Starting Yacas!
  Error in socketConnection(host = 127.0.0.1, port = 9734, server = FALSE,  
  :
 unable to open connection
  In addition: Warning message:
  127.0.0.1:9734 cannot be opened
   /usr/lib/R/library/Ryacas/yacdir/R.ys(1) : File not found
  
 
  I am using Fedora Core 6 (Linux), R 2.4.0 and Yacas 1.0.62.
 
  Any ideas?

Thanks, Gabor. I have followed the instructions given at:

http://groups.google.com/group/comp.os.linux.networking/msg/656bbead5059fc07

as suggested at

http://code.google.com/p/ryacas/

However, I still get the following:

$ telnet localhost 9734
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection refused
$

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 You might try posting your problem on the comp.os.linux.networking
 group since it appears to be a configuration problem with telnet
 on your machine.

Thanks, Gabor. I am going to do that and I will let you know about the result.

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 19 Nov 2006 16:11:52 +0100, Peter Dalgaard [EMAIL PROTECTED] wrote:
 Paul Smith [EMAIL PROTECTED] writes:

  On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
   You might try posting your problem on the comp.os.linux.networking
   group since it appears to be a configuration problem with telnet
   on your machine.
 
  Thanks, Gabor. I am going to do that and I will let you know about the 
  result.

 In particular, check whether you're firewalling yourself out.
 System/Administration/Security Level and Firewall -- I suspect that
 you have to add the ryacas port there. (Suspect meaning that I'm not
 sure that you really need this even for unprivileged ports on
 localhost, but it could be worth the try.)

Thanks, Peter. I put there port 9734, but no progress. Meanwhile, I
received this from someone on Fedora mailing list:

« Original Message 
 Date: Sunday, November 19, 2006 01:34:23 PM +
 From: Paul Smith [EMAIL PROTECTED]
 To: For users of Fedora [EMAIL PROTECTED]
 Subject: Re: Enabling telnet

 On 11/19/06, Tim [EMAIL PROTECTED] wrote:
  What I am trying to accomplish is the following:
 
  http://marc.10east.com/?l=r-helpm=116389849302592w=2

 Sounds like you don't want a telnet server, then.  But that you're
 trying to use a telnet client to debug some other server, and the
 problem is with *it*.  But I can't really tell what ryacas is about
 from that message, nor a quick internet search on it.

 Otherwise, if you had a telnet server installed, and running per the
 usual configuration, you could do telnet localhost in a command
 line, and you'd be logging into another command line interface, just
 as if you were logging into a computer through a network.

 Maybe the developers of Ryacas on R mailing list can help me further.
 According to the direction suggested by one of them,

 http://groups.google.com/group/comp.os.linux.networking/msg/656bbead5
 059fc07

 I should change the file

 /etc/xinetd.d/telnet

 However, there is no such a file, unless I install telnet-server.


you don't want to touch the /etc/xinetd.d/telnet file (if you had one).
that file relates to control of the telnet daemon - which is what the
user in that google groups message was trying to get going.

you're not interested in the telnet daemon, rather in the ryacas one,
and that's what you should focus on trying to get working.  your issue
with not being able to connect to port 9734 is because you haven't
managed to get the ryacas daemon started up correctly. when you do, and
it shows up in a netstat, then all should be well.

in short, your problem is with setting up ryacas, not enabling telnet.

in your context, your telnet client, which works just fine, has nothing
to do with your telnet daemon (which appears to not be enabled, which
is just fine).»

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Sorry but there is not much else I can tell you.  I don't have a UNIX system
 myself though I do know that others have used Ryacas on UNIX since the notes
 on the home page are based, in part, on their feedback of successfully using
 it on UNIX.

 I don't know if the responder is correct since one other person who had a
 similar problem on UNIX with Ryacas found that it was his telnet configuration
 that was the problem.

 Make sure you have tried all the possibilities on the home page.

 You should at the very least be able to run Ryacas using the system method
 since that does not require telnet in the first place.

 Also check which version of Ryacas you are using.

Thanks, Gabor. I am using Ryacas_0.2-3.tar.gz.

Do other people here using Fedora Core experience the same problem?
Can some FC users here run Ryacas well?

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
   Sorry but there is not much else I can tell you.  I don't have a UNIX 
   system
   myself though I do know that others have used Ryacas on UNIX since the 
   notes
   on the home page are based, in part, on their feedback of successfully 
   using
   it on UNIX.
  
   I don't know if the responder is correct since one other person who had a
   similar problem on UNIX with Ryacas found that it was his telnet 
   configuration
   that was the problem.
  
   Make sure you have tried all the possibilities on the home page.
  
   You should at the very least be able to run Ryacas using the system method
   since that does not require telnet in the first place.
  
   Also check which version of Ryacas you are using.
 
  Thanks, Gabor. I am using Ryacas_0.2-3.tar.gz.
 
  Do other people here using Fedora Core experience the same problem?
  Can some FC users here run Ryacas well?

 The troubleshooting notes were based on the feedback of a Debian user
 of Ryacas.

Therefore it would be very useful if someone here running Fedora Core
6 could test whether Ryacas works fine or not on FC6.

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Marc Schwartz [EMAIL PROTECTED] wrote:
 OK, after digging around for a couple of hours on this, thinking that
 this might be a firewall/SELinux/On Demand Services problem, I have, I
 think, nailed it down to two key things on FC6:

 1. It requires the use of the '--enable-server' configure option for
 yacas itself.

 2. There is a directory permissions problem in the Ryacas package,
 restricting a regular user's access to the files located in the 'yacdir'
 subdirectory.

 Note that in the instructions below, I also install the GSL, which
 presumably is not required, but I did it anyway after noting some
 warnings during the yacas build process.

 One other thing, which is that when downloading the Ryacas package from
 the Google site using Firefox, the file is downloaded as:

   Ryacas_0.2 3.tar.gz

 Note the missing '-' between the 2 and 3.  Be sure to check for this
 when saving the tarball to disk.


 So here goes:


 1. Install the GSL (including the devel RPM) as root:

   yum install gsl*




 2. Install yacas from the source tarball using:

   ./ configure --enable-server
   make

   then as root:

   make install




 4. Install the Ryacas package as root:

   R CMD INSTALL Ryacas_0.2-3.tar.gz


 Be sure that you also have the 'XML' package from CRAN installed, which
 is a dependency for Ryacas.




 3. Change the permissions for /usr/local/lib/R/library/Ryacas/yacdir:

 Note that the default permission for this directory after installation
 is:

 drwxr--r-- 2 root root  4096 Nov 19 15:17 yacdir


 Thus:

  su
  chmod +x /usr/local/lib/R/library/Ryacas/yacdir


 Now:

 drwxr-xr-x 2 root root  4096 Nov 19 15:17 yacdir



 Now in R as a regular user:

  library(Ryacas)
 Loading required package: XML

  yacas(5/8 * 3/4)
 [1] Starting Yacas!
 Accepting requests from port 9734
 expression(15/32)

  yacas(3/7 * 5/9)
 expression(5/21)

Excellent, Marc, it works! Thanks.

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.


Re: [R] Ryacas not working properly

2006-11-19 Thread Paul Smith
On 11/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Thanks, Marc.  I have placed a link to your post on the Ryacas home page.
 Also, Ryacas 0.2-3 is now on Omegahat (as well as google groups).

Apparently, the link

HowTo - Enable Telnet on Linux

at Ryacas site is misleading, as it suggests the installation of
telnet-server and that is not necessary. See the discussion at

http://groups-beta.google.com/group/comp.os.linux.networking/browse_thread/thread/2bb6a4c7a1167285/565dde88d7922659#565dde88d7922659

Paul




 On 11/19/06, Marc Schwartz [EMAIL PROTECTED] wrote:
  OK, after digging around for a couple of hours on this, thinking that
  this might be a firewall/SELinux/On Demand Services problem, I have, I
  think, nailed it down to two key things on FC6:
 
  1. It requires the use of the '--enable-server' configure option for
  yacas itself.
 
  2. There is a directory permissions problem in the Ryacas package,
  restricting a regular user's access to the files located in the 'yacdir'
  subdirectory.
 
  Note that in the instructions below, I also install the GSL, which
  presumably is not required, but I did it anyway after noting some
  warnings during the yacas build process.
 
  One other thing, which is that when downloading the Ryacas package from
  the Google site using Firefox, the file is downloaded as:
 
   Ryacas_0.2 3.tar.gz
 
  Note the missing '-' between the 2 and 3.  Be sure to check for this
  when saving the tarball to disk.
 
 
  So here goes:
 
 
  1. Install the GSL (including the devel RPM) as root:
 
   yum install gsl*
 
 
 
 
  2. Install yacas from the source tarball using:
 
   ./ configure --enable-server
   make
 
   then as root:
 
   make install
 
 
 
 
  4. Install the Ryacas package as root:
 
   R CMD INSTALL Ryacas_0.2-3.tar.gz
 
 
  Be sure that you also have the 'XML' package from CRAN installed, which
  is a dependency for Ryacas.
 
 
 
 
  3. Change the permissions for /usr/local/lib/R/library/Ryacas/yacdir:
 
  Note that the default permission for this directory after installation
  is:
 
  drwxr--r-- 2 root root  4096 Nov 19 15:17 yacdir
 
 
  Thus:
 
   su
   chmod +x /usr/local/lib/R/library/Ryacas/yacdir
 
 
  Now:
 
  drwxr-xr-x 2 root root  4096 Nov 19 15:17 yacdir
 
 
 
  Now in R as a regular user:
 
   library(Ryacas)
  Loading required package: XML
 
   yacas(5/8 * 3/4)
  [1] Starting Yacas!
  Accepting requests from port 9734
  expression(15/32)
 
   yacas(3/7 * 5/9)
  expression(5/21)
 
 
  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-help@stat.math.ethz.ch 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] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
Dear All

I am trying to convert from the type expression to the type
numeric. The following works:

 x - expression(6.2)
 as.numeric(as.character(x))
[1] 6.2

However, the following does not work:

 x - expression(62/100)
 as.numeric(as.character(x))
[1] NA
Warning message:
NAs introduced by coercion

Any idea about how to deal with the second case?

Thanks in advance,

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.


Re: [R] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
On 11/23/06, Barry Rowlingson [EMAIL PROTECTED] wrote:
 x - expression(62/100)
 as.numeric(as.character(x))
 
  [1] NA
  Warning message:
  NAs introduced by coercion
 
  Any idea about how to deal with the second case?
 

   eval-uate the expression:

x - expression(62/100)
eval(x)
   [1] 0.62

That is it, Barry. Thanks.

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.


Re: [R] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
On 23 Nov 2006 18:20:17 +0100, Peter Dalgaard [EMAIL PROTECTED] wrote:
  I am trying to convert from the type expression to the type
  numeric. The following works:
 
   x - expression(6.2)
   as.numeric(as.character(x))
  [1] 6.2
 
  However, the following does not work:
 
   x - expression(62/100)
   as.numeric(as.character(x))
  [1] NA
  Warning message:
  NAs introduced by coercion
 
  Any idea about how to deal with the second case?

 Well, you could start by watching where you are going...

  x - expression(62/100)
  x
 expression(62/100)
  as.character(x)
 [1] 62/100

 and as.numeric wouldn't know dashes about strings that contain
 slashes...

 eval(x) might be closer to the mark.

Thanks, Peter. I did not know about the existence of the command
'eval', in spite of the fact of having searched the Internet for a
solution for my problem.

'eval' seems not working in connection with Ryacas:

 library(Ryacas)
 x - yacas(2/3*5/7)
 x
expression(10/21)
 eval(x)
expression(10/21)


To work, one has to do the following:
 eval(x)
expression(10/21)
 eval(as.expression(x))
[1] 0.4761905

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] Ryacas and fractions with simultaenously very large numerators and denominators

2006-11-23 Thread Paul Smith
Dear All

I am doing the following:

 x - yacas(3/2)
 for (i in 2:400)
+x - yacas(paste(x,*,x))
 x
expression(Inf^1.260864167e+117/Inf^6.304320836e+116)
 Eval(x)
[1] NaN

No luck this way. However, I am successful with

 y - yacas((3/2)^400)
 y
expression(7.05507910865533e+190/2.58224987808691e+120)
 Eval(y)
[1] 2.732144e+70

If Ryacas/Yacas cannot multiply fractions with simultaenously very
large numerators and denominators, what else should I use?

Thanks in advnace,

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.


Re: [R] Ryacas and fractions with simultaenously very large numerators and denominators

2006-11-23 Thread Paul Smith
On 23 Nov 2006 20:17:15 +0100, Peter Dalgaard [EMAIL PROTECTED] wrote:
  I am doing the following:
 
   x - yacas(3/2)
   for (i in 2:400)
  +x - yacas(paste(x,*,x))
   x
  expression(Inf^1.260864167e+117/Inf^6.304320836e+116)
   Eval(x)
  [1] NaN
 
  No luck this way. However, I am successful with
 
   y - yacas((3/2)^400)
   y
  expression(7.05507910865533e+190/2.58224987808691e+120)
   Eval(y)
  [1] 2.732144e+70
 
  If Ryacas/Yacas cannot multiply fractions with simultaenously very
  large numerators and denominators, what else should I use?

 I don't think they are the same: the latter example has 400 terms, the
 other about 2^400 terms

Oops, Peter! You are absolutely right. However, my question remains because

 x - yacas(3/2)
 for (i in 2:2600)
+x - yacas(paste((3/2)*,x))
 x
expression(3.307388556e+261 * Inf^2/(2.404907546e+111 * Inf))
 Eval(x)
[1] NaN
 y - yacas((3/2)^2600)
 y
expression(Inf/Inf)
 Eval(y)
[1] NaN


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.


Re: [R] Ryacas not working properly

2006-11-25 Thread Paul Smith
On 11/19/06, Marc Schwartz [EMAIL PROTECTED] wrote:
 this might be a firewall/SELinux/On Demand Services problem, I have, I
 think, nailed it down to two key things on FC6:

 1. It requires the use of the '--enable-server' configure option for
 yacas itself.

 2. There is a directory permissions problem in the Ryacas package,
 restricting a regular user's access to the files located in the 'yacdir'
 subdirectory.

 Note that in the instructions below, I also install the GSL, which
 presumably is not required, but I did it anyway after noting some
 warnings during the yacas build process.

 One other thing, which is that when downloading the Ryacas package from
 the Google site using Firefox, the file is downloaded as:

   Ryacas_0.2 3.tar.gz

 Note the missing '-' between the 2 and 3.  Be sure to check for this
 when saving the tarball to disk.


 So here goes:


 1. Install the GSL (including the devel RPM) as root:

   yum install gsl*




 2. Install yacas from the source tarball using:

   ./ configure --enable-server
   make

   then as root:

   make install




 4. Install the Ryacas package as root:

   R CMD INSTALL Ryacas_0.2-3.tar.gz


 Be sure that you also have the 'XML' package from CRAN installed, which
 is a dependency for Ryacas.




 3. Change the permissions for /usr/local/lib/R/library/Ryacas/yacdir:

 Note that the default permission for this directory after installation
 is:

 drwxr--r-- 2 root root  4096 Nov 19 15:17 yacdir


 Thus:

  su
  chmod +x /usr/local/lib/R/library/Ryacas/yacdir


 Now:

 drwxr-xr-x 2 root root  4096 Nov 19 15:17 yacdir



 Now in R as a regular user:

  library(Ryacas)
 Loading required package: XML

  yacas(5/8 * 3/4)
 [1] Starting Yacas!
 Accepting requests from port 9734
 expression(15/32)

  yacas(3/7 * 5/9)
 expression(5/21)

There a side effect that I would like to remove: yacas compiled with
the option '--enable-server' runs like this

In x := 2
OMOBJ
  OMI2/OMI
/OMOBJ
In x
OMOBJ
  OMI2/OMI
/OMOBJ
In

i.e., with, apparently, xml commands. How can one run yacas normally,
without those pieces of xml?

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.


Re: [R] Ryacas not working properly

2006-11-25 Thread Paul Smith
On 11/25/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Ryacas starts up yacas with an initialization file R.ys which puts
 the server in a mode which outputs XML (which is what Ryacas reads).
 It does that by specifying --init /whatever/R.ys on the yacas command line
 when it is run.

 You can run yacas without that init file or you can just enter into yacas
 this to turn off XML output:

PrettyPrinter()

Yeah, the above works! Thanks, Gabor.

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] Question about rpart and regression trees

2007-01-22 Thread Paul Smith
Dear All

I would like to use rpart to obtain a regression tree for a dataset
like the following:

Y   X1  X2  X3  X4
5.500033B   A   3   2
0.35625148  D   B   6   5
0.8062546   E   C   4   3
5.100014C   A   3   2
5.7000422   A   A   3   2
0.76875436  C   A   6   5
1.0312537   D   A   4   1

Y is the objective variable. X1, X2, X3 and X4 can take, respectively,
the following values:

X1: A,B,C,D,E
X2: A,B,C,D,E
X3: 3,4,5,6
X4. 1,2,3,4,5

Should I convert X3 and X4 to factor before running rpart?

Thanks in advance,

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.


Re: [R] Question about rpart and regression trees

2007-01-23 Thread Paul Smith
On 1/23/07, Prof Brian Ripley [EMAIL PROTECTED] wrote:
  I would like to use rpart to obtain a regression tree for a dataset
  like the following:
 
  Y X1  X2  X3  X4
  5.500033  B   A   3   2
  0.35625148D   B   6   5
  0.8062546 E   C   4   3
  5.100014  C   A   3   2
  5.7000422 A   A   3   2
  0.76875436C   A   6   5
  1.0312537 D   A   4   1
 
  Y is the objective variable. X1, X2, X3 and X4 can take, respectively,
  the following values:
 
  X1: A,B,C,D,E
  X2: A,B,C,D,E
  X3: 3,4,5,6
  X4. 1,2,3,4,5
 
  Should I convert X3 and X4 to factor before running rpart?

 If they really are factors, yes.
 If they are ordered factors, no.

Thanks, Prof. Ripley. Is it correct to adopt the same procedure in
case of classification trees, i.e., in case the objective variable (Y)
is categorical and X1, X2, X3 and X4 are as above?

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.


Re: [R] Announcing another R search engine

2007-02-04 Thread Paul Smith
On 2/4/07, Sasha Goodman [EMAIL PROTECTED] wrote:
 Oh, I almost forgot:

 The search engine is at:
 http://www.rseek.org

 --Sasha

 On 2/3/07, Sasha Goodman [EMAIL PROTECTED] wrote:
 
  Hello all,
 
  I wanted to announce a new R search engine I made that covers all the
  major R mailing lists, CRAN, r-project.org, and more. Results are tabbed,
  so you can refine the search. Current refinements include searching just the
  mailing lists, searching just introductions, and searching the web for
  source files ending in .R.
 
  Please send comments and suggestions. If you want to add sites to the
  search, there is no need to contact me. Just hit the volunteer link at the
  bottom and you can use Google Coop to add links.

Thanks a lot for this very useful search tool, Sasha!

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.


Re: [R] Random Integers

2007-02-25 Thread Paul Smith
 Is there an R function to generate random integers?  Thanks in advance.

For example, if you want 5 random integers from the sequence 1:50, you
can do the following:

sample(1:50,5)

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] Cannot install iWidgetsRGtk

2007-04-04 Thread Paul Smith
Dear All

I am trying to install iWidgetsRGtk (on a Linux machine), but getting
the following error:

 install.packages(iWidgetsRGtk,repos=http://www.math.csi.cuny.edu/pmg;)
Warning in download.packages(unique(pkgs), destdir = tmpd, available =
available,  :
 no package 'iWidgetsRGtk' at the repositories


Any ideas?

Thanks in advance,

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.


Re: [R] Cannot install iWidgetsRGtk

2007-04-04 Thread Paul Smith
On 4/4/07, Michael Lawrence [EMAIL PROTECTED] wrote:
 iWidgetsRGtk is an obsolete package. Instead, install gWidgetsRGtk from
 CRAN. That's g not i.

Thanks, Michael. That is solved now.

Paul


 On 4/4/07, Paul Smith [EMAIL PROTECTED] wrote:
 
  Dear All
 
  I am trying to install iWidgetsRGtk (on a Linux machine), but getting
  the following error:
 
  
 install.packages(iWidgetsRGtk,repos=http://www.math.csi.cuny.edu/pmg
 )
  Warning in download.packages(unique(pkgs), destdir = tmpd, available =
  available,  :
   no package 'iWidgetsRGtk' at the repositories
  
 
  Any ideas?
 
  Thanks in advance,
 
  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-help@stat.math.ethz.ch 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] Computing the rank of a matrix.

2007-04-06 Thread Paul Smith
On 4/6/07, José Luis Aznarte M. [EMAIL PROTECTED] wrote:
 Hi! Maybe this is a silly question, but I need the column rank
 (http://en.wikipedia.org/wiki/Rank_matrix) of a matrix and R function
 'rank()' only gives me the ordering of the elements of my matrix.
 How can I compute the column rank of a matrix? Is there not an R
 equivalent to Matlab's 'rank()'?
 I've been browsing for a time now and I can't find anything, so any
 help will be greatly appreciated. Best regards!

This discussion may help you:

http://marc.info/?l=r-helpm=111522337531442w=2

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] A problem about all possible sequences

2007-04-17 Thread Paul Smith
Dear All

Suppose a sequence of length 10 generated by the following rule: the
first element is 0 with 50% of probability or 1 with the same
probability; the second element likewise; and so on.

Is there some R command to obtain all possible different sequences
formed by the above rule? I am aware that one could write a small
program to do that, but I am speculating about whether a command is
already existent.

Thanks in advance,

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.


Re: [R] A problem about all possible sequences

2007-04-17 Thread Paul Smith
On 4/17/07, Robin Hankin [EMAIL PROTECTED] wrote:
 f - function(n){expand.grid(rep(list(0:1),n))}
 f(10)
 [snip]

Thanks, Robin, that is it!

Paul


 On 17 Apr 2007, at 15:26, Paul Smith wrote:

  Dear All
 
  Suppose a sequence of length 10 generated by the following rule: the
  first element is 0 with 50% of probability or 1 with the same
  probability; the second element likewise; and so on.
 
  Is there some R command to obtain all possible different sequences
  formed by the above rule? I am aware that one could write a small
  program to do that, but I am speculating about whether a command is
  already existent.
 
  Thanks in advance,
 
  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.

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



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


[R] Bad optimization solution

2007-05-07 Thread Paul Smith
Dear All

I am trying to perform the below optimization problem, but getting
(0.5,0.5) as optimal solution, which is wrong; the correct solution
should be (1,0) or (0,1).

Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6 (Linux).

Thanks in advance,

Paul

--
myfunc - function(x) {
  x1 - x[1]
  x2 - x[2]
  abs(x1-x2)
}

optim(c(0.5,0.5),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=list(fnscale=-1))

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

2007-05-07 Thread Paul Smith
On 5/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I think the problem is the starting point.  I do not remember the details
 of the BFGS method, but I am almost sure the (.5, .5) starting point is
 suspect, since the abs function is not differentiable at 0.  If you perturb
 the starting point even slightly you will have no problem.

  Paul Smith
  [EMAIL PROTECTED]
To
  Sent by:  R-help r-help@stat.math.ethz.ch
  [EMAIL PROTECTED]  cc
  at.math.ethz.ch
Subject
[R] Bad optimization solution
  05/07/2007 04:30
  PM








 Dear All

 I am trying to perform the below optimization problem, but getting
 (0.5,0.5) as optimal solution, which is wrong; the correct solution
 should be (1,0) or (0,1).

 Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6 (Linux).

 Thanks in advance,

 Paul

 --
 myfunc - function(x) {
   x1 - x[1]
   x2 - x[2]
   abs(x1-x2)
 }

 optim(c(0.5,0.5),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=list(fnscale=-1))

Yes, with (0.2,0.9), a correct solution comes out. However, how can
one be sure in general that the solution obtained by optim is correct?
In ?optim says:

 Method 'L-BFGS-B' is that of Byrd _et. al._ (1995) which allows
 _box constraints_, that is each variable can be given a lower
 and/or upper bound. The initial value must satisfy the
 constraints. This uses a limited-memory modification of the BFGS
 quasi-Newton method. If non-trivial bounds are supplied, this
 method will be selected, with a warning.

which only demands that the initial value must satisfy the constraints.

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.


Re: [R] Bad optimization solution

2007-05-07 Thread Paul Smith
On 5/7/07, Paul Smith [EMAIL PROTECTED] wrote:
  I think the problem is the starting point.  I do not remember the details
  of the BFGS method, but I am almost sure the (.5, .5) starting point is
  suspect, since the abs function is not differentiable at 0.  If you perturb
  the starting point even slightly you will have no problem.
 
   Paul Smith
   [EMAIL PROTECTED]
 To
   Sent by:  R-help r-help@stat.math.ethz.ch
   [EMAIL PROTECTED]  cc
   at.math.ethz.ch
 Subject
 [R] Bad optimization solution
   05/07/2007 04:30
   PM
 
 
 
 
 
 
 
 
  Dear All
 
  I am trying to perform the below optimization problem, but getting
  (0.5,0.5) as optimal solution, which is wrong; the correct solution
  should be (1,0) or (0,1).
 
  Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6 (Linux).
 
  Thanks in advance,
 
  Paul
 
  --
  myfunc - function(x) {
x1 - x[1]
x2 - x[2]
abs(x1-x2)
  }
 
  optim(c(0.5,0.5),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=list(fnscale=-1))

 Yes, with (0.2,0.9), a correct solution comes out. However, how can
 one be sure in general that the solution obtained by optim is correct?
 In ?optim says:

  Method 'L-BFGS-B' is that of Byrd _et. al._ (1995) which allows
  _box constraints_, that is each variable can be given a lower
  and/or upper bound. The initial value must satisfy the
  constraints. This uses a limited-memory modification of the BFGS
  quasi-Newton method. If non-trivial bounds are supplied, this
  method will be selected, with a warning.

 which only demands that the initial value must satisfy the constraints.

Furthermore, X^2 is everywhere differentiable and notwithstanding the
reported problem occurs with

myfunc - function(x) {
  x1 - x[1]
  x2 - x[2]
  (x1-x2)^2
}

optim(c(0.2,0.2),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=list(fnscale=-1))

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.


Re: [R] Bad optimization solution

2007-05-08 Thread Paul Smith
It seems that there is here a problem of reliability, as one never
knows whether the solution provided by R is correct or not. In the
case that I reported, it is fairly simple to see that the solution
provided by R (without any warning!) is incorrect, but, in general,
that is not so simple and one may take a wrong solution as a correct
one.

Paul


On 5/8/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 Your function, (x1-x2)^2, has zero gradient at all the starting values such
 that x1 = x2, which means that the gradient-based search methods will
 terminate there because they have found a critical point, i.e. a point at
 which the gradient is zero (which can be a maximum or a minimum or a saddle
 point).

 However, I do not why optim converges to the boundary maximum, when analytic
 gradient is supplied (as shown by Sundar).

 Ravi.

 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

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



 
 


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
 Sent: Monday, May 07, 2007 6:26 PM
 To: R-help
 Subject: Re: [R] Bad optimization solution

 On 5/7/07, Paul Smith [EMAIL PROTECTED] wrote:
   I think the problem is the starting point.  I do not remember the
 details
   of the BFGS method, but I am almost sure the (.5, .5) starting point is
   suspect, since the abs function is not differentiable at 0.  If you
 perturb
   the starting point even slightly you will have no problem.
  
Paul Smith
[EMAIL PROTECTED]

 To
Sent by:  R-help r-help@stat.math.ethz.ch
[EMAIL PROTECTED]
 cc
at.math.ethz.ch
  
 Subject
  [R] Bad optimization solution
05/07/2007 04:30
PM
  
  
  
  
  
  
  
  
   Dear All
  
   I am trying to perform the below optimization problem, but getting
   (0.5,0.5) as optimal solution, which is wrong; the correct solution
   should be (1,0) or (0,1).
  
   Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6 (Linux).
  
   Thanks in advance,
  
   Paul
  
   --
   myfunc - function(x) {
 x1 - x[1]
 x2 - x[2]
 abs(x1-x2)
   }
  
  
 optim(c(0.5,0.5),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=
 list(fnscale=-1))
 
  Yes, with (0.2,0.9), a correct solution comes out. However, how can
  one be sure in general that the solution obtained by optim is correct?
  In ?optim says:
 
   Method 'L-BFGS-B' is that of Byrd _et. al._ (1995) which allows
   _box constraints_, that is each variable can be given a lower
   and/or upper bound. The initial value must satisfy the
   constraints. This uses a limited-memory modification of the BFGS
   quasi-Newton method. If non-trivial bounds are supplied, this
   method will be selected, with a warning.
 
  which only demands that the initial value must satisfy the constraints.

 Furthermore, X^2 is everywhere differentiable and notwithstanding the
 reported problem occurs with

 myfunc - function(x) {
   x1 - x[1]
   x2 - x[2]
   (x1-x2)^2
 }

 optim(c(0.2,0.2),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=
 list(fnscale=-1))

 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-help@stat.math.ethz.ch 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] Bad optimization solution

2007-05-08 Thread Paul Smith
Thanks, Ravi, for your clear explanation!

Paul


On 5/8/07, RAVI VARADHAN [EMAIL PROTECTED] wrote:
 Paul,

 The problem lies neither with R nor with numercial methods.  The onus is 
 always on the user to understand what the numerical schemes can do and what 
 they can't do.  One should never blindly take the results given by a 
 numerical scheme and run with it.  In your example, the optimization method 
 is doing what it was designed to do: to find a critical point of a function 
 where the gradient is zero.  It is your responsibility to ensure that the 
 result makes sense, and if it doesn't, to understand why it doesn't make 
 sense.  In your problem, maxima ((1,0) and (0,1)) lie on the boundary of the 
 parameter space, and the gradient at the maxima (defined as the limit from 
 within the domain) are clearly not zero.  Another problem with your example 
 is that the hessian for your function is singular, it has eigenvalues of 0 
 and 2.  In short, there is no substitute to using your analytic powers!

 Ravi.

 - Original Message -
 From: Paul Smith [EMAIL PROTECTED]
 Date: Tuesday, May 8, 2007 4:33 am
 Subject: Re: [R] Bad optimization solution
 To: R-help r-help@stat.math.ethz.ch


  It seems that there is here a problem of reliability, as one never
   knows whether the solution provided by R is correct or not. In the
   case that I reported, it is fairly simple to see that the solution
   provided by R (without any warning!) is incorrect, but, in general,
   that is not so simple and one may take a wrong solution as a correct
   one.
 
   Paul
 
 
   On 5/8/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
Your function, (x1-x2)^2, has zero gradient at all the starting
  values such
that x1 = x2, which means that the gradient-based search methods will
terminate there because they have found a critical point, i.e. a
  point at
which the gradient is zero (which can be a maximum or a minimum or
  a saddle
point).
   
However, I do not why optim converges to the boundary maximum, when
  analytic
gradient is supplied (as shown by Sundar).
   
Ravi.
   

  
---
   
Ravi Varadhan, Ph.D.
   
Assistant Professor, The Center on Aging and Health
   
Division of Geriatric Medicine and Gerontology
   
Johns Hopkins University
   
Ph: (410) 502-2619
   
Fax: (410) 614-9625
   
Email: [EMAIL PROTECTED]
   
Webpage:
   
   
   

  

   
   
-Original Message-
From: [EMAIL PROTECTED]
[ On Behalf Of Paul Smith
Sent: Monday, May 07, 2007 6:26 PM
To: R-help
Subject: Re: [R] Bad optimization solution
   
On 5/7/07, Paul Smith [EMAIL PROTECTED] wrote:
  I think the problem is the starting point.  I do not remember the
details
  of the BFGS method, but I am almost sure the (.5, .5) starting
  point is
  suspect, since the abs function is not differentiable at 0.  If
  you
perturb
  the starting point even slightly you will have no problem.
 
   Paul Smith
   [EMAIL PROTECTED]
   
To
   Sent by:  R-help 
  r-help@stat.math.ethz.ch
   [EMAIL PROTECTED]
cc
   at.math.ethz.ch
 
Subject
 [R] Bad optimization solution
   05/07/2007 04:30
   PM
 
 
 
 
 
 
 
 
  Dear All
 
  I am trying to perform the below optimization problem, but getting
  (0.5,0.5) as optimal solution, which is wrong; the correct solution
  should be (1,0) or (0,1).
 
  Am I doing something wrong? I am using R 2.5.0 on Fedora Core 6
  (Linux).
 
  Thanks in advance,
 
  Paul
 
  --
  myfunc - function(x) {
x1 - x[1]
x2 - x[2]
abs(x1-x2)
  }
 
 

  optim(c(0.5,0.5),myfunc,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=
list(fnscale=-1))

 Yes, with (0.2,0.9), a correct solution comes out. However, how can
 one be sure in general that the solution obtained by optim is correct?
 In ?optim says:

  Method 'L-BFGS-B' is that of Byrd _et. al._ (1995) which allows
  _box constraints_, that is each variable can be given a lower
  and/or upper bound. The initial value must satisfy the
  constraints. This uses a limited-memory modification of the
  BFGS
  quasi-Newton method. If non-trivial bounds are supplied, this
  method will be selected, with a warning.

 which only demands that the initial value must satisfy the 
  constraints.
   
Furthermore, X^2 is everywhere differentiable

[R] Increasing precision of rgenoud solutions

2007-05-09 Thread Paul Smith
Dear All

I am using rgenoud to solve the following maximization problem:

myfunc - function(x) {
  x1 - x[1]
  x2 - x[2]
  if (x1^2+x2^2  1)
return(-999)
  else x1+x2
}

genoud(myfunc, nvars=2,
Domains=rbind(c(0,1),c(0,1)),max=TRUE,boundary.enforcement=2,solution.tolerance=0.01)

How can one increase the precision of the solution

$par
[1] 0.7072442 0.7069694

?

I have tried solution.tolerance but without a significant improvement.

Any ideas?

Thanks in advance,

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] Nonlinear constrains with optim

2007-05-10 Thread Paul Smith
Dear All

I am dealing at the moment with optimization problems with nonlinear
constraints. Regenoud is quite apt to solve that kind of problems, but
the precision of the optimal values for the parameters is sometimes
far from what I need. Optim seems to be more precise, but it can only
accept box-constrained optimization problems. I read in the list
archives that optim can also be used with nonlinear constrains through
penalizations. However, I am not familiar with the technique of
penalizations. Could someone please indicate to me a site or a book to
learn about that penalization technique?

Thanks in advance,

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.


Re: [R] Increasing precision of rgenoud solutions

2007-05-10 Thread Paul Smith
Thanks, Jasjeet, for your reply, but maybe I was not enough clear.

The analytical solution for the optimization problem is the pair

(sqrt(2)/2,sqrt(2)/2),

which, approximately, is

(0.707106781186548,0.707106781186548).

The solution provided by rgenoud, with

solution.tolerance=0.1

was

$par
[1] 0.7090278 0.7051806

which is not very precise comparing with the values of the
(analytical) solution. Is it possible to increase the degree of
closeness of the rgenoud solutions with the analytical ones?

Paul


On 5/10/07, Jasjeet Singh Sekhon [EMAIL PROTECTED] wrote:

 Hi Paul,

 Solution.tolerance is the right way to increase precision.  In your
 example, extra precision *is* being obtained, but it is just not
 displayed because the number of digits which get printed is controlled
 by the options(digits) variable.  But the requested solution
 precision is in the object returned by genoud().

 For example, if I run

 a - genoud(myfunc, nvars=2,
  
 Domains=rbind(c(0,1),c(0,1)),max=TRUE,boundary.enforcement=2,solution.tolerance=0.01)

 I get

  a$par
 [1] 0.7062930 0.7079196

 But if I set options(digits=12), and without rerunning anything I check
 a$par again, I observe that:

  a$par
 [1] 0.706293049455 0.707919577559

 Cheers,
 Jas.

 ===
 Jasjeet S. Sekhon

 Associate Professor
 Survey Research Center
 UC Berkeley

 http://sekhon.berkeley.edu/
 V: 510-642-9974  F: 617-507-5524
 ===


 Paul Smith writes:
   Dear All
  
   I am using rgenoud to solve the following maximization problem:
  
   myfunc - function(x) {
 x1 - x[1]
 x2 - x[2]
 if (x1^2+x2^2  1)
   return(-999)
 else x1+x2
   }
  
   genoud(myfunc, nvars=2,
   
 Domains=rbind(c(0,1),c(0,1)),max=TRUE,boundary.enforcement=2,solution.tolerance=0.01)
  
   How can one increase the precision of the solution
  
   $par
   [1] 0.7072442 0.7069694
  
   ?
  
   I have tried solution.tolerance but without a significant improvement.
  
   Any ideas?
  
   Thanks in advance,
  
   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.


Re: [R] Increasing precision of rgenoud solutions

2007-05-10 Thread Paul Smith
Thanks a lot, Jasjeet. That is it.

Paul


On 5/10/07, Jasjeet Singh Sekhon [EMAIL PROTECTED] wrote:

 Hi Paul,

 I see.  You want to increase the population size (pop.size)
 option---of lesser importance are the max.generations,
 wait.generations and P9 options.  For more details, see
 http://sekhon.berkeley.edu/papers/rgenoudJSS.pdf.

 For example, if I run

 a - genoud(myfunc, nvars=2,
 
 Domains=rbind(c(0,1),c(0,1)),max=TRUE,boundary.enforcement=2,solution.tolerance=0.001,
 pop.size=6000, P9=50)

 options(digits=12)

 I obtain:

 #approx analytical solution
 sum(c(0.707106781186548,0.707106781186548))
 [1] 1.41421356237

 #genoud solution
 #a$value
 [1] 1.41421344205

 #difference
 a$value-sum(c(0.707106781186548,0.707106781186548))

 [1] -2.91195978441e-09

 If that's not enough precision, increase the options (and the
 run-time).  This would be faster with analytical derivatives.

 Cheers,
 Jas.

 ===
 Jasjeet S. Sekhon

 Associate Professor
 Travers Department of Political Science
 Survey Research Center
 UC Berkeley

 http://sekhon.berkeley.edu/
 V: 510-642-9974  F: 617-507-5524
 ===



 Paul Smith writes:
 Thanks, Jasjeet, for your reply, but maybe I was not enough clear.
 
 The analytical solution for the optimization problem is the pair
 
 (sqrt(2)/2,sqrt(2)/2),
 
 which, approximately, is
 
 (0.707106781186548,0.707106781186548).
 
 The solution provided by rgenoud, with
 
 solution.tolerance=0.1
 
 was
 
 $par
 [1] 0.7090278 0.7051806
 
 which is not very precise comparing with the values of the
 (analytical) solution. Is it possible to increase the degree of
 closeness of the rgenoud solutions with the analytical ones?
 
 Paul
 
 Paul Smith writes:
   Dear All
  
   I am using rgenoud to solve the following maximization problem:
  
   myfunc - function(x) {
 x1 - x[1]
 x2 - x[2]
 if (x1^2+x2^2  1)
   return(-999)
 else x1+x2
   }
  
   genoud(myfunc, nvars=2,
   Domains=rbind(c(0,1),c(0,1)),max=TRUE,boundary.enforcement=2,solution.tolerance=0.01)
  
   How can one increase the precision of the solution
  
   $par
   [1] 0.7072442 0.7069694
  
   ?
  
   I have tried solution.tolerance but without a significant improvement.
  
   Any ideas?
  
   Thanks in advance,
  
   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.


Re: [R] Nonlinear constrains with optim

2007-05-10 Thread Paul Smith
On 5/10/07, Spencer Graves [EMAIL PROTECTED] wrote:
  I don't know of any sources, but the idea is quite simple.
 
  For each constraint that is broken, the penalty is the amount
  by which the constraint is broken times a penalty rate.  The
  total penalty to add to the objective is the sum of penalties
  over all constraints.
 
  There is a catch or two when using this with derivative-based
  optimizers.  The objective typically becomes non-differentiable
  at the boundary, and optimizers can get confused.
 I believe I've gotten good results with penalties that are the SQUARE of
 the amount by which the constraints were violated.  These are
 continuously differentiable and so don't confuse the derivative-based
 optimizers much.

 Also, I start with a small penalty, then increase the penalty until I
 get a solution that seems sensible.  If you can't handle a solution just
 a little outside your constraints, shrink a little the place at which
 the penalty starts.

   Hope this helps.
   Spencer Graves

  They might
  be less confused with smaller penalty rates.  However if the
  penalty rate is too small, then you can get a solution that breaks
  one or more penalties.
 
  Starting from a solution given by Rgenoud or its ilk is probably
  a good idea.
 
  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)
 
  Paul Smith wrote:
 
 
  Dear All
 
  I am dealing at the moment with optimization problems with nonlinear
  constraints. Regenoud is quite apt to solve that kind of problems, but
  the precision of the optimal values for the parameters is sometimes
  far from what I need. Optim seems to be more precise, but it can only
  accept box-constrained optimization problems. I read in the list
  archives that optim can also be used with nonlinear constrains through
  penalizations. However, I am not familiar with the technique of
  penalizations. Could someone please indicate to me a site or a book to
  learn about that penalization technique?
 
  Thanks in advance,

Thanks to all. I have meanwhile had a look at Fletcher's book (as
suggested by Ravi) and I think that now I understand the idea behind
using penalties with constrained optimization problems.

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] Looking for easy way of getting the starting value for constrOptim

2007-07-02 Thread Paul Smith
Dear All,

I am using constrOptim, but facing a difficulty: how can I get the
starting value? Is there some automatic way of getting it? Since I
have many inequalities as constraints (all linear), it is quite
difficult to find a feasible value. I have tried to use rgenoud
solution as a feasible value, but rgenoud seems not being converging.

Any ideas?

Thanks in advance,

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] Fine tunning rgenoud

2007-07-03 Thread Paul Smith
Dear All,

I am trying to solve the following maximization problem, but I cannot
have rgenoud giving me a reliable solution.

Any ideas?

Thanks in advance,

Paul


library(rgenoud)

v - 0.90
O1 - 10
O2 - 20
O0 - v*O1+(1-v)*O2

myfunc - function(x) {
  U0 - x[1]
  U1 - x[2]
  U2 - x[3]
  q0 - x[4]
  q1 - x[5]
  q2 - x[6]
  p - x[7]

  if (U0  0)
return(-1e+200)
  else if (U1  0)
return(-1e+200)
  else if (U2  0)
return(-1e+200)
  else if ((U0-(U1+(O1-O0)*q1))  0)
return(-1e+200)
  else if ((U0-(U2+(O2-O0)*q2))  0)
return(-1e+200)
  else if ((U1-(U0+(O0-O1)*q0))  0)
return(-1e+200)
  else if ((U1-(U2+(O2-O1)*q2))  0)
return(-1e+200)
  else if((U2-(U0+(O0-O2)*q0))  0)
return(-1e+200)
  else if((U2-(U1+(O1-O2)*q1))  0)
return(-1e+200)
  else if(p  0)
return(-1e+200)
  else if(p  1)
return(-1e+200)
  else if(q0  0)
return(-1e+200)
  else if(q1  0)
return(-1e+200)
  else if(q2  0)
return(-1e+200)
  else 
return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2)-(O2*q2+U2

}
genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.generations=150,max.generations=300,boundary.enforcement=2)

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

2007-07-03 Thread Paul Smith
On 7/3/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 You had indicated in your previous email that you are having trouble finding
 a feasible starting value for constrOptim().  So, you basically need to
 solve a system of linear inequalities to obtain a starting point.  Have you
 considered using linear programming? Either simplex() in the boot package
 or solveLP() in linprog would work.  It seems to me that you could use any
 linear objective function in solveLP to obtain a feasible starting point.
 This is not the most efficient solution, but it might be worth a try.

 I am aware of other methods for generating n-tuples that satisfy linear
 inequality constraints, but AFAIK those are not available in R.

Thanks, Ravi. I had already conceived the solution that you suggest,
actually using lpSolve. I am able to get a solution for my problem
with constrOptim, but I am not enough confident that the solution is
right. That is why I am trying to get a solution with rgenoud, but
unsuccessfully until now.

Paul



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
 Sent: Tuesday, July 03, 2007 4:10 PM
 To: R-help
 Subject: [R] Fine tunning rgenoud

 Dear All,

 I am trying to solve the following maximization problem, but I cannot
 have rgenoud giving me a reliable solution.

 Any ideas?

 Thanks in advance,

 Paul

 
 library(rgenoud)

 v - 0.90
 O1 - 10
 O2 - 20
 O0 - v*O1+(1-v)*O2

 myfunc - function(x) {
   U0 - x[1]
   U1 - x[2]
   U2 - x[3]
   q0 - x[4]
   q1 - x[5]
   q2 - x[6]
   p - x[7]

   if (U0  0)
 return(-1e+200)
   else if (U1  0)
 return(-1e+200)
   else if (U2  0)
 return(-1e+200)
   else if ((U0-(U1+(O1-O0)*q1))  0)
 return(-1e+200)
   else if ((U0-(U2+(O2-O0)*q2))  0)
 return(-1e+200)
   else if ((U1-(U0+(O0-O1)*q0))  0)
 return(-1e+200)
   else if ((U1-(U2+(O2-O1)*q2))  0)
 return(-1e+200)
   else if((U2-(U0+(O0-O2)*q0))  0)
 return(-1e+200)
   else if((U2-(U1+(O1-O2)*q1))  0)
 return(-1e+200)
   else if(p  0)
 return(-1e+200)
   else if(p  1)
 return(-1e+200)
   else if(q0  0)
 return(-1e+200)
   else if(q1  0)
 return(-1e+200)
   else if(q2  0)
 return(-1e+200)
   else
 return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2
 )-(O2*q2+U2

 }
 genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene
 rations=150,max.generations=300,boundary.enforcement=2)

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

2007-07-03 Thread Paul Smith
On 7/4/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 It should be easy enough to check that your solution is valid (i.e. a local
 minimum):  first, check to see if the solution satisfies all the
 constraints; secondly, check to see if it is an interior point (i.e. none of
 the constraints become equality); and finally, if the solution is an
 interior point, check to see whether the gradient there is close to zero.
 Note that if the solution is one of the vertices of the polyhedron, then the
 gradient may not be zero.

That is a very good idea, Ravi! Thanks!

Paul



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
 Sent: Tuesday, July 03, 2007 5:10 PM
 To: R-help
 Subject: Re: [R] Fine tunning rgenoud

 On 7/3/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
  You had indicated in your previous email that you are having trouble
 finding
  a feasible starting value for constrOptim().  So, you basically need to
  solve a system of linear inequalities to obtain a starting point.  Have
 you
  considered using linear programming? Either simplex() in the boot
 package
  or solveLP() in linprog would work.  It seems to me that you could use
 any
  linear objective function in solveLP to obtain a feasible starting point.
  This is not the most efficient solution, but it might be worth a try.
 
  I am aware of other methods for generating n-tuples that satisfy linear
  inequality constraints, but AFAIK those are not available in R.

 Thanks, Ravi. I had already conceived the solution that you suggest,
 actually using lpSolve. I am able to get a solution for my problem
 with constrOptim, but I am not enough confident that the solution is
 right. That is why I am trying to get a solution with rgenoud, but
 unsuccessfully until now.

 Paul



  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
  Sent: Tuesday, July 03, 2007 4:10 PM
  To: R-help
  Subject: [R] Fine tunning rgenoud
 
  Dear All,
 
  I am trying to solve the following maximization problem, but I cannot
  have rgenoud giving me a reliable solution.
 
  Any ideas?
 
  Thanks in advance,
 
  Paul
 
  
  library(rgenoud)
 
  v - 0.90
  O1 - 10
  O2 - 20
  O0 - v*O1+(1-v)*O2
 
  myfunc - function(x) {
U0 - x[1]
U1 - x[2]
U2 - x[3]
q0 - x[4]
q1 - x[5]
q2 - x[6]
p - x[7]
 
if (U0  0)
  return(-1e+200)
else if (U1  0)
  return(-1e+200)
else if (U2  0)
  return(-1e+200)
else if ((U0-(U1+(O1-O0)*q1))  0)
  return(-1e+200)
else if ((U0-(U2+(O2-O0)*q2))  0)
  return(-1e+200)
else if ((U1-(U0+(O0-O1)*q0))  0)
  return(-1e+200)
else if ((U1-(U2+(O2-O1)*q2))  0)
  return(-1e+200)
else if((U2-(U0+(O0-O2)*q0))  0)
  return(-1e+200)
else if((U2-(U1+(O1-O2)*q1))  0)
  return(-1e+200)
else if(p  0)
  return(-1e+200)
else if(p  1)
  return(-1e+200)
else if(q0  0)
  return(-1e+200)
else if(q1  0)
  return(-1e+200)
else if(q2  0)
  return(-1e+200)
else
 
 return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2
  )-(O2*q2+U2
 
  }
 
 genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene
  rations=150,max.generations=300,boundary.enforcement=2)
 
  __
  R-help@stat.math.ethz.ch 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] Fine tunning rgenoud

2007-07-03 Thread Paul Smith
On 7/4/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 It should be easy enough to check that your solution is valid (i.e. a local
 minimum):  first, check to see if the solution satisfies all the
 constraints; secondly, check to see if it is an interior point (i.e. none of
 the constraints become equality); and finally, if the solution is an
 interior point, check to see whether the gradient there is close to zero.
 Note that if the solution is one of the vertices of the polyhedron, then the
 gradient may not be zero.

I am having bad luck: all constraints are satisfied, but the solution
given by constrOptim is not interior; the gradient is not equal to
zero.

Paul


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
 Sent: Tuesday, July 03, 2007 5:10 PM
 To: R-help
 Subject: Re: [R] Fine tunning rgenoud

 On 7/3/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
  You had indicated in your previous email that you are having trouble
 finding
  a feasible starting value for constrOptim().  So, you basically need to
  solve a system of linear inequalities to obtain a starting point.  Have
 you
  considered using linear programming? Either simplex() in the boot
 package
  or solveLP() in linprog would work.  It seems to me that you could use
 any
  linear objective function in solveLP to obtain a feasible starting point.
  This is not the most efficient solution, but it might be worth a try.
 
  I am aware of other methods for generating n-tuples that satisfy linear
  inequality constraints, but AFAIK those are not available in R.

 Thanks, Ravi. I had already conceived the solution that you suggest,
 actually using lpSolve. I am able to get a solution for my problem
 with constrOptim, but I am not enough confident that the solution is
 right. That is why I am trying to get a solution with rgenoud, but
 unsuccessfully until now.

 Paul



  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith
  Sent: Tuesday, July 03, 2007 4:10 PM
  To: R-help
  Subject: [R] Fine tunning rgenoud
 
  Dear All,
 
  I am trying to solve the following maximization problem, but I cannot
  have rgenoud giving me a reliable solution.
 
  Any ideas?
 
  Thanks in advance,
 
  Paul
 
  
  library(rgenoud)
 
  v - 0.90
  O1 - 10
  O2 - 20
  O0 - v*O1+(1-v)*O2
 
  myfunc - function(x) {
U0 - x[1]
U1 - x[2]
U2 - x[3]
q0 - x[4]
q1 - x[5]
q2 - x[6]
p - x[7]
 
if (U0  0)
  return(-1e+200)
else if (U1  0)
  return(-1e+200)
else if (U2  0)
  return(-1e+200)
else if ((U0-(U1+(O1-O0)*q1))  0)
  return(-1e+200)
else if ((U0-(U2+(O2-O0)*q2))  0)
  return(-1e+200)
else if ((U1-(U0+(O0-O1)*q0))  0)
  return(-1e+200)
else if ((U1-(U2+(O2-O1)*q2))  0)
  return(-1e+200)
else if((U2-(U0+(O0-O2)*q0))  0)
  return(-1e+200)
else if((U2-(U1+(O1-O2)*q1))  0)
  return(-1e+200)
else if(p  0)
  return(-1e+200)
else if(p  1)
  return(-1e+200)
else if(q0  0)
  return(-1e+200)
else if(q1  0)
  return(-1e+200)
else if(q2  0)
  return(-1e+200)
else
 
 return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2
  )-(O2*q2+U2
 
  }
 
 genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene
  rations=150,max.generations=300,boundary.enforcement=2)
 
  __
  R-help@stat.math.ethz.ch 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] Fine tunning rgenoud

2007-07-04 Thread Paul Smith
On 7/4/07, RAVI VARADHAN [EMAIL PROTECTED] wrote:
 Here is another approach: I wrote an R function that would generate interior 
 points as starting values for constrOptim.  This might work better than the 
 LP approach, since the LP approach gives you a starting value that is on the 
 boundary of the feasible region, i.e a vertex of the polyhedron, whereas this 
 new approach gives you points on the interior.  You can generate as many 
 points as you wish, but the approach is brute-force and is very inefficient - 
 it takes on the order of a 1000 tries to find one feasible point.

Thanks again, Ravi. Actually, the LP approach also works here. Let
g(X) = k be the constraints. Then, by solving a LP problem with the
constraints

g(X) = (k+0.2)

returns an interior starting value for constrOptim. I am aware that
the new set of constraints may correspond to an impossible linear
system, but it works in many cases.

Paul

 - Original Message -
 From: Paul Smith [EMAIL PROTECTED]
 Date: Tuesday, July 3, 2007 7:32 pm
 Subject: Re: [R] Fine tunning rgenoud
 To: R-help r-help@stat.math.ethz.ch


  On 7/4/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
It should be easy enough to check that your solution is valid (i.e.
  a local
minimum):  first, check to see if the solution satisfies all the
constraints; secondly, check to see if it is an interior point
  (i.e. none of
the constraints become equality); and finally, if the solution is an
interior point, check to see whether the gradient there is close to
  zero.
Note that if the solution is one of the vertices of the polyhedron,
  then the
gradient may not be zero.
 
   I am having bad luck: all constraints are satisfied, but the solution
   given by constrOptim is not interior; the gradient is not equal to
   zero.
 
   Paul
 
 
-Original Message-
From: [EMAIL PROTECTED]
[ On Behalf Of Paul Smith
Sent: Tuesday, July 03, 2007 5:10 PM
To: R-help
Subject: Re: [R] Fine tunning rgenoud
   
On 7/3/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
 You had indicated in your previous email that you are having trouble
finding
 a feasible starting value for constrOptim().  So, you basically
  need to
 solve a system of linear inequalities to obtain a starting point.
   Have
you
 considered using linear programming? Either simplex() in the boot
package
 or solveLP() in linprog would work.  It seems to me that you
  could use
any
 linear objective function in solveLP to obtain a feasible
  starting point.
 This is not the most efficient solution, but it might be worth a
  try.

 I am aware of other methods for generating n-tuples that satisfy
  linear
 inequality constraints, but AFAIK those are not available in R.
   
Thanks, Ravi. I had already conceived the solution that you suggest,
actually using lpSolve. I am able to get a solution for my problem
with constrOptim, but I am not enough confident that the solution is
right. That is why I am trying to get a solution with rgenoud, but
unsuccessfully until now.
   
Paul
   
   
   
 -Original Message-
 From: [EMAIL PROTECTED]
 [ On Behalf Of Paul Smith
 Sent: Tuesday, July 03, 2007 4:10 PM
 To: R-help
 Subject: [R] Fine tunning rgenoud

 Dear All,

 I am trying to solve the following maximization problem, but I cannot
 have rgenoud giving me a reliable solution.

 Any ideas?

 Thanks in advance,

 Paul

 
 library(rgenoud)

 v - 0.90
 O1 - 10
 O2 - 20
 O0 - v*O1+(1-v)*O2

 myfunc - function(x) {
   U0 - x[1]
   U1 - x[2]
   U2 - x[3]
   q0 - x[4]
   q1 - x[5]
   q2 - x[6]
   p - x[7]

   if (U0  0)
 return(-1e+200)
   else if (U1  0)
 return(-1e+200)
   else if (U2  0)
 return(-1e+200)
   else if ((U0-(U1+(O1-O0)*q1))  0)
 return(-1e+200)
   else if ((U0-(U2+(O2-O0)*q2))  0)
 return(-1e+200)
   else if ((U1-(U0+(O0-O1)*q0))  0)
 return(-1e+200)
   else if ((U1-(U2+(O2-O1)*q2))  0)
 return(-1e+200)
   else if((U2-(U0+(O0-O2)*q0))  0)
 return(-1e+200)
   else if((U2-(U1+(O1-O2)*q1))  0)
 return(-1e+200)
   else if(p  0)
 return(-1e+200)
   else if(p  1)
 return(-1e+200)
   else if(q0  0)
 return(-1e+200)
   else if(q1  0)
 return(-1e+200)
   else if(q2  0)
 return(-1e+200)
   else


  return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2
 )-(O2*q2+U2

 }


  genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene
 rations=150,max.generations=300,boundary.enforcement=2)

 __
 R-help@stat.math.ethz.ch mailing list

Re: [R] Fine tunning rgenoud

2007-07-04 Thread Paul Smith
0.673413934917665   5.55691871872657e-08
0.00206648968616976 0.690994737517309   8.53762213679993e-11
0.999553
2.78964308878308e-080.631906605077265   1.87081150212841e-08
0.00206682302780812 1.049128534593221.19798263785958e-10
0.9998404
0.0001860096553303420.0002069389731129881.18525336022574e-09
2.09286186935030e-050.00249989443096258 2.06676012144089e-05
2.57319855839169e-06
5.79914576203232e-050.00181271191072469 1.15884908131972e-09
0.00175471081855071 0.0024812702174432  6.44334507197721e-06
0.509698530097913
2.0503183260964e-08 0.546450460261978   1.27059638843222e-08
0.00206791702172114 1.140821996494028.5751965370755e-12 
0.999683
3.66836690280629e-080.481874078118496   3.13611734401948e-08
0.00207354422550728 0.990376379663234   2.13707863395726e-10
0.9975761
1.77224405556878e-080.493128575789259   8.63845133717168e-09
0.00207307974398005 0.493553411995952   3.19150428367562e-11
0.902
0.0001192348530163210.00194143059603129 2.65621637099599e-10
0.00182214114564480 0.00258385562559042 1.32482776896270e-05
0.564809333872708
1.91321783130778e-070.00205131977291163 2.45737561775750e-10
0.00205112100576657 0.00251498989989795 2.12303674145017e-08
0.981038377325434
2.04970869809e-09   0.615409680242671.80692316850342e-10
0.00206758160218205 0.616881623876956   9.88879753424694e-11
0.9998682
2.28380664111838e-070.495196927735637   2.03520983522517e-07
0.00206484911183903 0.495729865740038   3.10063601627842e-10
0.9998029
0.0001426632073528140.00136226156979156 2.47224893929883e-11
0.00121959537442013 0.00249964872330666 1.58514632925203e-05
0.213308634647407



 - Original Message -
 From: Paul Smith [EMAIL PROTECTED]
 Date: Wednesday, July 4, 2007 6:00 am
 Subject: Re: [R] Fine tunning rgenoud
 To: R-help r-help@stat.math.ethz.ch


  On 7/4/07, RAVI VARADHAN [EMAIL PROTECTED] wrote:
Here is another approach: I wrote an R function that would generate
  interior points as starting values for constrOptim.  This might work
  better than the LP approach, since the LP approach gives you a
  starting value that is on the boundary of the feasible region, i.e a
  vertex of the polyhedron, whereas this new approach gives you points
  on the interior.  You can generate as many points as you wish, but the
  approach is brute-force and is very inefficient - it takes on the
  order of a 1000 tries to find one feasible point.
 
   Thanks again, Ravi. Actually, the LP approach also works here. Let
   g(X) = k be the constraints. Then, by solving a LP problem with the
   constraints
 
   g(X) = (k+0.2)
 
   returns an interior starting value for constrOptim. I am aware that
   the new set of constraints may correspond to an impossible linear
   system, but it works in many cases.
 
   Paul
 
- Original Message -
From: Paul Smith [EMAIL PROTECTED]
Date: Tuesday, July 3, 2007 7:32 pm
Subject: Re: [R] Fine tunning rgenoud
To: R-help r-help@stat.math.ethz.ch
   
   
 On 7/4/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
   It should be easy enough to check that your solution is valid
  (i.e.
 a local
   minimum):  first, check to see if the solution satisfies all the
   constraints; secondly, check to see if it is an interior point
 (i.e. none of
   the constraints become equality); and finally, if the solution
  is an
   interior point, check to see whether the gradient there is
  close to
 zero.
   Note that if the solution is one of the vertices of the polyhedron,
 then the
   gradient may not be zero.

  I am having bad luck: all constraints are satisfied, but the solution
  given by constrOptim is not interior; the gradient is not equal
  to
  zero.

  Paul


   -Original Message-
   From: [EMAIL PROTECTED]
   [ On Behalf Of Paul Smith
   Sent: Tuesday, July 03, 2007 5:10 PM
   To: R-help
   Subject: Re: [R] Fine tunning rgenoud
  
   On 7/3/07, Ravi Varadhan [EMAIL PROTECTED] wrote:
You had indicated in your previous email that you are having
  trouble
   finding
a feasible starting value for constrOptim().  So, you basically
 need to
solve a system of linear inequalities to obtain a starting point.
  Have
   you
considered using linear programming? Either simplex() in the
  boot
   package
or solveLP() in linprog would work.  It seems to me that you
 could use
   any
linear objective function in solveLP to obtain a feasible
 starting point.
This is not the most efficient solution, but it might be
  worth a
 try

Re: [R] Fine tunning rgenoud

2007-07-04 Thread Paul Smith
On 7/4/07, Paul Smith [EMAIL PROTECTED] wrote:
 On 7/4/07, RAVI VARADHAN [EMAIL PROTECTED] wrote:
  My point is that it might be better to try multiple (feasible) starting 
  values for constrOptim to ensure that you have a good local minimum, since 
  it appears that constrOptim converges to a boundary solution where the 
  gradient is non-zero.  That is why my code could be useful.

 Thanks, Ravi. I have used your function, which works pretty fine.
 However, constrOptim returns solutions markedly different, depending
 on the starting values. That is true that I am expecting a solution in
 the boundary, but should not constrOptim find boundary solutions
 correctly? The set of solution that I got is below.

Unless, there are many local optimal solutions...

Paul


 

 2.67682495728743e-080.676401684216637   5.18627076390355e-09
 0.00206463986063195 0.871859686128364.32039325909089e-11
 0.9996234
 3.71711020733097e-080.539853580957444   1.82592937615235e-08
 0.00206941041763503 0.933052503934472.08076621230984e-11
 0.9995774
 1.55648443014316e-080.356047772992972   8.61341165816411e-09
 0.00207149128044574 0.939531540703735   2.55211186629222e-12
 0.424
 2.20685747493755e-070.575689534431218   5.30976753476747e-08
 0.00210500604605837 0.588947341576757   3.1310360048386e-10 
 0.9998789
 1.92961662926727e-080.773588030510204   1.04841835042200e-08
 0.00206723852358352 0.816755014708394   3.89478290348532e-11
 0.9997794
 0.0002798240512890820.0003109923855228861.01467522935252e-06
 3.11645639181419e-050.00249801538651552 3.0978819115532e-05 
 7.11821104872585e-06
 2.81901448690893e-070.381718731525906   4.72860507882539e-08
 0.00206807672109157 0.769178513763055   1.39278079797628e-09
 0.9967123
 5.58938545019597e-050.00171253668169328 4.54005998518212e-09
 0.00165663757292733 0.00247994862102590 6.20992250482468e-06
 0.419169641865998
 1.03300938985890e-080.438357835603591   6.89854079723234e-09
 0.00206693286138396 0.977554885433201   1.17209206267609e-10
 0.996921
 7.63336821363444e-050.00177141538041517 1.88050423143828e-10
 0.00169507950991094 0.00249739505142207 8.4814984916537e-06 
 0.470929220605509
 9.16005846107533e-090.682179815036755   1.63255733785783e-09
 0.00206922107327189 0.919323193130209   5.71436138398897e-11
 0.999629
 1.40968913167328e-080.343606628343661   1.33227447885302e-08
 0.00206789984370423 0.343671264496824   1.11679312116211e-11
 0.822
 4.76054734844857e-090.593022549313178   2.28102966623129e-09
 0.00206625165098398 0.947562121256448   8.9437610753173e-11 
 0.992
 1.96950784184139e-070.579488113726155   1.61915231214025e-07
 0.00208000350528798 1.008913405950401.22248906754713e-10
 0.9996493
 8.1448937742933e-09 0.441088618716555   4.54846390087941e-09
 0.00207634940425852 0.446155700100820   4.81439647816238e-12
 0.39
 4.82439218405912e-080.557771049256698   3.53737879481732e-08
 0.0020663035737319  0.588137767965923   2.6568947800491e-11 
 0.9988615
 2.43086751126363e-080.522927598354163   2.26886829089137e-08
 0.00206533531066324 0.611696593543814   4.51226610050184e-11
 0.087
 3.05498959434100e-080.465522202845817   1.09246302124670e-08
 0.00207004066920179 0.465583376966915   3.24213847202457e-11
 0.9997366
 1.88687179088788e-070.783614197203923   4.51346471059839e-08
 0.00222403775221293 0.786422171740329   8.17865794171933e-10
 0.9986103
 1.0154423824979e-08 0.30265579883   9.06923080122203e-09
 0.00206615353968094 0.359722316646974   8.27866320956902e-12
 0.998461
 8.91008717665837e-080.0020661526864997  3.08619455858999e-09
 0.00206579199039568 0.00275523149199496 9.55650084108725e-09
 0.985185595958656
 1.25320647920029e-070.635217955401437   7.44627883600107e-08
 0.00206656250455391 0.855937507707323   3.70326032870889e-10
 0.9998375
 2.57618374406559e-080.636499151952225   1.09822023878715e-08
 0.00206677354204888 0.772636071860102   8.99370944431481e-11
 0.9978744
 1.09474196877990e-080.501469973722704   1.19992915868609e-10
 0.00206117941606503 0.501594064757161   1.34320044786225e-11
 0.9991232
 5.24203710193977e-050.0001279983401441093.33258623630601e-09
 7.55779680724378e-050.00248898574263025 5.82411313482383e-06
 0.0221497278110802

Re: [R] Optimization

2007-07-17 Thread Paul Smith
On 7/16/07, massimiliano.talarico [EMAIL PROTECTED] wrote:
 I need a suggest to obtain the max of this function:

 Max x1*0.021986+x2*0.000964+x3*0.02913

 with these conditions:

 x1+x2+x3=1;
 radq((x1*0.114434)^2+(x2*0.043966)^2+(x3*0.100031)^2)=0.04;
 x1=0;
 x1=1;
 x2=0;
 x2=1;
 x3=0;
 x3=1;

 Any suggests ?

What do you mean by 'radq', Massimiliano?

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.


Re: [R] constraint in constrOptim

2007-08-02 Thread Paul Smith
On 8/2/07, André Rossi [EMAIL PROTECTED] wrote:
 I'm using the function constrOptim together with the SANN method and
 my objective function (f) has two parameters. One of the parameters
 needs be into (2^(-10), 2^4) range and the other into (2^(-2), 2^12)
 range. How can I do it using constrOptim??

I think that you, André, do not need constrOptim; optim is enough. See

?optim

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.


Re: [R] constraint in constrOptim

2007-08-02 Thread Paul Smith
On 8/2/07, Paul Smith [EMAIL PROTECTED] wrote:
  I'm using the function constrOptim together with the SANN method and
  my objective function (f) has two parameters. One of the parameters
  needs be into (2^(-10), 2^4) range and the other into (2^(-2), 2^12)
  range. How can I do it using constrOptim??

 I think that you, André, do not need constrOptim; optim is enough. See

 ?optim

The following example shows how to use optim to calculate the maximum of

f(x,y) := (x-y)^2

s.t. 0 = x,y = 1.

Paul

---

myfunc - function(x) {
  x1 - x[1]
  x2 - x[2]
  (x1-x2)^2
}

mygrad - function(x) {
  x1 - x[1]
  x2 - x[2]
  c(2, -2) * c(x1, x2)
}

optim(c(0.5,0.5),myfunc,mygrad,lower=c(0,0),upper=c(1,1),method=L-BFGS-B,control=list(fnscale=-1))

__
R-help@stat.math.ethz.ch 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] Optimal control package?

2007-08-04 Thread Paul Smith
Dear All,

Is there some package to do optimal control?

Thanks in advance,

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.


Re: [R] Differentiation

2007-08-20 Thread Paul Smith
On 8/20/07, nalluri pratap [EMAIL PROTECTED] wrote:
 try

   library(numDeriv)
 ?genD

   Pratap

 Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
   Hi,



 Could anyone tell me what is the command used in R to do

 1. Differentiation
 2. Newton Raphson method (Numerical Analysis in general...)



 Are there any packages separately for this?

In addition, you can use Ryacas:

«Ryacas (google code name ryacas) is an R package that allows R users
to access the yacas computer algebra system from within R. It can be
used for computer algebra, exact arithmetic, ASCII pretty printing and
R to TeX output.»

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.


Re: [R] Evaluating f(x(2,3)) on a function f- function(a,b){a+b}

2007-08-22 Thread Paul Smith
On 8/22/07, Søren Højsgaard [EMAIL PROTECTED] wrote:
 I have a function and a vector, say
 f - function(a,b){a+b}
 x - c(2,3)
 I want to evaluate f on x in the sense of computing f(x[1],x[2]). I would 
 like it to be so that I can write f(x). (I know I can write a wrapper 
 function g - function(x){f(x[1],x[2])}, but this is not really what I am 
 looking for). Is there a general way doing this (programmatically)? (E.g. by 
 unpacking the elements of x and putting them in the right places when 
 calling f...)
 I've looked under formals, alist etc. but so far without luck.

I hope that the following helps:

 f - function(x) {sum(x)}
 f(c(2,3))
[1] 5
 f(c(2,3,5))
[1] 10


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.


Re: [R] Calculating diameters of cirkels in a picture.

2007-08-23 Thread Paul Smith
On 8/23/07, Bart Joosen [EMAIL PROTECTED] wrote:
 Maybe this is more a programming questions than a specific R-project 
 question, but maybe there is someone who can point me in the right direction.

 I have a picture of cirkels which I took with a digital camera.
 Now I want to use the diameter of the cirkels on the picture for analysis in 
 R.
 I can use pixmap to import the picture, but how do I find the outside cirkels 
 and calculate the diameter?
 I pointed out that I can use the edci package, but then I need to preprocess 
 the data to reduce the points, otherwise it takes a long time, and my 
 computer crashes.

 If you want to see such a picture, I cropped a larger one, and highlighted 
 the cirkel which is of interest.
 In a real world, this is a plate with 36 cirkels, which all should be 
 measured.
 www.users.skynet.be/fa244930/fotos/outlined.jpg

You mean the diameter measured in number of pixels?

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.


Re: [R] Q: how to interrupt long calculation?

2007-08-29 Thread Paul Smith
On 8/29/07, D. R. Evans [EMAIL PROTECTED] wrote:
  The subject says it all really: I've tried hitting control-C (multiple
  times), but that doesn't seem to be a reliable way to interrupt a long
  calculation. What is the right way to interrupt a calculation that has
  been proceeding for several minutes and shows no sign of finishing
  soon?
 

 I forgot to mention that this is on an amd64 system running dapper (in
 case that makes any difference).

Assuming that you are using Linux, try the command

killall R

The instance of R running will be immediately killed and then you can
start R again.

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] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
Dear All,

I am trying to write my first R script. The code is simply

cat(Hello!\n)

However, when I run

$ R CMD BATCH myscript.R

I do not see Hello! on the console. I am using Fedora 7 (Linux) and R-2.5.1.

Any ideas?

Thanks in advance,

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.


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
On 8/30/07, Barry Rowlingson [EMAIL PROTECTED] wrote:
  I am trying to write my first R script. The code is simply
 
  cat(Hello!\n)
 
  However, when I run
 
  $ R CMD BATCH myscript.R
 
  I do not see Hello! on the console. I am using Fedora 7 (Linux) and 
  R-2.5.1.
 
  Any ideas?
 

   You shouldn't see it on the console! BATCH writes its output to a file.

   You should find a file called myscript.Rout that does contain the
 'Hello!'.

Thanks, Barry. Indeed, the file myscript.Rout exists and contains the
output of cat. I was expecting a behavior similar to the bash scripts.
And by the way, cannot a R script write only on the console and just
what one tells it to write, likewise bash scripts?

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.


Re: [R] R CMD BATCH: cat does not print

2007-08-30 Thread Paul Smith
On 8/30/07, Vladimir Eremeev [EMAIL PROTECTED] wrote:

 Use rscript

 Rscript myscript.R
 or
 Rscript -e 'cat(Hello!\n)'

 will show Hello! on the console.

 R CMD BATCH writes its output to the file myscript.Rout

Thanks, Vladimir. Rscript is exactly what I was looking for!

Paul



 Paul Smith wrote:
 
  Dear All,
 
  I am trying to write my first R script. The code is simply
 
  cat(Hello!\n)
 
  However, when I run
 
  $ R CMD BATCH myscript.R
 
  I do not see Hello! on the console. I am using Fedora 7 (Linux) and
  R-2.5.1.
 
  Any ideas?
 
  Thanks in advance,
 
  Paul
 




 --
 View this message in context: 
 http://www.nabble.com/R-CMD-BATCH%3A-cat-does-not-print-tf4353572.html#a12405494
 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.


  1   2   >