[R] Query regarding modelling using R

2006-07-07 Thread flash johny
Hi,
I am working on project to build a model for analysing Mortgage-backed
securities.
I am doing this as a part of my summer project.
After much thought I have decided on using R for doing this modelling.
One of the steps in this model is making an interest rate model to generate
interest rate paths in time.
My question is..
Is any package available to do the same in R?
or I will have to build a function myself from scratch?

Any kind of help will be appreciated.
Thank You
David Flash.

[[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] Crosstabs

2006-07-07 Thread Bi-Info (http://members.home.nl/bi-info)
Dear Users,

I'm a complete novice to R.

I need to do a crosstabs in R, but my data is almost completely 
alphanumeric (with some variables scaled). The Table routine does not 
seem to accept alphanumeric data. What should I do? Do I need to recode 
it? How should I do that?

Thanks in advance,

Wilfred

__
R-help@stat.math.ethz.ch 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] RMySQL Suse 10.0 installing problems

2006-07-07 Thread Prof Brian Ripley
On Thu, 6 Jul 2006, H. Paul Benton wrote:

 Thanks again everyone,
   I have a problem trying to install RMySQL on Suse 10.0. I have used
 both the install.packages() and the 'R CMD INSTALL RMySQL... neither
 worked. I get the error message telling me that it cannot find mysql. So I
 have set the flags using

 export PKG_CPPFLAGS=-I/usr/bin/
 export PKG_LIBS=-L/usr/lib/mysql

Those cannot be right: you don't want  and -I/usr/bin is not a plausible 
include path.  RPM-based systems normally need

export PKG_CPPFLAGS=-I/usr/include/mysql
export PKG_LIBS=-I/usr/lib/mysql

and if you have /usr/lib/mysql, try

/usr/lib/mysql/mysql_config -cflags

to be sure about the first.


 After that I run R CMD INSTALL RMySQL... it starts to check and it cannot
 find mysql_init, mysql.h then it exits after gcc(ing) with an error code of
 make:*** [RS-DBI.o] Error 1

 I also tried the other way that the help suggested of putting the dir in the
 R CMD INSTALL command but that didn't work either giving me the same help
 menu.

 I am on opensuse 10.0 x86, and yes I su(ed).

 Cheers,

 Research Technician
 Mass Spectrometry
  o The
 /
 o Scripps
 \
  o Research
 /
 o Institute

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

2006-07-07 Thread Prof Brian Ripley
Both format and formatC (and sprintf) use C facilities for scientific 
format.  As far as I know C has no facilities for your desired format, so 
you would need to write your own C code and interface to R.

On Thu, 6 Jul 2006, Walker, Sam wrote:

 Hi,

 How can I format numbers to engineering notation?

 That is, like scientific but where the exponent is always a multiple of
 three.

 Some examples:

 1635 000 000  = 1.635E9
  163 500 000 = 163.5E6
 0.000 000 000 135 = 135E-9

 I've tried format and formatC but I couldn't get them to work they I
 want.

 Any help is greatly appreciated.


 Thanks,
 Sam

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

2006-07-07 Thread Pfaff, Bernhard Dr.
Hello Sachin,

a sequential testing procedure is described in the useR! book:

  @Book{,
title = {Analysis of Integrated and Cointegrated Time Series with R},
author = {B. Pfaff},
publisher = {Springer},
edition = {First},
address = {New York},
year = {2006},
note = {ISBN 0-387-27960-1},
  }

Best,
Bernhard


Dr. Bernhard Pfaff
Global Structured Products Group
(Europe)

Invesco Asset Management Deutschland GmbH
Bleichstrasse 60-62
D-60313 Frankfurt am Main

Tel: +49(0)69 29807 230
Fax: +49(0)69 29807 178
Email: [EMAIL PROTECTED]  

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] Im Auftrag von Sachin J
Gesendet: Donnerstag, 6. Juli 2006 21:49
An: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Betreff: Re: [R] KPSS test

Hi Mark,
   
  Thanx for the help. I will verify my results with PP and DF 
test. Also as suggested I will take a look at the references 
pointed out. One small doubt: How do I decide what terms ( 
trend, constant, seasonality ) to include while using these 
stationarity tests. Any references would be of great help. 
   
  Thanx,
  Sachin
   
  

[EMAIL PROTECTED] wrote:
  From: 
Date: Thu Jul 06 14:17:25 CDT 2006
To: Sachin J 
Subject: Re: [R] KPSS test

sachin : i think your interpretations are right given the data
but kpss is quite a different test than the usual tests
because it assumes that the null is stationarity while dickey 
fuller ( DF ) and phillips perron ( PP ) ) assume that the 
null is a unit root. therefore, you should check whetheer
the conclusions you get from kpss are consistent with what you 
would get from DF or PP. the results often are not consistent.

also, DF depends on what terms ( trend, constant ) 
you used in your estimation of the model. i'm not sure if kpss 
does also. people generally report Dickey fuller results but they
are a little biased towards acepting unit root ( lower
power ) so maybe that's why
you are using KPSS ? Eric Zivot has a nice explanation
of a lot of the of the stationarity tests in his S+Finmetrics 
book.

testing for cyclical variation is pretty complex because
that's basically the same as testing for seasonality.
check ord's or ender's book for relatively simple ways of doing that.













From: Sachin J 
Date: Thu Jul 06 14:17:25 CDT 2006
To: R-help@stat.math.ethz.ch
Subject: [R] KPSS test

Hi,
 
 Am I interpreting the results properly? Are my conclusions correct?
 
  KPSS.test(df)
  
 KPSS test
  
 Null hypotheses: Level stationarity and stationarity around 
a linear trend.
 Alternative hypothesis: Unit root.

 Statistic for the null hypothesis of 
 level stationarity: 1.089 
 Critical values:
 0.10 0.05 0.025 0.01
 0.347 0.463 0.574 0.739

 Statistic for the null hypothesis of 
 trend stationarity: 0.13 
 Critical values:
 0.10 0.05 0.025 0.01
 0.119 0.146 0.176 0.216

 Lag truncation parameter: 1 
 
CONCLUSION: Reject Ho at 0.05 sig level - Level Stationary
 Fail to reject Ho at 0.05 sig level - Trend Stationary 
 
 kpss.test(df,null = c(Trend))
 KPSS Test for Trend Stationarity
 data: tsdata[, 6] 
KPSS Trend = 0.1298, Truncation lag parameter = 1, p-value = 0.07999
 
 CONCLUSION: Fail to reject Ho - Trend Stationary as p-value 
 sig. level (0.05)
 
 kpss.test(df,null = c(Level))
 KPSS Test for Level Stationarity
 data: tsdata[, 6] 
KPSS Level = 1.0891, Truncation lag parameter = 1, p-value = 0.01
 Warning message:
p-value smaller than printed p-value in: kpss.test(tsdata[, 
6], null = c(Level)) 
 
 CONCLUSION: Reject Ho - Level Stationary as p-value  sig. 
level (0.05)
 
 Following is my data set
 
 structure(c(11.08, 7.08, 7.08, 6.08, 6.08, 6.08, 23.08, 32.08, 
8.08, 11.08, 6.08, 13.08, 13.83, 16.83, 19.83, 8.83, 20.83, 17.83, 
9.83, 20.83, 10.83, 12.83, 15.83, 11.83), .Tsp = c(2004, 
2005.917, 
12), class = ts)

 Also how do I test this time series for cyclical varitions? 
 
 Thanks in advance.
 
 Sachin

 
-

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



   
-


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

*
Confidentiality Note: The information contained in this mess...{{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


[R] Polynomial kernel in SVM in e1071 package

2006-07-07 Thread Wuming Gong
Dear list,

In some places (for example,
http://en.wikipedia.org/wiki/Support_vector_machine) , the polynomail
kernel in SVM is written as (u'*v + 1)^d, while in the document of
svm() in e1071 package, the polynomial kernel is written as
(gamma*u'*v + coef0)^d.  I am a little confused here:

When doing parameter optimization (grid search or so) for polynomial
kernel, does it need to tune four parameters, gamma, coef0, C and
degree, or just two of them, C and degree (and fixing gamma to 1 and
coef0 = 1)?

Thanks,

Wuming

__
R-help@stat.math.ethz.ch 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 crash with 'library(Matrix); as(x, dgCMatrix)' ...

2006-07-07 Thread Martin Maechler
 JohnT == Thaden, John J [EMAIL PROTECTED]
 on Thu, 6 Jul 2006 12:29:42 -0500 writes:

JohnT Martin Maechler replied to my query Warning while subsetting...:
MartinM  JohnT == Thaden, John J [EMAIL PROTECTED]
MartinM  on Thu, 6 Jul 2006 00:02:10 -0500 writes:

JohnT ...
JohnT  # While subsetting x, I was surprised to get this warning: 
JohnT  y-x[1:300,]
JohnT Warning message:
JohnT number of items to replace is not a multiple of
JohnT replacement length

MartinM and later

JohnT Sorry, I omitted background information:
JohnT R version: 2.3.0
JohnT OS: Windows XP
JohnT CPU:  Pentium III, 
JohnT RAM:  768 MB

MartinM You omitted the most pertinent information: The 
MartinM version of 'Matrix' you are using.
MartinM The latest released version of Matrix does
MartinM *not* show the behavior you mentioned. {So I have 
MartinM now spent 20 minutes just because you did not 
MartinM update 'Matrix'..}

JohnT The Matrix package was version 0.995-10, now is 0.995-11. 
JohnT The R base was version 2.3.0, now is 2.3.1. 
JohnT Subsetting 'y - x[1:300,]' now works. Please accept my apology.

JohnT Also, what command-line memory settings might prevent
JohnT R from crashing while using the Matrix package to 
JohnT convert my 600 X 4482 dgTMatrix to the dgCMatrix class
JohnT or to an expanded Matrix, via the as() function? I can
JohnT do this with half of the matrix, 300 x 4482.

MartinM It's hard to believe that you get a crash 
MartinM when coercing to 'dgC' -- but of course this 
MartinM really depends how much memory you have already
MartinM goggled up by other large objects in your R
MartinM workspace, or by other applications running at
MartinM the same time in Windows.  Coercing to a full 
MartinM matrix will of course require 8 * 601 * 4482 = 
MartinM 21549456 extra bytes just for the numbers.
MartinM That's only 21.5 Megabytes, so I wonder..
MartinM 
MartinM I have never seen R crashes from using 'Matrix', 

 (actually that's not even true; at some point in time we had a
  bug in 'Matrix' which lead to spurious segmentation faults)

MartinM but then I work with an operating system, not 
MartinM with M$ Windows. 
MartinM 
MartinM Maybe you meant you got an error message 
MartinM ... memory allocation ..?

JohnT Testing again, I closed all applications; disabled antivirus; 
JohnT opened RGui; removed all R objects but 'x' (a 600x4482 dgTMatrix); 
JohnT opened WinXP's 'Task Manager'; saw only Rgui under 
JohnT 'Applications'; saw processes using a total of 287 MB of memory
JohnT under 'Processes'; closed 'Task Manager'; and typed R commands:

 # Steps leading to an R crash...
 ls()
JohnT [1] x
 str(x)
JohnT Formal class 'dgTMatrix' [package Matrix] with 6 slots
JohnT ..@ i   : int [1:923636] 1 2 3 4 5 6 7 8 9 10 ...
JohnT ..@ j   : int [1:923636] 1 1 1 1 1 1 1 1 1 1 ...
JohnT ..@ Dim : int [1:2] 600 4482
JohnT ..@ Dimnames:List of 2
JohnT .. ..$ : chr [1:601] 50 51 52 53 ...
JohnT .. ..$ : chr [1:4482] 1 2 3 4 ...
JohnT ..@ x   : num [1:923636] 50.2 51.2 52.2 53.2 54.2 ...
JohnT ..@ factors : list()
 gc()
JohnT used (Mb) gc trigger (Mb) max used (Mb)
JohnT Ncells  183529  5.0 407500 10.9   35  9.4
JohnT Vcells 1928101 14.82286173 17.5  1928652 14.8
 library(Matrix)
JohnT Loading required package: lattice
 gc()
JohnT used (Mb) gc trigger (Mb) max used (Mb)
JohnT Ncells  627772 16.81073225 28.7  1073225 28.7
JohnT Vcells 2165773 16.63345184 25.6  2332013 17.8
 search()
JohnT [1] .GlobalEnv package:Matrix package:lattice
JohnT [4] package:methods package:stats package:graphics  
JohnT [7] package:grDevices package:utils package:datasets
JohnT [10] Autoloads  package:base 
 #Now the line that causes crashes...
 y - as(x,dgCMatrix)

JohnT After ~10 seconds, R blinks off and a WinXP dialog appears: 

JohnT R for Windows GUI front-end has encountered 
JohnT a problem and needs to close.  We are sorry
JohnT for the inconvenienceError signature:
JohnT AppName: rgui.exe  AppVer: 2.31.38247.0  
JohnT ModName: matrix.dll Offset: ff31
JohnT Report error?

Thanks a lot, John, for the more detailed report.
I do wonder how it happens, since the memory allocation is not
really big.   E.g., I can easily solve ``your'' (well, a
simulated version of it) problem on a machine with only 512 MB
RAM:

  library(Matrix)

  ## MM: construct a matrix *as* John's :
  d - as.integer(c(600,4482))
  n0 - 923636
  set.seed(1)
  M - new(dgTMatrix, Dim = d,
   i = sort(sample(0:(d[1]-1), size = n0, replace = TRUE)),
   j = sample(0:(d[2]-1), size = n0, replace = TRUE),
   x = round(rnorm(n0, m = 50, sd = 10), 1))
  

[R] how to name a variable?

2006-07-07 Thread zhijie zhang
Dear friends,
 The s in the following argument don't have a variable name, how should i
give it a name?
  s-data.frame(seq(1,6,by=2))
 s
  seq.1..6..by...2.
1 1
2 3
3 5

thanks very much!

-- 
Kind Regards,
Zhi Jie,Zhang ,PHD
Department of Epidemiology
School of Public Health
Fudan University
Tel:86-21-54237149

[[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] engineering notation format

2006-07-07 Thread Hans-Joerg Bibiko
Hi,

try this:

formatEng - function(x) {
   s-as.numeric(strsplit(format(x, scientific=T),e)[[1]])
   return(paste(s[1]*10^(s[2]%%3),as.integer(s[2]-(s[2]%%3)),sep=e))
}


 Some examples:

 1635 000 000  = 1.635E9
  163 500 000 = 163.5E6
 0.000 000 000 135 != 135E-9
 0.000 000 000 135 = 125E-12 ?


Hans

**
Hans-Joerg Bibiko
Max Planck Institute for Evolutionary Anthropology
Department of Linguistics
Deutscher Platz 6 phone:   +49 (0) 341 3550 341
D-04103 Leipzig   fax: +49 (0) 341 3550 333
Germany   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] how to name a variable?

2006-07-07 Thread ronggui

s-data.frame(var.name=seq(1,6,by=2))
s

 var.name
11
23
35


2006/7/7, zhijie zhang [EMAIL PROTECTED]:

Dear friends,
 The s in the following argument don't have a variable name, how should i
give it a name?
  s-data.frame(seq(1,6,by=2))
 s
  seq.1..6..by...2.
1 1
2 3
3 5

thanks very much!

--
Kind Regards,
Zhi Jie,Zhang ,PHD
Department of Epidemiology
School of Public Health
Fudan University
Tel:86-21-54237149

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




--
黄荣贵
Department of Sociology
Fudan 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

Re: [R] Start Model for POLYCLASS

2006-07-07 Thread Spencer Graves
  I have not seen a reply, so I will offer a few suggestions, even 
though I've never used the 'polspline' package.  I scanned several of 
the help pages and looked in ~\library\polspline' where R is installed 
on my hard drive and found no further documentation, and I found nothing 
new from RSiteSearch(polyclass).  Googling for 'polyclass' led me to 
http://bear.fhcrc.org/~clk/soft.html;, the home page for Charles 
Kooperberg, the author and maintainer.  If it were my problem, I might 
try writing him directly at the email address given in 
help(package=polyclass);  I'm including him as a cc on this reply.

  I spent time looking at this, because 'polyclass', 'polymars' and 
'polspline' seem potentially related related to one of my secondary 
interests.  Unfortunately, I couldn't find sufficient documentation to 
allow me to proceed with the time I felt I could afford to invest in 
this right now.

  If it were my problem, before I wrote another email about this, I'd 
first list the function 'polyclass', make a local copy, then work 
through an example line by line using 'debug(polyclass)'.  This 'debug' 
facility is remarkably powerful and easy to use.  I've solved many 
problems like this using 'debug' in this way.

  If that failed to provide the necessary enlightenment, I'd submit 
another post including a self-contained example based on a modification 
of the 'iris' example featured in the 'polyclass' help page.  Your 
example is NOT self contained, so I would NOT use that.  Using the 
'iris' example would make it much easier to explain clearly what you 
want.  It also makes it much easier for someone like me to experiment 
with alternatives and describe what I did in terms of a tested example.

  Hope this helps.
p.s.  I suggest you also review the posting guide! 
www.R-project.org/posting-guide.html.

Xiaogang Su wrote:
 Dear all, 
 
 I have a question on how to set up the starting model in POLYCLASS and
 make sure the terms in the starting model retained in the final
 POLYCLASS model. 
 
 In the function POLYMARS, this can be done using the STARTMODEL option.
 See below for example, I started with model 
 y= b0 + b1*X1 + b2*X2 + b3*X4 + b4*X5 + b5*X2*X5 + e
 
 m00 - matrix(c(
  1,  NA, 0, NA, 1, 
  2,  NA, 0, NA, 1, 
  4,  NA, 0, NA, 1, 
  5,  NA, 0, NA, 1,
  2,  NA, 5, NA, 1),nrow = 5, ncol=5, byrow=TRUE);
 
 m2 - polymars(response=PID2$y, predictors=PID2[,1:7], 
 startmodel=m00) 
 summary(m2)  
 
 But I could not figure out how this works for POLYCLASS. There is an
 option FIT in POLYCLASS, which needs to be a POLYCLASS object though. 
 
 Any suggestion or information is greatly appreciated. 
 
 Sincerely,
 Xiaogang Su
 
 
 
 Xiaogang Su,  Assistant Professor
 Department of Statistics and Actuarial Science
 University of Central Florida
 Orlando, FL 32816
 (407) 823-2940 [O]
 [EMAIL PROTECTED]
 http://pegasus.cc.ucf.edu/~xsu/
 
 __
 R-help@stat.math.ethz.ch 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] Query regarding modelling using R

2006-07-07 Thread Dieter Menne
flash johny flash.johny at gmail.com writes:

 
 Hi,
 I am working on project to build a model for analysing Mortgage-backed
 securities.
 I am doing this as a part of my summer project.

Try

http://cran.r-project.org/src/contrib/Views/

Dieter

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

2006-07-07 Thread Uwe Ligges
Bi-Info (http://members.home.nl/bi-info) wrote:
 Dear Users,
 
 I'm a complete novice to R.
 
 I need to do a crosstabs in R, but my data is almost completely 
 alphanumeric (with some variables scaled). The Table routine does not 
 seem to accept alphanumeric data. What should I do? Do I need to recode 
 it? How should I do that?


Works for me:

  table(c(a, a, b), c(a, c, c))

Uwe Ligges


 
 Thanks in advance,
 
 Wilfred
 
 __
 R-help@stat.math.ethz.ch 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] Polynomial kernel in SVM in e1071 package

2006-07-07 Thread Uwe Ligges
Wuming Gong wrote:
 Dear list,
 
 In some places (for example,
 http://en.wikipedia.org/wiki/Support_vector_machine) , the polynomail
 kernel in SVM is written as (u'*v + 1)^d, while in the document of
 svm() in e1071 package, the polynomial kernel is written as
 (gamma*u'*v + coef0)^d.  I am a little confused here:
 
 When doing parameter optimization (grid search or so) for polynomial
 kernel, does it need to tune four parameters, gamma, coef0, C and
 degree, or just two of them, C and degree (and fixing gamma to 1 and
 coef0 = 1)?

All of them, unless you know reasonable values, but that's very improbable.

Uwe Ligges

 
 Thanks,
 
 Wuming
 
 __
 R-help@stat.math.ethz.ch 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] Diverging results with SPSS

2006-07-07 Thread Celso Barros
Dear List,

I apologize in advance if this is silly. I tried to replicate an analysis I
did previously in SPSS using R, and was surprised to find different results.


So my question is: shouldn't the following SPSS syntax


REGRESSION

DEPENDENT INC89

/METHOD=ENTER hiedyrs experien SE93rec.

Yeld the same results of the following R command

modelB-lm(INC89~HIEDYRS+EXPERIEN+SE93REC)


I assume the is some difference in some default options.Or maybe it was a
problem when the data was imported. After using the read.spss in the foreign
package, I got the following warning message:

Unrecognized record type 7, subtype 16 encountered in system file

Thanks in advance for the help and apologies for the trouble,


Celso

[[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] Diverging results with SPSS

2006-07-07 Thread Peter Dalgaard
Celso Barros [EMAIL PROTECTED] writes:

 Dear List,
 
 I apologize in advance if this is silly. I tried to replicate an analysis I
 did previously in SPSS using R, and was surprised to find different results.
 
 
 So my question is: shouldn't the following SPSS syntax
 
 
 REGRESSION
 
 DEPENDENT INC89
 
 /METHOD=ENTER hiedyrs experien SE93rec.
 
 Yeld the same results of the following R command
 
 modelB-lm(INC89~HIEDYRS+EXPERIEN+SE93REC)

Possibly, if all variables are quantitative.

What are the differences that you see?
 
 
 I assume the is some difference in some default options.Or maybe it was a
 problem when the data was imported. After using the read.spss in the foreign
 package, I got the following warning message:
 
 Unrecognized record type 7, subtype 16 encountered in system file

You might check whether your variables have the same summary
statistics in both systems.
 
 Thanks in advance for the help and apologies for the trouble,
 
 
 Celso
 
   [[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] Diverging results with SPSS

2006-07-07 Thread Florian Koller
If results are *very* different, I would suspect that R treated experien as a 
factor (when you use read.spss the default is to use value labels, which 
makes R treat such variables as factors -- set use.value.labels = F).
Another explanation could be missing data in SPSS (not sysmis, but coded with, 
say -99) that are not recognized by R.
 
Florian



Von: [EMAIL PROTECTED] im Auftrag von Celso Barros
Gesendet: Fr 07.07.2006 07:13
An: r-help@stat.math.ethz.ch
Betreff: [R] Diverging results with SPSS



Dear List,

I apologize in advance if this is silly. I tried to replicate an analysis I
did previously in SPSS using R, and was surprised to find different results.


So my question is: shouldn't the following SPSS syntax


REGRESSION

DEPENDENT INC89

/METHOD=ENTER hiedyrs experien SE93rec.

Yeld the same results of the following R command

modelB-lm(INC89~HIEDYRS+EXPERIEN+SE93REC)


I assume the is some difference in some default options.Or maybe it was a
problem when the data was imported. After using the read.spss in the foreign
package, I got the following warning message:

Unrecognized record type 7, subtype 16 encountered in system file

Thanks in advance for the help and apologies for the trouble,


Celso

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



[[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] R-sig-foo searching, was : High breakdown/efficiency statistics -- was RE: Rosner's test

2006-07-07 Thread Romain Francois
Le 23.06.2006 10:42, Martin Maechler a écrit :
 {BTW: Did you know that to *search* mailing list archives of
   such R-SIG-foo mailing lists, you can use google very
   efficiently by prepending the mailing list name and 'site:stat.ethz.ch'?
   e.g., use google search on
   R-SIG-robust site:stat.ethz.ch lmrob
 }
   
Great idea, with a little bonus for the gnome mini-commander lovers (the 
other folks can just ignore this), a new macro :

expression :  |^rs-(.*):(.*)$|
command : gnome-open http://www.google.fr/search?q=R-SIG-\1 \2 
site:stat.ethz.ch

Now you can type
  rs-robust:lmrob
on your gnome mini commander applet

Cheers,

Romain

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php
+---+
| Romain FRANCOIS - http://francoisromain.free.fr   |
| Doctorant INRIA Futurs / EDF  |
+---+

__
R-help@stat.math.ethz.ch 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] convert ms() to optim()

2006-07-07 Thread Xiaodong Jin
  How to convert the following ms() in Splus to Optim in R? The Calc function 
is also attached.
   
  ms(~ Calc(a.init, B, v, off, d, P.a, lambda.a, P.y, lambda.y,
  10^(-8), FALSE, 20, TRUE)$Bic,
  start = list(lambda.a = 0.5, lambda.y = 240),
  control = list(maxiter = 10, tol = 0.1))
   
  Calc - function(A.INIT., X., V., OFF., D.,
  P1., LAMBDA1., P2., LAMBDA2.,
  TOL., MONITOR., MAX.ITER., TRACE.){
  lambda1 - abs(LAMBDA1.)
  lambda2 - abs(LAMBDA2.)
  P - lambda1 * P1. + lambda2 * P2.
  a - Estimate(A.INIT., X., V., OFF., D., P,
  TOL., MONITOR., MAX.ITER.)
  Ita - OFF. + X. %*% a
  Mu - c(exp(Ita))
  Wt - Mu * V.
  Bt.W.B - t(X.) %*% (Wt * X.)
  BtWBplusP - Bt.W.B + P
  Rhs - Bt.W.B %*% a + t(X.) %*% (V. * (D. - Mu))
  a - solve(BtWBplusP, Rhs)
  Tr - sum(diag(solve(BtWBplusP, Bt.W.B)))
  y.init - D.
  y.init[D.==0] - 10^(-4)
  Dev - 2*sum( V. * D.*log(y.init/Mu) )
  Bic - Dev + log(sum(V.)) * Tr
  Hazard - Ita - OFF.
  if (TRACE. == TRUE) cat(lambda1, lambda2, Bic, \n)
  return(a, Hazard, Tr, Dev, Bic, BtWBplusP)
   
  Thanks, 
  Shelton


-

[[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] Calling R from Java

2006-07-07 Thread zana adeb
Madam,
   
  I've read your answer :
  ///
  Here are other alternatives that are easy to implement and that you 
should consider depending on what you want to do:

1- one is to use R in batch mode ie you create a file in your java code 
with all the R commands and send it to R (via Process 
pc=Runtime.getRuntime().exec(Rcall); )and then R creates an outputfile 
with all the results.
The matter with this is that there is no interactivity, variables are 
not kept, you have to parse the outputfile, ... (see the above article 
(see § FFinterface))

2- another one is to use the R server developed by Simon Urbanek:

http://stats.math.uni-augsburg.de/Rserve/

A java frontend is provided with the server, which allows to communicate 
easily with R and which sends back results in a java object. So for each 
connection to the server you have a R environment where all the variable 
generated are kept until you close the connection and from you java code 
it is as simple as this example: REXP mean = 
c.eval(mean+i+-apply(+data+[,data.cl==+(i-1)+],1,mean.na));

This is what I'am using in my application and I am quite satisfied with 
it.
//
  For the first solution, I have not understood how I get the results from R???
   
  For the second solution, I didn't understant the instruction, i'm beginner in 
R and Java???
  I ve understood that Rserve is a server that I should install server R, R and 
the JDK for the jav???
   
  Thank you in advance,
   
  XENA



-


[[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] engineering notation format

2006-07-07 Thread Walker, Sam
Clever...

Good observation on the last example, mistake on my part.

Thanks for all the suggestions.

Sam

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hans-Joerg Bibiko
Sent: Friday, July 07, 2006 4:27 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] engineering notation format

Hi,

try this:

formatEng - function(x) {
   s-as.numeric(strsplit(format(x, scientific=T),e)[[1]])
   return(paste(s[1]*10^(s[2]%%3),as.integer(s[2]-(s[2]%%3)),sep=e))
}


 Some examples:

 1635 000 000  = 1.635E9
  163 500 000 = 163.5E6
 0.000 000 000 135 != 135E-9
 0.000 000 000 135 = 125E-12 ? 

Hans

**
Hans-Joerg Bibiko
Max Planck Institute for Evolutionary Anthropology
Department of Linguistics
Deutscher Platz 6 phone:   +49 (0) 341 3550 341
D-04103 Leipzig   fax: +49 (0) 341 3550 333
Germany   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

__
R-help@stat.math.ethz.ch 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] parametric proportional hazard regression

2006-07-07 Thread Valentin Dimitrov
Dear all,

I am trying to find a suitable R-function for
parametric proportional hazard regressions. The
package survival contains the coxph() function which
performs a Cox regression which leaves the base hazard
unspecified, i.e. it is a semi-parametric method. The
package Design contains the function pphsm() which is
good for parametric proportional hazard regressions
when the underlying base distribution is weibull or
exponential. But what if I need a parametric
proportional hazard model with the other usual
distributions like 'gaussian', 'logistic',
'lognormal'and 'loglogistic?

Thanks a lot for your support!

Valentin Dimitrov
Statistics and Econometrics
University of Saarland

__
R-help@stat.math.ethz.ch 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] replace values in data frame

2006-07-07 Thread Wade Wall
Hi all,

I have a three columned list that I have imported into R.  The first column
is a plot (ex. Plot1), the second is a species name (ex ACERRUB) and the
third a numeric value.  I want to replace some of the second column names
with other names (for example replace ACERRUB with ACERDRU).  The original
and replacement values are in separate lists (not vectors), but I can't seem
to find the right function to perform this.  The replace function seems to
only want to work with numbers.

Any clues?

Wade

[[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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Sebastian Luque
Hi,

The following produces almost exactly what I needed.  The problems are
that the 'panel.dotplot' call (commented) generates the error 'Error in
NextMethod([) : argument subscripts is missing, with no default'.  The
other problem is that the colors alternate between the levels of the 'site'
variable, rather than 'year'.


barley$yield2 - with(barley, yield + 5)

dotplot(site ~ yield | variety, data=barley, groups=year,
yield2=barley$yield2, col=c(gray, black),
panel=function(x, y, subscripts, yield2, ...) {
## panel.dotplot(x, y, ...)
panel.segments(x, as.numeric(y),
   yield2[subscripts], as.numeric(y), ...)
})

R sessionInfo()
Version 2.3.1 (2006-06-01) 
i486-pc-linux-gnu 

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

other attached packages:
   chron  gmodels  lattice 
 2.3-3 2.12.0 0.13-8


Can somebody please suggest how to properly make that 'panel.dotplot' call
and set the 'col' argument?  Thanks in advance.


Cheers,

-- 
Seb

__
R-help@stat.math.ethz.ch 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] replace values in data frame

2006-07-07 Thread Marc Schwartz (via MN)
On Fri, 2006-07-07 at 11:20 -0400, Wade Wall wrote:
 Hi all,
 
 I have a three columned list that I have imported into R.  The first column
 is a plot (ex. Plot1), the second is a species name (ex ACERRUB) and the
 third a numeric value.  I want to replace some of the second column names
 with other names (for example replace ACERRUB with ACERDRU).  The original
 and replacement values are in separate lists (not vectors), but I can't seem
 to find the right function to perform this.  The replace function seems to
 only want to work with numbers.
 
 Any clues?
 
 Wade

Without seeing the code you are using, we can only guess a syntax error
of some sort.  It works fine using the iris dataset:

 head(iris)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   5.1 3.5  1.4 0.2  setosa
2   4.9 3.0  1.4 0.2  setosa
3   4.7 3.2  1.3 0.2  setosa
4   4.6 3.1  1.5 0.2  setosa
5   5.0 3.6  1.4 0.2  setosa
6   5.4 3.9  1.7 0.4  setosa
7   4.6 3.4  1.4 0.3  setosa
8   5.0 3.4  1.5 0.2  setosa
9   4.4 2.9  1.4 0.2  setosa
10  4.9 3.1  1.5 0.1  setosa

 iris$Species - replace(iris$Species, iris$Species == setosa,
  NewValue)

 head(iris)
   Sepal.Length Sepal.Width Petal.Length Petal.Width  Species
1   5.1 3.5  1.4 0.2 NewValue
2   4.9 3.0  1.4 0.2 NewValue
3   4.7 3.2  1.3 0.2 NewValue
4   4.6 3.1  1.5 0.2 NewValue
5   5.0 3.6  1.4 0.2 NewValue
6   5.4 3.9  1.7 0.4 NewValue
7   4.6 3.4  1.4 0.3 NewValue
8   5.0 3.4  1.5 0.2 NewValue
9   4.4 2.9  1.4 0.2 NewValue
10  4.9 3.1  1.5 0.1 NewValue


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


[R] How to change the type of segments ends?

2006-07-07 Thread Lu, Jiang Jane
Hi,

I am trying to plot odds ratios and the corresponding confidence
intervals in horizontal segments. It would be ideal if the confidence
interval segment can be drawn with little vertical bars at both ends. I
have tried very hard to change the type of ends by using 'lend'
arguments, but cannot make it. I even tried 'arrows()', but still
failed. Following is the code I use:

drug.or - c(1.017,1.437,1.427,2.211)
drug.orl - c(0.715,1.075,1.103,1.696)
drug.oru - c(1.446,1.922,1.845,2.882)

yaxis - seq(1,4,by=1)

plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
 xlab='Odds Ratio',ylab='',main='Reference Group: A only')
axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
axis(2,at=yaxis,las=2)


segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)

# or try
#arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
e=3,col=4,lend=2)

box()
=


Any comments or suggestions would be greatly appreciated.


Jane

University of Pittsburgh
Pittsburgh, PA 15261

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

2006-07-07 Thread Liaw, Andy
Naras presented something with similar functionalities using SVG a couple of
years ago, and since then the svgdevice package had been made available.  I
do not know SVG myself, but according to Naras, it's all possible.

Best,
Andy 

From: Terry Therneau
 
   I have an application where the Splus graphlets() package 
 would work very well, and would like to know if there is any 
 comparable work in R.  In response to a similar query on this 
 list about 1.5 years ago the Orca package was mentioned, but 
 it seems to be inactive.
   For those who don't know, graphlets are an extended java 
 graphics device.  The identify function, for instance, allows 
 one to link both a label and a set of html links to each 
 point.  I am aware of the Sjava package in Omega, and am 
 exploring that, but would be very interested if there is 
 anything more.
   Terry Therneau
   Mayo Clinic
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://www.stat.math.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] Diverging results with SPSS

2006-07-07 Thread Celso Barros
Dear Peter and Florian,

  I think you have spotted the problem, thank you very much. I checked
the frequencies, and R is not understanding that the (-1) value in a binary
variable was defined in SPSS as sysmis. This was precisely the variable
that showed the larger difference (it's the only binary variable in the
model). Thanks a lot.

  I am still trying to make R understand that, though. If I could
avoid defining missing values inside R for each of the variables in the
dataset, I would be happy. Does anyone know if there is a command in
foreign, for instance, that ensures that things coded as sysmis in SPSS are
read as sysmis in R?

  Thanks again, this has been very, very helpful


Celso


On 7/7/06, Florian Koller [EMAIL PROTECTED] wrote:

   If results are *very* different, I would suspect that R treated
 experien as a factor (when you use read.spss the default is to use
 value labels, which makes R treat such variables as factors -- set 
 use.value.labels = F).
 Another explanation could be missing data in SPSS (not sysmis, but coded
 with, say -99) that are not recognized by R.

 Florian

 --
 *Von:* [EMAIL PROTECTED] im Auftrag von Celso Barros
 *Gesendet:* Fr 07.07.2006 07:13
 *An:* r-help@stat.math.ethz.ch
 *Betreff:* [R] Diverging results with SPSS



 Dear List,

 I apologize in advance if this is silly. I tried to replicate an analysis
 I
 did previously in SPSS using R, and was surprised to find different
 results.


 So my question is: shouldn't the following SPSS syntax


 REGRESSION

 DEPENDENT INC89

 /METHOD=ENTER hiedyrs experien SE93rec.

 Yeld the same results of the following R command

 modelB-lm(INC89~HIEDYRS+EXPERIEN+SE93REC)


 I assume the is some difference in some default options.Or maybe it was a
 problem when the data was imported. After using the read.spss in the
 foreign
 package, I got the following warning message:

 Unrecognized record type 7, subtype 16 encountered in system file

 Thanks in advance for the help and apologies for the trouble,


 Celso

 [[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.htmlhttp://www.r-project.org/posting-guide.html



[[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] parametric proportional hazard regression

2006-07-07 Thread Thomas Lumley
On Fri, 7 Jul 2006, Valentin Dimitrov wrote:
 I am trying to find a suitable R-function for
 parametric proportional hazard regressions. The
 package survival contains the coxph() function which
 performs a Cox regression which leaves the base hazard
 unspecified, i.e. it is a semi-parametric method. The
 package Design contains the function pphsm() which is
 good for parametric proportional hazard regressions
 when the underlying base distribution is weibull or
 exponential. But what if I need a parametric
 proportional hazard model with the other usual
 distributions like 'gaussian', 'logistic',
 'lognormal'and 'loglogistic?

Those are not proportional hazards families of distributions. That is, if 
the distribution is gaussian for one value of the hazard ratio parameters 
it will not be gaussian for any other value.

You can get accelerated failure models with these distributions using 
survreg() in the survival package.


-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

__
R-help@stat.math.ethz.ch 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] parametric proportional hazard regression

2006-07-07 Thread Hamilton, Cody

Valentin,

Have you tried survreg() in the Design library?

Regards,
   -Cody

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Valentin Dimitrov
Sent: Friday, July 07, 2006 10:1 AM
To: r-help@stat.math.ethz.ch
Subject: [R] parametric proportional hazard regression

Dear all,

I am trying to find a suitable R-function for
parametric proportional hazard regressions. The
package survival contains the coxph() function which
performs a Cox regression which leaves the base hazard
unspecified, i.e. it is a semi-parametric method. The
package Design contains the function pphsm() which is
good for parametric proportional hazard regressions
when the underlying base distribution is weibull or
exponential. But what if I need a parametric
proportional hazard model with the other usual
distributions like 'gaussian', 'logistic',
'lognormal'and 'loglogistic?

Thanks a lot for your support!

Valentin Dimitrov
Statistics and Econometrics
University of Saarland

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

This e-mail, facsimile, or letter and any files or attachments transmitted with 
it contains information that is confidential and privileged. This information 
is intended only for the use of the individual(s) and entity(ies) to whom it is 
addressed. If you are the intended recipient, further disclosures are 
prohibited without proper authorization. If you are not the intended recipient, 
any disclosure, copying, printing, or use of this information is strictly 
prohibited and possibly a violation of federal or state law and regulations. If 
you have received this information in error, please notify Baylor Health Care 
System immediately at 1-866-402-1661 or via e-mail at [EMAIL PROTECTED] Baylor 
Health Care System, its subsidiaries, and affiliates hereby claim all 
applicable privileges related to this information.

__
R-help@stat.math.ethz.ch 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] Rpad Server Installation on Windows XP

2006-07-07 Thread Minjeong Ahn

 Hello,
 I have a question about Rpad Server Installation on Windows XP.
 Here is a guide
 http://www.rpad.org/Rpad/ServerNotes.html
 and I have been reading this more than ten times to figure this out, but
 still having trouble executing a Rpad website properly.

 Problem: for example, if I go to http://loclhost/Rpad/example1.rpad,
 I can see the whole website with the page loading sign staying on my
 screen (like forever)
 but if I push calculate button noting happens and the page loading
 sign goes away.

 Here, I think I have completed all steps needed,
 but I think I got something wrong with Install the Statistice-
 R_perl_interface that come with Rpad in the serverversion directory. part.

 My Question: When I try installing serverversion files, I used
 -perl makefile.pl
 -nmake
 -nmake install

 in C:/Perl/bin directory. But I think the directory of perl might be
 some problem. I asked somebody out a week ago and he said I have to
 install perl on my path. Actually I don't quite know which directory
 he is talking about. I'm using xampp advanced version, so I should have
 perl installed and also I have active perl installed on my computer
 (c:/perl) What am I getting wrong?

 Question2: Do I have to install rterm too? If so, where?

 Any of your advice will be very appreciated.
 Thank you for your reading and have a great day everybody!

 best,
 Claire Ahn
 MIT

__
R-help@stat.math.ethz.ch 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 change the type of segments ends?

2006-07-07 Thread Marc Schwartz (via MN)
On Fri, 2006-07-07 at 11:47 -0400, Lu, Jiang Jane wrote:
 Hi,
 
 I am trying to plot odds ratios and the corresponding confidence
 intervals in horizontal segments. It would be ideal if the confidence
 interval segment can be drawn with little vertical bars at both ends. I
 have tried very hard to change the type of ends by using 'lend'
 arguments, but cannot make it. I even tried 'arrows()', but still
 failed. Following is the code I use:
 
 drug.or - c(1.017,1.437,1.427,2.211)
 drug.orl - c(0.715,1.075,1.103,1.696)
 drug.oru - c(1.446,1.922,1.845,2.882)
 
 yaxis - seq(1,4,by=1)
 
 plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
  xlab='Odds Ratio',ylab='',main='Reference Group: A only')
 axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
 axis(2,at=yaxis,las=2)
 
 
 segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)
 
 # or try
 #arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
 e=3,col=4,lend=2)
 
 box()
 =

Try this using arrows():

drug.or - c(1.017,1.437,1.427,2.211)
drug.orl - c(0.715,1.075,1.103,1.696)
drug.oru - c(1.446,1.922,1.845,2.882)

yaxis - seq(1, 4, by=1)

plot(drug.or, yaxis ,type='p', pch=17, xlim=c(0,3), axes=FALSE,
 xlab='Odds Ratio', ylab='', main='Reference Group: A only')

axis(1, at=seq(0,3,by=0.5), labels=paste(seq(0,3,by=0.5)))
axis(2, at=yaxis, las=2)

arrows(drug.orl, yaxis, drug.oru, yaxis, angle=90,
   length=0.1, code=3, col=4, lend=2)


You need to specify an angle of 90 degrees to get the arrow heads to be
perpendicular to the primary line segment. An angle of 0 superimposes
the heads on the primary line segment, so they don't show.

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] How to change the type of segments ends?

2006-07-07 Thread Prof Brian Ripley
You need angle=90. From the help page:

angle: angle from the shaft of the arrow to the edge of the arrow
   head.


On Fri, 7 Jul 2006, Lu, Jiang Jane wrote:

 Hi,

 I am trying to plot odds ratios and the corresponding confidence
 intervals in horizontal segments. It would be ideal if the confidence
 interval segment can be drawn with little vertical bars at both ends. I
 have tried very hard to change the type of ends by using 'lend'
 arguments, but cannot make it. I even tried 'arrows()', but still
 failed. Following is the code I use:
 
 drug.or - c(1.017,1.437,1.427,2.211)
 drug.orl - c(0.715,1.075,1.103,1.696)
 drug.oru - c(1.446,1.922,1.845,2.882)

 yaxis - seq(1,4,by=1)

 plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
 xlab='Odds Ratio',ylab='',main='Reference Group: A only')
 axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
 axis(2,at=yaxis,las=2)


 segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)

 # or try
 #arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
 e=3,col=4,lend=2)

 box()
 =


 Any comments or suggestions would be greatly appreciated.


 Jane

 University of Pittsburgh
 Pittsburgh, PA 15261

 __
 R-help@stat.math.ethz.ch 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 change the type of segments ends?

2006-07-07 Thread Chuck Cleland
Lu, Jiang Jane wrote:
 Hi,
 
 I am trying to plot odds ratios and the corresponding confidence
 intervals in horizontal segments. It would be ideal if the confidence
 interval segment can be drawn with little vertical bars at both ends. I
 have tried very hard to change the type of ends by using 'lend'
 arguments, but cannot make it. I even tried 'arrows()', but still
 failed. Following is the code I use:
 
 drug.or - c(1.017,1.437,1.427,2.211)
 drug.orl - c(0.715,1.075,1.103,1.696)
 drug.oru - c(1.446,1.922,1.845,2.882)
 
 yaxis - seq(1,4,by=1)
 
 plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
  xlab='Odds Ratio',ylab='',main='Reference Group: A only')
 axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
 axis(2,at=yaxis,las=2)
 
 
 segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)
 
 # or try
 #arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
 e=3,col=4,lend=2)

   The call to arrows() seems to do what you want if angle=90.  Also the 
lend argument seems unnecessary if you have angle=90.

 box()
 =
 
 
 Any comments or suggestions would be greatly appreciated.
 
 
 Jane
 
 University of Pittsburgh
 Pittsburgh, PA 15261
 
 __
 R-help@stat.math.ethz.ch 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) 512-0171 (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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Gabor Grothendieck
It seems to work if you handle the col= argument explicitly.
Suggest you double check this since I have not carefully done so:

barley$yield2 - with(barley, yield + 5)

dotplot(site ~ yield | variety, data=barley, groups=year,
   yield2=barley$yield2, col=c(gray, black),
   panel=function(x, y, subscripts, groups, yield2, col, ...) {
   panel.dotplot(x, y, ...)
   panel.segments(x, as.numeric(y),
  yield2[subscripts], as.numeric(y),
col = col[groups[subscripts]], ...)
   })



On 7/7/06, Sebastian Luque [EMAIL PROTECTED] wrote:
 Hi,

 The following produces almost exactly what I needed.  The problems are
 that the 'panel.dotplot' call (commented) generates the error 'Error in
 NextMethod([) : argument subscripts is missing, with no default'.  The
 other problem is that the colors alternate between the levels of the 'site'
 variable, rather than 'year'.


 barley$yield2 - with(barley, yield + 5)

 dotplot(site ~ yield | variety, data=barley, groups=year,
yield2=barley$yield2, col=c(gray, black),
panel=function(x, y, subscripts, yield2, ...) {
## panel.dotplot(x, y, ...)
panel.segments(x, as.numeric(y),
   yield2[subscripts], as.numeric(y), ...)
})

 R sessionInfo()
 Version 2.3.1 (2006-06-01)
 i486-pc-linux-gnu

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

 other attached packages:
   chron  gmodels  lattice
  2.3-3 2.12.0 0.13-8


 Can somebody please suggest how to properly make that 'panel.dotplot' call
 and set the 'col' argument?  Thanks in advance.


 Cheers,

 --
 Seb

 __
 R-help@stat.math.ethz.ch 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] How to change the type of segments ends?

2006-07-07 Thread Gavin Simpson
On Fri, 2006-07-07 at 11:47 -0400, Lu, Jiang Jane wrote:
 Hi,
 
 I am trying to plot odds ratios and the corresponding confidence
 intervals in horizontal segments. It would be ideal if the confidence
 interval segment can be drawn with little vertical bars at both ends. I
 have tried very hard to change the type of ends by using 'lend'
 arguments, but cannot make it. I even tried 'arrows()', but still
 failed. Following is the code I use:
 
 drug.or - c(1.017,1.437,1.427,2.211)
 drug.orl - c(0.715,1.075,1.103,1.696)
 drug.oru - c(1.446,1.922,1.845,2.882)
 
 yaxis - seq(1,4,by=1)
 
 plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
  xlab='Odds Ratio',ylab='',main='Reference Group: A only')
 axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
 axis(2,at=yaxis,las=2)
 
 
 segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)
 
 # or try
 #arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
 e=3,col=4,lend=2)
 
 box()
 =
 
 
 Any comments or suggestions would be greatly appreciated.
 
 
 Jane

Hi Jane,

Thanks for the reproducible example. Why do you think lend will do what
you want? From ?par:

'lend' The line end style.  This can be specified as an integer or
  string:

  '0' and 'round' mean rounded line caps [_default_];

  '1' and 'butt' mean butt line caps;

  '2' and 'square' mean square line caps.

  As from R 2.3.0 this can be specified inline.

This is talking about line endings - do you want hard or soft line ends
or type of joins in line segments? It does not mean the type of line
endings you might get in Adobe Illustrator or Inkscape vector drawing
packages.

You were close with arrows:

drug.or - c(1.017,1.437,1.427,2.211)
drug.orl - c(0.715,1.075,1.103,1.696)
drug.oru - c(1.446,1.922,1.845,2.882)

yaxis - seq(1,4,by=1)

plot(x = drug.or, y = yaxis, pch=17, xlim = c(0,3), axes=FALSE,
 xlab = 'Odds Ratio', ylab = '', main = 'Reference Group: A only')
labs - seq(0, 3, by = 0.5)
axis(1, at = labs, labels = labs)
axis(2, at = yaxis, las = 2)
arrows(x0 = drug.orl, x1 = drug.oru, y0 = yaxis, y1 = yaxis, length=0.1,
code = 3, col = 4, angle = 90)

the angle argument is the key. See arrows? You don't need lend at all to
do what you want.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/cv/
 London, UK. WC1E 6BT. [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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 change the type of segments ends?

2006-07-07 Thread Lu, Jiang Jane
Thank you all for such a prompt response. I misunderstood the meaning of
'lend' in par(). Now I have got the ideal confidence segments. I
appreciate all the specific explanations you have offered.

Sincerely,

Jane

-Original Message-
From: Gavin Simpson [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 07, 2006 12:24 PM
To: Lu, Jiang Jane
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] How to change the type of segments ends?

On Fri, 2006-07-07 at 11:47 -0400, Lu, Jiang Jane wrote:
 Hi,
 
 I am trying to plot odds ratios and the corresponding confidence
 intervals in horizontal segments. It would be ideal if the confidence
 interval segment can be drawn with little vertical bars at both ends.
I
 have tried very hard to change the type of ends by using 'lend'
 arguments, but cannot make it. I even tried 'arrows()', but still
 failed. Following is the code I use:
 
 drug.or - c(1.017,1.437,1.427,2.211)
 drug.orl - c(0.715,1.075,1.103,1.696)
 drug.oru - c(1.446,1.922,1.845,2.882)
 
 yaxis - seq(1,4,by=1)
 
 plot(x=drug.or,y=yaxis,type='p',pch=17,xlim=c(0,3),axes=FALSE,
  xlab='Odds Ratio',ylab='',main='Reference Group: A only')
 axis(1,at=seq(0,3,by=0.5),labels=paste(seq(0,3,by=0.5)))
 axis(2,at=yaxis,las=2)
 
 
 segments(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,col=4,lend=2)
 
 # or try

#arrows(x0=drug.orl,x1=drug.oru,y0=yaxis,y1=yaxis,length=0.1,angle=0,cod
 e=3,col=4,lend=2)
 
 box()
 =
 
 
 Any comments or suggestions would be greatly appreciated.
 
 
 Jane

Hi Jane,

Thanks for the reproducible example. Why do you think lend will do what
you want? From ?par:

'lend' The line end style.  This can be specified as an integer or
  string:

  '0' and 'round' mean rounded line caps [_default_];

  '1' and 'butt' mean butt line caps;

  '2' and 'square' mean square line caps.

  As from R 2.3.0 this can be specified inline.

This is talking about line endings - do you want hard or soft line ends
or type of joins in line segments? It does not mean the type of line
endings you might get in Adobe Illustrator or Inkscape vector drawing
packages.

You were close with arrows:

drug.or - c(1.017,1.437,1.427,2.211)
drug.orl - c(0.715,1.075,1.103,1.696)
drug.oru - c(1.446,1.922,1.845,2.882)

yaxis - seq(1,4,by=1)

plot(x = drug.or, y = yaxis, pch=17, xlim = c(0,3), axes=FALSE,
 xlab = 'Odds Ratio', ylab = '', main = 'Reference Group: A only')
labs - seq(0, 3, by = 0.5)
axis(1, at = labs, labels = labs)
axis(2, at = yaxis, las = 2)
arrows(x0 = drug.orl, x1 = drug.oru, y0 = yaxis, y1 = yaxis, length=0.1,
code = 3, col = 4, angle = 90)

the angle argument is the key. See arrows? You don't need lend at all to
do what you want.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/cv/
 London, UK. WC1E 6BT. [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] replace values in data frame

2006-07-07 Thread Wade Wall
The format is like this.

Plot  species   Value

P1  ACERRUB   3
P2  MAGNVIR2
P3  ARONARB   2
etc.

imported using x-read.table(file=filename.txt)

I want to replace a list of values in the 2nd column with another list. For
example, I want to replace ARONARB with PHOTPYR.
list-read.table(file=originalnames.txt)
replace-read.table(file=replacementnames.txt)
I tried to use replace in this manner:

newx-replace(x,list,replace)
however, I get the error message: error in replace, invalid subscript type.

I have tried transforming the above list and modifying the column names
(column 2), but to no avail.  I hope this clarifies a little.  Sorry about
that.




On 7/7/06, Marc Schwartz (via MN) [EMAIL PROTECTED] wrote:

 On Fri, 2006-07-07 at 11:20 -0400, Wade Wall wrote:
  Hi all,
 
  I have a three columned list that I have imported into R.  The first
 column
  is a plot (ex. Plot1), the second is a species name (ex ACERRUB) and the
  third a numeric value.  I want to replace some of the second column
 names
  with other names (for example replace ACERRUB with ACERDRU).  The
 original
  and replacement values are in separate lists (not vectors), but I can't
 seem
  to find the right function to perform this.  The replace function seems
 to
  only want to work with numbers.
 
  Any clues?
 
  Wade

 Without seeing the code you are using, we can only guess a syntax error
 of some sort.  It works fine using the iris dataset:

  head(iris)
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
 1   5.1 3.5  1.4 0.2  setosa
 2   4.9 3.0  1.4 0.2  setosa
 3   4.7 3.2  1.3 0.2  setosa
 4   4.6 3.1  1.5 0.2  setosa
 5   5.0 3.6  1.4 0.2  setosa
 6   5.4 3.9  1.7 0.4  setosa
 7   4.6 3.4  1.4 0.3  setosa
 8   5.0 3.4  1.5 0.2  setosa
 9   4.4 2.9  1.4 0.2  setosa
 10  4.9 3.1  1.5 0.1  setosa

  iris$Species - replace(iris$Species, iris$Species == setosa,
  NewValue)

  head(iris)
   Sepal.Length Sepal.Width Petal.Length Petal.Width  Species
 1   5.1 3.5  1.4 0.2 NewValue
 2   4.9 3.0  1.4 0.2 NewValue
 3   4.7 3.2  1.3 0.2 NewValue
 4   4.6 3.1  1.5 0.2 NewValue
 5   5.0 3.6  1.4 0.2 NewValue
 6   5.4 3.9  1.7 0.4 NewValue
 7   4.6 3.4  1.4 0.3 NewValue
 8   5.0 3.4  1.5 0.2 NewValue
 9   4.4 2.9  1.4 0.2 NewValue
 10  4.9 3.1  1.5 0.1 NewValue


 HTH,

 Marc Schwartz




[[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] Converting data frame to zoo

2006-07-07 Thread Horace Tso
Dear list,

I know this is really basic question but I just couldn't get anything
to work. (I did a R site search with keywords zoo and data frame but
the server timed out on me.)

I have a time series which has the following (typical) format,

DATE   Open  High  Low  Close  
  Volume
01-JAN-2006 5.25   5.25  5.25  5.25
  256


I read the data in from a csv file with read.csv() and it defaulted to
a data frame which I thought is fine. Now I want to convert it to zoo so
I did

x - zoo(my.df)

which works just fine. But the Date column has been turned into a
factor. Is there a way to make it into a Date. I've tried,

x$Date - as.Date(x$Date)  

but R complains that

Error in fromchar(x) : character string is not in a standard
unambiguous format

Thanks in advance.

Horace W. Tso






__
R-help@stat.math.ethz.ch 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] replace values in data frame

2006-07-07 Thread Marc Schwartz (via MN)
Thanks for re-posting onlist.  My offlist reply:

The 'list' argument, as per ?replace, needs to be a vector of one or
more indices into another vector, generally the source vector argument
'x', not the actual values that you want to replace. 'list' can either
be explicit integers as the indices, or the result of a logical
operation as I used in my example.

In addition, the objects 'list' and 'replace' in your code are not
vectors, but they are data frames. That is the default
type of object created when using read.table().

You can use str(list) and str(replace) to check this. The str() function
returns the structure of an object.

It is likely that you really want list$V1 and replace$V1 as the vectors
of interest here. V1 thru Vx are the default column names created when
using read.table() if no header row exists in the incoming file.

In addition, note that replace() is not vectorized. It will not handle
multiple search and replace arguments in a single call. See my example
using the iris dataset.

You would need to do each one separately. You can create a loop of one
type or another to cycle through multiple arguments if you wish, where
each cycle through the loop is a single call to replace() with a new set
of values as appropriate for the arguments.

Finally, you should generally not use R object or function names for
user created objects. Both 'list' and 'replace' are such objects. R will
generally be able to differentiate, but there is no guarantee and it
will help you avoid code debugging headaches.

HTH,

Marc Schwartz



On Fri, 2006-07-07 at 12:58 -0400, Wade Wall wrote:
 The format is like this.
 
 Plot  species   Value
 
 P1  ACERRUB   3
 P2  MAGNVIR2
 P3  ARONARB   2
 etc.
 
 imported using x-read.table(file=filename.txt)
 
 I want to replace a list of values in the 2nd column with another list. For
 example, I want to replace ARONARB with PHOTPYR.
 list-read.table(file=originalnames.txt)
 replace-read.table(file=replacementnames.txt)
 I tried to use replace in this manner:
 
 newx-replace(x,list,replace)
 however, I get the error message: error in replace, invalid subscript type.
 
 I have tried transforming the above list and modifying the column names
 (column 2), but to no avail.  I hope this clarifies a little.  Sorry about
 that.

 
 
  On Fri, 2006-07-07 at 11:20 -0400, Wade Wall wrote:
   Hi all,
  
   I have a three columned list that I have imported into R.  The first
  column
   is a plot (ex. Plot1), the second is a species name (ex ACERRUB) and the
   third a numeric value.  I want to replace some of the second column
  names
   with other names (for example replace ACERRUB with ACERDRU).  The
  original
   and replacement values are in separate lists (not vectors), but I can't
  seem
   to find the right function to perform this.  The replace function seems
  to
   only want to work with numbers.
  
   Any clues?
  
   Wade
 

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

2006-07-07 Thread Gabor Grothendieck
Check out read.zoo in the zoo package.

On 7/7/06, Horace Tso [EMAIL PROTECTED] wrote:
 Dear list,

 I know this is really basic question but I just couldn't get anything
 to work. (I did a R site search with keywords zoo and data frame but
 the server timed out on me.)

 I have a time series which has the following (typical) format,

 DATE   Open  High  Low  Close
  Volume
 01-JAN-2006 5.25   5.25  5.25  5.25
  256
 

 I read the data in from a csv file with read.csv() and it defaulted to
 a data frame which I thought is fine. Now I want to convert it to zoo so
 I did

 x - zoo(my.df)

 which works just fine. But the Date column has been turned into a
 factor. Is there a way to make it into a Date. I've tried,

 x$Date - as.Date(x$Date)

 but R complains that

 Error in fromchar(x) : character string is not in a standard
 unambiguous format

 Thanks in advance.

 Horace W. Tso






 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] replace values in data frame

2006-07-07 Thread Marc Schwartz (via MN)
Wade,

Given that you appear to have multiple search and replace items to deal
with, here is a possible loop based Global Search and Replace
solution:

gsr - function(Source, Search, Replace)
{
  if (length(Search) != length(Replace))
stop(Search and Replace Must Have Equal Number of Items\n)

  Changed - as.character(Source)

  for (i in 1:length(Search))
  {
cat(Replacing: , Search[i],  With: , Replace[i], \n)
Changed - replace(Changed, Changed == Search[i], Replace[i])
  }

  cat(\n)
  
  Changed
}


Source:  The source vector, which will be coerced to character

Search: The Search values to be matched in Source as a character
vector

Replace: The values that will replace those found in 'Search' on a
one-for-one basis.


This function returns a character vector. As with replace(), the result
must be assigned. The change is not done 'in place'. The function will
also output the search and replace values to the console during the
loop.


Again, using the iris dataset as an example:

 iris$Species
  [1] setosa setosa setosa setosa setosa setosa
  [7] setosa setosa setosa setosa setosa setosa
 [13] setosa setosa setosa setosa setosa setosa
 [19] setosa setosa setosa setosa setosa setosa
 [25] setosa setosa setosa setosa setosa setosa
 [31] setosa setosa setosa setosa setosa setosa
 [37] setosa setosa setosa setosa setosa setosa
 [43] setosa setosa setosa setosa setosa setosa
 [49] setosa setosa versicolor versicolor versicolor versicolor
 [55] versicolor versicolor versicolor versicolor versicolor versicolor
 [61] versicolor versicolor versicolor versicolor versicolor versicolor
 [67] versicolor versicolor versicolor versicolor versicolor versicolor
 [73] versicolor versicolor versicolor versicolor versicolor versicolor
 [79] versicolor versicolor versicolor versicolor versicolor versicolor
 [85] versicolor versicolor versicolor versicolor versicolor versicolor
 [91] versicolor versicolor versicolor versicolor versicolor versicolor
 [97] versicolor versicolor versicolor versicolor virginica  virginica 
[103] virginica  virginica  virginica  virginica  virginica  virginica 
[109] virginica  virginica  virginica  virginica  virginica  virginica 
[115] virginica  virginica  virginica  virginica  virginica  virginica 
[121] virginica  virginica  virginica  virginica  virginica  virginica 
[127] virginica  virginica  virginica  virginica  virginica  virginica 
[133] virginica  virginica  virginica  virginica  virginica  virginica 
[139] virginica  virginica  virginica  virginica  virginica  virginica 
[145] virginica  virginica  virginica  virginica  virginica  virginica 
Levels: setosa versicolor virginica


Note that iris$Species is a factor with specific levels. The gsr()
function above will coerce the Source argument to a character vector
internally and return a character vector:

 iris$Species - gsr(iris$Species, 
  c(setosa, versicolor, virginica), 
  c(s1, v1, v2))
Replacing:  setosa  With:  s1 
Replacing:  versicolor  With:  v1 
Replacing:  virginica  With:  v2 

 iris$Species
  [1] s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1
 [14] s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1
 [27] s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1
 [40] s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 s1 v1 v1
 [53] v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1
 [66] v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1
 [79] v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1 v1
 [92] v1 v1 v1 v1 v1 v1 v1 v1 v1 v2 v2 v2 v2
[105] v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2
[118] v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2
[131] v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2 v2
[144] v2 v2 v2 v2 v2 v2 v2


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] Rpad Server Installation on Windows XP

2006-07-07 Thread roger bos
Claire,

I know you emailed me a question earlier and I just haven't gotten around to
answering it.  For both perl and rgui.exe (and rterm.exe) your path needs to
state the location of these files.  (I am not sure about this, but after you
change the path you may even need to reboot for the change to be applied).
Goto the dos prompt at C: and type in 'perl' and 'rterm' to make sure both
are recognized.

I don't really know what makefile does, but my understanding is that it just
copies the files and you can do that yourself.  Once you do that, your
'server' folder on the rapd server will have some .pl files.  An example of
the R_process.pl file is below.  I don't know why there is a #! in front of
the path on the first line, but make sure that path points to the location
of your perl install.  Your perl istall is likely different from the default
in the .pl files.

Once you have verified those two items, work through the troubleshooting
portion of the rpad install notes and let us know which steps are working
and which are not.  As you can tell, I am no expert myself.  I was very
happy once I got it to work.  Fortunately, it has worked like a charm ever
since.  I am just hoping I never have to do it again!! lol.

#!c:/perl/bin/perl.exe

# The following line is a test script to see if it works.
#
http://localhost/Rpad/server/R_process.pl?ID=ddNTlmHSvWZFcommand=R_commandsR_commands=print('hello'
)
use Statistics::Rpad ;
use strict ;
use CGI qw/:standard send_http_header/;
use Cwd ;
use utf8; # the decoding stuff is from spell-check-logic.cgi in the htmlarea
spellcheck plugin
use Encode;








On 7/7/06, Minjeong Ahn [EMAIL PROTECTED] wrote:


 Hello,
 I have a question about Rpad Server Installation on Windows XP.
 Here is a guide
 http://www.rpad.org/Rpad/ServerNotes.html
 and I have been reading this more than ten times to figure this out, but
 still having trouble executing a Rpad website properly.

 Problem: for example, if I go to http://loclhost/Rpad/example1.rpad,
 I can see the whole website with the page loading sign staying on my
 screen (like forever)
 but if I push calculate button noting happens and the page loading
 sign goes away.

 Here, I think I have completed all steps needed,
 but I think I got something wrong with Install the Statistice-
 R_perl_interface that come with Rpad in the serverversion directory.
 part.

 My Question: When I try installing serverversion files, I used
 -perl makefile.pl
 -nmake
 -nmake install

 in C:/Perl/bin directory. But I think the directory of perl might be
 some problem. I asked somebody out a week ago and he said I have to
 install perl on my path. Actually I don't quite know which directory
 he is talking about. I'm using xampp advanced version, so I should have
 perl installed and also I have active perl installed on my computer
 (c:/perl) What am I getting wrong?

 Question2: Do I have to install rterm too? If so, where?

 Any of your advice will be very appreciated.
 Thank you for your reading and have a great day everybody!

 best,
 Claire Ahn
 MIT

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


[[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] attach and detach question

2006-07-07 Thread markleeds

I have a large R program that I am constantly running over and over again. At 
the beginning of this program, I create a hige matrix and a huge dataframe but 
these are constant. What I mean by constant is that, if I run the program over 
later, I really should just use the old matrix and dataframe ( if they exist ) 
that were created in a previous run so that the program doesn't have to spend 
time creating them. Unfortunately, I don't know how to do this so things take 
foreeer because every time i do a new run, i recreate these objects and the 
boss is getting a little annoyed. I know/think that I should use attach and 
detach commands  but 

1) i can't find an example somewhere of
just saving two objects rather than the whole session.
i've looked and looked and i can't find it.

2) if i am able to save these two objects, i was hoping that it
would be possible to write code inside my R program
that basically says, if these objects already exist in
such and such database, then skip over this section of the code
that creates them.

if someone has some code or a page number or reference, this is fine because i 
used to do pretty much this in Splus so think i can figure it out if i can just 
find an example.  thanks a lot.

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

2006-07-07 Thread Horace Tso
Thanks Gabor. I figured out what went wrong. The culprit turns out to be
the headers in my data. read.zoo doesn't recognize column headers and
complains 

Error in read.zoo(C:\\...\\table.csv,  : 
index contains NAs

Or is there an option as in read.table(x, header=...) ? 

After the header line is removed it works fine.

H.



 Gabor Grothendieck [EMAIL PROTECTED] 7/7/2006 10:22 AM

Check out read.zoo in the zoo package.

On 7/7/06, Horace Tso [EMAIL PROTECTED] wrote:
 Dear list,

 I know this is really basic question but I just couldn't get
anything
 to work. (I did a R site search with keywords zoo and data frame
but
 the server timed out on me.)

 I have a time series which has the following (typical) format,

 DATE   Open  High  Low  Close
  Volume
 01-JAN-2006 5.25   5.25  5.25  5.25
  256
 

 I read the data in from a csv file with read.csv() and it defaulted
to
 a data frame which I thought is fine. Now I want to convert it to zoo
so
 I did

 x - zoo(my.df)

 which works just fine. But the Date column has been turned into a
 factor. Is there a way to make it into a Date. I've tried,

 x$Date - as.Date(x$Date)

 but R complains that

 Error in fromchar(x) : character string is not in a standard
 unambiguous format

 Thanks in advance.

 Horace W. Tso






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

2006-07-07 Thread Gabor Grothendieck
read.zoo supports all the arguments that read.table supports including
header=.  From the read.zoo help file:

 ...: further arguments passed to 'read.table'.

Regards.

On 7/7/06, Horace Tso [EMAIL PROTECTED] wrote:
 Thanks Gabor. I figured out what went wrong. The culprit turns out to be
 the headers in my data. read.zoo doesn't recognize column headers and
 complains

 Error in read.zoo(C:\\...\\table.csv,  :
index contains NAs

 Or is there an option as in read.table(x, header=...) ?

 After the header line is removed it works fine.

 H.



  Gabor Grothendieck [EMAIL PROTECTED] 7/7/2006 10:22 AM
 
 Check out read.zoo in the zoo package.

 On 7/7/06, Horace Tso [EMAIL PROTECTED] wrote:
  Dear list,
 
  I know this is really basic question but I just couldn't get
 anything
  to work. (I did a R site search with keywords zoo and data frame
 but
  the server timed out on me.)
 
  I have a time series which has the following (typical) format,
 
  DATE   Open  High  Low  Close
   Volume
  01-JAN-2006 5.25   5.25  5.25  5.25
   256
  
 
  I read the data in from a csv file with read.csv() and it defaulted
 to
  a data frame which I thought is fine. Now I want to convert it to zoo
 so
  I did
 
  x - zoo(my.df)
 
  which works just fine. But the Date column has been turned into a
  factor. Is there a way to make it into a Date. I've tried,
 
  x$Date - as.Date(x$Date)
 
  but R complains that
 
  Error in fromchar(x) : character string is not in a standard
  unambiguous format
 
  Thanks in advance.
 
  Horace W. Tso
 
 
 
 
 
 
  __
  R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] attach and detach question

2006-07-07 Thread Gabor Grothendieck
There is an example of saving just two objects in the example
section of ?save

To check whether an object of a given name exists see ?exists

On 7/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 I have a large R program that I am constantly running over and over again. At 
 the beginning of this program, I create a hige matrix and a huge dataframe 
 but these are constant. What I mean by constant is that, if I run the program 
 over later, I really should just use the old matrix and dataframe ( if they 
 exist ) that were created in a previous run so that the program doesn't have 
 to spend time creating them. Unfortunately, I don't know how to do this so 
 things take foreeer because every time i do a new run, i recreate these 
 objects and the boss is getting a little annoyed. I know/think that I should 
 use attach and detach commands  but

 1) i can't find an example somewhere of
 just saving two objects rather than the whole session.
 i've looked and looked and i can't find it.

 2) if i am able to save these two objects, i was hoping that it
 would be possible to write code inside my R program
 that basically says, if these objects already exist in
 such and such database, then skip over this section of the code
 that creates them.

 if someone has some code or a page number or reference, this is fine because 
 i used to do pretty much this in Splus so think i can figure it out if i can 
 just find an example.  thanks a lot.

 __
 R-help@stat.math.ethz.ch 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] attach and detach question

2006-07-07 Thread Chuck Cleland
[EMAIL PROTECTED] wrote:
 I have a large R program that I am constantly running over and over again. At 
 the beginning of this program, I create a hige matrix and a huge dataframe 
 but these are constant. What I mean by constant is that, if I run the program 
 over later, I really should just use the old matrix and dataframe ( if they 
 exist ) that were created in a previous run so that the program doesn't have 
 to spend time creating them. Unfortunately, I don't know how to do this so 
 things take foreeer because every time i do a new run, i recreate these 
 objects and the boss is getting a little annoyed. I know/think that I should 
 use attach and detach commands  but 
 
 1) i can't find an example somewhere of
 just saving two objects rather than the whole session.
 i've looked and looked and i can't find it.
 
 2) if i am able to save these two objects, i was hoping that it
 would be possible to write code inside my R program
 that basically says, if these objects already exist in
 such and such database, then skip over this section of the code
 that creates them.

   You probably want save() and load() rather than attach() and detach().

# Save only a couple of objects
save(huge.mat, huge.df, file=myfile.Rdata)

# Load objects only if they do not exist
if(!exists(huge.mat)  !exists (huge.df)) load(myfile.Rdata) else
   {cat(\n, Object(s) Already Exist, \n)}

?save
?load
?exists

 if someone has some code or a page number or reference, this is fine because 
 i used to do pretty much this in Splus so think i can figure it out if i can 
 just find an example.  thanks a lot.
 
 __
 R-help@stat.math.ethz.ch 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) 512-0171 (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] Levels and GLM

2006-07-07 Thread justin rapp
I am using the as.factor command to use with glm.  When I use the command

maj - as.factor(data.logistic$Majors)
maj

I receive the following output:
  [1] M M N M M M M N N M M M N M M M M M M M M M M M N M N N M M N M
M N M M M M M
 [40] N M N M M N M M M N M N M N M N N N M N M M M M M M N M N M M M
M M N N M M M
 [79] M M M N N M M N M N M M M M M M M M M M M M M M M N M M M M M N
M M M M M N M
[118] M M M N M N N M M M M M M M M N M N M M M M M N M M M M N M M M
N N M M M N M
[157] M M M M M M M M M M M M M N M M N N M M N M M M M M M M M M M M
M M N M N M M
[196] M N M M M M M M M M N M M M M M M M M N M M M M M M M M M M M M
M M N M M N N
[235] M M M M M N M M M M M M N N M M N M M M M M M M M M M M M M M M
M N M M M M N
[274] N M M M M M M N M M M M M M M M M M N N M N M M M M M M M M M M
N M N N M M M
[313] M M M M M M M N M M M M M N M M M M M M M M M M M M M M M N M M
M M M M M N M
[352] M N M N M M N M M M M N M M M M M M M M M M N M M N N
Levels: M N

When I enter:

 logistic.glm - glm(data.logistic$X100.Yard.Average ~ data.logistic$Overall + 
 maj, family=binomial)
 logistic.glm

I receive the following output:

Call:  glm(formula = data.logistic$X100.Yard.Average ~
data.logistic$Overall +  maj, family = binomial)

Coefficients:
  (Intercept)  data.logistic$Overall   majN
  2.38819   -0.02718   -0.18385

Degrees of Freedom: 377 Total (i.e. Null);  375 Residual
Null Deviance:  514.5
Residual Deviance: 410.7AIC: 416.7

My question:  Why is there no output for majM?  Any help would be
greatly appreciated

__
R-help@stat.math.ethz.ch 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-pkgs] ggplot: a new system for drawing graphics in R

2006-07-07 Thread Timm Danker
I think the ggplot package is extremely promising.
Parts of the dokumentation are very good alread, e.g I recently managed 
to write my first own grob function.
One thing I am missing in the dokumentation is a little more detail on 
how to modify the colours of a plot.
Specifically, if I have:

  xx-x y g bar
1 1 1 1
1 5 2 3
2 3 1 3
2 4 2 2
df=read.table(textConnection(xx),header=T);df
  ggplot(df, aes=list(y=y, x=factor(x),bar=bar))-p
  ggbar(p, aes=list(fill=g,barcolour=g+1), avoid=dodge, sort=TRUE)

... I get a beatiful barplot, but would like to change the colors of the 
bars. I tried

?scfill

and did not understand too much of the help file.
I think some more examples would do it.

Timm

hadley wickham schrieb:
 ggplot provides a new system for drawing graphics in R, based on the
 Grammar of Graphics. It combines the advantages of both base and
 lattice graphics: conditioning and shared axes are handled
 automatically, and you can still build up a plot step by step from
 multiple data sources. It also implements a more sophisticated
 multidimensional conditioning system and a consistent interface to map
 data to visual attributes.  ggplot (along with reshape) received the
 John Chambers Award for Statistical Computing.
 
 ggplot is available now from CRAN (install.packages(ggplot)) and
 more information is available at my website (http://had.co.nz/ggplot)
 including copies of talks, examples, and a guide showing how to
 convert your existing lattice code.
 
 To get started I recommend you look at:
 
  * the introductory vignette: vignette(introduction, ggplot)
  * help for the quick plotting command: ?qplot
  * help for the full plotting commands: ?ggplot
 
 I want to provide great documentation, so if there is anything you
 think I am missing, please let me know.
 
 Regards,
 
 Hadley
 
 ___
 R-packages mailing list
 [EMAIL PROTECTED]
 https://stat.ethz.ch/mailman/listinfo/r-packages
 
 __
 R-help@stat.math.ethz.ch 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] attach and detach question

2006-07-07 Thread Gavin Simpson
On Fri, 2006-07-07 at 12:57 -0500, [EMAIL PROTECTED] wrote:
snipped /
 
 1) i can't find an example somewhere of
 just saving two objects rather than the whole session.
 i've looked and looked and i can't find it.

?save

 2) if i am able to save these two objects, i was hoping that it
 would be possible to write code inside my R program
 that basically says, if these objects already exist in
 such and such database, then skip over this section of the code
 that creates them.
 

Is this the kind of thing you mean? I used the FileExists function from
package RandomFields as this does the file checking - you could do
something similar with ?file.list and match the name but why reinvent
the wheel.

I flipped your situation 2 around, if you have some really big objects
then it would make sense to generate the objects, save them out to
files. From a new session, you are likely not to have objects, so
perhaps better to check the file exists, if so load it, then check the
right objects are there. Alter to what suits you best.

## create two objects to be saved
obj1 - matrix(rnorm(1000), ncol = 10)
obj2 - matrix(rnorm(1000), ncol = 10)
## save them
save(obj1, obj2, file = tmp.file.RData)
## clean up
rm(list = ls())
ls()

## load the required package
require(RandomFields)

## load the saved objects
if(FileExists(tmp.file.RData)) {
  load(tmp.file.RData)
  if(exists(obj1)  exists(obj2)) {
## more code here
summary(obj1)
summary(obj2)
  } else
  stop(Required objects don't exist!)
} else
stop(Big objects not found, check file exists!)

## clean up
rm(list = ls())

## if file exists but not correct objects
if(FileExists(tmp.file.RData)) {
  load(tmp.file.RData)
  ## simulate different object names
  obj3 - obj1
  obj4 - obj2
  rm(obj1, obj2)
  if(exists(obj1)  exists(obj2)) {
## more code here
summary(obj1)
summary(obj2)
  } else
  stop(Required objects don't exist!)
} else
stop(Big objects not found, check file exists!)

## clean up
rm(list = ls())

## if file doesn't exists
unlink(tmp.file.RData)
if(FileExists(tmp.file.RData)) {
  load(tmp.file.RData)
  ## remove the objects
  obj3 - obj1
  obj4 - obj2
  rm(obj1, obj2)
  if(exists(obj1)  exists(obj2)) {
## more code here
summary(obj1)
summary(obj2)
  } else
  stop(Required objects don't exist!)
} else
stop(Big objects not found, check file exists!)

HTH,

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/cv/
 London, UK. WC1E 6BT. [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] panel ordering in nlme and augPred plots

2006-07-07 Thread Spencer Graves
  I'm not sufficiently familiar with 'trellis' / 'lattice' to provide 
an easy, complete answer to your question, but I can explain the current 
behavior and provide a hack to get you what you want.  With luck, 
someone else will suggest an improvement.

  First, let's decompose your lovely, self-contained example in a more 
informative way:

fm - lme(Orthodont)
ap - augPred(fm, level = 0:1)
plot(ap, skip = rep(c(F,T), c(16, 2)))

  Next, let's examine the structure of 'ap':

str(ap)
Classes augPred  and `data.frame':  2862 obs. of  4 variables:
  $ age : num  8 10 12 14 8 10 12 14 8 10 ...
  $ .groups : Ord.factor w/ 27 levels M16M05M02..: 15 15 15 15 
3 3 3 3 7 7 ...
   ..- attr(*, label)= chr Subject
snip ...

  The key here is that 'ap$.groups' is of class Ord.factor with levels 
as follows:

  levels(ap$.groups)
  [1] M16 M05 M02 M11 M07 M08 M03 M12 M13 M14 M09 
M15
[13] M06 M04 M01 M10 F10 F09 F06 F01 F05 F07 F02 F08
[25] F03 F04 F11

  These names appear in the same order here that they appear in the 
trellis display, reading the display from left to right and bottom to 
top -- NOT top to bottom.

  This also tells you one way to get around this:  Change the order of 
the levels.  We can do this as follows:

ap2 - ap
ap2$.groups - with(ap,
   ordered(as.character(.groups),
   sort(levels(.groups
plot(ap2, skip = rep(c(F,T), c(11, 1)))

  Hope this helps.
  Spencer Graves

Nathaniel Derby wrote:
 Hi,
 
 I'm new at this, I'm very confused, and I think I'm missing something
 important here.  In our pet example we have this:
 
 fm - lme(Orthodont)
 plot(Orthodont)
 plot(augPred(fm, level = 0:1))
 
 which gives us a trellis plot with the females above the males,
 starting with F03, F04, F11, F06, etc.  I thought the point of
 this was to create an ordering where the females are ordered (F01,
 F02, F03, etc -- followed by the males being ordered).  However,
 the solution given ...
 
 fm - lme(Orthodont)
 plot(Orthodont)
 plot(augPred(fm1, level = 0:1), skip = rep(c(F,T), c(16, 2)))
 
 ... doesn't solve it -- although it does do all the females before
 starting on the males.  That is, it starts with F02, F08, F03,
 ... which isn't in order either.
 
 Running Petr's code also gave output which wasn't ordered by the subjects.
 
 Could someone please explain to me how to order the panels of the
 trellis plot by the subjects?
 
 
 thanks,
 
 Nandor
 
 __
 R-help@stat.math.ethz.ch 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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Deepayan Sarkar
On 7/7/06, Sebastian Luque [EMAIL PROTECTED] wrote:
 Hi,

 The following produces almost exactly what I needed.  The problems are
 that the 'panel.dotplot' call (commented) generates the error 'Error in
 NextMethod([) : argument subscripts is missing, with no default'.

It's just as it says: panel.dotplot wants a 'subscripts' argument when
'groups' is not null, and you have forgotten to give it one.

 The
 other problem is that the colors alternate between the levels of the 'site'
 variable, rather than 'year'.

It's doing what it's being told to do. You probably want something like

dotplot(site ~ yield | variety, data=barley,
groups=year, yield2=barley$yield2,
col=c(gray, black),
panel = panel.superpose,
panel.groups = function(x, y, subscripts, yield2, col, ...) {
panel.xyplot(x, y, col = col, ...)
panel.segments(x, y, yield2[subscripts], y, col = col)
})

Note that you don't want to use panel.dotplot here as it would draw a
reference line both times. If you do want a reference line, add that
in the panel function.

The explicit use of 'col' should not have been necessary, i.e., the
following should have worked:

dotplot(site ~ yield | variety, data=barley,
groups=year, yield2=barley$yield2,
col=c(gray, black),
panel = panel.superpose,
panel.groups = function(x, y, subscripts, yield2, ...) {
panel.xyplot(x, y, col = ...)
panel.segments(x, y, yield2[subscripts], y, ...)
})

I believe this doesn't work because of a grid bug. I'll take that up
in a separate thread.

-Deepayan



 barley$yield2 - with(barley, yield + 5)

 dotplot(site ~ yield | variety, data=barley, groups=year,
 yield2=barley$yield2, col=c(gray, black),
 panel=function(x, y, subscripts, yield2, ...) {
 ## panel.dotplot(x, y, ...)
 panel.segments(x, as.numeric(y),
yield2[subscripts], as.numeric(y), ...)
 })

 R sessionInfo()
 Version 2.3.1 (2006-06-01)
 i486-pc-linux-gnu

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

 other attached packages:
chron  gmodels  lattice
  2.3-3 2.12.0 0.13-8


 Can somebody please suggest how to properly make that 'panel.dotplot' call
 and set the 'col' argument?  Thanks in advance.

__
R-help@stat.math.ethz.ch 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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Gabor Grothendieck
Could you explain what panel.groups= does and what the difference
is between panel.groups= and panel= ?  In ?xyplot it just says:

panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies
  when 'panel' is 'panel.superpose' (which happens by default
  in these cases if 'groups' is non-null)

which indicates when it might apply but not what it does.

Also can we assume from the above that the panel=panel.superpose
in your response could have been omitted?

Thanks.


On 7/7/06, Deepayan Sarkar [EMAIL PROTECTED] wrote:
 On 7/7/06, Sebastian Luque [EMAIL PROTECTED] wrote:
  Hi,
 
  The following produces almost exactly what I needed.  The problems are
  that the 'panel.dotplot' call (commented) generates the error 'Error in
  NextMethod([) : argument subscripts is missing, with no default'.

 It's just as it says: panel.dotplot wants a 'subscripts' argument when
 'groups' is not null, and you have forgotten to give it one.

  The
  other problem is that the colors alternate between the levels of the 'site'
  variable, rather than 'year'.

 It's doing what it's being told to do. You probably want something like

 dotplot(site ~ yield | variety, data=barley,
groups=year, yield2=barley$yield2,
col=c(gray, black),
panel = panel.superpose,
panel.groups = function(x, y, subscripts, yield2, col, ...) {
panel.xyplot(x, y, col = col, ...)
panel.segments(x, y, yield2[subscripts], y, col = col)
})

 Note that you don't want to use panel.dotplot here as it would draw a
 reference line both times. If you do want a reference line, add that
 in the panel function.

 The explicit use of 'col' should not have been necessary, i.e., the
 following should have worked:

 dotplot(site ~ yield | variety, data=barley,
groups=year, yield2=barley$yield2,
col=c(gray, black),
panel = panel.superpose,
panel.groups = function(x, y, subscripts, yield2, ...) {
panel.xyplot(x, y, col = ...)
panel.segments(x, y, yield2[subscripts], y, ...)
})

 I believe this doesn't work because of a grid bug. I'll take that up
 in a separate thread.

 -Deepayan

 
 
  barley$yield2 - with(barley, yield + 5)
 
  dotplot(site ~ yield | variety, data=barley, groups=year,
  yield2=barley$yield2, col=c(gray, black),
  panel=function(x, y, subscripts, yield2, ...) {
  ## panel.dotplot(x, y, ...)
  panel.segments(x, as.numeric(y),
 yield2[subscripts], as.numeric(y), ...)
  })
 
  R sessionInfo()
  Version 2.3.1 (2006-06-01)
  i486-pc-linux-gnu
 
  attached base packages:
  [1] methods   stats graphics  grDevices utils datasets
  [7] base
 
  other attached packages:
 chron  gmodels  lattice
   2.3-3 2.12.0 0.13-8
 
 
  Can somebody please suggest how to properly make that 'panel.dotplot' call
  and set the 'col' argument?  Thanks in advance.

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

2006-07-07 Thread Mark Hempelmann
Dear WizaRds, dear Thomas,

First of all, I want to tell you how grateful I am for all your 
support. I wish I will be able to help others along one day the same way 
you do. Thank you so much. I am struggling with a multistage sampling 
design:

library(survey)
multi3  - data.frame(cluster=c(1,1,1,1 ,2,2,2, 3,3), id=c(1,2,3,4, 
1,2,3, 1,2),
nl=c(4,4,4,4, 3,3,3, 2,2), Nl=c(100,100,100,100, 50,50,50, 75,75), 
M=rep(23,9),
y=c(23,33,77,25, 35,74,27, 37,72) )

dmulti3 - svydesign(id=~cluster+id, fpc=~M+Nl, data=multi3)
svymean (~y, dmulti3)
mean SE
y 45.796 5.5483

svytotal(~y, dmulti3)
  totalSE
y 78999 13643

and I estimate the population total as N=M/m sum(Nl) = 
23/3*(100+50+75)=1725. With this, my variance estimator is:
y1-mean(multi3$y[1:4]) # 39.5
y2-mean(multi3$y[5:7]) # 45.33
y3-mean(multi3$y[8:9]) # 54.5

yT1-100*y1 # 3950 total cluster 1
yT2-50*y2 # 2266.67 total cluster 2
yT3-75*y3 # 4087.5 total cluster 3
ybarT-1/3*sum(yT1,yT2,yT3) # 3434.722
s1 - var(multi3$y[1:4]) # 643.67 var cluster 1
s2 - var(multi3$y[5:7]) # 632.33 var cluster 2
s3 - var(multi3$y[8:9]) # 612.5 var cluster 3

var.yT - 23^2*( 20/23*1/6*sum( 
(yT1-ybarT)^2,(yT2-ybarT)^2,(yT3-ybarT)^2 ) +
1/69 * sum(100*96*s1, 50*47*s2, 75*73*s3) ) # 242 101 517

but
var.yT/1725^2 = 81.36157
SE = 9.02006,
but it should be SE=13643/1725=7.90899

Is this calculation correct? I remember svytotal using a different 
variance estimator compared to svymean, and that svytotal gives the 
unbiased estimation. To solve the problem, I went ahead and tried to 
calibrate the design object, telling Survey the population total N=1725:

dmulti3.cal - calibrate(dmulti3, ~1, pop=1725)
svymean (~y, dmulti3.cal)
mean SE
y 45.796 5.5483

svytotal(~y, dmulti3.cal)
  total SE
y 78999 9570.7

, which indeed gives me the computed svymean SE, but alas, I still don't 
know why my variance is so different. I think it might have sthg to do 
with a differently computed N and the fact that your estimator formula 
is a different one. Since I calculated the Taylor Series solution, i 
suppose there must be another approach? The calibration help page tells 
me to enter a list of population total vectors for each cluster, which 
would result in:

dmulti3.cal - calibrate(dmulti3, ~1, pop=c(100,50,75))
Error in regcalibrate.survey.design2(design, formula, population, 
aggregate.stage = aggregate.stage,  :
Population and sample totals are not the same length.

I am very grateful for your help and wish you alle the best
Yours
mark

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

2006-07-07 Thread markleeds
From: Mark Hempelmann [EMAIL PROTECTED]
Date: Fri Jul 07 14:05:29 CDT 2006
To: r-help@stat.math.ethz.ch
Subject: [R] Multistage Sampling

i also find it an truly amazing group also. the general kindness
and generosity of everyone is beyond belief.  it will be a long time coming but 
i hope i can help some day also. unfortunately,
i can't help you with your question either.

   mark



Dear WizaRds, dear Thomas,

First of all, I want to tell you how grateful I am for all your 
support. I wish I will be able to help others along one day the same way 
you do. Thank you so much. I am struggling with a multistage sampling 
design:

library(survey)
multi3  - data.frame(cluster=c(1,1,1,1 ,2,2,2, 3,3), id=c(1,2,3,4, 
1,2,3, 1,2),
nl=c(4,4,4,4, 3,3,3, 2,2), Nl=c(100,100,100,100, 50,50,50, 75,75), 
M=rep(23,9),
y=c(23,33,77,25, 35,74,27, 37,72) )

dmulti3 - svydesign(id=~cluster+id, fpc=~M+Nl, data=multi3)
svymean (~y, dmulti3)
mean SE
y 45.796 5.5483

svytotal(~y, dmulti3)
  totalSE
y 78999 13643

and I estimate the population total as N=M/m sum(Nl) = 
23/3*(100+50+75)=1725. With this, my variance estimator is:
y1-mean(multi3$y[1:4]) # 39.5
y2-mean(multi3$y[5:7]) # 45.33
y3-mean(multi3$y[8:9]) # 54.5

yT1-100*y1 # 3950 total cluster 1
yT2-50*y2 # 2266.67 total cluster 2
yT3-75*y3 # 4087.5 total cluster 3
ybarT-1/3*sum(yT1,yT2,yT3) # 3434.722
s1 - var(multi3$y[1:4]) # 643.67 var cluster 1
s2 - var(multi3$y[5:7]) # 632.33 var cluster 2
s3 - var(multi3$y[8:9]) # 612.5 var cluster 3

var.yT - 23^2*( 20/23*1/6*sum( 
(yT1-ybarT)^2,(yT2-ybarT)^2,(yT3-ybarT)^2 ) +
1/69 * sum(100*96*s1, 50*47*s2, 75*73*s3) ) # 242 101 517

but
var.yT/1725^2 = 81.36157
SE = 9.02006,
but it should be SE=13643/1725=7.90899

Is this calculation correct? I remember svytotal using a different 
variance estimator compared to svymean, and that svytotal gives the 
unbiased estimation. To solve the problem, I went ahead and tried to 
calibrate the design object, telling Survey the population total N=1725:

dmulti3.cal - calibrate(dmulti3, ~1, pop=1725)
svymean (~y, dmulti3.cal)
mean SE
y 45.796 5.5483

svytotal(~y, dmulti3.cal)
  total SE
y 78999 9570.7

, which indeed gives me the computed svymean SE, but alas, I still don't 
know why my variance is so different. I think it might have sthg to do 
with a differently computed N and the fact that your estimator formula 
is a different one. Since I calculated the Taylor Series solution, i 
suppose there must be another approach? The calibration help page tells 
me to enter a list of population total vectors for each cluster, which 
would result in:

dmulti3.cal - calibrate(dmulti3, ~1, pop=c(100,50,75))
Error in regcalibrate.survey.design2(design, formula, population, 
aggregate.stage = aggregate.stage,  :
Population and sample totals are not the same length.

I am very grateful for your help and wish you alle the best
Yours
mark

__
R-help@stat.math.ethz.ch 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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Deepayan Sarkar
On 7/7/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Could you explain what panel.groups= does and what the difference
 is between panel.groups= and panel= ?  In ?xyplot it just says:

 panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies
   when 'panel' is 'panel.superpose' (which happens by default
   in these cases if 'groups' is non-null)

 which indicates when it might apply but not what it does.

That's wrong (it used to be right - a good example of why \synopsis is
bad). Since lattice 0.13-x, panel.superpose is never the default panel
function. An updated version with improved documentation should be out
soon.

'panel.groups' is simply an argument to panel.superpose, and is
described in ?panel.superpose. Thus, it only makes sense as an
argument to xyplot/dotplot/whatever when the panel function is
panel.superpose, and not otherwise. The entry for the graphical
parameters in ?panel.superpose isn't as useful as it could be, I have
just updated it to read:

col, col.line, col.symbol, pch, cex, fill, font, fontface,
fontfamily, lty, lwd, alpha: graphical
  parameters, replicated to be as long as the number of
  groups.  These are eventually passed down to 'panel.groups',
  but as scalars rather than vectors.  When 'panel.groups' is
  called for the i-th level of 'groups', the corresponding
  element of each graphical parameter is passed to it.

Hope that makes things a bit clearer.

Deepayan

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


[R] FW: Levels and GLM

2006-07-07 Thread Kuhn, Max
 
One correction... since you are fitting a logistic model, it is 
technically correct to say the mean value of the linear predictor, 
instead of mean response.

20 lashes for me.

Max

-Original Message-
From: Kuhn, Max 
Sent: Friday, July 07, 2006 4:11 PM
To: 'r-help@stat.math.ethz.ch'
Subject: [R] Levels and GLM

jdrapp,

By default, R fits full rank models. If you are coming from SAS, you're 
probably used to less than full rank model parameterizations. 

From Section 11.1.1 of An Introduction to R at

http://cran.r-project.org/doc/manuals/R-intro.html#Contrasts

there is this:

 What about a k-level factor A? The answer differs for unordered and 
 ordered factors. For unordered factors k - 1 columns are generated 
 for the indicators of the second, ..., kth levels of the factor. 
 (Thus the implicit parameterization is to contrast the response at 
 each level with that at the first.)

So level M is the reference cell. Assuming that 
data.logistic$Overall is continuous, the intercept is the estimate of 
the mean response when maj = M and data.logistic$Overall = 0. The 
estimate for majN is the difference between the reference cell
(estimated 
by the intercept) and the mean response when maj = N and 
data.logistic$Overall = 0.

You should check out ?model.matrix and ?contrasts.

Max


 I am using the as.factor command to use with glm.  When I use the
command
 
 maj - as.factor(data.logistic$Majors)
 maj
 
 I receive the following output:
   [1] M M N M M M M N N M M M N M M M M M M M M M M M N M N N M M N M
 M N M M M M M
  [40] N M N M M N M M M N M N M N M N N N M N M M M M M M N M N M M M
 M M N N M M M
  [79] M M M N N M M N M N M M M M M M M M M M M M M M M N M M M M M N
 M M M M M N M
 [118] M M M N M N N M M M M M M M M N M N M M M M M N M M M M N M M M
 N N M M M N M
 [157] M M M M M M M M M M M M M N M M N N M M N M M M M M M M M M M M
 M M N M N M M
 [196] M N M M M M M M M M N M M M M M M M M N M M M M M M M M M M M M
 M M N M M N N
 [235] M M M M M N M M M M M M N N M M N M M M M M M M M M M M M M M M
 M N M M M M N
 [274] N M M M M M M N M M M M M M M M M M N N M N M M M M M M M M M M
 N M N N M M M
 [313] M M M M M M M N M M M M M N M M M M M M M M M M M M M M M N M M
 M M M M M N M
 [352] M N M N M M N M M M M N M M M M M M M M M M N M M N N
 Levels: M N
 
 When I enter:
 
  logistic.glm - glm(data.logistic$X100.Yard.Average ~
data.logistic$Overall + maj, family=binomial)
  logistic.glm
 
 I receive the following output:
 
 Call:  glm(formula = data.logistic$X100.Yard.Average ~
 data.logistic$Overall +  maj, family = binomial)
 
 Coefficients:
   (Intercept)  data.logistic$Overall   majN
   2.38819   -0.02718   -0.18385
 
 Degrees of Freedom: 377 Total (i.e. Null);  375 Residual
 Null Deviance:514.5
 Residual Deviance: 410.7  AIC: 416.7
 
 My question:  Why is there no output for majM?  Any help would be
 greatly appreciated
--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

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


Re: [R] FW: Levels and GLM

2006-07-07 Thread Peter Dalgaard
Kuhn, Max [EMAIL PROTECTED] writes:

  
 One correction... since you are fitting a logistic model, it is 
 technically correct to say the mean value of the linear predictor, 
 instead of mean response.
 
 20 lashes for me.

...plus five more for forgetting that the link is nonlinear and that
you can't meaningfully speak about the mean on the linear predictor
scale. Value of linear predictor corresponding to the mean response
is correct (I hope...)

 So level M is the reference cell. Assuming that 
 data.logistic$Overall is continuous, the intercept is the estimate of 
 the mean response when maj = M and data.logistic$Overall = 0. The 
 estimate for majN is the difference between the reference cell

-- 
   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] dotplot (lattice) with panel.segments and groups

2006-07-07 Thread Gabor Grothendieck
On 7/7/06, Deepayan Sarkar [EMAIL PROTECTED] wrote:
 On 7/7/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  Could you explain what panel.groups= does and what the difference
  is between panel.groups= and panel= ?  In ?xyplot it just says:
 
  panel.groups: useful mostly for 'xyplot' and 'densityplot'. Applies
when 'panel' is 'panel.superpose' (which happens by default
in these cases if 'groups' is non-null)
 
  which indicates when it might apply but not what it does.

 That's wrong (it used to be right - a good example of why \synopsis is
 bad). Since lattice 0.13-x, panel.superpose is never the default panel
 function. An updated version with improved documentation should be out
 soon.

 'panel.groups' is simply an argument to panel.superpose, and is
 described in ?panel.superpose. Thus, it only makes sense as an
 argument to xyplot/dotplot/whatever when the panel function is
 panel.superpose, and not otherwise. The entry for the graphical
 parameters in ?panel.superpose isn't as useful as it could be, I have
 just updated it to read:

 col, col.line, col.symbol, pch, cex, fill, font, fontface,
 fontfamily, lty, lwd, alpha: graphical
  parameters, replicated to be as long as the number of
  groups.  These are eventually passed down to 'panel.groups',
  but as scalars rather than vectors.  When 'panel.groups' is
  called for the i-th level of 'groups', the corresponding
  element of each graphical parameter is passed to it.

 Hope that makes things a bit clearer.

 Deepayan


Thanks.  That does help.

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

2006-07-07 Thread Thomas Lumley
On Fri, 7 Jul 2006, Mark Hempelmann wrote:
 library(survey)
 multi3  - data.frame(cluster=c(1,1,1,1 ,2,2,2, 3,3), id=c(1,2,3,4,
 1,2,3, 1,2),
 nl=c(4,4,4,4, 3,3,3, 2,2), Nl=c(100,100,100,100, 50,50,50, 75,75),
 M=rep(23,9),
 y=c(23,33,77,25, 35,74,27, 37,72) )

 dmulti3 - svydesign(id=~cluster+id, fpc=~M+Nl, data=multi3)
 svymean (~y, dmulti3)
mean SE
 y 45.796 5.5483

 svytotal(~y, dmulti3)
  totalSE
 y 78999 13643

 and I estimate the population total as N=M/m sum(Nl) =
 23/3*(100+50+75)=1725. With this, my variance estimator is:
 y1-mean(multi3$y[1:4]) # 39.5
 y2-mean(multi3$y[5:7]) # 45.33
 y3-mean(multi3$y[8:9]) # 54.5

 yT1-100*y1 # 3950 total cluster 1
 yT2-50*y2 # 2266.67 total cluster 2
 yT3-75*y3 # 4087.5 total cluster 3
 ybarT-1/3*sum(yT1,yT2,yT3) # 3434.722
 s1 - var(multi3$y[1:4]) # 643.67 var cluster 1
 s2 - var(multi3$y[5:7]) # 632.33 var cluster 2
 s3 - var(multi3$y[8:9]) # 612.5 var cluster 3

 var.yT - 23^2*( 20/23*1/6*sum(
 (yT1-ybarT)^2,(yT2-ybarT)^2,(yT3-ybarT)^2 ) +
 1/69 * sum(100*96*s1, 50*47*s2, 75*73*s3) ) # 242 101 517

I don't have any of my reference books here today, but if you use
   var.yT - 23^2*( 20/23*1/6*sum(
(yT1-ybarT)^2,(yT2-ybarT)^2,(yT3-ybarT)^2 ) +
1/69 * sum(100*96*s1/4, 50*47*s2/3, 75*73*s3/2) ) # 242 101 517
the results agrees with svytotal(), and with Stata, and with formulas in a 
couple of sets of lecture notes I found by Googling.


 but
 var.yT/1725^2 = 81.36157
 SE = 9.02006,
 but it should be SE=13643/1725=7.90899

 Is this calculation correct? I remember svytotal using a different
 variance estimator compared to svymean, and that svytotal gives the
 unbiased estimation.

This calculation is not correct for the mean, since it ignores the 
uncertainty in the estimated population total.  The correct standard error 
comes from treating the mean as a ratio of estimated total to estimated 
population size. In this case you have to do it that way since you don't 
know the population size, but R always does it this way. Because the 
estimated population size and total are correlated, taking into account 
the uncertainty in the denominator actually reduces the standard error.

The easiest way to reproduce the result that R gets is to do it the same 
way that R does: compute the standard error of the mean as the standard 
error of the total of a suitable set of estimating functions. If you 
define a new variable (y-45.796*1)/1725 and estimate the standard error of 
the total of this variable it will give:
 svytotal(~I((y-45.796)/1725),dmulti3) 
I((y - 45.796)/1725) 0.0002963 5.5482

which is what svymean() gives for the standard error of the mean of y. 
Using your formula for the variance of the total (with the corrections 
above) on this variable also gives
 sqrt(var.yT)
[1] 5.54824


-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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

2006-07-07 Thread Spencer Graves
  Since I haven't seen an answer to this, I'll offer a couple of 
comments.  I don't recall having heard the term 'harmonic regression' 
prior to seeing your email, but it sounded interesting, so I did some 
searching.  First, RSiteSearch(harminic regression) produced 7 hits, 
one of which discusses the 'cyclones' package, which may be what you want:

http://finzi.psych.upenn.edu/R/library/cyclones/html/00Index.html

  Second, for the benefit of folks like me who aren't sure of the 
definition, it appears to be linear regression on sines and cosines of 
something like 'time'.  The following link describes how to do this 
using 'lm' in S-Plus or R:

http://www.math.jmu.edu/~tomitayx/math328/Ch6SlideD.pdf

  Hope this helps.
  Spencer Graves

Airon Yiu wrote:
 Dear all:

   Does anyone has harmonic regresssion analysis package written in R (to be 
 used in Windows platform) ?

   Thanks
 
  ___
  YM - Â÷½u°T®§
  
 ´Nºâ§A¨S¦³¤Wºô¡A§AªºªB¤Í¤´¥i¥H¯d¤U°T®§µ¹§A¡A·í§A¤Wºô®É´N¯à¥ß§Y¬Ý¨ì¡A¥ô¦ó»¡¸Ü³£ÉN¨«¥¢¡C
  http://messenger.yahoo.com.hk
   [[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-help@stat.math.ethz.ch 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] Harmonic Regression in R

2006-07-07 Thread Gabor Grothendieck

I have not seen it myself (I have the first edition which uses FORTRAN)
but I believe the second edition of Peter Bloomfield's book on Fourier
Analysis contains harmonic regression code in S-Plus and that may
work in R.

On 7/7/06, Spencer Graves [EMAIL PROTECTED] wrote:

 Since I haven't seen an answer to this, I'll offer a couple of
comments.  I don't recall having heard the term 'harmonic regression'
prior to seeing your email, but it sounded interesting, so I did some
searching.  First, RSiteSearch(harminic regression) produced 7 hits,
one of which discusses the 'cyclones' package, which may be what you want:

http://finzi.psych.upenn.edu/R/library/cyclones/html/00Index.html

 Second, for the benefit of folks like me who aren't sure of the
definition, it appears to be linear regression on sines and cosines of
something like 'time'.  The following link describes how to do this
using 'lm' in S-Plus or R:

http://www.math.jmu.edu/~tomitayx/math328/Ch6SlideD.pdf

 Hope this helps.
 Spencer Graves

Airon Yiu wrote:
 Dear all:

   Does anyone has harmonic regresssion analysis package written in R (to be 
used in Windows platform) ?

   Thanks

  ___
  YM - 離線訊息
  就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
  http://messenger.yahoo.com.hk
   [[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-help@stat.math.ethz.ch 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] KhmaladzeTest

2006-07-07 Thread raul sanchez
Hello. I am a beginer in R and I can not implement the KhmaladzeTest in the 
following command. Please help me!!!
  PD: I attach thw results and the messages of the R program
   
  R : Copyright 2006, The R Foundation for Statistical Computing
Version 2.3.1 (2006-06-01)
ISBN 3-900051-07-0

R es un software libre y viene sin GARANTIA ALGUNA.
Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.
Escriba 'contributors()' para obtener mas informacion y
'citation()' para saber como citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line 
de ayuda,
o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

 utils:::menuInstallLocal()
package 'quantreg' successfully unpacked and MD5 sums checked
updating HTML package descriptions
 utils:::menuInstallLocal()
package 'foreign' successfully unpacked and MD5 sums checked
updating HTML package descriptions
 utils:::menuInstallLocal()
package 'Rcmdr' successfully unpacked and MD5 sums checked
updating HTML package descriptions
 local({pkg - select.list(sort(.packages(all.available = TRUE)))
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
 local({pkg - select.list(sort(.packages(all.available = TRUE)))
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
quantreg package loaded:  To cite see citation(quantreg)
 local({pkg - select.list(sort(.packages(all.available = TRUE)))
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
 local({pkg - select.list(sort(.packages(all.available = TRUE)))
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Loading required package: tcltk
Loading Tcl/Tk interface ... done
--- Please select a CRAN mirror for use in this session ---
also installing the dependencies 'acepack', 'scatterplot3d', 'fBasics', 
'Hmisc', 'quadprog', 'oz', 'mlbench', 'randomForest', 'SparseM', 
'xtable', 'chron', 'fCalendar', 'its', 'tseries', 'DAAG', 'e1071', 'mvtnorm', 
'zoo', 'strucchange', 'sandwich', 'dynlm', 'leaps'

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/acepack_1.3-2.2.zip'
Content 
type 'application/zip' length 55667 bytes
URL abierta
downloaded 54Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/scatterplot3d_0.3-24.zip'
Content 
type 'application/zip' length 540318 bytes
URL abierta
downloaded 527Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/fBasics_221.10065.zip'
Content 
type 'application/zip' length 3327499 bytes
URL abierta
downloaded 3249Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/Hmisc_3.0-12.zip'
Content 
type 'application/zip' length 1993038 bytes
URL abierta
downloaded 1946Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/quadprog_1.4-8.zip'
Content 
type 'application/zip' length 38626 bytes
URL abierta
downloaded 37Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/oz_1.0-13.zip'
Content 
type 'application/zip' length 39640 bytes
URL abierta
downloaded 38Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/mlbench_1.1-1.zip'
Content 
type 'application/zip' length 1324913 bytes
URL abierta
downloaded 1293Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/randomForest_4.5-16.zip'
Content 
type 'application/zip' length 209710 bytes
URL abierta
downloaded 204Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/SparseM_0.68.zip'
Content 
type 'application/zip' length 728594 bytes
URL abierta
downloaded 711Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/xtable_1.3-2.zip'
Content 
type 'application/zip' length 56703 bytes
URL abierta
downloaded 55Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/chron_2.3-4.zip'
Content 
type 'application/zip' length 101287 bytes
URL abierta
downloaded 98Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/fCalendar_221.10065.zip'
Content 
type 'application/zip' length 754551 bytes
URL abierta
downloaded 736Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/its_1.1.1.zip'
Content 
type 'application/zip' length 194287 bytes
URL abierta
downloaded 189Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/tseries_0.10-3.zip'
Content 
type 'application/zip' length 392748 bytes
URL abierta
downloaded 383Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/DAAG_0.79.zip'
Content 
type 'application/zip' length 796328 bytes
URL abierta
downloaded 777Kb

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/e1071_1.5-13.zip'
Content 
type 'application/zip' length 627972 bytes
URL abierta

probando la URL 
'http://cran.au.r-project.org/bin/windows/contrib/2.3/mvtnorm_0.7-2.zip'
Content 
type 

Re: [R] parametric proportional hazard regression

2006-07-07 Thread Valentin Dimitrov


 
 Those are not proportional hazards families of
 distributions. That is, if 
 the distribution is gaussian for one value of the
 hazard ratio parameters 
 it will not be gaussian for any other value.
 
 You can get accelerated failure models with these
 distributions using 
 survreg() in the survival package.
 
 
   -thomas


I do not need a accelerated failure model, but a
proportional hazard model with a f0= weibull,
exponential, loglogistic or lognormal baseline
distribution. The hazard function is
lambda(t)=exp(Xi*beta)*lambda0(t),
where lambda0 is the baseline hazard
lambda0(t)=f0(t)/(1-F0(t)) where f0 and F0 are the
baseline density and cumulative distribution
functions.
This is a proportional hazard model since the ratio
lambda(t|Xi)/lambda(t|Xj)=exp(Xi*beta)/exp(Xj*beta)
does not depend on t.

Valentin

__
R-help@stat.math.ethz.ch 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] parametric proportional hazard regression

2006-07-07 Thread Valentin Dimitrov
Cody,

I have tried the survreg() in the Design library, it
is analogous to survreg() in the survival library and
it seems to me it is designed only for accelerated
time models like the accelerated failure model (or
accelerated lifetime model) and not for proportional
hazard models. Correct me if I am wrong.

Valentin

--- Hamilton, Cody [EMAIL PROTECTED] wrote:

 
 Valentin,
 
 Have you tried survreg() in the Design library?
 
 Regards,
-Cody


__
R-help@stat.math.ethz.ch 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] Problems when computing the 1rst derivative of mixtures of densities

2006-07-07 Thread Spencer Graves
  What problem are you trying to solve?  The mixture proportion you are 
trying to estimate violates the assumptions that provide a normal 
approximation to the distribution of maximum likelihood estimators. 
These situations even violate the assumptions for 2*log(likelihood 
ratio) being approximately chi-square.

  If you want hypothesis tests or confidence intervals, Pinheiro and 
Bates (2000) recommended using 2*log(likelihood ratio) modified as 
suggested by Monte Carlo results.  More recently, Bates has incorporated 
an 'mcmcsamp' function in the 'lme4' and 'Matrix' libraries.

  The best references I know on testing a parameter at a boundary are 
the following:

Pinheiro and Bates (2000) Mixed-Effects Models in S and S-PLUS 
(Springer, sec. 2.4)

Crainiceanu, Ruppert and Vogelsang (2003) “Some properties of Likelihood 
Ratio tests in linear mixed models”

Crainiceanu, Ruppert, Claeskens, and Wand (2005) “Exact Likelihood Ratio 
Tests for Penalized Splines”, Biometrika, 92(1)

  Hope this helps.
  Spencer Graves
p.s.  See also inline.

Clément Viel wrote:
 Hi everybody,
 
 I am currently working on mixtures of two densities ( f(xi,teta)=
 (1-teta)*f1(xi) + teta*f2(xi) ),
 particularly on the behavior of the variance for teta=0 (so sample only
 comes from the first distribution).
 To determine the maximum likelihood estimator I use the Newton-Rapdon
 Iteration. But when
 computing the first derivative I get a none linear function (with several
 asymptotes) which is completely
 absurd.

Why do you think this is absurd?  Nonlinear estimation can be very 
difficult.

  Also, have you reviewed the capabilities in R for working with 
mixtures of distributions?  I just got 167 hits for 
RSiteSearch(mixtures) and 49 for RSiteSearch(mixture distributions, 
functions).
 
 This is my function to compute the first derivative:
 
 phy=function(teta,vect1,vect2){
 return( sum(( vect2 - vect1) / (( 1 - teta) * vect1 + teta * vect2)))
 }
 
 note: vect1 and vect2 contains  values of the  two distributions computed
 from sample previously extracted.
 
 Beside, vect2 - vect1 is constant and ( 1 - teta) * vect1 + teta * vect2) is
 linear and always defined so I am expecting
 a linear function for the first derivative. To my mind, it's likely comes
 from the operation of division but I don't understand
 why results are skewed.
 
 Have you got any suggestions, please?
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch 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] parametric proportional hazard regression

2006-07-07 Thread Frank E Harrell Jr
Valentin Dimitrov wrote:
 
 Those are not proportional hazards families of
 distributions. That is, if 
 the distribution is gaussian for one value of the
 hazard ratio parameters 
 it will not be gaussian for any other value.

 You can get accelerated failure models with these
 distributions using 
 survreg() in the survival package.


  -thomas
 
 
 I do not need a accelerated failure model, but a
 proportional hazard model with a f0= weibull,
 exponential, loglogistic or lognormal baseline
 distribution. The hazard function is
 lambda(t)=exp(Xi*beta)*lambda0(t),
 where lambda0 is the baseline hazard
 lambda0(t)=f0(t)/(1-F0(t)) where f0 and F0 are the
 baseline density and cumulative distribution
 functions.
 This is a proportional hazard model since the ratio
 lambda(t|Xi)/lambda(t|Xj)=exp(Xi*beta)/exp(Xj*beta)
 does not depend on t.
 
 Valentin

That will be a very strange model that I've never seen used before in 
survival analysis.  Interpretation of parameters other than the hazard 
ratio may be tricky.  Why do you need a nontraditional model such as this?

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


Re: [R] parametric proportional hazard regression

2006-07-07 Thread Frank E Harrell Jr
Valentin Dimitrov wrote:
 Cody,
 
 I have tried the survreg() in the Design library, it
 is analogous to survreg() in the survival library and
 it seems to me it is designed only for accelerated
 time models like the accelerated failure model (or
 accelerated lifetime model) and not for proportional
 hazard models. Correct me if I am wrong.
 
 Valentin

survreg does not exist in the Design package.  You may be thinking of 
psm which is a wrapper function for survreg.

 
 --- Hamilton, Cody [EMAIL PROTECTED] wrote:
 
 Valentin,

 Have you tried survreg() in the Design library?

 Regards,
-Cody

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


-- 
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] heteroskedastic ordered probit

2006-07-07 Thread Rendas-Baum, Regina
Dear all,
 
is there existing code to fit a ordinal regression model with probit link where 
the variance can be modeled? For example, the polr function from the MASS 
package fits:
 
probitP(Y = k | x) = zeta_k - eta

Instead of,
 
probitP(Y = k | x) = (zeta_k - eta)/scale, where scale = exp(b*z) 
 
which is what I need.
 
I've seen these models go by the name of heteroskedastic ordered probit, 
location-scale glms, generalized nonlinear models, ... .  I know the package 
gnlm (Jim Lindsey) has a function to fit this model using the logit link, so 
I'm wondering if this is already done in R using probit instead.
 
Thanks.
 
Regina

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