Re: [R] cor() function, method=spearman

2005-10-08 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

 Hello,
 
 Does anyone know if the cor function, when method = spearman, returns a 
 correlation coefficient corrected for any ties in the ranks of the data?  I 
 have data with quite a few ties and am thinking that I should use a 
 calculation of the coefficient corrected for ties, but before I try and code 
 this calculation myself, I thought I should check whether or not cor() 
 automatically does this.
 
 Thank you!
 Joanna McGarvie

The tie-corrected spearman correlation is the correlation of the
tie-corrected ranks, so yes, it does do that. 

Previous versions of R had an issue with p-values in cor.test, where
it used the exact distribution of the test for non-tied data, even
when ties were present. This was straightened out in 2.2.0, where it
now uses an asymptotic formula instead.

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

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


Re: [R] Converting PROC NLMIXED code to NLME

2005-10-08 Thread Peter Dalgaard
Singh, Jatinder [EMAIL PROTECTED] writes:

 Hi,
 
 I am trying to convert the following NLMIXED code to NLME, but am
 running into problems concerning 'Singularity in backsolve'. As I am new
 to R/S-Plus, I thought I may be missing something in the NLME code.

Which version of R and NLME? R 2.2.0 ships with a version where the
internal optimizer is changed to nlminb(). As I understand it, this
was in response to reports where code that worked in S-PLUS refused to
work in R.

 
 NLMIXED
 ***
 proc nlmixed data=kidney.kidney;
 parms delta=0.03 gamma=1.1 b1=-0.003 b2=-1.2 b3=0.09 b4=0.35 b5=-1.43
 varu=0.5;
 eta=b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u;
 hazard=eta+log(delta)+log(gamma)+(gamma-1)*log(rtime);
 survivor=(-exp(eta))*delta*(rtime**gamma);
 ll=(event*hazard)+survivor;
 model rtime ~ general(ll);
 random u~normal(0,varu) subject=patient out=frailty;
 run;
 
 NLME
 
 kidney.nlme-nlme(model=rtime~
 (event*
 ((b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u)+log(delta)+log(gamma)+(gamma-1)*lo
 g(rtime))
 +((-exp(b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u))*delta*(rtime**gamma))
 ),
 fixed=list(delta~1,gamma~1,b1~1,b2~1,b3~1,b4~1,b5~1),
 random=u~1|patient,
 start=c(delta=0.03,gamma=1.1,b1=-0.003,b2=-1.2,b3=0.09,b4=0.35,b5=-1.43)
 ,
 data=(kidney),
 method=ML,
 na.action=na.include
 )
 
 Error in NLME
 *
  traceback()
 11: eval(action, sys.parent())
 10: doErrorAction(Problem in .C(\fit_nlme\,: Singularity in
 backsolve, 1000)
 9: .C(fit_nlme,
 8: nlme(model = rtime ~ (event * ((b1 * age + b2 * sex + b3 * gn + b4 *
 an + b5 *
 7: NULL
 6: nlme.formula(model = rtime ~ (event * ((b1 * age + b2 * sex + b3 * gn
 + b4 *
 5: eval(i, local)
 4: source(auto.print = auto.print, exprs = substitute(exprs.literal))
 3: script.run(exprs.literal = {
 2: eval(expression(script.run(exprs.literal = {
 1: 
 Message: Problem in .C(fit_nlme,: Singularity in backsolve 
 
 I am actually trying to fit a parametric model to the kidney catheter
 data and compare NLMIXED with NLME. I am aware that COXPH and SURVREG
 are also available with a frailty element added in, but wanted to fit
 the likelihood model as above for a direct comparison.
 
 Cheers,
 
 Jindi
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

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

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


Re: [R] missing values in step procedure

2005-10-08 Thread Bernardo Rangel Tura
At 11:11 7/10/2005, you wrote:

Hi,
I have the problem that for the step procedure stops due to missing
values. There are no options in Step or stepAIC to handle missing
values. Is there any way to run stepwise modelselection in R in an
automated way in this case?

Here is the last step before it stops. Hope someone knows. Best regards,
Andreas

Step:  AIC= 1999.16
  EF ~ SF120_KS + SF120_PS + HADA0 + SOZU0 + LVEDD + logPROBNP +
 ALTER + SD0_01 + ASE_UK + DS140POS + RSQSICH0 + SD0_01:ASE_UK +
 SD0_01:DS140POS + SD0_01:RSQSICH0 + ASE_UK:DS140POS +
ASE_UK:RSQSICH0 +
 DS140POS:RSQSICH0 + SD0_01:ASE_UK:RSQSICH0 +
SD0_01:DS140POS:RSQSICH0 +
 ASE_UK:DS140POS:RSQSICH0

Df Sum of Sq RSS AIC
- SOZU0 1   3.0 25356.0  1997.2
- HADA0 1   7.6 25360.6  1997.3
- ALTER 1  13.0 25365.9  1997.4
- SF120_PS  1  14.7 25367.6  1997.5
- ASE_UK:DS140POS:RSQSICH0  1  20.1 25373.1  1997.6
- SD0_01:DS140POS:RSQSICH0  1  44.8 25397.7  1998.0
- SD0_01:ASE_UK:RSQSICH01  54.4 25407.4  1998.2
none  25352.9  1999.2
- LVEDD 1 382.2 25735.1  2004.6
- SF120_KS  1 476.4 25829.3  2006.4
- logPROBNP 1 891.9 26244.9  2014.4
Error in step(mod2, direction = back) :
 number of rows in use has changed: remove missing values?

Andreas

Try

data-na.omit(original database) before you run step() or stepAIC()




Bernardo Rangel Tura, MD, MSc
National Institute of Cardiology Laranjeiras
Rio de Janeiro Brazil  


--

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


Re: [R] Converting PROC NLMIXED code to NLME

2005-10-08 Thread Bernardo Rangel Tura
At 20:40 7/10/2005, Singh, Jatinder wrote:
NLME

kidney.nlme-nlme(model=rtime~
(event*
((b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u)+log(delta)+log(gamma)+(gamma-1)*lo
g(rtime))
+((-exp(b1*age+b2*sex+b3*gn+b4*an+b5*pkn+u))*delta*(rtime**gamma))
),
fixed=list(delta~1,gamma~1,b1~1,b2~1,b3~1,b4~1,b5~1),
random=u~1|patient,
start=c(delta=0.03,gamma=1.1,b1=-0.003,b2=-1.2,b3=0.09,b4=0.35,b5=-1.43)
,
data=(kidney),
method=ML,
na.action=na.include
)

Hi!

Try change na.action=na.include for na.action=na.omit

The singularity occurs because the fixed effects matrix is not of full rank 
due to the unused factor levels.




Bernardo Rangel Tura, MD, MSc
National Institute of Cardiology Laranjeiras
Rio de Janeiro Brazil 


--

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


[R] color for points

2005-10-08 Thread Sam R. Smith
Hi,
I have the following code to 
randomly generate the 
points:
csr -function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())
 
I wonder how to code to make the first twenty points to be BLUE; second twenty 
points to be RED; the last twenty points to be GREEN?
 
Thanks,
Sam
 





-

[[alternative HTML version deleted]]

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


Re: [R] Assign references

2005-10-08 Thread Patrick Burns
[EMAIL PROTECTED] wrote:

Patrick,

I'll have to check your S poetry, it's not clear why 'changing things
invisibly' is a bad thing in R, but is OK in C.  Perhaps the answer lies
therein.
  


I think Tony's reply has the main part of the answer.  R is
designed as a functional language -- meaning, essentially,
that side effects don't happen except for assignment.  The
- operator (and 'assign') are compromises from that
ideal. 

In C it is standard practice to pass by reference and that is
a great deal of its power.  In R it is standard practice not to
have to worry about objects being changed behind your
back -- that freedom is a part of the power of R.

On the surface this looks contradictory -- one of the two
approaches must be the better way.  But the two languages
have different uses.  C computes extremely efficiently in terms
of having operations that closely match the machine.  R computes
efficiently by having operations that closely match how people
think.

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

I'd considered returning a sequence, but it seems more straight forward
to be able to pass the arguments by reference.  The difficulty in doing
this in R points to a philosophical point which thus far has eluded me.
Certainly more thinking is in order.

Thanks for your help on this,
cur

--
Curt Seeliger, Data Ranger
CSC, EPA/WED contractor
541/754-4638
[EMAIL PROTECTED]

Patrick Burns [EMAIL PROTECTED] wrote on 10/07/2005 01:23:07
PM:

  

Because the function is using 'foo' and 'bar' as the global
variables, not 'x' and 'y'.  What you might have missed from
Thomas's statement (if I can take some liberties) is that you
almost surely don't want to do that -- it is bad style because
it changes things invisibly.  S Poetry has more on that.

Better is:

myFunk - function(a, b) {
x - a + b
y - a * b
list(x=x, y=y)
}

xy - myFunk(4, 5)
x - xy$x
y - xy$y


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

[EMAIL PROTECTED] wrote:



Folks,

I've run into trouble while writing functions that I hope will create
and modify a dataframe or two.  To that end I've written a toy
  

function
  

that simply sets a couple of variables (well, tries but fails).
Searching the archives, Thomas Lumley recently explained the -
operator, showing that it was necessary for x and y to exist prior to
the function call, but I haven't the faintest why this isn't working:



  

myFunk-function(a,b,foo,bar) {foo-a+b; bar-a*b;}
x-0; y-0;
myFunk(4,5,x,y)
x-0; y-0;
myFunk(4,5,x,y)
x




[1] 0


  

y




[1] 0

What (no doubt simple) reason is there for x and y not changing?

Thank you,
cur
--
Curt Seeliger, Data Ranger
CSC, EPA/WED contractor
541/754-4638
[EMAIL PROTECTED]

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

http://www.R-project.org/posting-guide.html
  




  





  


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


[R] square and points on the same figure

2005-10-08 Thread Sam R. Smith
Hi,
I have the following code to 
randomly generate the 
points:
csr -function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())

I wonder how to code to draw a square centering on 0.5,0.5; with the length of 
each side to be 0.3 on the same figure with these plotted points?

Thanks,
Sam





-

[[alternative HTML version deleted]]

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


Re: [R] color for points

2005-10-08 Thread vincent
Sam R. Smith a écrit :

 Hi,
 I have the following code to randomly generate the points:
 csr -function(n=60){
 x=runif(n)
 y=runif(n)
 f=cbind(x,y)
 }
 plot(csr())
  
 I wonder how to code to make the first twenty points to be BLUE; second 
 twenty points to be RED; the last twenty points to be GREEN?

mynewfct = function(n=60)
{
x=runif(n)
y=runif(n)
f=cbind(x,y)
plot(f[1:20] , col='blue');
par(new=T);
plot(f[21:40] , col='red');
par(new=T);
plot(f[41:60] , col='green');
}

hih

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


Re: [R] R version 2.01.1, Crimson Editor and the one from nowhere

2005-10-08 Thread Philippe Grosjean
Hello Olivier,

The problem prob ably comes from TpR.exe. It first sends Alt-w 1 before 
the command, to make sure the console is the active window. You should 
try to switch R in SDI mode, which is definitely the best mode for 
running R side-by-side with a text editor. Tell me if it solves the problem.
Best,

Philippe Grosjean

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

Olivier ETERRADOSSI wrote:
 Dear List
 sorry to bother you R-gurus with such an unstatistical question... but 
 I face a problem using Crimson Editor with R 2.01.1 that I never had 
 using R 2.00.1.
 I already posted on the Crimson Editor forum but it seems to be VERY few 
 R-users there
 
 I successfully used R v2.00.1until now (under Windows XP professionnal, 
 version 2002, Service Pack 2, P4 processor CPU 1.8 GHz), together with 
 Crimson Editor.
 This editor is linked to R using three files (TpR.exe, R.SPC and R.KEYS).
 I recently upgraded to R 2.01.1.
 I kept using my old TpR.exe, R.SPC and R.KEYS, because I did not find 
 any new files on the Crimson Editor Release web page.
 When I now launch a script, instead of getting my old, well known prompt :
   source(C:/Program Files/R/fooscript.txt)
 I get :
   1source(C:/Program Files/R/fooscript.txt)
 with a 1 in front of the line and of course R  greets me with a 
 syntax error message.
 Then I have to remove the 1 by hand (pretty prehistoric, ...and does 
 not work if  my script is meant to launch other scripts during the 
 night)
 I cannot figure where this 1 comes from !!
 Did some of you already encountered this problem, and how did you get 
 rid of it ?
 Thanks a lot, have a nice week-end. Olivier


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


Re: [R] square and points on the same figure

2005-10-08 Thread vincent
?rect
(and don't forget par(new=T))
hih

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


Re: [R] R version 2.01.1, Crimson Editor and the one from nowhere

2005-10-08 Thread Philippe Grosjean
... OK, I have spot the problem: TpR.exe expects RGui running in 
English. Shortcut for the Windows menu is Alt-w, which is what it sends 
to R. Then, it sends 1, meaning, activate first window (the console). 
You have probably RGui running in French, or in another language. In 
French the menu is called Fenêtres, with the corresponding shortcut 
being Alt-n. Consequently, the menu is not triggered and the 1 is send 
to the command line.

Two solutions to continue using TpR.exe with R 2.1.1 or more:
1) Switch R in SDI mode,
2) Use RGui in MDI mode, but in English.

The third solution is to patch TpR.exe, which I will not do, because I 
need to program a separate command for each different language of R!
Best,

Philippe Grosjean

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

Olivier ETERRADOSSI wrote:
 Dear List
 sorry to bother you R-gurus with such an unstatistical question... but 
 I face a problem using Crimson Editor with R 2.01.1 that I never had 
 using R 2.00.1.
 I already posted on the Crimson Editor forum but it seems to be VERY few 
 R-users there
 
 I successfully used R v2.00.1until now (under Windows XP professionnal, 
 version 2002, Service Pack 2, P4 processor CPU 1.8 GHz), together with 
 Crimson Editor.
 This editor is linked to R using three files (TpR.exe, R.SPC and R.KEYS).
 I recently upgraded to R 2.01.1.
 I kept using my old TpR.exe, R.SPC and R.KEYS, because I did not find 
 any new files on the Crimson Editor Release web page.
 When I now launch a script, instead of getting my old, well known prompt :
   source(C:/Program Files/R/fooscript.txt)
 I get :
   1source(C:/Program Files/R/fooscript.txt)
 with a 1 in front of the line and of course R  greets me with a 
 syntax error message.
 Then I have to remove the 1 by hand (pretty prehistoric, ...and does 
 not work if  my script is meant to launch other scripts during the 
 night)
 I cannot figure where this 1 comes from !!
 Did some of you already encountered this problem, and how did you get 
 rid of it ?
 Thanks a lot, have a nice week-end. Olivier


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


[R] keeping interaction terms

2005-10-08 Thread Christian Jones


Hello,?xml:namespace prefix = o ns = urn:schemas-microsoft-com:office:office 
/o:p/o:p

while doing my thesis in habitat modelling I´ve come across a problem with 
interaction terms. My question concerns the usage of interaction terms for 
linear regression modelling with R. If an interaction-term (predictor) is 
chosen for a multiple model, then, according to ?xml:namespace prefix = st1 ns 
= urn:schemas-microsoft-com:office:smarttags /st1:place 
w:st=onCrawley/st1:place its single term has to be added to the multiple 
model: lrm(N~a*b+a+b).o:p/o:p

This nearly always leads to high correlation rates between the interaction term 
a*b and its single term a or b. With regards to the law of colinearity 
modelling should not include correlated variables with an Spearman index 0,7. 
Does this mean that the interaction term has to be discarded or can the 
variables stay within the model when correlated? I do not necessarily want to 
do a PCA on this issue.o:p/o:p

Thanks for helpingo:p/o:p

Christiano:p/o:p



Verschicken Sie romantische, coole und witzige Bilder per SMS! 
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193 


[[alternative HTML version deleted]]

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

[R] square and points on the same figure

2005-10-08 Thread Sam R. Smith
Hi,
I have the following code to 
randomly generate the 
points:
csr -function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())

I wonder how to code to draw a square centering on 0.5,0.5; with the length of 
each side to be 0.3 on the same figure with these plotted points?

Thanks,
Sam



-

[[alternative HTML version deleted]]

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


Re: [R] color for points

2005-10-08 Thread jim holtman
If you know explicitly that there are just 60 points, you can use:
 plot(csr(),col=c(rep('blue',20), rep('red',20), rep('green',20)))


 On 10/8/05, Sam R. Smith [EMAIL PROTECTED] wrote:

 Hi,
 I have the following code to
 randomly generate the
 points:
 csr -function(n=60){
 x=runif(n)
 y=runif(n)
 f=cbind(x,y)
 }
 plot(csr())

 I wonder how to code to make the first twenty points to be BLUE; second
 twenty points to be RED; the last twenty points to be GREEN?

 Thanks,
 Sam






 -

 [[alternative HTML version deleted]]

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




--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] square and points on the same figure

2005-10-08 Thread Chuck Cleland
Sam R. Smith wrote:
 Hi,
 I have the following code to 
 randomly generate the 
 points:
 csr -function(n=60){
 x=runif(n)
 y=runif(n)
 f=cbind(x,y)
 }
 plot(csr())
 
 I wonder how to code to draw a square centering on 0.5,0.5; with the length 
 of each side to be 0.3 on the same figure with these plotted points?

?symbols

symbols(x=0.5, y=0.5, squares=c(0.3), add=TRUE)

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

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

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


Re: [R] square and points on the same figure

2005-10-08 Thread Sam R. Smith
after typing
symbols(x=0.5, y=0.5, squares=c(0.3), add=TRUE)
it works.
I want to add one more using different length such as
symbols(x=0.5, y=0.5, squares=c(0.15), add=TRUE)
but this square did not show.

Chuck Cleland [EMAIL PROTECTED] wrote:
Sam R. Smith wrote:
 Hi,
 I have the following code to 
 randomly generate the 
 points:
 csr -function(n=60){
 x=runif(n)
 y=runif(n)
 f=cbind(x,y)
 }
 plot(csr())
 
 I wonder how to code to draw a square centering on 0.5,0.5; with the length 
 of each side to be 0.3 on the same figure with these plotted points?

?symbols

symbols(x=0.5, y=0.5, squares=c(0.3), add=TRUE)

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

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894



-

[[alternative HTML version deleted]]

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


Re: [R] square and points on the same figure

2005-10-08 Thread Chuck Cleland
Sam R. Smith wrote:
 after typing
 symbols(x=0.5, y=0.5, squares=c(0.3), add=TRUE)
 it works.
 I want to add one more using different length such as
 symbols(x=0.5, y=0.5, squares=c(0.15), add=TRUE)
 but this square did not show.

Specify both (all) squares in the same call to symbols:

csr -function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())

symbols(x=c(0.5, 0.5), y=c(0.5, 0.5), squares=c(0.30,0.15), add=TRUE)

 Chuck Cleland [EMAIL PROTECTED] wrote:
 Sam R. Smith wrote:
 
Hi,
I have the following code to 
randomly generate the 
points:
csr -function(n=60){
x=runif(n)
y=runif(n)
f=cbind(x,y)
}
plot(csr())

I wonder how to code to draw a square centering on 0.5,0.5; with the length 
of each side to be 0.3 on the same figure with these plotted points?
 
 
 ?symbols
 
 symbols(x=0.5, y=0.5, squares=c(0.3), add=TRUE)
 
 
Thanks,
Sam



-

[[alternative HTML version deleted]]

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

 
 


-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

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


[R] Two-factor ANOVA Help

2005-10-08 Thread Jim Brindle
Hello,

I am trying to perform a two-factor ANOVA analysis using a blocking design with 
Vol as the response variable.  My intent is to have Rater treated as the 
treatment variable and the Pipe treated as the blocking variable.  I am 
reading and preparing my dataset using the following three lines of code:

values - read.table(filename, header=TRUE)
attach(values)
values = data.frame(values)

The dataset is the following:

Pipe Rater Volume 
1A   5.129
1B   5.296
1C   4.679
1D   4.776
2A   8.519
2B   8.482
2C   7.659
2D   7.798 
3A   13.769
3B   14.621
3C   12.418
3D   13.189

Below there are 2 versions which I've used to run my analysis.  

Option #1:

g - lm(Volume ~ factor(Rater) + factor(Pipe), values)
print(anova(g))

Option #2: 

Rater - as.factor(Rater)
Pipe - as.factor(Pipe)  
g - lm(Volume ~ Rater + Pipe, values)
print(anova(g)) 


A couple of questions I have are:

1.  I thought that option #1 and option #2 would have given me the same results 
and they don't appear to.  The only difference (to me) is how I have specified 
the factors used in the model.  However, there appears to be something else I 
am missing and I was just wondering if anyone has any insight as to which is 
the correct way to code this analysis?  

2.  Unless otherwise specified is there a particular reference level that R 
uses by default - for example in this case, the second treatment level (Rater 
B)?   

3.  Is there a good reference someone can point me to for more insight on the 
two-factor ANOVA analysis with R?


Thank you kindly in advance,
Jim
[[alternative HTML version deleted]]

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


Re: [R] keeping interaction terms

2005-10-08 Thread Frank E Harrell Jr
Your note is formatted strangely.  You seem to be using Microsoft - 
please tell your software to send plain text e-mails - Microsoft doesn't 
own plain ASCII text format, at least not yet (have they applied for a 
patent for it?).


Christian Jones wrote:
 
 Hello,?xml:namespace prefix = o ns = 
 urn:schemas-microsoft-com:office:office /o:p/o:p
 
 while doing my thesis in habitat modelling I´ve come across a problem with 
 interaction terms. My question concerns the usage of interaction terms for 
 linear regression modelling with R. If an interaction-term (predictor) is 
 chosen for a multiple model, then, according to ?xml:namespace prefix = st1 
 ns = urn:schemas-microsoft-com:office:smarttags /st1:place 
 w:st=onCrawley/st1:place its single term has to be added to the multiple 
 model: lrm(N~a*b+a+b).o:p/o:p
 
 This nearly always leads to high correlation rates between the interaction 
 term a*b and its single term a or b. With regards to the law of colinearity 
 modelling should not include correlated variables with an Spearman index 
 0,7. Does this mean that the interaction term has to be discarded or can the 
 variables stay within the model when correlated? I do not necessarily want to 
 do a PCA on this issue.o:p/o:p
 
 Thanks for helpingo:p/o:p
 
 Christiano:p/o:p

Your query opens up many issues.  First, the statement that a main 
effect has to be added if an interaction term is chosen assumes that an 
interaction has meaning without adjustment for main effects.  This is 
not the case.  The hierarchy principle needs to be executed in a forward 
manner.  Second, you are implying that you are not fitting a single 
pre-specified model but are doing variable selection based on p-values. 
  This creates a host of problems.  Third, you imply that correlations 
between main effects and interactions are not to be tolerated.  Again 
this is not the case.  It is a fact of life that we must accomodate. 
[Some people like to center main effects to reduce this correlation but 
that is an artificial and not helpful approach.]

Frank


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

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


[R] obfuscated identity

2005-10-08 Thread Martin Maechler
 Globe == Globe Trotter [EMAIL PROTECTED]
 on Fri, 7 Oct 2005 16:39:10 -0700 (PDT) writes:

  .

Globe I use this Yahoo! e-mail address as a junk e-mail
Globe address since the archives contain the complete
Globe e-mail address (no anti-spam measures taken) so I do
Globe not include my real name.

  [there are many different archives and some do some anti-spam measures..
   to strip or obfuscate e-mail addresses before mail is sent
   out, is really not an option!]

Globe It would be nice if the R-archivers stripped e-mail
Globe addresses from posters (or messed it up) so that
Globe spider programs would not be able to get it.

  (yes, but *all* of them would have to do it; and do it so
   smartly that smart address collecting software cannot
   regenerate it; ... )

Globe Many thanks and best wishes, GT

and you still don't tell us who you are!

Bert's remark was very much on point:  Using a yahoo or gmail or
... e-mail address is one thing; but then we'd expect at least a
full name (and often affiliation) as signature.
It not only netiquette, it's real life etiquette to not send
anonymous letters

Martin Maechler, ETH Zurich

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


[R] Warning: condition has length 1

2005-10-08 Thread nawaf b
Hi -

I was wondering if anyone came across a problem such as mine! I was trying
to create a user-defined function, however, the results from calling the
function are unexpected!

When passing X parameter as a single value variable (x-c(3)), everything
works fine. However, when passing a parameter as a vector with multiple
values (as the case in my code), the 'if condition' is only executed once!

Here is my code:
 x
[1]  0.3  1.0  0.7 22.0
 myfunction-function(x)
+ {
+ if (x=1) 0
+ else x^2
+ }
 myfunction(x)
[1]   0.09   1.00   0.49 484.00
Warning message:
the condition has length  1 and only the first element will be used in: if
(x = 1) 0 else x^2 


Is there a way to overcome this issue? Can you please explain what
modifications to the code I need to accommodate to make it work.

Thanks,

Nawaf

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


Re: [R] keeping interaction terms

2005-10-08 Thread Ted Harding
Adding a bit to Frank Harrell's good comments.

1. Regarding HTML infection: I rolled up my sleeves, washed
   my hands carefully, took a fine sharp knife, cut it all
   out, and then sowed up the incisions.

2. For the rest, see below.

On 08-Oct-05 Christian Jones wrote:
 Hello,
 
 while doing my thesis in habitat modelling I´ve come across a
 problem with interaction terms. My question concerns the usage
 of interaction terms for linear regression modelling with R.
 If an interaction-term (predictor) is chosen for a multiple model,
 then, according to Crawley its single term has to be added to the
 multiple model: lrm(N~a*b+a+b).
 
 This nearly always leads to high correlation rates between the
 interaction term a*b and its single term a or b. With regards to
 the law of colinearity modelling should not include correlated
 variables with an Spearman index 0,7. Does this mean that the
 interaction term has to be discarded or can the variables stay
 within the model when correlated?
 I do not necessarily want to do a PCA on this issue.

There's more than a suggestion in your statements that you tend
to be drawn along by people's prescriptions. Instead, try to
think simply about it.

If, after fitting a+b, you make a significant difference by
further including a:b, then the interaction between a and b
matters, even if you observe high correlations. The latter should
not lead you to ignore the former.

How much it matters is of course another question. You could
examine this, in R, by comparing the predicted values from the
a+b model with the predicted values from the a*b model.
Though they will be different, you will have to judge whether
the amount of difference is large enough to be of real importance
in your application. (It is possible to get highly significant
results, i.e. small P-values, from small effects).

Even if it does matter, in real terms, you are left with the
fundamental difficulty, indicated by Frank, that interpreting
interaction between variables a and b is simple only when the
variables a and b are orthogonal in the data (either by accident
or by design). If they are non-orthogonal, then you have to
think carefully about how to interpret it, and this does depend
on what it all means.

Maybe we could help more with this if we knew more about your
investigation (perhaps off-list, if you prefer).

Best wishes,
Ted.



E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 08-Oct-05   Time: 14:14:48
-- XFMail --

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


Re: [R] Warning: condition has length 1

2005-10-08 Thread Chuck Cleland
nawaf b wrote:
 Hi -
 
 I was wondering if anyone came across a problem such as mine! I was trying
 to create a user-defined function, however, the results from calling the
 function are unexpected!
 
 When passing X parameter as a single value variable (x-c(3)), everything
 works fine. However, when passing a parameter as a vector with multiple
 values (as the case in my code), the 'if condition' is only executed once!
 
 Here is my code:
 
x
 
 [1]  0.3  1.0  0.7 22.0
 
myfunction-function(x)
 
 + {
 + if (x=1) 0
 + else x^2
 + }

?ifelse

myfunction - function(x){ifelse(x = 1, 0, x^2)}

  myfunction(c(.3, 1, .7, 22))
[1] 0.09 0.00 0.49 0.00

myfunction(x)
 
 [1]   0.09   1.00   0.49 484.00
 Warning message:
 the condition has length  1 and only the first element will be used in: if
 (x = 1) 0 else x^2 
 
 
 Is there a way to overcome this issue? Can you please explain what
 modifications to the code I need to accommodate to make it work.
 
 Thanks,
 
 Nawaf
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

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


Re: [R] Warning: condition has length 1

2005-10-08 Thread Gabor Grothendieck
ifelse(x = 1, 0, x^2)

or

(x = 1) * x^2

Also, you might need x  (1 - e) where e is some small number since your
numbers may not be exact.



On 10/8/05, nawaf b [EMAIL PROTECTED] wrote:
 Hi -

 I was wondering if anyone came across a problem such as mine! I was trying
 to create a user-defined function, however, the results from calling the
 function are unexpected!

 When passing X parameter as a single value variable (x-c(3)), everything
 works fine. However, when passing a parameter as a vector with multiple
 values (as the case in my code), the 'if condition' is only executed once!

 Here is my code:
  x
 [1]  0.3  1.0  0.7 22.0
  myfunction-function(x)
 + {
 + if (x=1) 0
 + else x^2
 + }
  myfunction(x)
 [1]   0.09   1.00   0.49 484.00
 Warning message:
 the condition has length  1 and only the first element will be used in: if
 (x = 1) 0 else x^2
 

 Is there a way to overcome this issue? Can you please explain what
 modifications to the code I need to accommodate to make it work.

 Thanks,

 Nawaf

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


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


Re: [R] Warning: condition has length 1

2005-10-08 Thread Roger Bivand
On Sat, 8 Oct 2005, nawaf b wrote:

 Hi -
 
 I was wondering if anyone came across a problem such as mine! I was trying
 to create a user-defined function, however, the results from calling the
 function are unexpected!
 
 When passing X parameter as a single value variable (x-c(3)), everything
 works fine. However, when passing a parameter as a vector with multiple
 values (as the case in my code), the 'if condition' is only executed once!
 
 Here is my code:
  x
 [1]  0.3  1.0  0.7 22.0
  myfunction-function(x)
 + {
 + if (x=1) 0
 + else x^2
 + }
  myfunction(x)
 [1]   0.09   1.00   0.49 484.00
 Warning message:
 the condition has length  1 and only the first element will be used in: if
 (x = 1) 0 else x^2 
 
 
 Is there a way to overcome this issue? Can you please explain what
 modifications to the code I need to accommodate to make it work.

 myfunction-function(x)
+ ifelse(x=1, 0, x^2)
 x - c(0.3, 1.0, 0.7, 22.0)
 myfunction(x)
[1] 0.09 0.00 0.49 0.00

ifelse() is vectorised, but if() only looks at the first element in x 
before deciding what to do - so if the condition is longer, the rest gets 
ignored.

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

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

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


Re: [R] Warning: condition has length 1

2005-10-08 Thread Gabor Grothendieck
On 10/8/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 ifelse(x = 1, 0, x^2)

 or

 (x = 1) * x^2

Sorry, that should have been (x  1) * x^2


 Also, you might need x  (1 - e) where e is some small number since your
 numbers may not be exact.



 On 10/8/05, nawaf b [EMAIL PROTECTED] wrote:
  Hi -
 
  I was wondering if anyone came across a problem such as mine! I was trying
  to create a user-defined function, however, the results from calling the
  function are unexpected!
 
  When passing X parameter as a single value variable (x-c(3)), everything
  works fine. However, when passing a parameter as a vector with multiple
  values (as the case in my code), the 'if condition' is only executed once!
 
  Here is my code:
   x
  [1]  0.3  1.0  0.7 22.0
   myfunction-function(x)
  + {
  + if (x=1) 0
  + else x^2
  + }
   myfunction(x)
  [1]   0.09   1.00   0.49 484.00
  Warning message:
  the condition has length  1 and only the first element will be used in: if
  (x = 1) 0 else x^2
  
 
  Is there a way to overcome this issue? Can you please explain what
  modifications to the code I need to accommodate to make it work.
 
  Thanks,
 
  Nawaf
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
 


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


[R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Denis Chabot
Hi,

A few times I tried to control the number and position of tick marks  
in plots with the yasp or xasp parameters. For example, a y axis was  
drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to  
get tick marks every 10 by adding

yasp=(0, 100, 10)

but this had no effect at all. I know I can draw the axis and tick  
marks manually, but often this simple option would suffice if I could  
understand how to make it work.

Thanks in advance,

Denis Chabot

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


Re: [R] Two-factor ANOVA Help

2005-10-08 Thread Gabor Grothendieck
On 10/8/05, Jim Brindle [EMAIL PROTECTED] wrote:
 Hello,

 I am trying to perform a two-factor ANOVA analysis using a blocking design 
 with Vol as the response variable.  My intent is to have Rater treated as 
 the treatment variable and the Pipe treated as the blocking variable.  I am 
 reading and preparing my dataset using the following three lines of code:

 values - read.table(filename, header=TRUE)
 attach(values)
 values = data.frame(values)

 The dataset is the following:

 Pipe Rater Volume
 1A   5.129
 1B   5.296
 1C   4.679
 1D   4.776
 2A   8.519
 2B   8.482
 2C   7.659
 2D   7.798
 3A   13.769
 3B   14.621
 3C   12.418
 3D   13.189

 Below there are 2 versions which I've used to run my analysis.

 Option #1:

 g - lm(Volume ~ factor(Rater) + factor(Pipe), values)
 print(anova(g))

 Option #2:

 Rater - as.factor(Rater)
 Pipe - as.factor(Pipe)
 g - lm(Volume ~ Rater + Pipe, values)
 print(anova(g))


 A couple of questions I have are:

 1.  I thought that option #1 and option #2 would have given me the same 
 results and they don't appear to.  The only difference (to me) is how I have 
 specified the factors used in the model.  However, there appears to be 
 something else I am missing and I was just wondering if anyone has any 
 insight as to which is the correct way to code this analysis?

Note that values, as returned from read.table, is already a data frame
and Rater is already a factor so you only need to convert Pipe to a
factor:

values - read.table(filename.dat, header = TRUE)

# shows classes of columns among other things
# note that Rater is already a factor and values is already a data frame
str(g)

# convert Pipe to a factor
values$Pipe - factor(values$Pipe)
g - lm(Volume ~., values)
g


 2.  Unless otherwise specified is there a particular reference level that R 
 uses by default - for example in this case, the second treatment level (Rater 
 B)?

By default R uses treatment contrasts and uses the first level as the baseline.
You can change this using contrasts and contr.treatment.

 e.g. To use treatment effects on Pipe with level 2 as the baseline:

contrasts(values$Pipe) - contr.treatment(3, base = 2)
g2 - lm(Volume ~., values)
g2


 3.  Is there a good reference someone can point me to for more insight on the 
 two-factor ANOVA analysis with R?


See ?read.table, ?contrasts, ?contr.treatment

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


Re: [R] Two-factor ANOVA Help

2005-10-08 Thread Gabor Grothendieck
On 10/8/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 On 10/8/05, Jim Brindle [EMAIL PROTECTED] wrote:
  Hello,
 
  I am trying to perform a two-factor ANOVA analysis using a blocking design 
  with Vol as the response variable.  My intent is to have Rater treated 
  as the treatment variable and the Pipe treated as the blocking variable.  
  I am reading and preparing my dataset using the following three lines of 
  code:
 
  values - read.table(filename, header=TRUE)
  attach(values)
  values = data.frame(values)
 
  The dataset is the following:
 
  Pipe Rater Volume
  1A   5.129
  1B   5.296
  1C   4.679
  1D   4.776
  2A   8.519
  2B   8.482
  2C   7.659
  2D   7.798
  3A   13.769
  3B   14.621
  3C   12.418
  3D   13.189
 
  Below there are 2 versions which I've used to run my analysis.
 
  Option #1:
 
  g - lm(Volume ~ factor(Rater) + factor(Pipe), values)
  print(anova(g))
 
  Option #2:
 
  Rater - as.factor(Rater)
  Pipe - as.factor(Pipe)
  g - lm(Volume ~ Rater + Pipe, values)
  print(anova(g))
 
 
  A couple of questions I have are:
 
  1.  I thought that option #1 and option #2 would have given me the same 
  results and they don't appear to.  The only difference (to me) is how I 
  have specified the factors used in the model.  However, there appears to be 
  something else I am missing and I was just wondering if anyone has any 
  insight as to which is the correct way to code this analysis?

 Note that values, as returned from read.table, is already a data frame
 and Rater is already a factor so you only need to convert Pipe to a
 factor:

 values - read.table(filename.dat, header = TRUE)

 # shows classes of columns among other things
 # note that Rater is already a factor and values is already a data frame
 str(g)

 # convert Pipe to a factor
 values$Pipe - factor(values$Pipe)
 g - lm(Volume ~., values)
 g

 
  2.  Unless otherwise specified is there a particular reference level that R 
  uses by default - for example in this case, the second treatment level 
  (Rater B)?

 By default R uses treatment contrasts and uses the first level as the 
 baseline.
 You can change this using contrasts and contr.treatment.

  e.g. To use treatment effects on Pipe with level 2 as the baseline:

 contrasts(values$Pipe) - contr.treatment(3, base = 2)
 g2 - lm(Volume ~., values)
 g2

 
  3.  Is there a good reference someone can point me to for more insight on 
  the two-factor ANOVA analysis with R?
 

 See ?read.table, ?contrasts, ?contr.treatment


One more point.  In your #2 the second argument to lm is specified
as values so that's where lm will look for the variables.  The Rater
and Pipe defined immediately above that line will never be found since
those variables will already have been found in the values data frame.

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Marc Schwartz
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
 Hi,
 
 A few times I tried to control the number and position of tick marks  
 in plots with the yasp or xasp parameters. For example, a y axis was  
 drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to  
 get tick marks every 10 by adding
 
 yasp=(0, 100, 10)
 
 but this had no effect at all. I know I can draw the axis and tick  
 marks manually, but often this simple option would suffice if I could  
 understand how to make it work.
 
 Thanks in advance,
 
 Denis Chabot


I suspect that one problem you are having is that there is no
par(xasp) or par(yasp)unless these are typos and you are trying
to use par(xaxp) and par(yaxp)?

There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.

par(xaxp) and par(yaxp) are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the user
settings during the calculation of the axes, whether passed as arguments
to a plot function or set a priori via a par() call.

If you want explicit control over the tick marks, you will need to use
axis(), perhaps in combination with axTicks(), after using 'xaxt = n'
and/or 'yaxt = n' in the plot call, depending upon the circumstances.

HTH,

Marc Schwartz

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


Re: [R] Matrix calculations in R--erroneous?

2005-10-08 Thread Peter Muhlberger

Hi Spencer:  Thanks!  This gives me a number of other ways of thinking about
this problem.  My one concern is that these approaches would also run into
some difficulties with how long it takes to calculate.  I'm interested not
in a single value but a matrix of over 300k values that has to be recomputed
more than a million times.  If I had to apply ifelse or floor to each of
these, it might take too long.  I'll have to see.

Peter

On 10/7/05 5:55 PM, Spencer Graves [EMAIL PROTECTED] wrote:

  Rather than adding 1e-15 to all numbers, I suggest you simply make
 that the floor.  (Or use .Machine$double.eps or 2*.Machine$double.eps in
 place of 1e-15.)
 
  Another alternative that may or may not apply in your case is to
 develop an asymptotic expansion for the log(likelihood) for the small
 numbers.  I've had good success with this kind of method.  For example,
 consider the Box-Cox transformation:
 
  bc(y, b) = (y^b-1)/b
 
  What do we do with b = 0?  We can test for b = 0 and replace those
 cases by the limit log(y).  However, it is numerically more stable to
 use the following:
 
  bc(y, b) = ifelse(abs(b*log(y)).Machine$double.eps,
 (expm1(b*log(y))/b, log(y)).
 
  I don't have time to study your example to see if I could see
 anything like this that could be done, but I think there should be a
 good chance of finding something like this.  Of course, if there are
 only very few 0's, then it hardly matters.  However, if there are quite
 a few, then you need something like this.
 
  hope this helps.
  spencer graves

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


[R] add leading 0s to %d from png() {was Automatic creation of file names}

2005-10-08 Thread bogdan romocea
Dear useRs,

Is there a way to 'properly' format %d when plotting more than one
page on png()? 'Properly' means to me with leading 0s, so that the
PNGs become easy to navigate in a file/image browser. Lacking a better
solution I ended up using the code below, but would much prefer
something like
   png(test_%d.png,bg=white,width=1000,height=700)
where %d could be formatted like
   formatC(%d,digits=0,wid=3,flag=0,mode=integer)

Thank you,
b.

#---works, but is rather complicated---
pngno - 0 ; i - 1
for (w in 1:53) {
  if (i %in% c(4*0:100+1)) {
pngno - pngno + 1
png(paste(test_,formatC(pngno,digits=0,wid=4,flag=0,mode=integer),
  .png,sep=),bg=white,width=1000,height=750)
par(mfrow=c(2,2),mai=c(4,5,3,2)/10,omi=c(0.2,0,0,0),
  cex.axis=1,cex.main=1.2)
}
  plot(1:10,main=w)
  if (i %in% c(4*1:100)) dev.off()
  i - i+1
  }
dev.off()


From: Mike Prager Mike.Prager at noaa.gov
Subject: Re: [R] Automatic creation of file names
Newsgroups: gmane.comp.lang.r.general
Date: 2005-09-22 14:51:54 GMT (2 weeks, 1 day, 23 hours and 55 minutes ago)

Walter --

P.S.  The advantage of using formatC over pasting the digits (1:1000)
directly is that when one uses leading zeroes, as in the formatC example
shown, the resulting filenames will sort into proper order.

...MHP

You can use paste() with something like

 formatC(number,digits=0,wid=3,flag=0)

(where number is your loop index) to generate the filenames.

on 9/22/2005 10:21 AM Leite,Walter said the following:

I have a question about how to save to the hard drive the one thousand
datasets I generated in a simulation. ://www.R-project.org/posting-guide.html

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


[R] request

2005-10-08 Thread nmi13
Dear All,

Can someone please tell me if there is a provision in R to fit a random 
coefficient multinomial logistic regression.

Thanks in advance for your help and suggestions.

Regards
Murthy.N.M

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Prof Brian Ripley
On Sat, 8 Oct 2005, Marc Schwartz wrote:

 On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
 Hi,

 A few times I tried to control the number and position of tick marks
 in plots with the yasp or xasp parameters. For example, a y axis was
 drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to
 get tick marks every 10 by adding

 yasp=(0, 100, 10)

 but this had no effect at all. I know I can draw the axis and tick
 marks manually, but often this simple option would suffice if I could
 understand how to make it work.

 Thanks in advance,

 Denis Chabot


 I suspect that one problem you are having is that there is no
 par(xasp) or par(yasp)unless these are typos and you are trying
 to use par(xaxp) and par(yaxp)?

In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is needed.

 There is an 'asp' argument to some of the plot functions (ie.
 plot.default), but this has a different intention.

 par(xaxp) and par(yaxp) are not listed as read only pars in ?par,
 however, I cannot recall an instance where R does not overwrite the user
 settings during the calculation of the axes, whether passed as arguments
 to a plot function or set a priori via a par() call.

Really?  Try

 plot(1:100, xaxt=n)
 par(xaxp=c(0, 50, 5))  # the value is reset at each plot
 axis(1)

for how it works (but not inline, which is probably a bug).

 If you want explicit control over the tick marks, you will need to use
 axis(), perhaps in combination with axTicks(), after using 'xaxt = n'
 and/or 'yaxt = n' in the plot call, depending upon the circumstances.

That is usually as easy.

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

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


Re: [R] add leading 0s to %d from png() {was Automatic creation of file names}

2005-10-08 Thread Prof Brian Ripley
The example on the png help page, Rplot%03d.png, _is_ what you want.
(More details are on ?postscript.)

formatC() is an S/R peculiarity: sprintf() is the cross-language way to do 
this sort of thing.

On Sat, 8 Oct 2005, bogdan romocea wrote:

 Dear useRs,

 Is there a way to 'properly' format %d when plotting more than one
 page on png()? 'Properly' means to me with leading 0s, so that the
 PNGs become easy to navigate in a file/image browser. Lacking a better
 solution I ended up using the code below, but would much prefer
 something like
   png(test_%d.png,bg=white,width=1000,height=700)
 where %d could be formatted like
   formatC(%d,digits=0,wid=3,flag=0,mode=integer)

 Thank you,
 b.

 #---works, but is rather complicated---
 pngno - 0 ; i - 1
 for (w in 1:53) {
  if (i %in% c(4*0:100+1)) {
pngno - pngno + 1
png(paste(test_,formatC(pngno,digits=0,wid=4,flag=0,mode=integer),
  .png,sep=),bg=white,width=1000,height=750)
par(mfrow=c(2,2),mai=c(4,5,3,2)/10,omi=c(0.2,0,0,0),
  cex.axis=1,cex.main=1.2)
}
  plot(1:10,main=w)
  if (i %in% c(4*1:100)) dev.off()
  i - i+1
  }
 dev.off()


 From: Mike Prager Mike.Prager at noaa.gov
 Subject: Re: [R] Automatic creation of file names
 Newsgroups: gmane.comp.lang.r.general
 Date: 2005-09-22 14:51:54 GMT (2 weeks, 1 day, 23 hours and 55 minutes ago)

 Walter --

 P.S.  The advantage of using formatC over pasting the digits (1:1000)
 directly is that when one uses leading zeroes, as in the formatC example
 shown, the resulting filenames will sort into proper order.

 ...MHP

 You can use paste() with something like

 formatC(number,digits=0,wid=3,flag=0)

 (where number is your loop index) to generate the filenames.

 on 9/22/2005 10:21 AM Leite,Walter said the following:

 I have a question about how to save to the hard drive the one thousand
 datasets I generated in a simulation. 
 ://www.R-project.org/posting-guide.html

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


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

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Peter Dalgaard
Denis Chabot [EMAIL PROTECTED] writes:

 Oops, Mark, bad typo indeed.
 
 But yaxp is what I had in my R program and it did not help.
 
 I did obtain control over my tick marks by drawing them myself, as  
 you suggest. But I was curious as to how to use yaxp since the help  
 on par gives it as a possible way of controlling ticks. Maybe it  
 should be removed from the help file?

plot(1)
par(xaxp)
par(xaxp=c(.6,1.4,8))
axis(3)

So it does do something...

 
 Thanks for your help,
 
 Denis
 Le 05-10-08 à 11:16, Marc Schwartz a écrit :
 
  On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
 
  Hi,
 
  A few times I tried to control the number and position of tick marks
  in plots with the yasp or xasp parameters. For example, a y axis was
  drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to
  get tick marks every 10 by adding
 
  yasp=(0, 100, 10)
 
  but this had no effect at all. I know I can draw the axis and tick
  marks manually, but often this simple option would suffice if I could
  understand how to make it work.
 
  Thanks in advance,
 
  Denis Chabot
 
 
 
  I suspect that one problem you are having is that there is no
  par(xasp) or par(yasp)unless these are typos and you are  
  trying
  to use par(xaxp) and par(yaxp)?
 
  There is an 'asp' argument to some of the plot functions (ie.
  plot.default), but this has a different intention.
 
  par(xaxp) and par(yaxp) are not listed as read only pars in ?par,
  however, I cannot recall an instance where R does not overwrite the  
  user
  settings during the calculation of the axes, whether passed as  
  arguments
  to a plot function or set a priori via a par() call.
 
  If you want explicit control over the tick marks, you will need to use
  axis(), perhaps in combination with axTicks(), after using 'xaxt =  
  n'
  and/or 'yaxt = n' in the plot call, depending upon the  
  circumstances.
 
  HTH,
 
  Marc Schwartz
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

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

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Marc Schwartz
On Sat, 2005-10-08 at 16:37 +0100, Prof Brian Ripley wrote:
 On Sat, 8 Oct 2005, Marc Schwartz wrote:
 
  On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
  Hi,
 
  A few times I tried to control the number and position of tick marks
  in plots with the yasp or xasp parameters. For example, a y axis was
  drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to
  get tick marks every 10 by adding
 
  yasp=(0, 100, 10)
 
  but this had no effect at all. I know I can draw the axis and tick
  marks manually, but often this simple option would suffice if I could
  understand how to make it work.
 
  Thanks in advance,
 
  Denis Chabot
 
 
  I suspect that one problem you are having is that there is no
  par(xasp) or par(yasp)unless these are typos and you are trying
  to use par(xaxp) and par(yaxp)?
 
 In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is needed.

Indeed.

  There is an 'asp' argument to some of the plot functions (ie.
  plot.default), but this has a different intention.
 
  par(xaxp) and par(yaxp) are not listed as read only pars in ?par,
  however, I cannot recall an instance where R does not overwrite the user
  settings during the calculation of the axes, whether passed as arguments
  to a plot function or set a priori via a par() call.
 
 Really?  Try
 
  plot(1:100, xaxt=n)
  par(xaxp=c(0, 50, 5))  # the value is reset at each plot
  axis(1)
 
 for how it works (but not inline, which is probably a bug).

AhI had not thought about that 'par'ticular combination...  ;-)

Hence, not R.O.  So it must be used _after_ a plot call, which makes
sense.

I had reached for my copy of Paul's book and on page 96 (last paragraph
in section 3.4.5 on Axes), he suggests using the approach I elucidate
below with axTicks(). I thought he might have some other ideas and that
I was missing something. This is also referenced on page 70, third
paragraph in section 3.2.5 on Axes.

  If you want explicit control over the tick marks, you will need to use
  axis(), perhaps in combination with axTicks(), after using 'xaxt = n'
  and/or 'yaxt = n' in the plot call, depending upon the circumstances.
 
 That is usually as easy.

Agreed.

Thanks,

Marc

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


[R] Rpart -- using predict() when missing data is present?

2005-10-08 Thread Ajay Narottam Shah
I am doing

 library(rpart)
 m - rpart(y ~ x, D[insample,])
 D[outsample,]
y   x
8  0.78391922 0.579025591
9  0.06629211  NA
10 NA 0.001593063
   p - predict(m, newdata=D[9,])
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  : 
invalid result from na.action

How do I persuade him to give me NA since x is NA?

I looked at ?predict.rpart but didn't find any mention about NAs.

(In this problem, I can easily do it manually, but this is a part of
something bigger where I want him to be able to gracefully handle
prediction requests involving NA).

-- 
Ajay Shah   Consultant
[EMAIL PROTECTED]  Department of Economic Affairs
http://www.mayin.org/ajayshah   Ministry of Finance, New Delhi

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Denis Chabot
Hi, sorry about the bad syntax, though the right syntax would not  
have worked either, according to your tests (Mark, Brian, Peter).

Anyway it is too finicky, I will draw them myself. For instance,

plot(1:100, xaxt=n)
par(xaxp=c(0, 100, 10))  # the value is reset at each plot
axis(1)

Placed tick marks at intervals at 0, 10, ..., 100, as expected, but  
did not place a label under 100...

Thanks for the answers, usufull as always,

Denis


Le 05-10-08 à 11:58, Marc Schwartz a écrit :

 On Sat, 2005-10-08 at 16:37 +0100, Prof Brian Ripley wrote:

 On Sat, 8 Oct 2005, Marc Schwartz wrote:


 On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:

 Hi,

 A few times I tried to control the number and position of tick  
 marks
 in plots with the yasp or xasp parameters. For example, a y axis  
 was
 drawn by default with tick marks at 0, 20, 40, 80 and 100. I  
 tried to
 get tick marks every 10 by adding

 yasp=(0, 100, 10)

 but this had no effect at all. I know I can draw the axis and tick
 marks manually, but often this simple option would suffice if I  
 could
 understand how to make it work.

 Thanks in advance,

 Denis Chabot



 I suspect that one problem you are having is that there is no
 par(xasp) or par(yasp)unless these are typos and you are  
 trying
 to use par(xaxp) and par(yaxp)?


 In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is  
 needed.


 Indeed.


 There is an 'asp' argument to some of the plot functions (ie.
 plot.default), but this has a different intention.

 par(xaxp) and par(yaxp) are not listed as read only pars in ? 
 par,
 however, I cannot recall an instance where R does not overwrite  
 the user
 settings during the calculation of the axes, whether passed as  
 arguments
 to a plot function or set a priori via a par() call.


 Really?  Try


 plot(1:100, xaxt=n)
 par(xaxp=c(0, 50, 5))  # the value is reset at each plot
 axis(1)


 for how it works (but not inline, which is probably a bug).


 AhI had not thought about that 'par'ticular combination...  ;-)

 Hence, not R.O.  So it must be used _after_ a plot call, which makes
 sense.

 I had reached for my copy of Paul's book and on page 96 (last  
 paragraph
 in section 3.4.5 on Axes), he suggests using the approach I elucidate
 below with axTicks(). I thought he might have some other ideas and  
 that
 I was missing something. This is also referenced on page 70, third
 paragraph in section 3.2.5 on Axes.


 If you want explicit control over the tick marks, you will need  
 to use
 axis(), perhaps in combination with axTicks(), after using 'xaxt  
 = n'
 and/or 'yaxt = n' in the plot call, depending upon the  
 circumstances.


 That is usually as easy.


 Agreed.

 Thanks,

 Marc




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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Prof Brian Ripley
On Sat, 8 Oct 2005, Denis Chabot wrote:

 Hi, sorry about the bad syntax, though the right syntax would not have worked 
 either, according to your tests (Mark, Brian, Peter).

It DOES work according to my tests!  (Do give us the credit for testing 
our advice:  we would appreciate your showing equal care.)

 Anyway it is too finicky, I will draw them myself. For instance,

 plot(1:100, xaxt=n)
 par(xaxp=c(0, 100, 10))  # the value is reset at each plot
 axis(1)

 Placed tick marks at intervals at 0, 10, ..., 100, as expected, but did not 
 place a label under 100...

Does for me (2.2.0, Windows and X11 on Linux).  Might the text be clipped 
on your unnamed device, so you need to set xpd?  (If so, it will be 
clipped however you try to do this, and is an unrelated local problem.)

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

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


Re: [R] how to control ticks in plots with yasp or xasp

2005-10-08 Thread Denis Chabot
Hi Brian,
Le 05-10-08 à 13:21, Prof Brian Ripley a écrit :

 On Sat, 8 Oct 2005, Denis Chabot wrote:


 Hi, sorry about the bad syntax, though the right syntax would not  
 have worked either, according to your tests (Mark, Brian, Peter).


 It DOES work according to my tests!  (Do give us the credit for  
 testing our advice:  we would appreciate your showing equal care.)

I am very sorry, I did not express myself properly. I do appreciate  
your help, and I did take the time to test your solution. What I  
meant was that even if I had use the proper syntax, i.e. yaxp=c 
(10,100,10) instead of y=(10,100,10) [actually in my program I had  
used it but I was careless when I composed the message], it would not  
have worked because you demonstrated that it has to be used within a  
par statement, which I had not done. Therefore my attempt was  
doomed. I did not mean there was no way to make yaxp work, so I  
apologize if you think I take your advice lightly, and I cannot state  
strongly enough that it is not the case at all.


 Anyway it is too finicky, I will draw them myself. For instance,

 plot(1:100, xaxt=n)
 par(xaxp=c(0, 100, 10))  # the value is reset at each plot
 axis(1)

 Placed tick marks at intervals at 0, 10, ..., 100, as expected,  
 but did not place a label under 100...


 Does for me (2.2.0, Windows and X11 on Linux).  Might the text be  
 clipped on your unnamed device, so you need to set xpd?  (If so, it  
 will be clipped however you try to do this, and is an unrelated  
 local problem.)


This is strange.

I work on Mac OS X, so the default device is quartz. Label 100 is  
shown without clipping if plot without changing xaxp. But just in  
case I made more space at the right of the graph with

par(mai=c(0.7, 0.7, 0.5, 0.5))
plot(1:100, xaxt=n)
par(xaxp=c(0, 100, 10))  # the value is reset at each plot
axis(1)

and the 100 does not appear. If I run this again:
plot(1:100, xaxt=n)
axis(1)

I'm back with R's default axis and the 100 is present. Anyone on a  
Mac wants to try?

Denis


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


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


Re: [R] Rpart -- using predict() when missing data is present?

2005-10-08 Thread Prof Brian Ripley
On Sat, 8 Oct 2005, Ajay Narottam Shah wrote:

 I am doing

 library(rpart)
 m - rpart(y ~ x, D[insample,])
 D[outsample,]
y   x
 8  0.78391922 0.579025591
 9  0.06629211  NA
 10 NA 0.001593063
   p - predict(m, newdata=D[9,])
 Error in model.frame(formula, rownames, variables, varnames, extras, 
 extranames,  :
   invalid result from na.action

 How do I persuade him to give me NA since x is NA?

I think the point is to do something sensible!  One x prediction problems 
are not what rpart is designed to do, and the default na.action (na.rpart) 
fails in that case.  (The author forgot drop=F.)

 I looked at ?predict.rpart but didn't find any mention about NAs.

How about ?rpart ?  That does.

 (In this problem, I can easily do it manually, but this is a part of
 something bigger where I want him to be able to gracefully handle
 prediction requests involving NA).

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

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


Re: [R] quasi-random vector according to an independent graph

2005-10-08 Thread Jinfang Wang
Hi



I was waiting for more advices and prepared to summarize to reduce the mail 
traffic. I got two answers (I realize that my explanation was definitely 
insufficient).



Thanks Reid  Spencer ! The link http://www.r-project.org/gR/ was helpful, 
although it does not directly answer my question.



I think I have got some idea to do what I want. When I have a more or less 
satisfactory solution I will report to the list to share (if I think it is 
worthwhile).



Jinfang Wang







- Original Message - 
From: Huntsinger, Reid [EMAIL PROTECTED]
To: 'Spencer Graves' [EMAIL PROTECTED]; Jinfang Wang 
[EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Friday, September 30, 2005 2:00 AM
Subject: RE: [R] quasi-random vector according to an independent graph


 Might the graphical models in R packages be of interest?
 http://www.r-project.org/gR/

 Reid Huntsinger

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Spencer Graves
 Sent: Thursday, September 29, 2005 11:43 AM
 To: Jinfang Wang
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] quasi-random vector according to an independent graph


   Are you still interested in a reply to this post?  I have not seen

 any.  If you are, it might help if you were more specific, e.g.,
 following the posting guide www.R-project.org/posting-guide.html.  I'm
 not certain what you mean by a joint distribution defined by an
 independent graph, and my efforts using RSiteSearch exposed several
 things that might be useful but none that seemed to me to be obvious
 answers to your question.

   Sorry I could not be more helpful.
   spencer graves

 Jinfang Wang wrote:

 Dear R-users,

 Is anyone aware of any function/package for generating a random vector
 from
 a joint distribution defined by an independent graph? Or I have to work 
 it

 out myself?

 Thanks.

 Jinfang

 --
 Jinfang Wang, Associate Professor
 Chiba University, Japan

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

 -- 
 Spencer Graves, PhD
 Senior Development Engineer
 PDF Solutions, Inc.
 333 West San Carlos Street Suite 700
 San Jose, CA 95110, USA

 [EMAIL PROTECTED]
 www.pdf.com http://www.pdf.com
 Tel:  408-938-4420
 Fax: 408-280-7915

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



 --
 Notice:  This e-mail message, together with any attachment...{{dropped}}

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


Re: [R] quasi-random vector according to an independent graph

2005-10-08 Thread Spencer Graves
Hi, Jihfang:

  Definitely, please report to the list when you think you have a more
or less satisfactory solution.  The archives are searchable, and your
comments might help someone else.  They might also provoke useful
suggestions of other things you might try that might provide even better
solutions.

  Also, if you get stuck in the process, please report to the list your
progress and where you are stuck.

  Good Luck,
  spencer graves

Jinfang Wang wrote:
 Hi
 
 
 
 I was waiting for more advices and prepared to summarize to reduce the 
 mail traffic. I got two answers (I realize that my explanation was 
 definitely insufficient).
 
 
 
 Thanks Reid  Spencer ! The link http://www.r-project.org/gR/ was 
 helpful, although it does not directly answer my question.
 
 
 
 I think I have got some idea to do what I want. When I have a more or 
 less satisfactory solution I will report to the list to share (if I 
 think it is worthwhile).
 
 
 
 Jinfang Wang
 
 
 
 
 
 
 
 - Original Message - From: Huntsinger, Reid 
 [EMAIL PROTECTED]
 To: 'Spencer Graves' [EMAIL PROTECTED]; Jinfang Wang 
 [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Friday, September 30, 2005 2:00 AM
 Subject: RE: [R] quasi-random vector according to an independent graph
 
 
 Might the graphical models in R packages be of interest?
 http://www.r-project.org/gR/

 Reid Huntsinger

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Spencer Graves
 Sent: Thursday, September 29, 2005 11:43 AM
 To: Jinfang Wang
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] quasi-random vector according to an independent graph


   Are you still interested in a reply to this post?  I have not seen

 any.  If you are, it might help if you were more specific, e.g.,
 following the posting guide www.R-project.org/posting-guide.html.  I'm
 not certain what you mean by a joint distribution defined by an
 independent graph, and my efforts using RSiteSearch exposed several
 things that might be useful but none that seemed to me to be obvious
 answers to your question.

   Sorry I could not be more helpful.
   spencer graves

 Jinfang Wang wrote:

 Dear R-users,

 Is anyone aware of any function/package for generating a random vector

 from

 a joint distribution defined by an independent graph? Or I have to 
 work it


 out myself?

 Thanks.

 Jinfang

 --
 Jinfang Wang, Associate Professor
 Chiba University, Japan

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

 http://www.R-project.org/posting-guide.html

 -- 
 Spencer Graves, PhD
 Senior Development Engineer
 PDF Solutions, Inc.
 333 West San Carlos Street Suite 700
 San Jose, CA 95110, USA

 [EMAIL PROTECTED]
 www.pdf.com http://www.pdf.com
 Tel:  408-938-4420
 Fax: 408-280-7915

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



 --
  

 Notice:  This e-mail message, together with any attachments, contains 
 information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station, 
 New Jersey, USA 08889), and/or its affiliates (which may be known 
 outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD 
 and in Japan, as Banyu) that may be confidential, proprietary 
 copyrighted and/or legally privileged. It is intended solely for the 
 use of the individual or entity named on this message.  If you are not 
 the intended recipient, and have received this message in error, 
 please notify us immediately by reply e-mail and then delete it from 
 your system.
 --
  



 
 

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

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


[R] lm.ridge

2005-10-08 Thread Erin Hodgess
Dear R People:

I have a question about the lm.ridge function, please.

In the example, there is one set of output values in the select
function but another in the comment section.

Am I missing something please?


R Version 2.1.1 Windows

Thanks,
Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

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


Re: [R] Warning: condition has length 1

2005-10-08 Thread sosman
nawaf b wrote:
 Hi -
 
 I was wondering if anyone came across a problem such as mine! I was trying
 to create a user-defined function, however, the results from calling the
 function are unexpected!
 
 When passing X parameter as a single value variable (x-c(3)), everything
 works fine. However, when passing a parameter as a vector with multiple
 values (as the case in my code), the 'if condition' is only executed once!
 
 Here is my code:
 
x
 
 [1]  0.3  1.0  0.7 22.0
 
myfunction-function(x)
 
 + {
 + if (x=1) 0
 + else x^2
 + }
 
myfunction(x)
 
 [1]   0.09   1.00   0.49 484.00
 Warning message:
 the condition has length  1 and only the first element will be used in: if
 (x = 1) 0 else x^2 
 
 
 Is there a way to overcome this issue? Can you please explain what
 modifications to the code I need to accommodate to make it work.

I am going to go out on a limb here (I don't know much about R) but I'm 
not sure it has anything to do with that fact that you have defined a 
function.

It seems to me that if (x  1) {...} expects a scalar and if x is not 
a scalar, it will use the first value.  To apply your function to each 
element, check out the help for sapply (eg ?sapply).  I am guessing the 
solution is something like sapply(x, myfunction) but don't quote me.

paul sorenson

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


Re: [R] R-2.2.0 compilation problem

2005-10-08 Thread Bill Northcott
On 07/10/2005, at 8:00 PM, Robin Hankin wrote:
 I tried to compile R-2.2.0 just now.  configure worked fine, but
 compilation stopped with



 ld: Undefined symbols:
 restFP
 saveFP
 /usr/bin/libtool: internal link edit command failed
 make[3]: *** [libR.dylib] Error 1
 make[2]: *** [R] Error 2
 make[1]: *** [R] Error 1
 make: *** [R] Error 1
 octopus:~/scratch/R-2.2.0%

This has been written up many times already.  It would be nice if it  
was in the documentation.

g77 can only be used with gcc-3.x and earlier.  The default compiler  
on Tiger is gcc-4.

All you need to do to build with g77 on Tiger is use the command
sudo gcc_select 3.3
which will make gcc-3.3 the default compiler and it will all work.

Bill Northcott

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


Re: [R] Warning: condition has length 1

2005-10-08 Thread Andrew Robinson
ifelse() should work too.

Andrew

On Sun, Oct 09, 2005 at 03:30:42PM +1000, sosman wrote:
 nawaf b wrote:
  Hi -
  
  I was wondering if anyone came across a problem such as mine! I was trying
  to create a user-defined function, however, the results from calling the
  function are unexpected!
  
  When passing X parameter as a single value variable (x-c(3)), everything
  works fine. However, when passing a parameter as a vector with multiple
  values (as the case in my code), the 'if condition' is only executed once!
  
  Here is my code:
  
 x
  
  [1]  0.3  1.0  0.7 22.0
  
 myfunction-function(x)
  
  + {
  + if (x=1) 0
  + else x^2
  + }
  
 myfunction(x)
  
  [1]   0.09   1.00   0.49 484.00
  Warning message:
  the condition has length  1 and only the first element will be used in: if
  (x = 1) 0 else x^2 
  
  
  Is there a way to overcome this issue? Can you please explain what
  modifications to the code I need to accommodate to make it work.
 
 I am going to go out on a limb here (I don't know much about R) but I'm 
 not sure it has anything to do with that fact that you have defined a 
 function.
 
 It seems to me that if (x  1) {...} expects a scalar and if x is not 
 a scalar, it will use the first value.  To apply your function to each 
 element, check out the help for sapply (eg ?sapply).  I am guessing the 
 solution is something like sapply(x, myfunction) but don't quote me.
 
 paul sorenson
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Andrew Robinson
Senior Lecturer in Statistics   Tel: +61-3-8344-9763
Department of Mathematics and StatisticsFax: +61-3-8344-4599
University of Melbourne, VIC 3010 Australia
Email: [EMAIL PROTECTED]Website: http://www.ms.unimelb.edu.au

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