[R] Weird problem with median on a factor

2003-10-31 Thread Christoph Bier
Hi all,

I hope this isn't a naive newbie question again. Here you can see column 264 of
a data frame containing data of the same interview in May and September. Column
264 contains the answers of 49 persons to a question in May.
fbhint.spss1[,264]
 [1] teils/teils  sehr wichtig NA NA sehr wichtig
 [6] sehr wichtig sehr wichtig sehr wichtig NA NA
[11] NA NA wichtig  NA NA
[16] sehr wichtig NA NA NA NA
[21] NA NA NA wichtig  NA
[26] NA NA NA NA NA
[31] NA NA NA NA teils/teils
[36] sehr wichtig NA NA NA NA
[41] wichtig  NA sehr wichtig NA NA
[46] sehr wichtig wichtig  NA NA
Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
Column 566 contains the answers from the same persons to the same question in
September.
fbhint.spss1[,566]
 [1] NA NA NA wichtig  wichtig
 [6] sehr wichtig sehr wichtig wichtig  wichtig  NA
[11] NA NA sehr wichtig sehr wichtig sehr wichtig
[16] sehr wichtig NA unwichtigwichtig  wichtig
[21] NA NA teils/teils  teils/teils  NA
[26] unwichtigNA NA NA NA
[31] wichtig  sehr wichtig sehr wichtig NA unwichtig
[36] sehr wichtig NA NA teils/teils  wichtig
[41] wichtig  wichtig  NA NA wichtig
[46] NA sehr wichtig teils/teils  NA
Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
The following works:

median(fbhint.spss1[,264], na.rm=T)
[1] sehr wichtig
Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
... but here it doesn't:

median(fbhint.spss1[,566], na.rm=T)
Error in Summary.factor(..., na.rm = na.rm) :
sum not meaningful for factors
I don't have any ideas why! Can somebody give me a hint?

TIA

Best regards,

Christoph

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] inverse function for positive definite matrix

2003-10-31 Thread Yulei He
Hi, there.

Can anyone tell me inverse function for positive definite matrix in R? In
GAUSS, this function is called invpd and is known to be faster than the
normal inverse function.

Thanks!


Yulei

$$$
Yulei He
1586 Murfin Ave. Apt 37
Ann Arbor, MI 48105-3135
[EMAIL PROTECTED]
734-647-0305(H)
734-763-0421(O)
734-763-0427(O)
734-764-8263(fax)
$$

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] RMySQL and '_' character in column names

2003-10-31 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 ?make.names may help.

Or backtick quoting in 1.8.0 (which this is clearly not since _ now
gives a syntax error).
 
 On Thu, 30 Oct 2003, Xavier Fernández i Marín wrote:
 
  Hi,
  
  I'm using RMySQL in order to obtain data from my MySQL server. In my databases 
  sometimes I have columns with names that contain '_' character (ex: 
  'gdp_capita', 'population_total', etc...). When these names appear as the 
  names of the vectors in the data frame that I get, sometimes I have problems 
  as:
  
   cor(gdp_capita, population_total)
  Error: object _capita not found
  use of _ is soon to be removed.
  
  Is there an automatic way to transform the '_' characters in MySQL to '.' in R 
  using RMysql?
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] long algo

2003-10-31 Thread Richard A. O'Keefe
Alessandro Semeria [EMAIL PROTECTED] wrote:
Is well know that R is inefficent  on loops.

This is a dangerous half-truth.  R is an interpreted language.
The interpreter uses techniques similar to those used in Scheme
interpreters.  As interpreters go, it's pretty good.  For comparison,
in processing XML documents, I've had interpreted Scheme running rings
around compiled Java (by doing the task a different way, of course).
Also for comparison, years ago I had a Prolog program for median
polish that made a published Fortran program for median polish look
sick (by using a much better data structure).  With Luke Tierney's
byte-code compiler, I expect R loops will become close to as efficient
as Python ones, and people run entire web sites with Python.

It is more accurate to say that R code qua R code is not as efficient
as the large body of primitives that operate on entire arrays.

When you have to perform heavy loop
is better to use a call to fortran or c code (.Fortran() , .C() functions)

Even if the premiss were literally and exactly true, the conclusion
would not follow.  When you have a speed problem with R code,

(1) Find out where the problem is, exactly.  People's intuition about
performance bottlenecks is notoriously bad.  Do what the experts do:
*measure*.
(2) Try to restructure the code *entirely in R* to be as clear and high
level as possible.  If there have to be subscripts, at least let them
be vector subscripts.
(3) Measure again.  Chances are that making the code clear and high level
has fixed the performance problem.
(4) If that fails, try restructuring the code a couple of ways,
*entirely in R*.  The two basic techniques for optimising a calculation
are (a) eliminate it entirely and (b) if you can't eliminate the first
evaluation of an expression, eliminate the second by saving the result.
As a special case of (b), try moving things out of loops; try splitting
a calculation into a part that changes a lot and a part that changes
very little, and update the small-change part only when you have to.
Perhaps apply the idea of program differentiation.  (NOT the idea of
taking a function that computes a value and automatically computing
a function that computes the derivative of the first, but the idea of
saying if I have z-f(x,y) and I make a small change to x, do I have
to recompute z completely or can I came a small change to z?)
Try to use built in operations as much as possible on data structures
that are as large as appropriate.
(5) Measure again.  This will probably have fixed the performance problem.
(6) If all else fails, now it's time to try Fortran or C.  It's too bad
there isn't an existing Fortran or C module you can just call, if there
had been you'd have used that before writing the original R code.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] cross-classified random factors in lme without blocking

2003-10-31 Thread Gordon Smyth
On page 165 of Mixed-Effects Models in S and S-Plus by Pinheiro and Bates 
there is an example of using lme() in the nlme package to fit a model with 
crossed random factors. The example assumes though that the data is 
grouped. Is it possible to use lme() to fit crossed random factors when the 
data is not grouped?

E.g., y - rnorm(12); a=gl(4,1,12); b=gl(3,4,12). Can I fit an additive 
model like y~a+b but with a and b random?

Everything I've tried gives an error:

 lme(y~1,random=~1|(a+b))
Error in switch(mode(object), name = , numeric = , call = object, character 
= as.name(object),  :
[[ cannot be of mode (
 lme(y~1,random=~a+b)
Error in getGroups.data.frame(dataMix, groups) :
Invalid formula for groups

Thanks
Gordon
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] which argument is missing from my boot...

2003-10-31 Thread umeno
Hi,

I just cannot figure out what is missing from my boot.. This is what I have in 
my R codes:
-

payment.data-read.csv(maintenance payment.csv.,header=TRUE)
fee-lm(log(payment.data[,2])~payment.data[,1])
g-fee$coefficients[2]
g

phat.data-read.csv(phat.csv.,header=TRUE)
phat1-phat.data[,2]+0.01
PreOLS-lm(log(phat1)~phat.data[,1])
resid-PreOLS$residuals
esqu-resid^2
sigma-(1-phat1)/(phat1*nrow(phat.data))
cnsOLS-lm((esqu-sigma)~1)
f-cnsOLS$fitted.values-sigma

window-phat.data[,1]
phat2-phat.data[,2]
data-data.frame(window,phat2)
maxpay-max(payment.data[2])
minpay-min(payment.data[2])

delta.fun-function(data)
{
wOLS-lm(log(data[,2]+0.01)~data[,1],weights=f^(-0.5))
g -1*wOLS$coefficients[2]*log(maxpay/minpay)/wOLS$coefficients[1]
}

boot(data,delta.fun,100)


Then, I get this message:
Error in statistic(data, original, ...) : unused argument(s) ( ...)

I tried so many combinations by defining variables in the statistic...I could 
not figure out what arguments are unused...I checked the delta.fun, and it 
seems to be working...

Could anyone help me, PLEASE???

Thank you 
soyoko

__
Ms. Soyoko Umeno
Graduate Research Assitant for the Illinois-Missouri Biotechnology Alliance (IMBA) at 
http://www.imba.missouri.edu/
Ph.D. Student at the Department of Agricultural and Consumer Economics
at the University of Illinois at Urbana-Champaign
Office Phone: 217-333-3417 or 217-333-0364
Fax: 217-244-4817
Mailing Address: 1301 W. Gregory Dr. MC710, Urbana, IL 61801

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Weird problem with median on a factor

2003-10-31 Thread Simon Fear
What do you expect the median of a factor to be? Are
you sure you don't want the *mode* (most common
value)?
If you want the median numeric code of ordered
factors, maybe use `as.numeric` first. Consider what you
think should happen if this median is not an integer.

HTH

 -Original Message-
 From: Christoph Bier [mailto:[EMAIL PROTECTED]
 Sent: 30 October 2003 21:35
 To: [EMAIL PROTECTED]
 Subject: [R] Weird problem with median on a factor
 
 
 Security Warning: 
 If you are not sure an attachment is safe to open please contact  
 Andy on x234. There are 0 attachments with this message. 
  
  
 Hi all,
 
 I hope this isn't a naive newbie question again. Here you can 
 see column 264 of
 a data frame containing data of the same interview in May and 
 September. Column
 264 contains the answers of 49 persons to a question in May.
 
  fbhint.spss1[,264]
   [1] teils/teils  sehr wichtig NA NA sehr wichtig
   [6] sehr wichtig sehr wichtig sehr wichtig NA NA
 [11] NA NA wichtig  NA NA
 [16] sehr wichtig NA NA NA NA
 [21] NA NA NA wichtig  NA
 [26] NA NA NA NA NA
 [31] NA NA NA NA teils/teils
 [36] sehr wichtig NA NA NA NA
 [41] wichtig  NA sehr wichtig NA NA
 [46] sehr wichtig wichtig  NA NA
 Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
 
 Column 566 contains the answers from the same persons to the 
 same question in
 September.
 
  fbhint.spss1[,566]
   [1] NA NA NA wichtig  wichtig
   [6] sehr wichtig sehr wichtig wichtig  wichtig  NA
 [11] NA NA sehr wichtig sehr wichtig sehr wichtig
 [16] sehr wichtig NA unwichtigwichtig  wichtig
 [21] NA NA teils/teils  teils/teils  NA
 [26] unwichtigNA NA NA NA
 [31] wichtig  sehr wichtig sehr wichtig NA unwichtig
 [36] sehr wichtig NA NA teils/teils  wichtig
 [41] wichtig  wichtig  NA NA wichtig
 [46] NA sehr wichtig teils/teils  NA
 Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
 
 The following works:
 
  median(fbhint.spss1[,264], na.rm=T)
 [1] sehr wichtig
 Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
 
 ... but here it doesn't:
 
  median(fbhint.spss1[,566], na.rm=T)
 Error in Summary.factor(..., na.rm = na.rm) :
  sum not meaningful for factors
 
 I don't have any ideas why! Can somebody give me a hint?
 
 TIA
 
 Best regards,
 
 Christoph
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
  
 
Simon Fear 
Senior Statistician 
Syne qua non Ltd 
Tel: +44 (0) 1379 69 
Fax: +44 (0) 1379 65 
email: [EMAIL PROTECTED] 
web: http://www.synequanon.com 
  
Number of attachments included with this message: 0 
  
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] weighted rank correlation test?

2003-10-31 Thread Philipp Pagel

Hi R-gurus!

Is there a package that implements corr.test with weights, or will I
have to deal with this myself?

I found corr() from the boot package which will calculate r for me and I
could certainly do the ranking myself but it does not give me a
p-value...

Thanks for any hints.

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Weird problem with median on a factor

2003-10-31 Thread Peter Dalgaard
Christoph Bier [EMAIL PROTECTED] writes:

 The following works:
 
  median(fbhint.spss1[,264], na.rm=T)
 [1] sehr wichtig
 Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig
 
 ... but here it doesn't:
 
  median(fbhint.spss1[,566], na.rm=T)
 Error in Summary.factor(..., na.rm = na.rm) :
  sum not meaningful for factors
 
 I don't have any ideas why! Can somebody give me a hint?

Offhand, I'd guess that the median is inbetween two factor levels in
one case and not in the other. However, both cases should give an
error, especially for unordered factors, but it is not well-defined
for ordered factors either. If you want to interpret your factor as a
numeric scale, use as.numeric first.

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] cross-classified random factors in lme without blocking

2003-10-31 Thread Peter Dalgaard
Gordon Smyth [EMAIL PROTECTED] writes:

 On page 165 of Mixed-Effects Models in S and S-Plus by Pinheiro and
 Bates there is an example of using lme() in the nlme package to fit a
 model with crossed random factors. The example assumes though that the
 data is grouped. Is it possible to use lme() to fit crossed random
 factors when the data is not grouped?
 
 E.g., y - rnorm(12); a=gl(4,1,12); b=gl(3,4,12). Can I fit an
 additive model like y~a+b but with a and b random?
 
 Everything I've tried gives an error:
 
   lme(y~1,random=~1|(a+b))
 Error in switch(mode(object), name = , numeric = , call = object,
 character = as.name(object),  :
  [[ cannot be of mode (
   lme(y~1,random=~a+b)
 Error in getGroups.data.frame(dataMix, groups) :
  Invalid formula for groups
 

A standard trick is to define a grouping with one level:

one - rep(1,length(y)
lme(, random=~pdBlocked(.)|one)

(Sorry, I'm a little rusty on the syntax, but just follow the example
in PB)

AFAIR, it also works with random=list(a=~1,one=~b) and vice versa.

(The model is the same but you get different DF calculations, none of
which are correct in the completely balanced case...)

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Weird problem with median on a factor

2003-10-31 Thread Christoph Bier
Peter Dalgaard wrote:

Offhand, I'd guess that the median is inbetween two factor levels in
one case and not in the other. 
Hm, maybe. A problem, that would not occur, if I used the 
median on the numeric data of this factor.

However, both cases should give an
error, especially for unordered factors, but it is not well-defined
That's what I expected.

for ordered factors either. If you want to interpret your factor as a
numeric scale, use as.numeric first.
Yes, I already understood this :-) (At last we received your 
book or rather three of your books and the MASS-book).

Thanks for your answer.

Regards,

Christoph
--
Christoph Bier, Dipl.Oecotroph., Email: [EMAIL PROTECTED]
Universitaet Kassel, FG Oekologische Lebensmittelqualitaet und
Ernaehrungskultur \\ Postfach 12 52 \\ 37202 Witzenhausen
Tel.: +49 (0) 55 42 / 98 -17 21, Fax: -17 13
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Weird problem with median on a factor

2003-10-31 Thread Christoph Bier
Simon Fear schrieb:
The last part of my message is what I thought might be the cause -
maybe your median is not an integer, so what category
should it be mapped to? What do you get if you slip
in an `as.numeric` before calculating the median?
[if still an error, then there is definitely something else
going wrong to report]
Then everything is ok.

 as.numeric(fbhint.spss1$V15.SP1) - tmp.data2
 median(tmp.data2, na.rm=T)
[1] 2
Christoph
--
Christoph Bier, Dipl.Oecotroph., Email: [EMAIL PROTECTED]
Universitaet Kassel, FG Oekologische Lebensmittelqualitaet und
Ernaehrungskultur \\ Postfach 12 52 \\ 37202 Witzenhausen
Tel.: +49 (0) 55 42 / 98 -17 21, Fax: -17 13
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] too long

2003-10-31 Thread Uwe Ligges
william ritchie wrote:

Hi everyone,

 I ve been using R for months and find it really
practical and straight forward.
However (the inevitable however), I am finding it very
slow for one of my operations:
it s basically an itertation over i and j in a pretty
big table (4* 4608). It takes 30 minutes
Thanks


You got at least 3 replies on your first message. Why do you post it 
again???

Uwe Ligges

Ps:if it can help here is the source:

median1-matrix(nrow=4608,ncol=1)
median2-matrix(nrow=4608,ncol=1)
median3-matrix(nrow=4608,ncol=1)
median4-matrix(nrow=4608,ncol=1)
v-c(18,19,20,21,23)
for (i in 0:11)
{
 for (j in 1:384)
{
 
median1[j+(i*384),]-puce[j+(i*384),5]+median(puce[v+384*i,2]-puce[v+384*i,5])

median2[j+(i*384),]-puce[j+(i*384),19]+median(puce[v+384*i,16]-puce[v+384*i,19])

median3[j+(i*384),]-puce[j+(i*384),12]+median(puce[v+384*i,9]-puce[v+384*i,12])

median4[j+(i*384),]-puce[j+(i*384),26]+median(puce[v+384*i,23]-puce[v+384*i,26])
 
   
  puce[,5]-median1
 puce[,19]-median2
 puce[,12]-median3
 puce[,26]-median4

 }
 }
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Weird problem with median on a factor

2003-10-31 Thread Simon Fear
Final guess as to observed behaviour: in the first case after
removal of NAs there were an odd number of observations
(so that sum was not called within the code for median).
In your second call I suspect that even though you got
an integer answer, it was found as sum(2,2)/2.

It seems to me the best way to deal with this bug would
be to make calling median with a factor argument be an 
immediate error. Or just trust users never to attempt such
a thing ...  
 
Simon Fear 
Senior Statistician 
Syne qua non Ltd 
Tel: +44 (0) 1379 69 
Fax: +44 (0) 1379 65 
email: [EMAIL PROTECTED] 
web: http://www.synequanon.com 
  
Number of attachments included with this message: 0 
  
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] strange logLik results in gls (nlme)

2003-10-31 Thread Wilhelm B. Kloke
I am trying to analyse a data with gls/lm using the following set of models

prcn.0.lm - lm( log10(Y)~(cond-1)+(cond-1):t ,prcn)
prcn.1.gls - gls( log10(Y)~(cond-1)+(cond-1):t ,prcn,cor=corAR1())
prcn.0.gls - gls( log10(Y)~(cond-1)+(cond-1):t ,prcn)
prcn.1m.gls - gls( log10(Y)~(cond-1)+(cond-1):t ,prcn,cor=corAR1(),method=ML)

I get the following AICs for these models:
 AIC(prcn.1m.gls)
[1] -78.3
 AIC(prcn.1.gls)
[1] -46.3
 AIC(prcn.0.gls)
[1] -24.7
 AIC(prcn.0.lm)
[1] -59.8
It is the difference between the last two, which puzzles me. They are
the same models. So I can't compare the AICs of prcn.0.lm and prcn.1.gls
directly. When using anova() for the comparison, I get a sensible result:
 anova(prcn.1.gls,prcn.0.lm)
   Model df   AICBIC logLik   Test L.Ratio p-value
prcn.1.gls 1  6 -46.3 -28.62   29.1   
prcn.0.lm  2  5 -24.7  -9.97   17.3 1 vs 223.6  .0001

Multiple arguments in AIC() give:

 AIC(prcn.1.gls,prcn.0.lm)
   df   AIC
prcn.1.gls  6 -46.3
prcn.0.lm   5 -59.8

How can I be sure to make it right?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] How to grow an R object from C (.Call Interface)

2003-10-31 Thread Jens Oehlschlägel

What is the best way to grow an R return object in writing a C function
using the Rdefines.h macros.
In my application, the final size of the return object is not known during
construction. My understanding is that each time I grow an R object I have to
use PROTECT() again, probably before UNPROTECTing the smaller version.
However, due to the stack character of the PROTECT mechanism, UNPROTECT would not
work to remove the smaller one, after the bigger has been protected. Is this
an indication to use UNPROTECT_PTR ? Or is another approach recommended?

May be the solution to this is worth a sentence in Wrtiting R Extensions.

Thanks for any help


Jens Oehlschlägel

-- 
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse für Mail, Message, More! +++

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] How to grow an R object from C (.Call Interface)

2003-10-31 Thread Prof Brian Ripley
I think the solution is PROTECT_WITH_INDEX. From the Rinternals.h file

/* We sometimes need to coerce a protected value and place the new
   coerced value under protection.  For these cases PROTECT_WITH_INDEX
   saves an index of the protection location that can be used to
   replace the protected value using REPROTECT. */
typedef int PROTECT_INDEX;
#define PROTECT_WITH_INDEX(x,i) R_ProtectWithIndex(x,i)
#define REPROTECT(x,i) R_Reprotect(x,i)

You can see examples in dataentry.c, optim.c and elsewhere.

I agree that should be mentioned in R-exts.

On Fri, 31 Oct 2003, Jens Oehlschlägel wrote:

 
 What is the best way to grow an R return object in writing a C function
 using the Rdefines.h macros.
 In my application, the final size of the return object is not known during
 construction. My understanding is that each time I grow an R object I have to
 use PROTECT() again, probably before UNPROTECTing the smaller version.
 However, due to the stack character of the PROTECT mechanism, UNPROTECT would not
 work to remove the smaller one, after the bigger has been protected. Is this
 an indication to use UNPROTECT_PTR ? Or is another approach recommended?
 
 May be the solution to this is worth a sentence in Wrtiting R Extensions.
 
 Thanks for any help
 
 
 Jens Oehlschlägel
 
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] How to grow an R object from C (.Call Interface)

2003-10-31 Thread Peter Dalgaard
Jens Oehlschlägel [EMAIL PROTECTED] writes:

 What is the best way to grow an R return object in writing a C function
 using the Rdefines.h macros.
 In my application, the final size of the return object is not known during
 construction. My understanding is that each time I grow an R object I have to
 use PROTECT() again, probably before UNPROTECTing the smaller version.
 However, due to the stack character of the PROTECT mechanism, UNPROTECT would not
 work to remove the smaller one, after the bigger has been protected. Is this
 an indication to use UNPROTECT_PTR ? Or is another approach recommended?
 
 May be the solution to this is worth a sentence in Wrtiting R Extensions.
 
 Thanks for any help

It depends on the kind of object, I'll assume we're talking vector
objects here. If you're *extending* an existing object (the new object
becomes part of the old object) matters are quite different.

I think you are looking for the PROTECT_WITH_INDEX and REPROTECT
mechanism that Luke added (I almost said recently, but it was
in fact three years ago!). If that is not in the manual, it should
be. 

UNPROTECT_PTR is older and solves a similar problem, but where the
routine that unprotects is not the same as the one that protects (this
happens a lot in the parser code) and you cannot be sure that it is
the top item that needs to be removed. UNPROTECT_PTR works by
searching the stack for the pointer, pulling the record out of the
stack, and dropping every stack element on top of it. In contrast
REPROTECT knows which record to extract and just changes the pointer
value in it. I.e. UNPROTECT_PTR is potentially much less efficient,
although I don't think there are practical cases where more than an
handful of items have been pushed on the stack (the usual cases are
zero or one).

Also remember not to call any routine that could trigger a garbage
collection while you need access to both the old and the new extended
object. So, allocate, copy, reprotect, and *then* start computing new
entries. 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] cross-classified random factors in lme without blocking

2003-10-31 Thread Douglas Bates
Peter Dalgaard [EMAIL PROTECTED] writes:

 Gordon Smyth [EMAIL PROTECTED] writes:
 
  On page 165 of Mixed-Effects Models in S and S-Plus by Pinheiro and
  Bates there is an example of using lme() in the nlme package to fit a
  model with crossed random factors. The example assumes though that the
  data is grouped. Is it possible to use lme() to fit crossed random
  factors when the data is not grouped?
  
  E.g., y - rnorm(12); a=gl(4,1,12); b=gl(3,4,12). Can I fit an
  additive model like y~a+b but with a and b random?
  
  Everything I've tried gives an error:
  
lme(y~1,random=~1|(a+b))
  Error in switch(mode(object), name = , numeric = , call = object,
  character = as.name(object),  :
   [[ cannot be of mode (
lme(y~1,random=~a+b)
  Error in getGroups.data.frame(dataMix, groups) :
   Invalid formula for groups
  
 
 A standard trick is to define a grouping with one level:
 
 one - rep(1,length(y)
 lme(, random=~pdBlocked(.)|one)
 
 (Sorry, I'm a little rusty on the syntax, but just follow the example
 in PB)
 
 AFAIR, it also works with random=list(a=~1,one=~b) and vice versa.

Not sure about that.

 (The model is the same but you get different DF calculations, none of
 which are correct in the completely balanced case...)

I realize that it is awkward to use lme to fit models with crossed
random effects.  As Saikat DebRoy and I described in a recent preprint
http://www.stat.wisc.edu/~bates/reports/MultiComp.pdf
we now have a good handle on the computational methods for
mixed-effects models with nested or crossed or partially crossed
random effects.

Both the nlme and the lme4 packages are based on structures that are
tuned to nested random effects and do not easily accomodate crossed
random effects.  I have a draft of the contents of classes and methods
for fitting linear mixed-effects models with nested or crossed or
... but it is a long way from the draft to working, tested code.
Although it will take some time to get all the pieces in place I do
offer some encouragement that this awkward phrasing of crossed random
effects will some day be behind us.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] cross-classified random factors in lme without blocking

2003-10-31 Thread Peter Dalgaard
Douglas Bates [EMAIL PROTECTED] writes:

  (Sorry, I'm a little rusty on the syntax, but just follow the example
  in PB)
  
  AFAIR, it also works with random=list(a=~1,one=~b) and vice versa.
 
 Not sure about that.

Sorry. It's certainly not correct as written. It has to be something like

list(a=1,one=pdIdent(form=~b-1))
 
otherwise you get a general symmetric covariance for the effect of b.

  (The model is the same but you get different DF calculations, none of
  which are correct in the completely balanced case...)
 
 I realize that it is awkward to use lme to fit models with crossed
 random effects.  As Saikat DebRoy and I described in a recent preprint
 http://www.stat.wisc.edu/~bates/reports/MultiComp.pdf

.../MixedComp.pdf, right?

 we now have a good handle on the computational methods for
 mixed-effects models with nested or crossed or partially crossed
 random effects.
 
 Both the nlme and the lme4 packages are based on structures that are
 tuned to nested random effects and do not easily accomodate crossed
 random effects.  I have a draft of the contents of classes and methods
 for fitting linear mixed-effects models with nested or crossed or
 ... but it is a long way from the draft to working, tested code.
 Although it will take some time to get all the pieces in place I do
 offer some encouragement that this awkward phrasing of crossed random
 effects will some day be behind us.

Looking forward to it... :-)

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] cross-classified random factors in lme without blocking

2003-10-31 Thread Douglas Bates
Douglas Bates [EMAIL PROTECTED] writes:

...
 I realize that it is awkward to use lme to fit models with crossed
 random effects.  As Saikat DebRoy and I described in a recent preprint
 http://www.stat.wisc.edu/~bates/reports/MultiComp.pdf
 we now have a good handle on the computational methods for
 mixed-effects models with nested or crossed or partially crossed
 random effects.

That URL should have been
http://www.stat.wisc.edu/~bates/reports/MixedComp.pdf

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Re: packaging a package addon

2003-10-31 Thread Liaw, Andy
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 
 On Thu, 30 Oct 2003, Ross Boylan wrote:
[...]
  Finally, a comment on R CMD check: perhaps it could produce 
 some more 
  of the output when things fail?  I found that to diagnose 
 the loading 
  problems as I developed this, I had to attempt to load the package 
  myself in R to see what the actual problem was.  There 
 wasn't enough 
  info in the R CMD check to tell what exactly the problem was.
 
 I think there usually is, but you have to look in the log 
 file or one of 
 the example files.
 
 But I would not be doing R CMD check until I had both installed and 
 loaded the package and run a few examples.

I often do what Ross does, just because it's easy to do...

Is it possible to get R to at least print the trackback on error when
checking the package, so there's a bit more info in the log file?

Best,
Andy


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


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Creating packages in 1.8

2003-10-31 Thread Crispin Miller
Hi,
I decided to upgrade to 1.8 today... :-)
Anyway, we are writing our own package that is dependent on a
bioconductor library - 'affy'.
I've checked and when I fire up R, library(affy) behaves as expected...
so it all seems to be installed and OK...

In the DESCRIPTION file in my package source I have the line:

Depends: affy

When I run R CMD check simpleaffy

I get to:

...
* checking package dependencies ... ERROR
Packages required but not available:
  WARNING: ignoring environment value of R_HOME
Prompt 

Any ideas what is going on - as far as I can see the only dependency is
to affy which is there and OK... I get no list of packages that are
missing :-(

I'm assuming the warning comes because I have R_ENVIRON pointing to a
.Renviron file in my home directory...

Any help would be much appreciated!
Cheers,
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] print(), cat() and simple I/O in R

2003-10-31 Thread ryszard . czerminski
I am trying to produce rather mundane output of the form e.g.

pi, e = 3.14   2.718

The closest result I achieved so far with print() is:

 print (c(pi, exp(1)), digits = 3)
[1] 3.14 2.72

 print(c(pi, e =, pi, exp(1)), digits = 3)
[1] pi, e =  3.14159265358979 2.71828182845905
I understand that c() promotes floats to strings and this is why I get 
what I get.

and with cat() (it apparently does not have equivalent of digits 
parameter)
 cat (pi, e =, pi, exp(1), \n)
pi, e = 3.141593 2.718282

Any pointers with respect how can I print what I want to print would be 
greatly appreciated.


Ryszard
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] print(), cat() and simple I/O in R

2003-10-31 Thread Spencer Graves
Have you considered round and paste? 

hope this helps.  spencer graves

[EMAIL PROTECTED] wrote:

I am trying to produce rather mundane output of the form e.g.

pi, e = 3.14   2.718

The closest result I achieved so far with print() is:

 

print (c(pi, exp(1)), digits = 3)
   

[1] 3.14 2.72

 

print(c(pi, e =, pi, exp(1)), digits = 3)
   

[1] pi, e =  3.14159265358979 2.71828182845905
I understand that c() promotes floats to strings and this is why I get 
what I get.

and with cat() (it apparently does not have equivalent of digits 
parameter)
 

cat (pi, e =, pi, exp(1), \n)
   

pi, e = 3.141593 2.718282

Any pointers with respect how can I print what I want to print would be 
greatly appreciated.

Ryszard
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] print(), cat() and simple I/O in R

2003-10-31 Thread Henrik Bengtsson
See format(), formatC() and sprintf().

/Henrik

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 [EMAIL PROTECTED]
 Sent: den 31 oktober 2003 16:48
 To: [EMAIL PROTECTED]
 Subject: [R] print(), cat() and simple I/O in R
 
 
 I am trying to produce rather mundane output of the form e.g.
 
 pi, e = 3.14   2.718
 
 The closest result I achieved so far with print() is:
 
  print (c(pi, exp(1)), digits = 3)
 [1] 3.14 2.72
 
  print(c(pi, e =, pi, exp(1)), digits = 3)
 [1] pi, e =  3.14159265358979 2.71828182845905
 I understand that c() promotes floats to strings and this is 
 why I get 
 what I get.
 
 and with cat() (it apparently does not have equivalent of digits 
 parameter)
  cat (pi, e =, pi, exp(1), \n)
 pi, e = 3.141593 2.718282
 
 Any pointers with respect how can I print what I want to 
 print would be 
 greatly appreciated.
 
 
 Ryszard
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailma n/listinfo/r-help
 


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] print(), cat() and simple I/O in R

2003-10-31 Thread Giovanni Petris

?format
?formatC

 Date: Fri, 31 Oct 2003 10:47:36 -0500
 From: [EMAIL PROTECTED]
 Sender: [EMAIL PROTECTED]
 Precedence: list
 
 I am trying to produce rather mundane output of the form e.g.
 
 pi, e = 3.14   2.718
 
 The closest result I achieved so far with print() is:
 
  print (c(pi, exp(1)), digits = 3)
 [1] 3.14 2.72
 
  print(c(pi, e =, pi, exp(1)), digits = 3)
 [1] pi, e =  3.14159265358979 2.71828182845905
 I understand that c() promotes floats to strings and this is why I get 
 what I get.
 
 and with cat() (it apparently does not have equivalent of digits 
 parameter)
  cat (pi, e =, pi, exp(1), \n)
 pi, e = 3.141593 2.718282
 
 Any pointers with respect how can I print what I want to print would be 
 greatly appreciated.
 
 
 Ryszard
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 
 

-- 

 __
[  ]
[ Giovanni Petris [EMAIL PROTECTED] ]
[ Department of Mathematical Sciences  ]
[ University of Arkansas - Fayetteville, AR 72701  ]
[ Ph: (479) 575-6324, 575-8630 (fax)   ]
[ http://definetti.uark.edu/~gpetris/  ]
[__]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] constrained nonlinear optimisation in R?

2003-10-31 Thread Bill Shipley
Hello.  I have searched the archives but have not found anything.  I
need to solve a constrained optimisation problem for a nonlinear
function (“maximum entropy formalism”).  Specifically,

Optimise: -1*SUM(p_ilog(p_i)) for a vector p_i of probabilities,
conditional on a series of constraints of the form:

 

SUM(T_i*p_i)=k_i  for given values of T_i and k_i  (these are
constraints on expectations).

 

Can this be done in R?

 

Bill Shipley

Associate Editor, Ecology

North American Editor, Annals of Botany

Département de biologie, Université de Sherbrooke,

Sherbrooke (Québec) J1K 2R1 CANADA

[EMAIL PROTECTED]

 http://callisto.si.usherb.ca:8080/bshipley/
http://callisto.si.usherb.ca:8080/bshipley/

 


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Change in 'solve' for r-patched

2003-10-31 Thread Ole F. Christensen
Dear R help

Thanks to Professor Bates for his information about how to calculate 
least square estimates [not using solve] in ``the right way''.
This is very useful indead, I am clearly one of of the package 
maintainers who is not using using solve in a proper way at the moment.
However, the calculations in my code look more like GLS than LS.

## GLS could in principlpe be implemented like this :
betahat - solve(t(X) %*% solve(Omega)%*% X) %*% t(X)%*%solve(Omega)%*% y
## where Omega is a strictly p.d. symmetric matrix
Does someone have a recommendation on how to do this in ``the right way'' ?

My first attempt (trying to imitate the LS solution recommended by Prof. Bates) is :

temp - backsolve(chol(Omega),cbind(X,y))
betahat - qr.coef(qr(temp[,1:ncol(X)]), temp[,ncol(X)+1])


Thank you in advance for any help

Cheers Ole

--
Ole F. Christensen
Center for Bioinformatik
Datalogisk Institut
Aarhus Universitet
Ny Munkegade, Bygning 540
8000 Aarhus C
Denmark
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] constrained nonlinear optimisation in R?

2003-10-31 Thread Simon Wood
 Hello.  I have searched the archives but have not found anything.  I
 need to solve a constrained optimisation problem for a nonlinear
 function (“maximum entropy formalism”).  Specifically,

 Optimise: -1*SUM(p_ilog(p_i)) for a vector p_i of probabilities,
 conditional on a series of constraints of the form:

 SUM(T_i*p_i)=k_i  for given values of T_i and k_i  (these are
 constraints on expectations).

A better answer may exist to this question, but here goes anyway
Could you use sequential quaratic programming here (i.e. just constrain
the QP problem generated at each iterate of Newton's method)? There's an R
library for quadratic programming

Simon

_
 Simon Wood [EMAIL PROTECTED]www.stats.gla.ac.uk/~simon/
  Department of Statistics, University of Glasgow, Glasgow, G12 8QQ
   Direct telephone: (0)141 330 4530  Fax: (0)141 330 4814

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] constrained nonlinear optimisation in R?

2003-10-31 Thread Spencer Graves
 Other alternatives to the R library for quadratic programming: 

 1.  What are the nature of your constraints?  optim will 
optimize a function with optional box constraints.  constrOptim will 
optimize a function subject to linear inequality constraints. 

 2.  If you want to estimate the p[i]'s, i = 1, ..., k, I would 
recommend a multivariate logistic transformation to (k-1) unconstrained 
variables.  I have had serious difficulties with constrained optimizers 
testing values outside the constraints and then stopping because the 
objective function misbehaved.  I don't know if optim does this, but I 
don't even try constrained optimization if I can find a sensible, 
unconstrained parameterization.  Often, confidence regions, etc., are 
better behaved in the unconstrained space as well. 

hope this helps.  spencer graves

Simon Wood wrote:

Hello.  I have searched the archives but have not found anything.  I
need to solve a constrained optimisation problem for a nonlinear
function (?maximum entropy formalism?).  Specifically,
Optimise: -1*SUM(p_ilog(p_i)) for a vector p_i of probabilities,
conditional on a series of constraints of the form:
SUM(T_i*p_i)=k_i  for given values of T_i and k_i  (these are
constraints on expectations).
   

A better answer may exist to this question, but here goes anyway
Could you use sequential quaratic programming here (i.e. just constrain
the QP problem generated at each iterate of Newton's method)? There's an R
library for quadratic programming
Simon

_
 

Simon Wood [EMAIL PROTECTED]www.stats.gla.ac.uk/~simon/
   

Department of Statistics, University of Glasgow, Glasgow, G12 8QQ
 

 Direct telephone: (0)141 330 4530  Fax: (0)141 330 4814
   

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Creating packages in 1.8

2003-10-31 Thread Crispin Miller
Hi,
Firstly, sorry to reply to my own posting... Also for not having done
more trawling before I sent the original message...

The problems we are having were down to R being installed in a different
directory to the default one (for various sysadmin reasons)...

We've successfully got R runnning on a single machine in the default
directories where it likes to be - it is happy, and 'R CMD check' works
fine... :-)

Alas, this is not a good long-term solution for us can anyone help us
work out the easiest way to get R installed in another directory
structure instead of  the default ones? 

I appreciate that very similar questions have been asked before, but I
suspect that 1.8 is slightly different (since R CMD check ... worked
fine for us in 1.7.1).


Crispin

 -Original Message-
 From: Crispin Miller 
 Sent: 31 October 2003 14:51
 To: [EMAIL PROTECTED]
 Subject: [R] Creating packages in 1.8
 
 
 Hi,
 I decided to upgrade to 1.8 today... :-)
 Anyway, we are writing our own package that is dependent on a 
 bioconductor library - 'affy'. I've checked and when I fire 
 up R, library(affy) behaves as expected... so it all seems to 
 be installed and OK...
 
 In the DESCRIPTION file in my package source I have the line:
 
 Depends: affy
 
 When I run R CMD check simpleaffy
 
 I get to:
 
 ...
 * checking package dependencies ... ERROR
 Packages required but not available:
   WARNING: ignoring environment value of R_HOME
 Prompt 
 
 Any ideas what is going on - as far as I can see the only 
 dependency is to affy which is there and OK... I get no list 
 of packages that are missing :-(
 
 I'm assuming the warning comes because I have R_ENVIRON 
 pointing to a .Renviron file in my home directory...
 
 Any help would be much appreciated!
 Cheers,
 Crispin
  
 
 
  
 This email is confidential and intended solely for the use 
 o...{{dropped}}
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help

 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Change in 'solve' for r-patched

2003-10-31 Thread Prof Brian Ripley
GLS is usually solved by taking a matrix square root and converting to 
least squares (and BTW you might want to use lm.fit not solve for least 
squares to allow for aliased columns).

So your idea is right (and is the one given in my 1981 Spatial Statistics 
book).  These days I would usually use an eigendecomposition instead of 
Cholesky as it will enable you to cope better with nearly 
non-positive-definite Omega.  See lm.gls in package MASS for an outline 
implementation.

On Fri, 31 Oct 2003, Ole F. Christensen wrote:

 Dear R help
 
 Thanks to Professor Bates for his information about how to calculate 
 least square estimates [not using solve] in ``the right way''.
 This is very useful indead, I am clearly one of of the package 
 maintainers who is not using using solve in a proper way at the moment.
 However, the calculations in my code look more like GLS than LS.
 
 ## GLS could in principlpe be implemented like this :
 betahat - solve(t(X) %*% solve(Omega)%*% X) %*% t(X)%*%solve(Omega)%*% y
 ## where Omega is a strictly p.d. symmetric matrix
 
 Does someone have a recommendation on how to do this in ``the right way'' ?
 
 My first attempt (trying to imitate the LS solution recommended by Prof. Bates) is :
 
 temp - backsolve(chol(Omega),cbind(X,y))
 betahat - qr.coef(qr(temp[,1:ncol(X)]), temp[,ncol(X)+1])
 
 
 
 Thank you in advance for any help
 
 
 Cheers Ole
 
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] constrained nonlinear optimisation in R?

2003-10-31 Thread A.J. Rossini
Simon Wood [EMAIL PROTECTED] writes:

 Hello.  I have searched the archives but have not found anything.  I
 need to solve a constrained optimisation problem for a nonlinear
 function (“maximum entropy formalism”).  Specifically,

 Optimise: -1*SUM(p_ilog(p_i)) for a vector p_i of probabilities,
 conditional on a series of constraints of the form:

 SUM(T_i*p_i)=k_i  for given values of T_i and k_i  (these are
 constraints on expectations).

 A better answer may exist to this question, but here goes anyway
 Could you use sequential quaratic programming here (i.e. just constrain
 the QP problem generated at each iterate of Newton's method)? There's an R
 library for quadratic programming

 Simon

 _
 Simon Wood [EMAIL PROTECTED]www.stats.gla.ac.uk/~simon/
  Department of Statistics, University of Glasgow, Glasgow, G12 8QQ
   Direct telephone: (0)141 330 4530  Fax: (0)141 330 4814

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help


help.search(constrained) suggests:

constrOptim(base)   Linearly constrained optimisation

which might do the trick.


-- 
[EMAIL PROTECTED]http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN  Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Creating packages in 1.8

2003-10-31 Thread Prof Brian Ripley
On what OS?

It's easy on Windows: choose the directory in the installer.

It's easy for a source build on Unix: set --prefix at configure time.

It's easy for rpms if you know how.

I suspect it is easy for .debs.

And there is no R 1.8: it is R 1.8.0.

On Fri, 31 Oct 2003, Crispin Miller wrote:

 Hi,
 Firstly, sorry to reply to my own posting... Also for not having done
 more trawling before I sent the original message...
 
 The problems we are having were down to R being installed in a different
 directory to the default one (for various sysadmin reasons)...
 
 We've successfully got R runnning on a single machine in the default
 directories where it likes to be - it is happy, and 'R CMD check' works
 fine... :-)
 
 Alas, this is not a good long-term solution for us can anyone help us
 work out the easiest way to get R installed in another directory
 structure instead of  the default ones? 
 
 I appreciate that very similar questions have been asked before, but I
 suspect that 1.8 is slightly different (since R CMD check ... worked
 fine for us in 1.7.1).
 
 
 Crispin
 
  -Original Message-
  From: Crispin Miller 
  Sent: 31 October 2003 14:51
  To: [EMAIL PROTECTED]
  Subject: [R] Creating packages in 1.8
  
  
  Hi,
  I decided to upgrade to 1.8 today... :-)
  Anyway, we are writing our own package that is dependent on a 
  bioconductor library - 'affy'. I've checked and when I fire 
  up R, library(affy) behaves as expected... so it all seems to 
  be installed and OK...
  
  In the DESCRIPTION file in my package source I have the line:
  
  Depends: affy
  
  When I run R CMD check simpleaffy
  
  I get to:
  
  ...
  * checking package dependencies ... ERROR
  Packages required but not available:
WARNING: ignoring environment value of R_HOME
  Prompt 
  
  Any ideas what is going on - as far as I can see the only 
  dependency is to affy which is there and OK... I get no list 
  of packages that are missing :-(
  
  I'm assuming the warning comes because I have R_ENVIRON 
  pointing to a .Renviron file in my home directory...
  
  Any help would be much appreciated!
  Cheers,
  Crispin
   
  
  
   
  This email is confidential and intended solely for the use 
  o...{{dropped}}
  
  __
  [EMAIL PROTECTED] mailing list 
  https://www.stat.math.ethz.ch/mailman/listinfo /r-help
 
  
 
 
  
 This email is confidential and intended solely for the use o...{{dropped}}
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Fatal error in SJava.

2003-10-31 Thread Markus Helbig
Hi

can you please send me your compiled SJava package with the modified REmbed.c because 
in Windows i'm not able to recompile the package because of errors

Thanks very much

Markus Helbig




[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] dnorm() lead to a probability 1

2003-10-31 Thread Marc Belisle
Howdee,

One of my student spotted something I can't explain: a probability 1 vs a
normal probability density function.

 dnorm(x=1, mean=1, sd=0.4)
[1] 0.9973557

 dnorm(x=1, mean=1, sd=0.39)
[1] 1.022929

 dnorm(x=1, mean=1, sd=0.3)
[1] 1.329808

 dnorm(x=1, mean=1, sd=0.1)
[1] 3.989423

 dnorm(x=1, mean=1, sd=0.01)
[1] 39.89423

 dnorm(x=1, mean=1, sd=0.001)
[1] 398.9423

Is there a bug with the algorithm?

Thanks,

Marc


Marc Bélisle
Professeur adjoint
Département de biologie
Université de Sherbrooke
2500 boul. de l'Université
Sherbrooke, Québec
J1K 2R1 CANADA

Tél: +1-819-821-8000 poste 1313
Fax: +1-819-821-8049
Courriél: [EMAIL PROTECTED]
Site Web:
www.usherbrooke.ca/biologie/recherche/ecologie/Belisle/belisle.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] question about optim

2003-10-31 Thread Mikyoung Jun
Hello,

When we use optim and run into errors, such as generates NA/NaN/Inf, and 
the routine stops because of this error, is there a way to print the 
values of the argument of the functions where the error occurs? 
For example, I am doing minimizing negative log likelihood and when the 
optim stops because of those errors, I'd like to know what was the 
parameter values at that time. I heard nlm has something called 
print.level and I am wondering there is a way for optim as well. Thank 
you.

Mikyoung Jun

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] dnorm() lead to a probability 1

2003-10-31 Thread Dirk Eddelbuettel
On Fri, Oct 31, 2003 at 02:40:15PM -0500, Marc Belisle wrote:
 Howdee,
 
 One of my student spotted something I can't explain: a probability 1 vs a
 normal probability density function.

The integral has to be 1 --- but dnorm doesn't compute that. 

You were probably looking for pnorm(), and it will give you 0.5 for all
those cases (where x==mean) as you'd expect.

Hth,  Dirk


  dnorm(x=1, mean=1, sd=0.4)
 [1] 0.9973557
 
  dnorm(x=1, mean=1, sd=0.39)
 [1] 1.022929
 
  dnorm(x=1, mean=1, sd=0.3)
 [1] 1.329808
 
  dnorm(x=1, mean=1, sd=0.1)
 [1] 3.989423
 
  dnorm(x=1, mean=1, sd=0.01)
 [1] 39.89423
 
  dnorm(x=1, mean=1, sd=0.001)
 [1] 398.9423
 
 Is there a bug with the algorithm?
 
 Thanks,
 
 Marc
 
 
 Marc B?lisle
 Professeur adjoint
 D?partement de biologie
 Universit? de Sherbrooke
 2500 boul. de l'Universit?
 Sherbrooke, Qu?bec
 J1K 2R1 CANADA
 
 T?l: +1-819-821-8000 poste 1313
 Fax: +1-819-821-8049
 Courri?l: [EMAIL PROTECTED]
 Site Web:
 www.usherbrooke.ca/biologie/recherche/ecologie/Belisle/belisle.html
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

-- 
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] strange sprintf() behaviour ?

2003-10-31 Thread ryszard . czerminski
This is quite strange behaviour - at least for R-novice as myself

Consider this:

 testf - function() { x -2; sprintf(%s %f, x =, x); return(x) }
 result - testf()
 testf - function() { x -2; sprintf(%s %f, x =, x) }
 result - testf()
 testf()
[1] x = 2.00

Apparently  adding return() statement and invoking function like this 
result - testf()
suppresses output from sprintf()

Output from print() is NOT suppressed:

 testf - function() { x -2; print(c(x =, x)) }
 result - testf()
[1] x = 2
 testf - function() { x -2; print(c(x =, x)); return(x) }
 result - testf()
[1] x = 2

Is there a way to use sprintf() inside a function ?

I guess I can say: print(sprintf()) - is it the only solution for this ?

R

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] question about optim

2003-10-31 Thread Roger D. Peng
You might want to try using options(error = recover) or perhaps 
options(error = browser).

-roger

Mikyoung Jun wrote:
Hello,

When we use optim and run into errors, such as generates NA/NaN/Inf, and 
the routine stops because of this error, is there a way to print the 
values of the argument of the functions where the error occurs? 
For example, I am doing minimizing negative log likelihood and when the 
optim stops because of those errors, I'd like to know what was the 
parameter values at that time. I heard nlm has something called 
print.level and I am wondering there is a way for optim as well. Thank 
you.

Mikyoung Jun

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] dnorm() lead to a probability 1

2003-10-31 Thread Achim Zeileis
On Friday 31 October 2003 20:40, Marc Belisle wrote:

 Howdee,

 One of my student spotted something I can't explain: a probability
 1 vs a normal probability density function.

  dnorm(x=1, mean=1, sd=0.4)

 [1] 0.9973557

  dnorm(x=1, mean=1, sd=0.39)

 [1] 1.022929

  dnorm(x=1, mean=1, sd=0.3)

 [1] 1.329808

  dnorm(x=1, mean=1, sd=0.1)

 [1] 3.989423

  dnorm(x=1, mean=1, sd=0.01)

 [1] 39.89423

  dnorm(x=1, mean=1, sd=0.001)

 [1] 398.9423

 Is there a bug with the algorithm?

The *area* under the density curve corresponds to the probability in 
the corresponding interval...as you might have learned in a statistics 
course.
So it's perfeclty alright for a density function to exceed 1 if the 
area under the whole curve still equals one. Immediately obvious for
  curve(dunif(x, min = 0, max = 0.5))

hth,
Z

 Thanks,

 Marc

 
 Marc Bélisle
 Professeur adjoint
 Département de biologie
 Université de Sherbrooke
 2500 boul. de l'Université
 Sherbrooke, Québec
 J1K 2R1 CANADA

 Tél: +1-819-821-8000 poste 1313
 Fax: +1-819-821-8049
 Courriél: [EMAIL PROTECTED]
 Site Web:
 www.usherbrooke.ca/biologie/recherche/ecologie/Belisle/belisle.html

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] dnorm() lead to a probability 1

2003-10-31 Thread RBaskin
Dnorm isn't the probability - it's the y-value on the density function.  Try
plotting it - it makes a nice normal plot.
See ?dnorm for definition.

Bob


-Original Message-
From: Marc Belisle [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 31, 2003 2:40 PM
To: R-Help
Subject: [R] dnorm() lead to a probability 1

Howdee,

One of my student spotted something I can't explain: a probability 1 vs a
normal probability density function.

 dnorm(x=1, mean=1, sd=0.4)
[1] 0.9973557

 dnorm(x=1, mean=1, sd=0.39)
[1] 1.022929

 dnorm(x=1, mean=1, sd=0.3)
[1] 1.329808

 dnorm(x=1, mean=1, sd=0.1)
[1] 3.989423

 dnorm(x=1, mean=1, sd=0.01)
[1] 39.89423

 dnorm(x=1, mean=1, sd=0.001)
[1] 398.9423

Is there a bug with the algorithm?

Thanks,

Marc


Marc Bélisle
Professeur adjoint
Département de biologie
Université de Sherbrooke
2500 boul. de l'Université
Sherbrooke, Québec
J1K 2R1 CANADA

Tél: +1-819-821-8000 poste 1313
Fax: +1-819-821-8049
Courriél: [EMAIL PROTECTED]
Site Web:
www.usherbrooke.ca/biologie/recherche/ecologie/Belisle/belisle.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Change in 'solve' for r-patched

2003-10-31 Thread Williams, Elliot - BLS
Hi all,

Thanks Douglas for bringing up numerical stability and OLS regression
coefficients.  I'm often worried about the speed of regression runs, as I
sometimes run large simulations or resamplings.  Inspired, and prone to run
many regressions, I did a little simulation as follows.  XP results are on a
2.4Ghz Pentium 4 in Windows from the binaries (without BLAS?) and Linux
results are on a 1.5Ghz Pentium M laptop with a Pentium Atlas BLAS.

Setting up the data: x is rnormals with a vector of ones prepended... 
 x - cbind(rep(1,100), matrix(rnorm(1000), nc=10))
 beta0 - runif(11)
 y - x %*% beta0 + rnorm(100)

Estimating Slope Coefficients:

 system.time(for (i in 1:1000) lm( y~ x -1))
XP:  [1] 5.91 0.00 5.90   NA   NA
Linux: [1] 5.27 0.01 5.28 0.00 0.00

 system.time(for (i in 1:1000) solve(t(x) %*% x) %*% t(x) %*% y)
XP: [1] 0.64 0.01 0.65   NA   NA
Linux: [1] 0.51 0.01 0.57 0.00 0.00

 system.time(for (i in 1:1000) qr.coef(qr(x), y) )
XP: [1] 0.75 0.00 0.75   NA   NA
Linux: [1] 0.76 0.00 0.77 0.00 0.00

 system.time(for (i in 1:1000) solve(crossprod(x), crossprod(x,y)))
XP: [1] 0.45 0.00 0.53   NA   NA
Linux: [1] 0.35 0.00 0.36 0.00 0.00

On both platforms, BLAS or not, the solve(crossprod()) method works the
fastest, with the naïve solve(t(x)%*%x) second-fastest.  

Calculating (t(x)%*%x)^-1:

 system.time(for (i in 1:1000) chol2inv(qr.R(qr(x
XP: [1] 0.44 0.00 0.44   NA   NA
Linux: [1] 0.40 0.00 0.40 0.00 0.00

 system.time(for (i in 1:1000) solve(crossprod(x)) )
XP: [1] 0.58 0.01 0.59   NA   NA
Linux: [1] 0.34 0.00 0.34 0.00 0.00

Where the chol2inv() method was faster in Windows but slower in Linux, which
I'm guessing is due to differential uses of BLAS functions.

None of these address the problem of numerical accuracy, which was the
thrust of Doug's comments.  Has anyone done a quick simulation to
investigate the stability of the solutions?  Is it small coefficients or
near-collinearity (or both) that one has to worry about?  

Are the solve(crossprod()) methods obviously unstable?  They surely do work
quickly!

Thanks again R-universe.  I've needed no other statistical software for the
last 2 years.  I hope to get around to contributing a package or two soon.

Elliot.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Summing elements in a list

2003-10-31 Thread Giovanni Petris

The following seems to give what you want.


tmp - rep(w, each=nrow1*ncol1+nrow2*ncol2) * unlist(matlist)
tmp - rowSums(matrix(tmp,nr=nrow1*ncol1+nrow2*ncol2))
mat1 - tmp[1:(nrow1*ncol1)]; dim(mat1) - c(nrow1,ncol1)
mat2 - tmp[nrow1*ncol1+1:(nrow2*ncol2)]; dim(mat2) - c(nrow2,ncol2)


Giovanni

-- 

 __
[  ]
[ Giovanni Petris [EMAIL PROTECTED] ]
[ Department of Mathematical Sciences  ]
[ University of Arkansas - Fayetteville, AR 72701  ]
[ Ph: (479) 575-6324, 575-8630 (fax)   ]
[ http://definetti.uark.edu/~gpetris/  ]
[__]

 Date: Fri, 31 Oct 2003 14:16:31 -0500
 From: Angelo Canty [EMAIL PROTECTED]
 Sender: [EMAIL PROTECTED]
 Organization: McMaster University
 Precedence: list
 
 Hi,
 
 Suppose that I have a list where each component is a list of two
 matrices.  I also have a vector of weights.  How can I collapse my
 list of lists into a single list of two matrices where each matrix
 in the result is the weighted sum of the corresponding matrices.
 
 I could use a loop but this is a nested calculation so I was hoping
 there is a more efficient way to do this.  To help clarify, here is
 the code I would use with a for loop
 
 result - list(mat1=matrix(0,nrow1,ncol1),
mat2=matrix(0,nrow2,ncol2))
 for (i in seq(along=matlist)) {
result$mat1 - result$mat1+w[i]*matlist[[i]]$mat1
result$mat2 - result$mat2+w[i]*matlist[[i]]$mat2
 }
 
 I apologise if this is a trivial question.  Unfortunately I don't have
 my copy of VR S Programming to hand.
 
 Thanks for your help,
 Angelo
 -- 
 --
 |   Angelo J. CantyEmail: [EMAIL PROTECTED] |
 |   Mathematics and Statistics Phone: (905) 525-9140 x 27079 |
 |   McMaster UniversityFax  : (905) 522-0935 |
 |   1280 Main St. W. |
 |   Hamilton ON L8S 4K1  |
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Summing elements in a list

2003-10-31 Thread Paul Y. Peng
Angelo Canty wrote:
Hi,

Suppose that I have a list where each component is a list of two
matrices.  I also have a vector of weights.  How can I collapse my
list of lists into a single list of two matrices where each matrix
in the result is the weighted sum of the corresponding matrices.
I could use a loop but this is a nested calculation so I was hoping
there is a more efficient way to do this.  To help clarify, here is
the code I would use with a for loop
result - list(mat1=matrix(0,nrow1,ncol1),
   mat2=matrix(0,nrow2,ncol2))
for (i in seq(along=matlist)) {
   result$mat1 - result$mat1+w[i]*matlist[[i]]$mat1
   result$mat2 - result$mat2+w[i]*matlist[[i]]$mat2
}
I apologise if this is a trivial question.  Unfortunately I don't have
my copy of VR S Programming to hand.
Here is one possibility:

result - list(
  mat1 = matrix(rowSums(sapply(matlist, function(x)x$mat1) %*% diag(w)), nrow1, ncol1)
  mat2 = matrix(rowSums(sapply(matlist, function(x)x$mat2) %*% diag(w)), nrow2, ncol2)
)
Warning: It doesn't have the readability that the original code has though.

Paul.
--
--
  Dr. Paul Y. Peng, Associate ProfessorPhone: (709) 737 8080
  Department of Mathematics and Statistics   Fax: (709) 737 3010
  Memorial University of Newfoundland  E-mail: [EMAIL PROTECTED]
  St. John's, NL A1C 5S7, Canada Web: www.math.mun.ca/~ypeng
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] problem with tune.svm

2003-10-31 Thread ryszard . czerminski
 rng - list(gamma = 2^(-1:1), cost = 2^(2:4))
 rng
$gamma
[1] 0.5 1.0 2.0

$cost
[1]  4  8 16

 obj - tune.svm(pIC50 ~ ., data = data, ranges = rng)
Error in tune(svm, train.x = x, data = data, ranges = ranges, ...) :
formal argument ranges matched by multiple actual arguments

Ay idea why ???

Ryszard

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Weird problem with median on a factor

2003-10-31 Thread RBaskin
Beating a dead horse...

I am an R beginner trying to understand this factor business.  While the
entire business of finding the median of factor may be silly from a
practical point of view, this email chain has helped me understand
something.  

I have looked at the median function and it tests to see if what is passed
to it is numeric.  If I were building a function, if I tested for mode
numeric, and if something told me it was numeric then like the median
function I would naively assume that I could do arithmetic on it:
 saywhut-as.factor(c(NA,1,1,1,1,2,10))
 mode(saywhut)
[1] numeric

It appears to me that the when the median function tests for numeric it
doesn't have the desired result with an object of class factor (and maybe
other classes?) as was shown by the example.

I have a suspicion that something of class factor has at least two pieces,
one of which is the levels which can possibly be character or something else
and the other piece is the ordering of the levels which is of storage.mode
integer.  Is it this ordering that determines the mode of the factor??  

But if the mode of factor is truly numeric, why doesn't the median function
use the numeric piece for finding the median (like it did with odd n - not
that anyone would ever really want the median of a factor:)??  I think that
Simon Fear hit on the right idea because of the definition of median that is
used for an even number of observations takes the sum of the ordered middle
two observations.  It is the sum (called by the median function) that chokes
on a factor.

 sum(saywhut,na.rm=T)
Error in Summary.factor(..., na.rm = na.rm) : 
sum not meaningful for factors

It appears that whoever built the sum function built in a test for factor
(Simon Fear's first suggestion for median)


On the other hand:
 sd(saywhut,na.rm=T)
[1] 3.614784
(Simon Fear's second suggestion for median)

Bytheway, mean treats factor in different way:
mean(saywhut)
[1] NA
Warning message: 
argument is not numeric or logical: returning NA in: mean.default(saywhut).


There is an R-FAQ that tells one how to convert a factor to 'numeric' but if
I had tested for something being numeric to begin with I never would have
guessed that I needed to convert it to numeric.  I think what this
conversion is really doing is getting rid of the machinery associated with
the class factor:
 #from the R-FAQ
 test-as.numeric(as.character(saywhut))
 mode(test)
[1] numeric
 median(test,na.rm=T)
[1] 1

and bytheway:
 not.a.factor-c(NA,1,1,2,10)
 mode(not.a.factor)
[1] character
 median(not.a.factor,na.rm=T)
Error in median(not.a.factor, na.rm = T) : 
need numeric data


Simon Fear: It seems to me the best way to deal with this bug would
be to make calling median with a factor argument be an immediate error.
Do you think that all base functions (sum, sd, mean, median,...) should deal
with this in a consistent way (This might be much more work.)?  Another
thing that would make things consistent would be to take the stop-work
behavior out of sum:)  

I don't think there is any real problem in the current behavior of factor as
long as the interaction between functions and classes produces this
stop-work behavior - preferably with a warning - and not unexpected side
effects. I am curious if there are other classes of mode numeric which
median-mean-sum-sd-etc might choke on.

tongue-in-cheek on
Of course, R would produce a median for factors by using the correct
defintion of a median of samples i.e., one that agrees with the definition
of median on a CDF, even though this concept gives most people apoplexy.
off
Thanks
Bob
Usual disclaimers


-Original Message-
From: Simon Fear [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 31, 2003 6:18 AM
To: Christoph Bier
Cc: [EMAIL PROTECTED]
Subject: RE: [R] Weird problem with median on a factor

Final guess as to observed behaviour: in the first case after
removal of NAs there were an odd number of observations
(so that sum was not called within the code for median).
In your second call I suspect that even though you got
an integer answer, it was found as sum(2,2)/2.

It seems to me the best way to deal with this bug would
be to make calling median with a factor argument be an 
immediate error. Or just trust users never to attempt such
a thing ...  
 
Simon Fear 
Senior Statistician 
Syne qua non Ltd 
Tel: +44 (0) 1379 69 
Fax: +44 (0) 1379 65 
email: [EMAIL PROTECTED] 
web: http://www.synequanon.com 
  
Number of attachments included with this message: 0 
  
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Array Dimension Names

2003-10-31 Thread Benjamin . STABLER
I would like to reference array dimensions by name in an apply and a summary
function.  For example:

apply(x, workers, sum)

Is there a better way to do this than creating a new attribute for the array
and then creating new methods for apply and summary?  I don't want to name
the individual elements of each dimension (such as with dimnames) but rather
name the dimensions.  Thanks for your help.

Benjamin Stabler
Transportation Planning Analysis Unit
Oregon Department of Transportation
555 13th Street NE, Suite 2
Salem, OR 97301  Ph: 503-986-4104

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Weird problem with median on a factor

2003-10-31 Thread Tony Plate
median() has this test in it:
if (mode(x) != numeric)
stop(need numeric data)
Note the following:

 is.numeric(factor(letters))
[1] FALSE
 mode(factor(letters))
[1] numeric

It seems as though median() is using the wrong test.

-- Tony Plate

At Friday 03:37 PM 10/31/2003 -0500, [EMAIL PROTECTED] wrote:
Beating a dead horse...

I am an R beginner trying to understand this factor business.  While the
entire business of finding the median of factor may be silly from a
practical point of view, this email chain has helped me understand
something.
I have looked at the median function and it tests to see if what is passed
to it is numeric.  If I were building a function, if I tested for mode
numeric, and if something told me it was numeric then like the median
function I would naively assume that I could do arithmetic on it:
 saywhut-as.factor(c(NA,1,1,1,1,2,10))
 mode(saywhut)
[1] numeric
It appears to me that the when the median function tests for numeric it
doesn't have the desired result with an object of class factor (and maybe
other classes?) as was shown by the example.
I have a suspicion that something of class factor has at least two pieces,
one of which is the levels which can possibly be character or something else
and the other piece is the ordering of the levels which is of storage.mode
integer.  Is it this ordering that determines the mode of the factor??
But if the mode of factor is truly numeric, why doesn't the median function
use the numeric piece for finding the median (like it did with odd n - not
that anyone would ever really want the median of a factor:)??  I think that
Simon Fear hit on the right idea because of the definition of median that is
used for an even number of observations takes the sum of the ordered middle
two observations.  It is the sum (called by the median function) that chokes
on a factor.
 sum(saywhut,na.rm=T)
Error in Summary.factor(..., na.rm = na.rm) :
sum not meaningful for factors
It appears that whoever built the sum function built in a test for factor
(Simon Fear's first suggestion for median)
On the other hand:
 sd(saywhut,na.rm=T)
[1] 3.614784
(Simon Fear's second suggestion for median)
Bytheway, mean treats factor in different way:
mean(saywhut)
[1] NA
Warning message:
argument is not numeric or logical: returning NA in: mean.default(saywhut).
There is an R-FAQ that tells one how to convert a factor to 'numeric' but if
I had tested for something being numeric to begin with I never would have
guessed that I needed to convert it to numeric.  I think what this
conversion is really doing is getting rid of the machinery associated with
the class factor:
 #from the R-FAQ
 test-as.numeric(as.character(saywhut))
 mode(test)
[1] numeric
 median(test,na.rm=T)
[1] 1
and bytheway:
 not.a.factor-c(NA,1,1,2,10)
 mode(not.a.factor)
[1] character
 median(not.a.factor,na.rm=T)
Error in median(not.a.factor, na.rm = T) :
need numeric data
Simon Fear: It seems to me the best way to deal with this bug would
be to make calling median with a factor argument be an immediate error.
Do you think that all base functions (sum, sd, mean, median,...) should deal
with this in a consistent way (This might be much more work.)?  Another
thing that would make things consistent would be to take the stop-work
behavior out of sum:)
I don't think there is any real problem in the current behavior of factor as
long as the interaction between functions and classes produces this
stop-work behavior - preferably with a warning - and not unexpected side
effects. I am curious if there are other classes of mode numeric which
median-mean-sum-sd-etc might choke on.
tongue-in-cheek on
Of course, R would produce a median for factors by using the correct
defintion of a median of samples i.e., one that agrees with the definition
of median on a CDF, even though this concept gives most people apoplexy.
off
Thanks
Bob
Usual disclaimers
-Original Message-
From: Simon Fear [mailto:[EMAIL PROTECTED]
Sent: Friday, October 31, 2003 6:18 AM
To: Christoph Bier
Cc: [EMAIL PROTECTED]
Subject: RE: [R] Weird problem with median on a factor
Final guess as to observed behaviour: in the first case after
removal of NAs there were an odd number of observations
(so that sum was not called within the code for median).
In your second call I suspect that even though you got
an integer answer, it was found as sum(2,2)/2.
It seems to me the best way to deal with this bug would
be to make calling median with a factor argument be an
immediate error. Or just trust users never to attempt such
a thing ...
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 69
Fax: +44 (0) 1379 65
email: [EMAIL PROTECTED]
web: http://www.synequanon.com
Number of attachments included with this message: 0

This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list

Re: [R] Array Dimension Names

2003-10-31 Thread Ben Bolker

  Not that I know of.  BUT dimnames can themselves have names attributes, 
so a very small hack to apply() will do what you want.

I did 

dump(apply,file=apply.R)

and added the following lines after dn - dimnames(X) (line 14) [this is 
in R 1.7.1].

if (is.character(MARGIN)) {
  if (is.null(dn) stop(dimnames(X) must have names)
  MARGIN - match(MARGIN,names(dn))
}

and then did 

source(apply.R)
x = array(1,dim=c(2,2,2))
dimnames(x) = list(a=1:2,b=1:2,c=1:2)
apply(x,a,sum)
apply(x,c(a,b),sum)

On Fri, 31 Oct 2003 [EMAIL PROTECTED] wrote:

 I would like to reference array dimensions by name in an apply and a summary
 function.  For example:
 
 apply(x, workers, sum)
 
 Is there a better way to do this than creating a new attribute for the array
 and then creating new methods for apply and summary?  I don't want to name
 the individual elements of each dimension (such as with dimnames) but rather
 name the dimensions.  Thanks for your help.
 
 Benjamin Stabler
 Transportation Planning Analysis Unit
 Oregon Department of Transportation
 555 13th Street NE, Suite 2
 Salem, OR 97301  Ph: 503-986-4104
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

-- 
620B Bartram Hall[EMAIL PROTECTED]
Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker
Box 118525   (ph)  352-392-5697
Gainesville, FL 32611-8525   (fax) 352-392-3704

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Problems with help.start()

2003-10-31 Thread Henrique Patrício Sant'Anna Branco
Hello there,
I've just installed R for Windows 1.8.0 and I'm experiencing problems with
help.start().
It opens the help page as it supposed to do, then I go to Search Engine 
Keywords, but when I click anything there, it returns me a (aparently)
JavaScript error, something like The object does not support this method or
property.
The Search Engine doesn't work as well.
I tried to open with Internet Explorer 6 and Mozilla (the last one).
Have anybody already seen this problem?
Thanks,
Henrique.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: packaging a package addon

2003-10-31 Thread Ross Boylan
On Fri, 2003-10-31 at 03:14, Prof Brian Ripley wrote:

 But I would not be doing R CMD check until I had both installed and 
 loaded the package and run a few examples.

That's interesting; I thought R CMD check was supposed to be done before
hand.  So are you saying the proper development sequence is
1.
Do as much as you can with the basic R and C (Fortran, whatever) code to
check it's OK.

2.
R CMD build
test, revise
R CMD build
etc

3. then, when everything looks OK
R CMD check
?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: packaging a package addon

2003-10-31 Thread Ross Boylan
On Fri, 2003-10-31 at 06:41, A.J. Rossini wrote:
 Ross Boylan [EMAIL PROTECTED] writes:
 
  I also added library(survival) to my .First.lib.  Is library, rather
  than require, the right choice here?  I want it to fail if survival
  doesn't load.
 
 test the results from require, something like: 
 
  if (!require(survival)) stop(can't load survival)
Doesn't using library do about the same thing?  What's the advantage of
this, clearer diagnostics?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Array Dimension Names

2003-10-31 Thread Benjamin . STABLER
Oh yeah, thanks.  I thought I might write a function such as getNames() that
returns the dimension number of the names of the dimnames of an object.
That way I don't have to rewrite apply, sweep, and aperm.  But even better
would be for R to allow character names in addition to index numbers for the
MARGIN argument to apply and sweep, and the perm argument to aperm.

Thanks again,
Ben Stabler

-Original Message-
From: Tony Plate [mailto:[EMAIL PROTECTED]
Sent: Friday, October 31, 2003 1:07 PM
To: STABLER Benjamin; [EMAIL PROTECTED]
Subject: Re: [R] Array Dimension Names


You can already name dimensions using standard arrays (but you 
can't use 
these names for the MARGIN argument of apply) e.g.:

  x - array(1:6, 3:2, 
dimnames=list(rows=letters[1:3],cols=LETTERS[24:25]))
  x
 cols
rows X Y
a 1 4
b 2 5
c 3 6
  apply(x, 2, sum)
  X  Y
  6 15
  apply(x, cols, sum)
Error in -MARGIN : Invalid argument to unary operator
 

You could pretty easily create your own version of apply() 
that checked if 
MARGIN was character, and if it were, matched it against 
names(dimnames(X))

hope this helps,

Tony Plate

At Friday 12:50 PM 10/31/2003 -0800, 
[EMAIL PROTECTED] wrote:
I would like to reference array dimensions by name in an 
apply and a summary
function.  For example:

apply(x, workers, sum)

Is there a better way to do this than creating a new 
attribute for the array
and then creating new methods for apply and summary?  I don't 
want to name
the individual elements of each dimension (such as with 
dimnames) but rather
name the dimensions.  Thanks for your help.

Benjamin Stabler
Transportation Planning Analysis Unit
Oregon Department of Transportation
555 13th Street NE, Suite 2
Salem, OR 97301  Ph: 503-986-4104

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problems with help.start()

2003-10-31 Thread Prof Brian Ripley
No, so looks like a problem with your browser/OS.  Are you sure you have 
working Java and JavaScript?

Both a fully patched IE6 and Netscape 7.1 work for me (as do Opera 6 
and Mozilla 1.2).

On Fri, 31 Oct 2003, Henrique Patrício Sant'Anna Branco wrote:

 Hello there,
 I've just installed R for Windows 1.8.0 and I'm experiencing problems with
 help.start().
 It opens the help page as it supposed to do, then I go to Search Engine 
 Keywords, but when I click anything there, it returns me a (aparently)
 JavaScript error, something like The object does not support this method or
 property.
 The Search Engine doesn't work as well.
 I tried to open with Internet Explorer 6 and Mozilla (the last one).
 Have anybody already seen this problem?
 Thanks,
 Henrique.
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] help with constrOptim function

2003-10-31 Thread Thomas Lumley
On Fri, 31 Oct 2003, Bill Shipley wrote:

 Hello.  I had previously posted a question concerning the optimization
 of a nonlinear function conditional on equality constraints.  I was
 pointed towards the contrOptim function.

Perhaps mistakenly, then.  constrOptim() does linear *inequality*
constraints.  Equality constraints are probably best handled by Lagrange
multipliers or reparametrisation.

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: packaging a package addon

2003-10-31 Thread Ross Boylan
On Fri, 2003-10-31 at 13:29, Prof Brian Ripley wrote:
 I would do 1 3 2  as R CMD check works on a source dir, not a .tar.gz.
 
 Your mileage may vary and all that.
I'm not following something.  1 3 2 was what I was doing.  I thought you
said (below on Fri) that you'd do 2, then 3.  I may be misunderstanding
what the phrase installed and loaded the package means.  I thought
installing and loading it referred to doing an R CMD build to make the
package, and then R CMD INSTALL on the result.

 
 I'd say R CMD check was a final check before distribution via R CMD build.
 
 On Fri, 31 Oct 2003, Ross Boylan wrote:
 
  On Fri, 2003-10-31 at 03:14, Prof Brian Ripley wrote:
  
   But I would not be doing R CMD check until I had both installed and 
   loaded the package and run a few examples.
  
  That's interesting; I thought R CMD check was supposed to be done before
  hand.  So are you saying the proper development sequence is
  1.
  Do as much as you can with the basic R and C (Fortran, whatever) code to
  check it's OK.
  
  2.
  R CMD build
  test, revise
  R CMD build
  etc
  
  3. then, when everything looks OK
  R CMD check
  ?
  
  
-- 
Ross Boylan  wk:  (415) 502-4031
530 Parnassus Avenue (Library) rm 115-4  [EMAIL PROTECTED]
Dept of Epidemiology and Biostatistics   fax: (415) 476-9856
University of California, San Francisco
San Francisco, CA 94143-0840 hm:  (415) 550-1062

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: packaging a package addon

2003-10-31 Thread Thomas Lumley
On Fri, 31 Oct 2003, Ross Boylan wrote:

 On Fri, 2003-10-31 at 06:41, A.J. Rossini wrote:
  Ross Boylan [EMAIL PROTECTED] writes:
  
   I also added library(survival) to my .First.lib.  Is library, rather
   than require, the right choice here?  I want it to fail if survival
   doesn't load.
 
  test the results from require, something like:
 
   if (!require(survival)) stop(can't load survival)
 Doesn't using library do about the same thing?  What's the advantage of
 this, clearer diagnostics?



If you are going to fail when survival isn't found you should probably
just use library, though Tony's suggestion is effectively equivalent, and
I have also seen the Perly
   require(tcltk) || stop(error message)

The main point of require() is when failure isn't completely fatal: eg
hypothetically

if (!require(boot)) {
warning(No `boot' package -- you're not getting confidence intervals)
conf.int-FALSE
}


-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problems with help.start()

2003-10-31 Thread Marc Schwartz
On Fri, 2003-10-31 at 15:05, Henrique Patrcio Sant'Anna Branco wrote:
 Hello there,
 I've just installed R for Windows 1.8.0 and I'm experiencing problems with
 help.start().
 It opens the help page as it supposed to do, then I go to Search Engine 
 Keywords, but when I click anything there, it returns me a (aparently)
 JavaScript error, something like The object does not support this method or
 property.
 The Search Engine doesn't work as well.
 I tried to open with Internet Explorer 6 and Mozilla (the last one).
 Have anybody already seen this problem?
 Thanks,
 Henrique.


This has been discussed previously. It is tied to having both Java and
JavaScript functioning in your browser. If Java is installed on your
computer, be sure that both are enabled in your browser. Both must be
functional in order to use the help.start() search engine which is a
java applet.

The following link provides information for Mozilla 1.5, which is the
latest version, regarding installing Java:

http://www.mozilla.org/releases/mozilla1.5/installation-extras.html

There is also a FAQ at Sun here:

http://www.java.com/en/download/help/enable_browser.jsp

If you do not have Java installed on your computer yet, you can go here:

http://www.java.com/en/download/help/auto_install.jsp

for instructions on how to download and install it.

HTH,

Marc Schwartz

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: packaging a package addon

2003-10-31 Thread Prof Brian Ripley
On Fri, 31 Oct 2003, Ross Boylan wrote:

 On Fri, 2003-10-31 at 13:29, Prof Brian Ripley wrote:
  I would do 1 3 2  as R CMD check works on a source dir, not a .tar.gz.
  
  Your mileage may vary and all that.
 I'm not following something.  1 3 2 was what I was doing.  I thought you
 said (below on Fri) that you'd do 2, then 3.  I may be misunderstanding
 what the phrase installed and loaded the package means.  I thought
 installing and loading it referred to doing an R CMD build to make the
 package, and then R CMD INSTALL on the result.

NO, do R CMD INSTALL on the sources, and the R  run some tests.

 
  
  I'd say R CMD check was a final check before distribution via R CMD build.
  
  On Fri, 31 Oct 2003, Ross Boylan wrote:
  
   On Fri, 2003-10-31 at 03:14, Prof Brian Ripley wrote:
   
But I would not be doing R CMD check until I had both installed and 
loaded the package and run a few examples.
   
   That's interesting; I thought R CMD check was supposed to be done before
   hand.  So are you saying the proper development sequence is
   1.
   Do as much as you can with the basic R and C (Fortran, whatever) code to
   check it's OK.
   
   2.
   R CMD build
   test, revise
   R CMD build
   etc
   
   3. then, when everything looks OK
   R CMD check
   ?
   
   
 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] problem with tune.svm

2003-10-31 Thread David Meyer


On Fri, 31 Oct 2003 [EMAIL PROTECTED] wrote:

  rng - list(gamma = 2^(-1:1), cost = 2^(2:4))
  rng
 $gamma
 [1] 0.5 1.0 2.0
 
 $cost
 [1]  4  8 16
 
  obj - tune.svm(pIC50 ~ ., data = data, ranges = rng)
 Error in tune(svm, train.x = x, data = data, ranges = ranges, ...) :
 formal argument ranges matched by multiple actual arguments

The function `tune.svm' has no `range' argument, use `gamma' and `cost'
separately. The idea is to make `tune.foo' a `vectorized' function of
`foo' in the parameters. If you want to preconstruct a list, use

tune(svmobj, ranges = ...)

instead.

g.,
-d

 
 Ay idea why ???
 
 Ryszard
 
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Array Dimension Names

2003-10-31 Thread Gabor Grothendieck


You could add attributes to your array when creating it
and then retrieve them:

  x - matrix(1:8,2,4)
  attr(x,workers) - 1
  attr(x,variables) - 2

  apply(x,attr(x,variables),sum)

or perhaps:

  y - matrix(1:8,2,4)
  attr(y,margins) - list(workers = 1, variables = 2)

  apply(y,attr(y,margins)$variables,sum) 

These are simple enough that you might not need to develop your
own apply but you could pretty them up even more if you did:

  my.apply - function(x,dim,fn) apply(x,attr(x,dim),fn)

  my.apply(x,variables,sum)

---

From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED] 
Subject: [R] Array Dimension Names 

 
 
I would like to reference array dimensions by name in an apply and a summary
function. For example:

apply(x, workers, sum)

Is there a better way to do this than creating a new attribute for the array
and then creating new methods for apply and summary? I don't want to name
the individual elements of each dimension (such as with dimnames) but rather
name the dimensions. Thanks for your help.

Benjamin Stabler
Transportation Planning Analysis Unit
Oregon Department of Transportation
555 13th Street NE, Suite 2
Salem, OR 97301 Ph: 503-986-4104


___
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Change in 'solve' for r-patched

2003-10-31 Thread Thomas Lumley
On Fri, 31 Oct 2003, Williams, Elliot - BLS wrote:

 None of these address the problem of numerical accuracy, which was the
 thrust of Doug's comments.  Has anyone done a quick simulation to
 investigate the stability of the solutions?  Is it small coefficients or
 near-collinearity (or both) that one has to worry about?

 Are the solve(crossprod()) methods obviously unstable?  They surely do work
 quickly!


They are usually not *very* unstable.  That is, solve(crossprod())
potentially loses about twice as many digits to rounding error as Doug's
proposals. In many cases this is not that serious -- if you have 15 digits
accuracy then losing 2 instead of 1 (or even 8 instead of 4) of them may
not be a big deal.  Back in the days of single precision this was more
obviously important and you would get visible differences between
statistical packages based on their linear algebra routines. (There was a
notorious econometric data set that caused problems in single precision
with the solve(crossprod()) approach but was fine with QR decomposition).

On the other hand, even with double precision in extreme situations the
harm can be noticeable, and the cost of working with QR or Cholesky
decompositions instead is fairly small (and often negative -- with larger
matrices you would probably see the cholesky-based method being faster)

In linear regression the problem happens with collinearity, or when one
variable has much smaller variance than another.  In both of these cases
the eigenvalues of the information matrix are of very different sizes. The
ratio of the smallest to the largest eigenvalue is called the condition
number, and the tolerance in solve() is based on condition numbers.

So how bad is the error? For any matrix M there exists some vector b and
error e in b so that the relative error in solve(M,b+e) compared to
solve(M,b) is the condition number of the matrix M times the relative
error in b.  This means that condition numbers greater than 10^7 (and
finding these in package examples is what prompted Doug's message) can
amplify numerical error ten million times.  This is starting to get
undesirable even when you have 15 digits to work with.

Working with very ill-conditioned matrices is possible, but it requires
care in tracking and bounding errors, and if I wanted to do that I'd be in
applied math, not biostatistics.  That's why a simple fix that reduces
condition numbers from, say, 10^10 to 10^5 really is worthwhile,
especially for software that will be used by other people who don't
understand its internals.


-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Partial least squares.

2003-10-31 Thread Carlos J. Gil Bellosta
Dear R-helpers,

I am looking, quite unsuccesfully, for a number of functions/packages.

Firstly, I am interested in a package for partial least squares. I have 
found that there seemed to exist a package called pls, but which seems 
not to run any more with modern versions of R. I have not been able to 
find certain chemometrics package I found some people discussing about 
in this list some time ago and that, it seems, included these kind of 
functions.

Secondly, I have not been able to find a function equivalent to the 
SAS procedure STEPDISC which performs a step process (only available for 
lm and glm on R) on linear discriminant analysis (lda on R).

Does anybody know of a top-the-shelf answer to these questions?

Carlos J. Gil Bellosta
Sigma Consultores Estadísticos
http://www.consultoresestadisticos.com
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Partial least squares.

2003-10-31 Thread Liaw, Andy
The package `pls.pcr' has NIPALS and SIMPLS.  There's also gpls in
BioConductor 1.3.

Andy

 -Original Message-
 From: Carlos J. Gil Bellosta 
 [mailto:[EMAIL PROTECTED] 
 Sent: Friday, October 31, 2003 8:02 PM
 To: [EMAIL PROTECTED]
 Subject: [R] Partial least squares.
 
 
 Dear R-helpers,
 
 I am looking, quite unsuccesfully, for a number of functions/packages.
 
 Firstly, I am interested in a package for partial least 
 squares. I have 
 found that there seemed to exist a package called pls, but 
 which seems 
 not to run any more with modern versions of R. I have not 
 been able to 
 find certain chemometrics package I found some people 
 discussing about 
 in this list some time ago and that, it seems, included these kind of 
 functions.
 
 Secondly, I have not been able to find a function equivalent to the 
 SAS procedure STEPDISC which performs a step process (only 
 available for 
 lm and glm on R) on linear discriminant analysis (lda on R).
 
 Does anybody know of a top-the-shelf answer to these questions?
 
 Carlos J. Gil Bellosta
 Sigma Consultores Estadísticos http://www.consultoresestadisticos.com
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] html glitches with help?

2003-10-31 Thread Ross Boylan
Looking at the html generated help pages for a package I'm working on, I
noticed a couple of things that looked a little funny.  I suspect they
are general features of the html for R (I don't usually look at it).

First is a problem of vertical alignment in tables. The first column
consistently aligned vertically *below* the alignment line of the bottom
line of the second column.  This was a problem even when both columns
were a single line; it was worse when they were multiple lines.

In slightly exagerated form, the output looked like this:

   long discussion of what paramater pp does
   and its wonderful features
pp

Likely at least two separate issues: why is it aligning with the last,
rather than the first, line of the second column, and why is it below
that?

It may be relevant that the first column was in \code{a} and the whole
thing was in an \arguments{\item{foo}{\tabular{ll} section.

Second, the items marked with \code{} appeared fainter than the other
text, and were a little hard to read.  I'd expect them to be bolder.

Perhaps the R.css style sheet could be tweaked for this?
R 1.7.1-1 on Debian GNU/Linux
Viewed with Mozilla 1.4
Konqueror from KDE 3.1.3 looked very similar, except the typeface for
\code was identical to that of the rest.

Sample excerpt from the .Rd file:

\value{returns a list:
  \item{singles}{data frame, one row per simulation, with the following
columns:
\tabular{ll}{
  coefficients \tab one column per variable\cr

  \code{pi1} \tab conditional probability of sampling cases \cr

Similar behavior in \arguments section.  It is the pi1 above, for
example, that is aligned poorly.  Alignment of the outer level \item's
is better (in fact, the opposite problem, their baseline is above the
baseline of the first line of the second column, though their tops are
not much higher).

-- 
Ross Boylan  wk:  (415) 502-4031
530 Parnassus Avenue (Library) rm 115-4  [EMAIL PROTECTED]
Dept of Epidemiology and Biostatistics   fax: (415) 476-9856
University of California, San Francisco
San Francisco, CA 94143-0840 hm:  (415) 550-1062

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Question about the high dimensional density estimation

2003-10-31 Thread hungy
Hi,
I found that the R package KernSmooth can deal with only 1D and 2D data. But now I 
have a collection of 4-dimensional data (x1,x2,x3,x4) and would like to estimate the 
mode of the underlying density. What can I do about it ?
Thanks a lot.


--
Ying-Chao Hung
Assistant Professor
Graduate Institute of Statistics
National Central University
Chung-Li, Taiwan
TEL: 886-3-426-7219
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Therotical basis of Kriging

2003-10-31 Thread temiz
hello

I want to know about therotical basis of Kriging in elemantary level.
I will appreciate if anyone sends me address,link,e-documents, etc..
kind regards
--
Ahmet Temiz
General Directory of Disaster Affairs
Ankara TURKEY
__
Inflex - installed on mailserver for domain @deprem.gov.tr
Queries to: [EMAIL PROTECTED]
__
The views and opinions expressed in this e-mail message are ...{{dropped}}
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Re: [STATSGRASS] Therotical basis of Kriging

2003-10-31 Thread Massimiliano Cannata
Hello,
here is a link about kriging, I think is clear enough to understand it.

http://www.geomatics.ucalgary.ca/~nel-shei/DTMLectureNotes/ENGO%20573%20-%20Chapter%203%20Kriging%20and%20variograms.doc

Bye

temiz wrote:

 hello

 I want to know about therotical basis of Kriging in elemantary level.
 I will appreciate if anyone sends me address,link,e-documents, etc..

 kind regards
 --

 Ahmet Temiz
 General Directory of Disaster Affairs
 Ankara TURKEY

 __
 Inflex - installed on mailserver for domain @deprem.gov.tr
 Queries to: [EMAIL PROTECTED]

 __
 The views and opinions expressed in this e-mail message are the sender's own
 and do not necessarily represent the views and the opinions of Earthquake Research 
 Dept.
 of General Directorate of Disaster Affairs.

 Bu e-postadaki fikir ve gorusler gonderenin sahsina ait olup, yasal olarak T.C.
 B.I.B. Afet Isleri Gn.Mud. Deprem Arastirma Dairesi'ni baglayici nitelikte degildir.

 ___
 statsgrass mailing list
 [EMAIL PROTECTED]
 http://grass.itc.it/mailman/listinfo/statsgrass

--
-
note: change my e-mail reference to [EMAIL PROTECTED]
  because the old one will be deleted soon.
-
Ing.  Massimiliano Cannata
Istituto di Scienze della Terra - SUPSI
C.P. 72 - CH-6952 Canobbio (Ticino, Switzerland)
Tel +41 91 /935 12 25 - Fax +41 91 /935 12 09
eMail: [EMAIL PROTECTED]
Internet: http://www.ist.supsi.ch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help