[R] Problem on Matrix multiplication

2006-06-15 Thread Arun Kumar Saha
Dear all r-users,

I am getting a big problem with matrix multiplication

suppose I have,

 weight
  Weight
1   1067640
2   8871500
3  42948778
4 127583735
5  2200
6  4400
7  5685
8  23805662

and,
 s
a  b  c  d  e
f  g  h
a   402493.18 -133931.62   461483.3  -94042.86   674493.8 -1493713.2  -
714081.5 -1320551.6
b  -133931.62  192766.63  -414674.4  -36700.74  -276595.3   798034.6
382661.6   883478.4
c   461483.25 -414674.43  1618660.4  660949.18   988526.5 -2795048.7 -
1483334.1 -1761234.9
d   -94042.86  -36700.74   660949.2 1053310.43  -300291.4   -98814.9  -
263716.7  1130451.3
e   674493.80 -276595.33   988526.5 -300291.35  3090869.8 -3017747.3 -
1766040.6 -2295605.0
f -1493713.19  798034.60 -2795048.7  -98814.90 -3017747.3 10558734.1
4415620.8  6200897.7
g  -714081.51  382661.62 -1483334.1 -263716.67 -1766040.6  4415620.8
2593947.5  2341455.0
h -1320551.58  883478.39 -1761234.9 1130451.26 -2295605.0  6200897.7
2341455.0  7756557.3


But when I want to get [transpose(weight)][s][weight] using following
syntax,

t(weight)%*%s%*%weight


I got error:

Error in t(weight) %*% s %*% weight : requires numeric matrix/vector
arguments

Can anyone please tell me that where my error is?

Thanks and regards,

[[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] Problem on Matrix multiplication

2006-06-15 Thread Daniel Nordlund
It looks like weight and s are data frames, not vectors/matrices as required 
(and as the error message tells you).

Dan

Daniel Nordlund
Bothell, WA

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Arun Kumar Saha
 Sent: Wednesday, June 14, 2006 11:10 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Problem on Matrix multiplication
 
 Dear all r-users,
 
 I am getting a big problem with matrix multiplication
 
 suppose I have,
 
  weight
   Weight
 1   1067640
 2   8871500
 3  42948778
 4 127583735
 5  2200
 6  4400
 7  5685
 8  23805662
 
 and,
  s
 a  b  c  d  e
 f  g  h
 a   402493.18 -133931.62   461483.3  -94042.86   674493.8 -1493713.2  -
 714081.5 -1320551.6
 b  -133931.62  192766.63  -414674.4  -36700.74  -276595.3   798034.6
 382661.6   883478.4
 c   461483.25 -414674.43  1618660.4  660949.18   988526.5 -2795048.7 -
 1483334.1 -1761234.9
 d   -94042.86  -36700.74   660949.2 1053310.43  -300291.4   -98814.9  -
 263716.7  1130451.3
 e   674493.80 -276595.33   988526.5 -300291.35  3090869.8 -3017747.3 -
 1766040.6 -2295605.0
 f -1493713.19  798034.60 -2795048.7  -98814.90 -3017747.3 10558734.1
 4415620.8  6200897.7
 g  -714081.51  382661.62 -1483334.1 -263716.67 -1766040.6  4415620.8
 2593947.5  2341455.0
 h -1320551.58  883478.39 -1761234.9 1130451.26 -2295605.0  6200897.7
 2341455.0  7756557.3
 
 
 But when I want to get [transpose(weight)][s][weight] using following
 syntax,
 
 t(weight)%*%s%*%weight
 
 
 I got error:
 
 Error in t(weight) %*% s %*% weight : requires numeric matrix/vector
 arguments
 
 Can anyone please tell me that where my error is?
 
 Thanks and regards,
 
   [[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] Latex-Style Characters in R

2006-06-15 Thread Lorenzo Isella
Dear All,
I am starting to use R excellent graphical facilities to produce
good-looking plots.
However, I do not know yet how for use  pedices/apices (e.g. when you
write cm^3) and Greek letters (e.g. \sigma) which I really need now.
Is there a special package to load? Could anyone post a simple example
of such a plot so that I can re-use it?
Cheers

Lorenzo

__
R-help@stat.math.ethz.ch 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] Latex-Style Characters in R

2006-06-15 Thread Stefano Calza
Try ?plotmath

Stefano

On Thu, Jun 15, 2006 at 10:18:25AM +0200, Lorenzo Isella wrote:
LorenzoDear All,
LorenzoI am starting to use R excellent graphical facilities to produce
Lorenzogood-looking plots.
LorenzoHowever, I do not know yet how for use  pedices/apices (e.g. when you
Lorenzowrite cm^3) and Greek letters (e.g. \sigma) which I really need now.
LorenzoIs there a special package to load? Could anyone post a simple example
Lorenzoof such a plot so that I can re-use it?
LorenzoCheers
Lorenzo
LorenzoLorenzo
Lorenzo
Lorenzo__
LorenzoR-help@stat.math.ethz.ch mailing list
Lorenzohttps://stat.ethz.ch/mailman/listinfo/r-help
LorenzoPLEASE 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] Latex-Style Characters in R

2006-06-15 Thread Detlef Steuer
Hi,

just take a look at demo(plotmath) and example(plotmath).

Detlef

On Thu, 15 Jun 2006 10:18:25 +0200
Lorenzo Isella [EMAIL PROTECTED] wrote:

 Dear All,
 I am starting to use R excellent graphical facilities to produce
 good-looking plots.
 However, I do not know yet how for use  pedices/apices (e.g. when you
 write cm^3) and Greek letters (e.g. \sigma) which I really need now.
 Is there a special package to load? Could anyone post a simple example
 of such a plot so that I can re-use it?
 Cheers
 
 Lorenzo
 
 __
 R-help@stat.math.ethz.ch 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] MDS with missing data?

2006-06-15 Thread Jari Oksanen
On Thu, 2006-06-15 at 07:13 +0300, Jari Oksanen wrote:


 
  1) use nonmetric/gradient descent MDS which seems to
  allow missing data, or
 
 Not the isoMDS function in MASS. if N(N-1) is a problem, then nonmetric 
 MDS may not be the solution.

Sorry for the wrong information: isoMDS does handle NA. I remembered old
times when I looked at the issue, but isoMDS changed since. Fine work!

cheers, jari oksanen
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
email [EMAIL PROTECTED], homepage http://cc.oulu.fi/~jarioksa/

__
R-help@stat.math.ethz.ch 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] survival probabilities with cph (counting process)

2006-06-15 Thread Alberts Laurens (Stud. SIT)
Hi,
 
I have fitted a cox model with time-varying covariates (counting process style)
using the cph function of the Design package. Now I want to know the survival 
probabilities at each time point given the history of a single individual. 
 
I know the survest function, but I am not sure how to interpretet its output 
when using time-varying covariates. Does it just give the probabilities as if 
it are independent individuals or can/does it take in consideration that it is 
the history of a single individual? Is this even possible?
 
An example: Individual x has a history of 3 months and the cox model is fitted 
with two time-varying covariates: a  b
 
testcase - data.frame(a =[4 5 2], b = [1 0 1])
survest(coxmodel, testcase, time = c(1,2,3))

Is this the right way to compute the probabilities?

Thank you in advance!
 
Regards, Laurens Alberts

[[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] Problem on Matrix multiplication

2006-06-15 Thread Michal Bojanowski
Hi,


AKS But when I want to get [transpose(weight)][s][weight] using following
AKS syntax,

AKS t(weight)%*%s%*%weight

I guess 'weight' and 's' are dataframes and you need matrices. Like
here:

x - rnorm(8)
s - matrix(rnorm(64), ncol=8)

t(x) %*% s %*% x   # this is OK

d - as.data.frame(x)
t(d) %*% s %*% d  # this is your error


You can use data.matrix() to convert dataframes to matrices:

t( data.matrix(d) ) %*% s %*% data.matrix(d)   # again OK




HTH,

Michal

~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~

Michal Bojanowski
ICS/Utrecht
Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
Room 1428
[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] data managment

2006-06-15 Thread Adaikalavan Ramasamy
If your df contains your data, try

 tmp - cbind( paste(df[ ,1], df[ ,2], sep=:), 
   paste(df[ ,3], df[ ,4], sep=:) )
 tmp - t( apply(tmp, 1, sort) )

 out - data.frame( do.call(rbind, strsplit( tmp[,1], split=: )), 
do.call(rbind, strsplit( tmp[,2], split=: )) )
 colnames(out) - colnames(df)
 out

Regards, Adai



On Wed, 2006-06-14 at 16:35 +0100, yohannes alazar wrote:
 First I would really like to thank the mailing list for help I got in the
 past, as a new to R I am really needing some support on hoe to code the
 following problem.
 
 
 
 I am trying to sort some data I have in a big file. The file has 4 columns
 and 19000 rows. An example of it looks like this:-
 
 
 
 G 0.892   A 0.108
 
 G 0.883   T  0.117
 
 T  0.5   C 0.5
 
 A 0.617   G 0.383
 
 G 0.925   A 0.075
 
 A 0.967   G 0.033
 
 C 0.883   T  0.117
 
 C 0.633   T  0.367
 
 G 0.95 A 0.05
 
 C 0.742   G 0.258
 
 G 0.875   T  0.125
 
 T  0.167   C 0.833
 
 C 0.792   A 0.208
 
 
 
 Columns one and three are alphabets while three and four are their
 corresponding values.
 
 I wanted to sort this data so that my first and third columns are in
 alphabetic order. For example in the first row the order is G then A.
 This is not in alphabetic order therefore we swap them along with their
 values and it becomes:
 
  A0.108   G 0.892
 
 Row two looks fine but row three needs the same rearrangement as row one.
 And the final out put looks like:
 
 A 0.108   G 0.892
 
 G 0.883   T  0.117
 
 C 0.5   T  0.5
 
 A 0.617   G 0.383
 
 A 0.075   G 0.925
 
 A 0.967   G 0.033
 
 C 0.883   T  0.117
 
 C 0.633   T  0.367
 
 A 0.05 G 0.95
 
 C 0.742   G 0.258
 
 G 0.875   T  0.125
 
 C 0.833   T  0.167
 
 A 0.208   C 0.792
 
 Please some help with the relevant command names or a technique to code this
 task.
 
 Thank you in advance
 
 Regards Hannes
 
   [[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] appending

2006-06-15 Thread Martin Henry H. Stevens
Hi Dave,
Does this do what you want?
Hank

comp.CAND.frm - read.table(comp.CAND.frm.frm, header=TRUE)
names(comp.CAND.frm) - make.names(gsub(_, ., names 
(comp.CAND.frm)), unique=TRUE)

creatine.function.new = function(delta.0.Y.0=50, gamma=40,
   dat=comp.CAND.frm) {
   ## function to calcuate the delta.i, i.e. the percent
   ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr
   ## delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##

##
unlist(
tapply(dat$Ucr, dat$Patient.no, function(Cs)  {
   n.obs - length(Cs)
   Y=numeric(n.obs+1)
   Y[1] = delta.0.Y.0 + gamma
   delta = numeric(n.obs)
for (i in 1:n.obs) delta[i] - {
d - (Y[i] - Cs[i])/Y[i]
 Y[i+1] = delta[i] * Y[i] + gamma
 d
}
  delta}
 )
)
}
dim(comp.CAND.frm)
6*24
creatine.function.new()
### The names are the concatenation of the patient and the observation
## e.g. patient 24 observation 6 is labeled 246.

On Jun 14, 2006, at 2:35 PM, Afshartous, David wrote:

 Hank,
 Attached is the dataframe that can be supplied for the argument
 comp.CAND.frm.  The argument for comp.LIS.frm can be deleted since
 it currently isn't used.   The other arguments can be set as:
 delta.0.Y.0 = 50
 gamma = 40.
 cheers,
 dave




 -Original Message-
 From: Martin Henry H. Stevens [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 14, 2006 1:23 PM
 To: Afshartous, David
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] appending

 Hi David,
 It would be helpful if you supply a little data, upon which this would
 operate.
 Hank
 On Jun 14, 2006, at 12:31 PM, Afshartous, David wrote:

  All,

 In the function below I have 24 individuals and 6 calculations per
 individual.
 The 6 calculations are collected each time in a 1:24 loop when
 calculating delta.

 I'd like to collect all 144 = 24*6 calculations in one vector
 (delta.patient.comb).
 The function works as is via indexing, but is there an easier way to
 collect the measurements via appendinng the 6 measurements each time
 to the current set?  I couldn't find anything in Intro to R on
 appending.

 cheers,
 Dave
 ps - please respond directly to [EMAIL PROTECTED]



 creatine.function.new = function(delta.0.Y.0, gamma, comp.LIS.frm,
 comp.CAND.frm) { ## function to calcuate the delta.i, i.e. the  
 percent

 ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr ##
 delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##
 Y.1 = delta.0.Y.0 + gamma
 delta = numeric(6)
 delta.patient = numeric(24)
 delta.patient.comb = numeric(144)
 ##
  for (k in 1:24) {   ## each patient
  patient.k.CAND = which(comp.CAND.frm$Patient_no == k)
  Ucr.CAND.patient.k = comp.CAND.frm$Ucr[patient.k.CAND]
  C = Ucr.CAND.patient.k  ## 6 observed creatanine values
 for each
 patient
  delta[1] = (Y.1 - C[1])/Y.1
  Y.i = Y.1
  delta.i = delta[1]
  for (i in 1:5) {## six measurments per
 patient
  Y.i.plus.1 = delta.i * Y.i + gamma
  delta.i.plus.1 = (Y.i.plus.1 -
 C[i+1])/Y.i.plus.1
  delta[i+1] = delta.i.plus.1
  delta.i = delta[i+1]
  Y.i = Y.i.plus.1
  }
  delta.patient[k] = list(delta)  
  delta.patient.comb[(6*(k-1)+1):(6*(k-1)+ 6)] = delta
  }
 list(delta.patient, delta.patient.comb) }

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

 Dr. M. Hank H. Stevens, Assistant Professor
 338 Pearson Hall
 Botany Department
 Miami University
 Oxford, OH 45056

 Office: (513) 529-4206
 Lab: (513) 529-4262
 FAX: (513) 529-4243
 http://www.cas.muohio.edu/~stevenmh/
 http://www.muohio.edu/ecology/
 http://www.muohio.edu/botany/
 E Pluribus Unum




 comp.CAND.frm.frm

Dr. M. Hank H. Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/
E Pluribus Unum

__
R-help@stat.math.ethz.ch 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] A whine and a request

2006-06-15 Thread Jim Lemon
John Vokey wrote:
 Thanks.  But, as is common with e-mail communication, nobody seems to  
 have understood the issue I was whining about.

Indeed, I was totally wrong.

 So, here is an actual  
 case...
 
 Now, what I want is to regress the proportions of column(1)/(column(0) 
 +column(1)) on x.  I can accomplish the proportions as follows:  
 props=tab[,2]/(tab[,1]+tab[,2]).  So, I want to regress props on the  
 *row labels* of tab.  But I can't seem to get them to be anything  *but* 
 row labels.  For example,
   tab[,0]
... 
 extracts the row labels, *but still as labels*, not data. 

as.numeric(rownames(tab))

Jim

__
R-help@stat.math.ethz.ch 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] Problem with Julian function

2006-06-15 Thread Devred, Emmanuel
Dear all,

I have a problem with the function Julian, may be a bug in the function ?
Here is a vector of character, which represents dates (May 18 to May 20
2000):

  amj - c(2000-05-18,2000-05-18,2000-05-18,2000-05-19,2000-05-19
  ,2000-05-19, 2000-05-19, 2000-05-20, 2000-05-20, 2000-05-20)

I load the date and chron libraries, I define the vector of character as a
date variable using the dates function:

 ymd - dates(amj,format=c(dates=y-m-d),origin=c(month=1,
day=1,year=2000))

Then when I apply the Julian function:

 julian(months(ymd),days(ymd),years(ymd),origin=c(month = 1, day = 1, year
= as.numeric(years(ymd[1]

I get the following result:

[1] 137 137 137 138 138 138 138 139 139 139

However, when I check on the calendar, the dates I have correspond to the
139th, 140th and 141st  days of the year (there is a two days shift because
it is a leap year, for other years I have a one day shift).
I tried the default origin when I use the dates function but I get the same
results.

Did anyone have this problem before ? I would appreciate some help,

  Thank you very much,

   Emmanuel

[[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] Saving R graphics with version 2.3.1

2006-06-15 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote:
 HI !

 I´ve installed the latest R version (2.3.1) and I´ve had problems to 
 save my graphics as JPEG, PNG and the others available formats.
 R saves the file with no extension. Then, I have to open this file 
 using an image visualizer and save it as PNG, for instance.
   
You can type the extension when you save it, if you're typing the 
filename.  The default
names generally include the extension.
 Previous R versions work without problems.
   

Could you give a detailed description to reproduce the problem?

Duncan Murdoch
 Has everyone had a similar problem?
 Is it a bug of R 2.3.1?

 Thanks in advance.


 Ilka Afonso Reis

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

2006-06-15 Thread Jan . Kleinn

Dear all,

I don't know, whether this is a bug or whether I', doing something wrong,
but since I installed the latest versions of R and ESS, R hangs within ESS,
when 'select.list' is the first command trying to open a window. Basically,
this hangs:
 x - c('a', 'b', 'c', 'd')
 y - select.list(x)
and this works fine:
 winDialog('ok', 'Hello')
 x - c('a', 'b', 'c', 'd')
 y - select.list(x)

Here are my specs:
 version
   _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)
 win.version()
[1] Windows XP Professional (build 2600) Service Pack 2.0

Furthermore, this is within GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) with
the latest ESS 5.3.1.

Any help is highly welcome.

Many thanks in advance and best regards,
Jan

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

2006-06-15 Thread Wong, Kim
Hi,

 

I have a test_table where the dim is 62220 by 73 (row by col)

 

I would like to partition the rows into 170 equal parts (170 tables
where each is of dim 366 by 73), and rearrange them horizontally. The
source codes I have:

 

for (i in 1:170) {

c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);

  }

 

Unfortunately, using for loop and cbind for a table of this size causes
long running time.  What is the most efficient way to get the table that
I want? 

 

Thanks for any help.

K.




-
CONFIDENTIALITY NOTICE: This message and any attachments rel...{{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] matrix selection return types

2006-06-15 Thread vincent
Dear Rusers,

I would like some comments about the following results
(under R-2.2.0)

  m = matrix(1:6 , 2 , 3)
  m
  [,1] [,2] [,3]
[1,]135
[2,]246

  z1 = m[(m[,1]==2),]
  z1
[1] 2 4 6
  is.matrix(z1)
[1] FALSE

  z2 = m[(m[,1]==0),]
  z2
  [,1] [,2] [,3]
  is.matrix(z2)
[1] TRUE

Considered together, I'm a bit surprised about the
returned types from z1 and z2.
I would not have been surprised if z1 would still
have been a matrix, or z2=NULL.

There is certainly a logic behind this choice
but it's not very clear for me,
so any help/comment appreciated.

Thanks
Vincent

__
R-help@stat.math.ethz.ch 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] A question about stepwise procedures: step function

2006-06-15 Thread Li, Jia
Hi,
 
Step works for a Cox model. And I got the same error massage using
stepAIC.
 
Jia

  _  

From: Ritwik Sinha [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 15, 2006 12:12 AM
To: Li, Jia
Subject: Re: [R] A question about stepwise procedures: step function


Hi,

The step documentation says 

object: an object representing a model of an appropriate class
  (mainly 'lm' and 'glm'). This is used as the initial
  model in the stepwise search. 

I wonder if it will work for a cox proportional hazard model. You could
try stepAIC in MASS.




On 6/14/06, Li, Jia  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote: 

Dear all,

I tried to use step  function to do model selection, but I got
an error massage.  What I don't understand is that data as data.frame
worked well for my other programs, how come I cannot make it run this
time. Could you please tell me how I can fix it?



*** 

all-data.frame(z1,z2,z3)

fit.model.all- coxph(Surv(t,cen) ~z1+z2+z3,data=all)

 reg.model.all-step(fit.model.all)
Start:  AIC= 689.1
Surv(t, cen) ~ z1 + z2 + z3
Error in as.data.frame.default(data) : cannot coerce class
function into a data.frame


***
Thanks a lot!

Jia

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





-- 
Ritwik Sinha
Graduate Student 
Epidemiology and Biostatistics
Case Western Reserve University

http://darwin.cwru.edu/~rsinha 

[[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] Access and assign list sub-elements using a string such as l$a$b

2006-06-15 Thread Gregory Jefferis
If I have a list I can set a sub-element as follows on the command line:

people=list()
people$tom$hair=brown
people

But what if I have a string containing the name of the sub-element that I
want to access?

subel= people$tom$hair

get(subel) # returns error
assign(subel,red) # silent but doesn't change list
people

The attempts above using assign/get won't do what I am trying to do [nor
according to the help should they].  I would be very grateful for any
suggestions.  Many thanks,

Greg.

-- 
Gregory Jefferis, PhD   and:
Research Fellow
Department of Zoology   St John's College
University of Cambridge Cambridge
Downing Street  CB2 1TP
Cambridge, CB2 3EJ 
United Kingdom

Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223 339899
Lab Fax: +44 (0)1223 336676

http://www.zoo.cam.ac.uk/zoostaff/jefferis.html   [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] Question concerning mle

2006-06-15 Thread Rainer M Krug
Hi

I hope this is the right forum - if not, point me please to a better one.

I am using R 2.3.0 on Linux, SuSE 10.


I have a question concerning mle (method=BFGS).

I have a few models which I am fitting to existing data points. I
realised, that the likelihood is quite sensitive to the start values for
one parameter.

I am wondering: what is the best approach to identify the right initial
values? Do I have to do it recursively, and if yes, how can I automate
it? Or do I have to play with the system?

I am quite confident that the resulting parameters are the optimal for
my problem - but can I verify it?

Thanks,

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

__
R-help@stat.math.ethz.ch 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] Problem with Julian function

2006-06-15 Thread Gabor Grothendieck
This looks like a bug to me too although its one off rather than two off since
julian uses origin 0, not 1, e.g.

 julian(1,1,2000, origin = c(1,1,2000))
[1] 0

Here is a workaround that seems to work ok and uses origin 1:

 as.numeric(format(as.Date(ymd), %j)) # ymd from your post
 [1] 139 139 139 140 140 140 140 141 141 141



On 6/15/06, Devred, Emmanuel [EMAIL PROTECTED] wrote:
 Dear all,

 I have a problem with the function Julian, may be a bug in the function ?
 Here is a vector of character, which represents dates (May 18 to May 20
 2000):

   amj - c(2000-05-18,2000-05-18,2000-05-18,2000-05-19,2000-05-19
   ,2000-05-19, 2000-05-19, 2000-05-20, 2000-05-20, 2000-05-20)

 I load the date and chron libraries, I define the vector of character as a
 date variable using the dates function:

  ymd - dates(amj,format=c(dates=y-m-d),origin=c(month=1,
 day=1,year=2000))

 Then when I apply the Julian function:

  julian(months(ymd),days(ymd),years(ymd),origin=c(month = 1, day = 1, year
 = as.numeric(years(ymd[1]

 I get the following result:

 [1] 137 137 137 138 138 138 138 139 139 139

 However, when I check on the calendar, the dates I have correspond to the
 139th, 140th and 141st  days of the year (there is a two days shift because
 it is a leap year, for other years I have a one day shift).
 I tried the default origin when I use the dates function but I get the same
 results.

 Did anyone have this problem before ? I would appreciate some help,

  Thank you very much,

   Emmanuel

[[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] help with table partition

2006-06-15 Thread Jacques VESLOT
do.call(cbind, split(as.data.frame(test_table), rep(1:170,each=366)))
---
Jacques VESLOT

CNRS UMR 8090
I.B.L (2ème étage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr
---


Wong, Kim a écrit :
 Hi,
 
  
 
 I have a test_table where the dim is 62220 by 73 (row by col)
 
  
 
 I would like to partition the rows into 170 equal parts (170 tables
 where each is of dim 366 by 73), and rearrange them horizontally. The
 source codes I have:
 
  
 
 for (i in 1:170) {
 
 c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
 
   }
 
  
 
 Unfortunately, using for loop and cbind for a table of this size causes
 long running time.  What is the most efficient way to get the table that
 I want? 
 
  
 
 Thanks for any help.
 
 K.
 
 
 
 
 -
 CONFIDENTIALITY NOTICE: This message and any attachments rel...{{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-help@stat.math.ethz.ch 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] help with table partition

2006-06-15 Thread Petr Pikal
Hi

maybe ?split and ?t is what you want

mat-matrix(rnorm(1000), 100,10)

mat.s-split(data.frame(mat), rep(1:5, each=20)) 
#splits mat to list with 5 eqal submatrices

lapply(mat.s,t)
# transpose matrices in list

gives you a list of transposed tables, which is probably better than 
separate tables. Just change rep(1:5,each=20) to rep (1:170, 
each=366).

or
a quicker one without data frame

mat - matrix(rnorm(62220*73), 62220,73)

dim(mat) - c(366,73,170)
mat.i - array(0,dim=c(73,366,170))
for (i in 1:170) mat[ , , i] - t(mat[ , , i])

HTH
Petr





On 15 Jun 2006 at 9:38, Wong, Kim wrote:

Date sent:  Thu, 15 Jun 2006 09:38:29 -0400
From:   Wong, Kim [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] help with table partition

 Hi,
 
 
 
 I have a test_table where the dim is 62220 by 73 (row by col)
 
 
 
 I would like to partition the rows into 170 equal parts (170 tables
 where each is of dim 366 by 73), and rearrange them horizontally. The
 source codes I have:
 
 
 
 for (i in 1:170) {
 
 c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
 
   }
 
 
 
 Unfortunately, using for loop and cbind for a table of this size
 causes long running time.  What is the most efficient way to get the
 table that I want? 
 
 
 
 Thanks for any help.
 
 K.
 
 
 
 
 -
 CONFIDENTIALITY NOTICE: This message and any attachments
 rel...{{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

Petr Pikal
[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] Array

2006-06-15 Thread stat stat
Dear all R users,
   
  I am wondering if there is any way to define a 3 dimentional or 4 dimentional 
array in R.
   
  Sincerely yours,
   


thanks in advance
 Send instant messages to your online friends http://in.messenger.yahoo.com 

 Stay connected with your friends even when away from PC.  Link: 
http://in.mobile.yahoo.com/new/messenger/  
[[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] Array

2006-06-15 Thread Petr Pikal
Hi

see ?array if you are interested

array(0, c(5,5,5,5,5))

gives you 5 dimensional array.

HTH
Petr


On 15 Jun 2006 at 15:34, stat stat wrote:

Date sent:  Thu, 15 Jun 2006 15:34:29 +0100 (BST)
From:   stat stat [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Array

 Dear all R users,
 
   I am wondering if there is any way to define a 3 dimentional or 4
   dimentional array in R.
 
   Sincerely yours,
 
 
 
 thanks in advance
  Send instant messages to your online friends
  http://in.messenger.yahoo.com 
 
  Stay connected with your friends even when away from PC.  Link:
  http://in.mobile.yahoo.com/new/messenger/  [[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

Petr Pikal
[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] matrix selection return types

2006-06-15 Thread Petr Pikal
Hi

On 15 Jun 2006 at 15:41, [EMAIL PROTECTED] wrote:

Date sent:  Thu, 15 Jun 2006 15:41:14 +0200
From:   [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] matrix selection return types

 Dear Rusers,
 
 I would like some comments about the following results
 (under R-2.2.0)
 
   m = matrix(1:6 , 2 , 3)
   m
   [,1] [,2] [,3]
 [1,]135
 [2,]246
 
   z1 = m[(m[,1]==2),]
   z1
 [1] 2 4 6
   is.matrix(z1)
 [1] FALSE
 
   z2 = m[(m[,1]==0),]
   z2
   [,1] [,2] [,3]
   is.matrix(z2)
 [1] TRUE
 
 Considered together, I'm a bit surprised about the
 returned types from z1 and z2.
 I would not have been surprised if z1 would still
 have been a matrix, or z2=NULL.

If you want z1 to be matrix see argument drop in ?[

z1 = m[(m[,1]==2),,drop=F]

however why matrix is retained in second case i am not sure. Probably 
only if the result has exactly one dimension it is stripped from dim 
attribute by default.

HTH
Petr


 
 There is certainly a logic behind this choice
 but it's not very clear for me,
 so any help/comment appreciated.
 
 Thanks
 Vincent
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

Petr Pikal
[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] Standard Deviation Distribution

2006-06-15 Thread davidr
I'm having trouble with the standard deviation distribution
as shown on http://mathworld.wolfram.com/StandardDeviationDistribution.html .
(Eric Weisstein references Kenney and Keeping 1951, which I can't check.)

I believe the graphs they show, but when I code the function in R, according to 
the listed formula,
I get very different graphs.

Would someone please point out my error or tell me where it's already 
implemented in R?

Here is my version:
 sddist
function(s,n) {
sig2 - n*s*s/(n-1)
2*(n/(2*sig2))^((n-1)/2) / gamma((n-1)/2) * exp(-n*s*s/(2*sig2)) * s^(n-2)
}

Version 2.3.1 (2006-06-01) on Windows XP SP2

Thanks for any help.

David L. Reiner
Rho Trading Securities, LLC
Chicago  IL  60605
312-362-4963

__
R-help@stat.math.ethz.ch 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] Access and assign list sub-elements using a string such as l$a$b

2006-06-15 Thread Petr Pikal
Hi
very, very close


On 15 Jun 2006 at 13:27, Gregory Jefferis wrote:

Date sent:  Thu, 15 Jun 2006 13:27:05 +0100
From:   Gregory Jefferis [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Forwarded to:   r-help@stat.math.ethz.ch
Forwarded by:   Gregory Jefferis [EMAIL PROTECTED]
Date forwarded: Thu, 15 Jun 2006 14:54:13 +0100
Subject:[R] Access and assign list sub-elements using a string 
such as
l$a$b

 If I have a list I can set a sub-element as follows on the command
 line:
 
 people=list()
 people$tom$hair=brown
 people
 
 But what if I have a string containing the name of the sub-element
 that I want to access?
 
 subel= people$tom$hair
 
 get(subel) # returns error
 assign(subel,red) # silent but doesn't change list
 people

See what happens when

people-assign(subel, red)

HTH
Petr


 
 The attempts above using assign/get won't do what I am trying to do
 [nor according to the help should they].  I would be very grateful for
 any suggestions.  Many thanks,
 
 Greg.
 
 -- 
 Gregory Jefferis, PhD   and:
 Research Fellow
 Department of Zoology   St John's
 College University of Cambridge
 Cambridge Downing Street   CB2 1TP
 Cambridge, CB2 3EJ United Kingdom
 
 Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223
 339899 Lab Fax: +44 (0)1223 336676
 
 http://www.zoo.cam.ac.uk/zoostaff/jefferis.html  
 [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

Petr Pikal
[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] Install R 2.3.1 on SUSE Linux

2006-06-15 Thread dennis.mcleod
Hello:

I am new to Linux, and I am trying to install R 2.3.1 on SUSE Linux
10.0. The RPM installer, YAST, states that I need libgfortran.so.0.
I have loaded Intel FORTRAN and GCC FORTRAN; but I still do not have the
libgfortran.so.0 module YAST is asking for. 

Is there somewhere I can get this module for SUSE Linux 10.0. There is a
post on the R-Help for this same problem; but I cannot seem to find the
resolution.

I would appreciate any help you could provide.

Thanks
Dennis





This e-mail is intended only for the use of the individual or entity to which
it is addressed and may contain information that is privileged and confidential.
If the reader of this e-mail message is not the intended recipient, you are 
hereby notified that any dissemination, distribution or copying of this
communication is prohibited. If you have received this e-mail in error, please 
notify the sender and destroy all copies of the transmittal. 

Thank you
University of Chicago Hospitals

[[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] Access and assign list sub-elements using a string suchas l$a$b

2006-06-15 Thread Dimitris Rizopoulos

- Original Message - 
From: Petr Pikal [EMAIL PROTECTED]
To: Gregory Jefferis [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Thursday, June 15, 2006 4:56 PM
Subject: Re: [R] Access and assign list sub-elements using a string 
suchas l$a$b


 Hi
 very, very close


 On 15 Jun 2006 at 13:27, Gregory Jefferis wrote:

 Date sent:  Thu, 15 Jun 2006 13:27:05 +0100
 From:   Gregory Jefferis [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 [EMAIL PROTECTED]
 Forwarded to:   r-help@stat.math.ethz.ch
 Forwarded by:   Gregory Jefferis [EMAIL PROTECTED]
 Date forwarded: Thu, 15 Jun 2006 14:54:13 +0100
 Subject:[R] Access and assign list sub-elements using a 
 string such as
 l$a$b

 If I have a list I can set a sub-element as follows on the command
 line:

 people=list()
 people$tom$hair=brown
 people

 But what if I have a string containing the name of the sub-element
 that I want to access?

 subel= people$tom$hair

 get(subel) # returns error
 assign(subel,red) # silent but doesn't change list
 people

 See what happens when

 people-assign(subel, red)

but I think this is not what Greg wanted; the above just assigns red 
to object 'people' (i.e., check `str(assign(subel, red))'). If I 
understood correctly, the following could be of help:

people - list()
people$tom$hair - brown
people
#
subel - people$tom$hair
eval(parse(text = subel))
eval(parse(text = paste(subel, - 'red')))
people


Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


 HTH
 Petr



 The attempts above using assign/get won't do what I am trying to do
 [nor according to the help should they].  I would be very grateful 
 for
 any suggestions.  Many thanks,

 Greg.

 -- 
 Gregory Jefferis, PhD   and:
 Research Fellow
 Department of Zoology   St John's
 College University of Cambridge
 Cambridge Downing Street   CB2 1TP
 Cambridge, CB2 3EJ United Kingdom

 Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223
 339899 Lab Fax: +44 (0)1223 336676

 http://www.zoo.cam.ac.uk/zoostaff/jefferis.html
 [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

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


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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

2006-06-15 Thread Marc Bernard
Dear all,
   
  I have created  the following data (that you can run) in order to  explain my 
problem:
   
  y - rep(c(1,2), 8)
  id - rep(1:8,each=2)
x1 - rep(c(-a,+a), each = 8)
x2 - rep(c(-b,+b), each = 2, times = 4)
x3 - rep(c(-c, +c), each = 4,2)
df - data.frame(cbind(id,y,x1,x2,x3))
   
  If I do:
   
  xyplot(y~ x3|x1*x2,data=df,groups=id,type = b)
   
  then my id's  are joined by lines which is what I want. However when I wanted 
to add an horizontal line for each panel by using panel.abline the lines 
disapears, i.e.
   
  xyplot(y~ x3|x1*x2,data=df,groups=id,type = b,panel=function(x,y)
{
panel.xyplot(x,y)
panel.abline(h=1.5)
}
) 
   
   
  I would be grateful if someone can tell me how can I correct the second 
statement in order to have horizontal lines for each panel and each id are 
joined  by lines.
   
  Thank you,
   
  Bernard,
   
   

 __



[[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] y-axis label location relative to tick label width?

2006-06-15 Thread ivo welch
Dear R experts:  I have an odd question:  would it be better to
calculate the location of the axis label relative to the furthest
protruding tick label?  the background is that I have my y-tick labels
oriented horizontally rather than vertically.  if R chooses to set a
tick mark at 2, the y label should be relatively close to the axis.
if R chooses to put 1.998, it should sit farther (because otherwise
the 1 may touch the y label).  possible?  regards,  /ivo

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

2006-06-15 Thread Albert Vilella
Thanks Bogdan for the reply,

I almost got it working, but in my case, the rownames and colnames are
strings, not numbers, and I guess that this is a problem when using your
snippet:

a -
matrix(sample(1:5,100,replace=TRUE),nrow=10,dimnames=list(1:10,5*1:10))
rownames(a) =
c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
colnames(a) =
c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
x - y - z - vector()
for (i in 1:nrow(a)) {
  x - c(x,rep(rownames(a)[i],ncol(a)))
  y - c(y,colnames(a))
  z - c(z,a[i,])
}
symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
text(as.numeric(x),as.numeric(y),labels=z)

 symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
Error in plot.window(xlim, ylim, log, asp, ...) : 
need finite 'xlim' values
In addition: Warning messages:
1: NAs introduced by coercion 
2: NAs introduced by coercion 
3: no finite arguments to min; returning Inf 
4: no finite arguments to max; returning -Inf 
5: no finite arguments to min; returning Inf 
6: no finite arguments to max; returning -Inf

Any guess?

Thanks in advance,

Albert.

On Wed, 2006-06-14 at 16:47 -0400, bogdan romocea wrote:
 Here's an example. By the way, I find that it's more convenient (where
 applicable) to keep the data in 3 vectors/factors rather than one
 matrix/data frame.
 
 a - matrix(sample(1:5,100,replace=TRUE),nrow=10,dimnames=list(1:10,5*1:10))
 x - y - z - vector()
 for (i in 1:nrow(a)) {
   x - c(x,rep(rownames(a)[i],ncol(a)))
   y - c(y,colnames(a))
   z - c(z,a[i,])
 }
 symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
 text(as.numeric(x),as.numeric(y),labels=z)
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Albert Vilella
  Sent: Tuesday, June 13, 2006 7:11 AM
  To: r-help@stat.math.ethz.ch
  Subject: [R] bubbleplot for matrix
 
  Hi all,
 
  I would like to ask if it is possible to use bubbleplot for a 20x20
  matrix, instead of a dataframe with factors in columns.
 
  The idea would be to get a tabular representation with bubbles like in
  Rnews_2006_2 article, which look very nice.
 
  Thanks in advance,
 
  Albert.
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 

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


[R] how to set up parallel environment?

2006-06-15 Thread Mike Wolfgang
Dear list,

My institution has a Beowulf Linux cluster with 128 nodes. I want to set up
a parallel environment for R so that I can run some easily parallelizable
jobs. I searched around and only found some packages (like snow, rpvm) with
tutorials on how to run R functions in a already-setup parallel environment.
But did not have success finding tutorials on how to setup parallel R.
Should I compile R at each node? How should I install it in the main node?
Is there any steo-by-step tutorial on R installation in Beowulf? Thanks a
lot,

mike

[[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] Repost: Estimation when interaction is present: How do I get get the parameters from nlme?

2006-06-15 Thread John S. Walker
Gday,

This is a repost since I only had one direct reply and I remain 
mystified- This
may be stupidity on my part but it may not be so simple.




In brief, my problem is I'm not sure how to extract parameter 
values/effect sizes from a nonlinear
regression model with a significant interaction term.

My data sets are dose response curves (force and dose) for muscle that 
also have two treatments applied
Treatment A (A- or A+) and Treatment B (B-/B+). A single muscle was 
used for each experiment - a full dose response curve and one treatment 
from the matrix A*B (A-/B-, A+/B-, A-/B+ and A+,B+). There are 8 
replicates for each combination of treatments
We fit a dose response curve to each experiment with parameters upper, 
ed50 and slope; we expect treatment A to change upper and ed50. We want 
to know if treatment B blocks the effect of treatment A and if so to 
what degree.
This is similar to the Ludbrook example in Venables and Ripley, however 
they only had one treatment and I have two.

my approach

The dataframe is structured like this:
expttreatA  treatB  doseforce.
1   -   -   0.1 20
1   -   -   0.2 40
...
4   +   +   0.1 20
4   +

I used a groupedData object:  mydata=groupedData(force ~ dose | expt)

I used an nlme obect to model the data as follows (pseudocode):

myfit.nlme - nlme(force ~ ss_tpl(dose, upper, ed50,slope), 
fixed=list(ed50~factor(treatA)*factor(treatB)))


The function ss_tpl  is a properly debugged and fully functional
selfstarting three parameter logistic function that I wrote- no problem 
here. In my analysis
I also included fixed terms for the other fit parameters; upper and 
slope, but my main problem  is with  the
ed50 so that's all I've included here.

Running an anova on the resulting object (anova(myfit.nlme) I found the 
A -/B- (control) to
be significantly different from zero, treatment A was significantly 
different, treatment B had no significant
effect  and there was a significant interaction between treatment A and 
treatment B.

The interaction term is likely to be real. The treatments are on
sequential steps in a pathway and treatment B may be blocking the
effect of treatment A, i.e. treatment B alone has no effect because it
blocks a pathway that is not active, treatment A reduces force via this
pathway and treament B therefore blocks the effect of treatment A when
used together.

 From what I understand, please correct me if I'm wrong, the parameter 
estimates from summary(model.nlme) are not correct for main effects if 
a significant interaction is present. For example in my data treatment 
B alone has no signifcant effect in the anova but the interaction term 
A:B is significant. I believe The summary estimate for B is the 
estimate across all levels of A. What I want to do is pull out the 
estimate for B when A is not present. I suppose I can do it manually 
from the list of coefficients from nls or fit a oneway model with 
treatment levels A, B, AB. But I was kind of hoping there was some 
extractor function.

The reason I need this is that the co-authors want to include a table 
of  parameter values  with std errs or confidence intervals ala:

Treat   upper   ed50slope
A-/B-   x   x   x   - shows value 
for comparison to control studies
A+/B-   x   x   x   -Shows A is working0
A-/B+   x   x   x   - Shows B has no 
effect alone
A+/B+   x   x   x   -shows B 
blocks A (not necessarily total)

So back to my question,How do I extract estimates of the parameters 
from my model object for a
specific combination of factors including the interaction term.
   i.e. what is the ed50 (and std err) for A-/B-, A+/B-, A-/B+, A+/B+ ?


I think this is a fair question and one that many biomedical scientists 
would need.

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

2006-06-15 Thread Kevin E. Thorpe
Marc Bernard wrote:
 Dear all,

   I have created  the following data (that you can run) in order to  explain 
 my problem:

   y - rep(c(1,2), 8)
   id - rep(1:8,each=2)
 x1 - rep(c(-a,+a), each = 8)
 x2 - rep(c(-b,+b), each = 2, times = 4)
 x3 - rep(c(-c, +c), each = 4,2)
 df - data.frame(cbind(id,y,x1,x2,x3))

   If I do:

   xyplot(y~ x3|x1*x2,data=df,groups=id,type = b)

   then my id's  are joined by lines which is what I want. However when I 
 wanted to add an horizontal line for each panel by using panel.abline the 
 lines disapears, i.e.

   xyplot(y~ x3|x1*x2,data=df,groups=id,type = b,panel=function(x,y)
 {
 panel.xyplot(x,y)
 panel.abline(h=1.5)
 }
 ) 


   I would be grateful if someone can tell me how can I correct the second 
 statement in order to have horizontal lines for each panel and each id are 
 joined  by lines.

   Thank you,

   Bernard,

This appears to work for me.

xyplot(y~ x3|x1*x2,data=df,groups=id,type = b,
   panel=function(x,y,groups,...) {
 panel.superpose(x,y,groups,...)
 panel.abline(h=1.5)})


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

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

2006-06-15 Thread Afshartous, David
Hi Hank,
Thanks so much for looking at this. 
Yes, it does what I want and is much more efficient than my code.
I have a couple questions, please see my inserted comments after your
tapply statement and within your for loop.  Also, how do you accomplish
what you mentioned RE the concatation in the naming? 
cheers,
Dave
Ps - just noticed that a quick fix to my code would be to use unlist
towards my original
result delta.patient, then the creative indexing I used would not have
been needed (but your code still more efficient). 



comp.CAND.frm - read.table(comp.CAND.frm.frm, header=TRUE)
names(comp.CAND.frm) - make.names(gsub(_, ., names
(comp.CAND.frm)), unique=TRUE)
#

creatine.function.new.R.help = function(delta.0.Y.0=50, gamma=40,
   dat=comp.CAND.frm) 
{
   ## function to calcuate the delta.i, i.e. the percent
   ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr
   ## delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##
unlist(
tapply(dat$Ucr, dat$Patient.no, function(Cs)  
{   ## Cs is the argument to the function
defined 
## for this tapply statement
## Cs will equal Ucr?
n.obs - length(Cs) 
Y=numeric(n.obs+1)
Y[1] = delta.0.Y.0 + gamma
delta = numeric(n.obs)
for (i in 1:n.obs) delta[i] -  ## why delta[i] outside
the {}?
{
d - (Y[i] - Cs[i])/Y[i]## why not just call
this d[i]?
Y[i+1] = delta[i] * Y[i] + gamma
d   ## the output of each iteration; set equal to
d[i] each time?
}
delta   # result of function(Cs) used in tapply
}
 )
   )
}
dim(comp.CAND.frm)
6*24
creatine.function.new()
### The names are the concatenation of the patient and the observation
## e.g. patient 24 observation 6 is labeled 246.




-Original Message-
From: Martin Henry H. Stevens [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 15, 2006 7:00 AM
To: Afshartous, David
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] appending

Hi Dave,
Does this do what you want?
Hank

comp.CAND.frm - read.table(comp.CAND.frm.frm, header=TRUE)
names(comp.CAND.frm) - make.names(gsub(_, ., names
(comp.CAND.frm)), unique=TRUE)

creatine.function.new = function(delta.0.Y.0=50, gamma=40,
   dat=comp.CAND.frm) {
   ## function to calcuate the delta.i, i.e. the percent
   ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr
   ## delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##

##
unlist(
tapply(dat$Ucr, dat$Patient.no, function(Cs)  {
   n.obs - length(Cs)
   Y=numeric(n.obs+1)
   Y[1] = delta.0.Y.0 + gamma
   delta = numeric(n.obs)
for (i in 1:n.obs) delta[i] - {
d - (Y[i] - Cs[i])/Y[i]
 Y[i+1] = delta[i] * Y[i] + gamma
 d
}
  delta}
 )
)
}
dim(comp.CAND.frm)
6*24
creatine.function.new()
### The names are the concatenation of the patient and the observation
## e.g. patient 24 observation 6 is labeled 246.

On Jun 14, 2006, at 2:35 PM, Afshartous, David wrote:

 Hank,
 Attached is the dataframe that can be supplied for the argument 
 comp.CAND.frm.  The argument for comp.LIS.frm can be deleted since
 it currently isn't used.   The other arguments can be set as:
 delta.0.Y.0 = 50
 gamma = 40.
 cheers,
 dave




 -Original Message-
 From: Martin Henry H. Stevens [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 14, 2006 1:23 PM
 To: Afshartous, David
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] appending

 Hi David,
 It would be helpful if you supply a little data, upon which this would

 operate.
 Hank
 On Jun 14, 2006, at 12:31 PM, Afshartous, David wrote:

  All,

 In the function below I have 24 individuals and 6 calculations per 
 individual.
 The 6 calculations are collected each time in a 1:24 loop when 
 calculating delta.

 I'd like to collect all 144 = 24*6 calculations in one vector 
 (delta.patient.comb).
 The function works as is via indexing, but is there an easier way to 
 collect the measurements via appendinng the 6 measurements each time 
 to the current set?  I couldn't find anything in Intro to R on 
 appending.

 cheers,
 Dave
 ps - please respond directly to [EMAIL PROTECTED]



 creatine.function.new = function(delta.0.Y.0, gamma, comp.LIS.frm,
 comp.CAND.frm) { ## function to calcuate the delta.i, i.e. the 
 percent

 ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr ## 
 delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##
 Y.1 = delta.0.Y.0 + gamma
 delta = numeric(6)
 delta.patient = numeric(24)
 delta.patient.comb = numeric(144)
 ##
  for (k in 1:24) {   ## each patient
  patient.k.CAND = which(comp.CAND.frm$Patient_no == k)
  Ucr.CAND.patient.k = comp.CAND.frm$Ucr[patient.k.CAND]
  C = Ucr.CAND.patient.k  ## 6 

Re: [R] A question about stepwise procedures: step function

2006-06-15 Thread Li, Jia
Sorry, I still cannot find what's wrong with it. And it seems that
nothing is wrong with t.
 
Jia
 
 z1-rnorm(N,0,1)
 z2-rnorm(N,3,5)
 z3-rbinom(N,1,0.6)
 
 prop.cens-0.45   
 cen-rbinom(N,1,1-prop.cens) #-- censor indicator:45% censor in
the data.
 t- rexp(N)

 all-data.frame(z1,z2,z3)
 fit.model.all- coxph(Surv(t,cen) ~z1+z2+z3,data=all)
 fit.model.all
Call:
coxph(formula = Surv(t, cen) ~ z1 + z2 + z3, data = all)
 

coef exp(coef) se(coef)   zp
z1  0.057466 1.059   0.1377  0.4173 0.68
z2  0.000907 1.001   0.0332  0.0273 0.98
z3 -0.349273 0.705   0.2867 -1.2184 0.22
 
Likelihood ratio test=1.81  on 3 df, p=0.613  n= 100 
 reg.model.all-step(fit.model.all)
Start:  AIC= 376.39 
 Surv(t, cen) ~ z1 + z2 + z3 
 
Error in as.data.frame.default(data) : cannot coerce class function
into a data.frame


  _  

From: Hong Ooi [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 15, 2006 10:53 AM
To: Li, Jia
Subject: RE: [R] A question about stepwise procedures: step function



Note: This e-mail is subject to the disclaimer contained at the bottom
of this message.

  _  

t is the name of a function. If you have a variable called t in your
dataset, try renaming it.
 

  _  

From: [EMAIL PROTECTED] on behalf of Li, Jia
Sent: Thu 15/06/2006 11:52 PM
To: r-help@stat.math.ethz.ch; [EMAIL PROTECTED]
Subject: Re: [R] A question about stepwise procedures: step function



Hi,

Step works for a Cox model. And I got the same error massage using
stepAIC.

Jia

  _ 

From: Ritwik Sinha [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 15, 2006 12:12 AM
To: Li, Jia
Subject: Re: [R] A question about stepwise procedures: step function


Hi,

The step documentation says

object: an object representing a model of an appropriate class
  (mainly 'lm' and 'glm'). This is used as the initial
  model in the stepwise search.

I wonder if it will work for a cox proportional hazard model. You could
try stepAIC in MASS.




On 6/14/06, Li, Jia  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

Dear all,
   
I tried to use step  function to do model selection, but I got
an error massage.  What I don't understand is that data as data.frame
worked well for my other programs, how come I cannot make it run this
time. Could you please tell me how I can fix it?
   
   

***
   
all-data.frame(z1,z2,z3)
   
fit.model.all- coxph(Surv(t,cen) ~z1+z2+z3,data=all)
   
 reg.model.all-step(fit.model.all)
Start:  AIC= 689.1
Surv(t, cen) ~ z1 + z2 + z3
Error in as.data.frame.default(data) : cannot coerce class
function into a data.frame
   

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




--
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University

http://darwin.cwru.edu/~rsinha

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


  _  

The information transmitted in this message and its attachme...{{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] matrix selection return types

2006-06-15 Thread jim holtman
 m = matrix(1:6 , 2 , 3)
 ?'['
 z1 - m[m[,1] == 2,]
 z1
[1] 2 4 6
 is.matrix(z1)
[1] FALSE
 z1 - m[m[,1] == 2,, drop=FALSE]
 z1
 [,1] [,2] [,3]
[1,]246
 is.matrix(z1)
[1] TRUE



On 6/15/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Dear Rusers,

 I would like some comments about the following results
 (under R-2.2.0)

  m = matrix(1:6 , 2 , 3)
  m
  [,1] [,2] [,3]
 [1,]135
 [2,]246

  z1 = m[(m[,1]==2),]
  z1
 [1] 2 4 6
  is.matrix(z1)
 [1] FALSE

  z2 = m[(m[,1]==0),]
  z2
  [,1] [,2] [,3]
  is.matrix(z2)
 [1] TRUE

 Considered together, I'm a bit surprised about the
 returned types from z1 and z2.
 I would not have been surprised if z1 would still
 have been a matrix, or z2=NULL.

 There is certainly a logic behind this choice
 but it's not very clear for me,
 so any help/comment appreciated.

 Thanks
 Vincent

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] Access and assign list sub-elements using a string suchas l$a$b

2006-06-15 Thread Petr Pikal
Hi

yes you are correct, I remembered there is something with eval from 
older posts but did not find a connection to parse from eval help 
page. Shouldn't there be a link? Or even an example?

Best regards
Petr


On 15 Jun 2006 at 17:21, Dimitris Rizopoulos wrote:

From:   Dimitris Rizopoulos [EMAIL PROTECTED]
To: Petr Pikal [EMAIL PROTECTED], [EMAIL PROTECTED]
Copies to:  r-help@stat.math.ethz.ch
Subject:Re: [R] Access and assign list sub-elements using a 
string suchas   l$a$b
Date sent:  Thu, 15 Jun 2006 17:21:26 +0200

 
 - Original Message - 
 From: Petr Pikal [EMAIL PROTECTED]
 To: Gregory Jefferis [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Thursday, June 15, 2006 4:56 PM
 Subject: Re: [R] Access and assign list sub-elements using a string
 suchas l$a$b
 
 
  Hi
  very, very close
 
 
  On 15 Jun 2006 at 13:27, Gregory Jefferis wrote:
 
  Date sent:  Thu, 15 Jun 2006 13:27:05 +0100
  From:   Gregory Jefferis [EMAIL PROTECTED]
  To: [EMAIL PROTECTED] 
  [EMAIL PROTECTED]
  Forwarded to:   r-help@stat.math.ethz.ch
  Forwarded by:   Gregory Jefferis [EMAIL PROTECTED]
  Date forwarded: Thu, 15 Jun 2006 14:54:13 +0100
  Subject:[R] Access and assign list sub-elements using a
  string such as l$a$b
 
  If I have a list I can set a sub-element as follows on the command
  line:
 
  people=list()
  people$tom$hair=brown
  people
 
  But what if I have a string containing the name of the sub-element
  that I want to access?
 
  subel= people$tom$hair
 
  get(subel) # returns error
  assign(subel,red) # silent but doesn't change list
  people
 
  See what happens when
 
  people-assign(subel, red)
 
 but I think this is not what Greg wanted; the above just assigns red
 to object 'people' (i.e., check `str(assign(subel, red))'). If I
 understood correctly, the following could be of help:
 
 people - list()
 people$tom$hair - brown
 people
 #
 subel - people$tom$hair
 eval(parse(text = subel))
 eval(parse(text = paste(subel, - 'red')))
 people
 
 
 Best,
 Dimitris
 
 
 
 Dimitris Rizopoulos
 Ph.D. Student
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven
 
 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
  HTH
  Petr
 
 
 
  The attempts above using assign/get won't do what I am trying to do
  [nor according to the help should they].  I would be very grateful
  for any suggestions.  Many thanks,
 
  Greg.
 
  -- 
  Gregory Jefferis, PhD   and:
  Research Fellow
  Department of Zoology   St John's
  College University of Cambridge Cambridge Downing Street   
 CB2 1TP Cambridge, CB2 3EJ United Kingdom
 
  Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223
  339899 Lab Fax: +44 (0)1223 336676
 
  http://www.zoo.cam.ac.uk/zoostaff/jefferis.html
  [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
 
  Petr Pikal
  [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
  
 
 
 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
 

Petr Pikal
[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] Install R 2.3.1 on SUSE Linux

2006-06-15 Thread François Pinard
[EMAIL PROTECTED]

I am new to Linux, and I am trying to install R 2.3.1 on SUSE Linux
10.0. The RPM installer, YAST, states that I need libgfortran.so.0.

There is a SuSE 10.0 machine somewhere.  Yes: I installed R on it,
and it works well there:

   $ rpm -qf /usr/lib/libgfortran.so
   gcc-fortran-4.0.2_20050901-3

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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

2006-06-15 Thread Spencer Graves
see inline

Arun Kumar Saha wrote:
 Dear Spencer,
  
 Can you be more clear on your suggestion?
 
  
 On 6/15/06, *Spencer Graves* [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:
 
  Your example is not reproducible.  

  Can you find a simple example, preferably obtained either from a 
simple simulation or from a minor modification of an example included in 
some of the standard documentation.  This listserve sometimes refuses to 
accept attachments, so I would not suggest you attach a data set unless 
it was quite small.  You could, for example, try reducing the size of 
your data set, e.g., using a binary search to find the smallest number 
of observations that would still generate the same error message.

  Alternatively, the posting guide 
(www.R-project.org/posting-guide.html) includes the following:

'When providing examples, it is best to give an R command that 
constructs the data, as in the matrix() expression above. For more 
complicated data structures, dump(x, file=stdout()) will print an 
expression that will recreate the object x.'

Have you tried walking
 through the code line by line after debug(garch)?  

  I know I've discussed this issue on this listserve before. 
Therefore, I tried RSiteSearch(graves debug).  This produced 77 hits, 
many of which were not relevant.  The following seemed to be: 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/68215.html;.

After you've tried
 that, if you'd still like help from this listserve, please submit a
 simple, self-contained / reproducible example, as suggested the posting
 guide! www.R-project.org/posting-guide.html
 http://www.R-project.org/posting-guide.html.
 
  hope this helps.
  spencer graves
 
 Arun Kumar Saha wrote:
   Dear all R-users,
  
   I wanted to fit a Garch(1,1) model to a dataset by:
  
   garch1 = garch( na.omit(dat))
  
   But I got a warning message while executing, which is:
  
   Warning message:
   NaNs produced in: sqrt(pred$e)
  
   The garch parameters that I got are:
  
  
   garch1
  
   Call:
   garch(x = na.omit(dat))
  
   Coefficient(s):
  a0 a1 b1
   1.212e-04  1.001e+00  1.111e-14
  
   Can any one please tell me that why got this message? What is the
 remedy?
  
   Thanks and Regards
  
 [[alternative HTML version deleted]]
  
   __
   R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch
 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] Repost: Estimation when interaction is present: How do I get get the parameters from nlme?

2006-06-15 Thread Martin Henry H. Stevens
Hi John,
I think a solution is to
1. recode A and B as a single factor, AB, with four levels,
2. define each fixed effect as a function of  AB minus the intercept  
(e.g.  ed50 ~ as.factor(AB)-1).
3. extract the tTable as a data.frame with  summary(model)$tTable.

I will be interested to see what other folks suggest.
Cheers,
Hank

  and then run the Probably not the best, nor the worst solution,  
might be to recode A and B
On Jun 15, 2006, at 11:36 AM, John S. Walker wrote:

 Gday,

 This is a repost since I only had one direct reply and I remain
 mystified- This
 may be stupidity on my part but it may not be so simple.




 In brief, my problem is I'm not sure how to extract parameter
 values/effect sizes from a nonlinear
 regression model with a significant interaction term.

 My data sets are dose response curves (force and dose) for muscle that
 also have two treatments applied
 Treatment A (A- or A+) and Treatment B (B-/B+). A single muscle was
 used for each experiment - a full dose response curve and one  
 treatment
 from the matrix A*B (A-/B-, A+/B-, A-/B+ and A+,B+). There are 8
 replicates for each combination of treatments
 We fit a dose response curve to each experiment with parameters upper,
 ed50 and slope; we expect treatment A to change upper and ed50. We  
 want
 to know if treatment B blocks the effect of treatment A and if so to
 what degree.
 This is similar to the Ludbrook example in Venables and Ripley,  
 however
 they only had one treatment and I have two.

 my approach

 The dataframe is structured like this:
 expt  treatA  treatB  doseforce.
 1 -   -   0.1 20
 1 -   -   0.2 40
 ...
 4 +   +   0.1 20
 4 +

 I used a groupedData object:  mydata=groupedData(force ~ dose | expt)

 I used an nlme obect to model the data as follows (pseudocode):

 myfit.nlme - nlme(force ~ ss_tpl(dose, upper, ed50,slope),
 fixed=list(ed50~factor(treatA)*factor(treatB)))


 The function ss_tpl  is a properly debugged and fully functional
 selfstarting three parameter logistic function that I wrote- no  
 problem
 here. In my analysis
 I also included fixed terms for the other fit parameters; upper and
 slope, but my main problem  is with  the
 ed50 so that's all I've included here.

 Running an anova on the resulting object (anova(myfit.nlme) I found  
 the
 A -/B- (control) to
 be significantly different from zero, treatment A was significantly
 different, treatment B had no significant
 effect  and there was a significant interaction between treatment A  
 and
 treatment B.

 The interaction term is likely to be real. The treatments are on
 sequential steps in a pathway and treatment B may be blocking the
 effect of treatment A, i.e. treatment B alone has no effect because it
 blocks a pathway that is not active, treatment A reduces force via  
 this
 pathway and treament B therefore blocks the effect of treatment A when
 used together.

  From what I understand, please correct me if I'm wrong, the parameter
 estimates from summary(model.nlme) are not correct for main effects if
 a significant interaction is present. For example in my data treatment
 B alone has no signifcant effect in the anova but the interaction term
 A:B is significant. I believe The summary estimate for B is the
 estimate across all levels of A. What I want to do is pull out the
 estimate for B when A is not present. I suppose I can do it manually
 from the list of coefficients from nls or fit a oneway model with
 treatment levels A, B, AB. But I was kind of hoping there was some
 extractor function.

 The reason I need this is that the co-authors want to include a table
 of  parameter values  with std errs or confidence intervals ala:

 Treat upper   ed50slope
 A-/B- x   x   x   - shows value 
 for comparison to control studies
 A+/B- x   x   x   -Shows A is working0
 A-/B+ x   x   x   - Shows B has no 
 effect alone
 A+/B  +   x   x   x   -shows B 
 blocks A (not necessarily total)
   
 So back to my question,How do I extract estimates of the parameters
 from my model object for a
 specific combination of factors including the interaction term.
i.e. what is the ed50 (and std err) for A-/B-, A+/B-, A-/B+, A+/B 
 + ?


 I think this is a fair question and one that many biomedical  
 scientists
 would need.

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

Dr. M. Hank H. Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/

Re: [R] help with table partition

2006-06-15 Thread Wong, Kim

Hi, thank you all for the help.

The split function works very well.

I have an additional question.  If I have a matrix of prices (row = 30,
col = 2) in matrix P

P:

30 40
31.5 42




32 43

What is the quickest way to get a new matrix, where each entry is the
ln(Pt/Pt-1)?

I have no prob doing this using a loop, but that might not be most
efficient if my table is huge.  Moreover, I've read the apply/lapply
functions, but I could not get the right parameters to use.

Thank you all for help.
K.


-Original Message-
From: Petr Pikal [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 15, 2006 10:35 AM
To: Wong, Kim
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] help with table partition

Hi

maybe ?split and ?t is what you want

mat-matrix(rnorm(1000), 100,10)

mat.s-split(data.frame(mat), rep(1:5, each=20)) 
#splits mat to list with 5 eqal submatrices

lapply(mat.s,t)
# transpose matrices in list

gives you a list of transposed tables, which is probably better than 
separate tables. Just change rep(1:5,each=20) to rep (1:170, 
each=366).

or
a quicker one without data frame

mat - matrix(rnorm(62220*73), 62220,73)

dim(mat) - c(366,73,170)
mat.i - array(0,dim=c(73,366,170))
for (i in 1:170) mat[ , , i] - t(mat[ , , i])

HTH
Petr





On 15 Jun 2006 at 9:38, Wong, Kim wrote:

Date sent:  Thu, 15 Jun 2006 09:38:29 -0400
From:   Wong, Kim [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] help with table partition

 Hi,
 
 
 
 I have a test_table where the dim is 62220 by 73 (row by col)
 
 
 
 I would like to partition the rows into 170 equal parts (170 tables
 where each is of dim 366 by 73), and rearrange them horizontally. The
 source codes I have:
 
 
 
 for (i in 1:170) {
 
 c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
 
   }
 
 
 
 Unfortunately, using for loop and cbind for a table of this size
 causes long running time.  What is the most efficient way to get the
 table that I want? 
 
 
 
 Thanks for any help.
 
 K.
 
 
 
 
 -
 CONFIDENTIALITY NOTICE: This message and any attachments
 rel...{{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

Petr Pikal
[EMAIL PROTECTED]


-
CONFIDENTIALITY NOTICE: This message and any attachments rel...{{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] Saving R graphics with version 2.3.1

2006-06-15 Thread Michael H. Prager
In response to the OP's query, we use numerous R scripts that save 
graphics as PNG and EPS through savePlot() commands.  We have not 
experienced any problems with R 2.3.1.

MHP


on 6/15/2006 9:25 AM Duncan Murdoch said the following:
 [EMAIL PROTECTED] wrote:
   
 HI !

 I´ve installed the latest R version (2.3.1) and I´ve had problems to 
 save my graphics as JPEG, PNG and the others available formats.
 R saves the file with no extension. Then, I have to open this file 
 using an image visualizer and save it as PNG, for instance.
   
 

-- 
Michael Prager, Ph.D.
Southeast Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
** Opinions expressed are personal, not official.  No
** official endorsement of any product is made or implied.

__
R-help@stat.math.ethz.ch 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] Name of a column

2006-06-15 Thread David Hajage
Hello,

My problem is quite simply, but I didn't find any solution...

I have a vector :

 truc
   longueur30 longueur40 longueur50 longueur60 longueur70 longueur80
longueur90
34  FALSE  FALSE  FALSE  FALSE   TRUE  FALSE
FALSE

I would like to have the name of the column where there is TRUE.

 colnames(truc)
[1] longueur30 longueur40 longueur50 longueur60 longueur70
[6] longueur80 longueur90

 truc[truc == T]
[1] TRUE

 colnames(truc[truc == T])
NULL

How can I do it ?

Thank you for your help.

-- 
David

[[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] Compact sums in functions definitions

2006-06-15 Thread Alessandro Antonucci
I'm trying to make more compact the definition
of a function as for example:

f - function(x) 2/x+3/x

by simply defining the array of coefficients

arr = c(2,3)

and setting:

g - function(x) sum((arr/x))

Everything seems to work fine because the values returned 
by f and g result coincident for different values of their
argument, but when I try to plot the function g using:

x = seq(-1,1,.01)
plot(x,g(x))

I receive the errors/warnings:

Error in xy.coords(x, y, xlabel, ylabel, log) : 
'x' and 'y' lengths differ
In addition: Warning message:
longer object length
is not a multiple of shorter object length in: b/t 
Execution halted

Any idea about that?

Thanks.

Alessandro

-- 

Alessandro Antonucci
Dalle Molle Institute for Artificial Intelligence (IDSIA)
at Idsiae-mail: [EMAIL PROTECTED]
Galleria 2  web:   idsia.ch/~alessandro
Via Cantonale   mobile:   +39 339-567-23-28
CH-6928 tel:   +41 58-666-66-69
Manno - Lugano  fax:   +41 58-666-66-61
Switzerland skype: alessandro.antonucci

__
R-help@stat.math.ethz.ch 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] Access and assign list sub-elements using a string suchas l$a$b

2006-06-15 Thread Joerg van den Hoff
Petr Pikal wrote:
 Hi
 
 yes you are correct, I remembered there is something with eval from 
 older posts but did not find a connection to parse from eval help 
 page. Shouldn't there be a link? Or even an example?

would be a good thing to do (there only is a link from parse to eval). 
after all eval(parse(text = some_string)) is what many users (which 
might come from matlab/octave where this _would_ suffice) want when they 
try out eval(some_string)). and a standard eval(parse(text=...) example 
on the eval manpage (where most people probably would look, would be 
very good.
 
 Best regards
 Petr
 
 
 On 15 Jun 2006 at 17:21, Dimitris Rizopoulos wrote:
 
 From: Dimitris Rizopoulos [EMAIL PROTECTED]
 To:   Petr Pikal [EMAIL PROTECTED], [EMAIL PROTECTED]
 Copies to:r-help@stat.math.ethz.ch
 Subject:  Re: [R] Access and assign list sub-elements using a 
 string suchas   l$a$b
 Date sent:Thu, 15 Jun 2006 17:21:26 +0200
 
 - Original Message - 
 From: Petr Pikal [EMAIL PROTECTED]
 To: Gregory Jefferis [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Thursday, June 15, 2006 4:56 PM
 Subject: Re: [R] Access and assign list sub-elements using a string
 suchas l$a$b


 Hi
 very, very close


 On 15 Jun 2006 at 13:27, Gregory Jefferis wrote:

 Date sent:  Thu, 15 Jun 2006 13:27:05 +0100
 From:   Gregory Jefferis [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 [EMAIL PROTECTED]
 Forwarded to:   r-help@stat.math.ethz.ch
 Forwarded by:   Gregory Jefferis [EMAIL PROTECTED]
 Date forwarded: Thu, 15 Jun 2006 14:54:13 +0100
 Subject:[R] Access and assign list sub-elements using a
 string such as l$a$b

 If I have a list I can set a sub-element as follows on the command
 line:

 people=list()
 people$tom$hair=brown
 people

 But what if I have a string containing the name of the sub-element
 that I want to access?

 subel= people$tom$hair

 get(subel) # returns error
 assign(subel,red) # silent but doesn't change list
 people
 See what happens when

 people-assign(subel, red)
 but I think this is not what Greg wanted; the above just assigns red
 to object 'people' (i.e., check `str(assign(subel, red))'). If I
 understood correctly, the following could be of help:

 people - list()
 people$tom$hair - brown
 people
 #
 subel - people$tom$hair
 eval(parse(text = subel))
 eval(parse(text = paste(subel, - 'red')))
 people


 Best,
 Dimitris


 
 Dimitris Rizopoulos
 Ph.D. Student
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven

 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm


 HTH
 Petr


 The attempts above using assign/get won't do what I am trying to do
 [nor according to the help should they].  I would be very grateful
 for any suggestions.  Many thanks,

 Greg.

 -- 
 Gregory Jefferis, PhD   and:
 Research Fellow
 Department of Zoology   St John's
 College University of Cambridge Cambridge Downing Street   
CB2 1TP Cambridge, CB2 3EJ United Kingdom

 Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223
 339899 Lab Fax: +44 (0)1223 336676

 http://www.zoo.cam.ac.uk/zoostaff/jefferis.html
 [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
 Petr Pikal
 [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


 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

 
 Petr Pikal
 [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] Simulation / bayesian model

2006-06-15 Thread Ahmed Elhabti
Hi,
   
  (In the bayesian model, this program makes estimate the value of theta (tn)
  with the empirical method.)
   
  I want to know how one can repeat this program 100 times, before to have 100 
estimated values of tn.
   
  This is the program:
   
  a-1 
theta-rexp(50,a)
x-rpois(length(theta),theta)
  t-rexp(a)
  xn-rpois(1,t)
  tn-(1+xn)*mean(x)/(1+mean(x))
  tn
   
   
  Thank you very much.

 __



[[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] R with tcl/tk 8.5

2006-06-15 Thread JeeBee
Hi List,

Is it possible to tell R to use tcl/tk 8.5?
My R package seems to depend on libtcl8.4.so.
However, in Windows it seems to be possible to set
TCL_LIBRARY and MY_TCLTK.
Is there something similar possible in Linux?

I have installed:

$ rpm -q R
R-2.3.1-1.fc5

$ locate libtcl8
/usr/lib/libtcl8.4.so
/usr/local/lib/libtcl8.5.so

__
R-help@stat.math.ethz.ch 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] Name of a column

2006-06-15 Thread Chuck Cleland
X - as.logical(rep(c(0,1), each=13))

names(X) - LETTERS

which(X)
  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
14 15 16 17 18 19 20 21 22 23 24 25 26

names(which(X))
  [1] N O P Q R S T U V W X Y Z

?which

David Hajage wrote:
 Hello,
 
 My problem is quite simply, but I didn't find any solution...
 
 I have a vector :
 
 truc
longueur30 longueur40 longueur50 longueur60 longueur70 longueur80
 longueur90
 34  FALSE  FALSE  FALSE  FALSE   TRUE  FALSE
 FALSE
 
 I would like to have the name of the column where there is TRUE.
 
 colnames(truc)
 [1] longueur30 longueur40 longueur50 longueur60 longueur70
 [6] longueur80 longueur90
 
 truc[truc == T]
 [1] TRUE
 
 colnames(truc[truc == T])
 NULL
 
 How can I do it ?
 
 Thank you for your help.
 

-- 
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] flipping a plot vertically?

2006-06-15 Thread Tim Brown
Hi,

This seems like an obvious question but I can't find the answer in 
the par help document --- I'd like to make a plot where the 0,0 
point is in the top left of the screen rather than bottom left... . 
This is just a regular plot that is flipped vertically -- i.e.  the 
x-values will run along the top of the plot and the y-values will go 
from the top left (0,0) to the bottom left (0,ymax) --  I assume 
there is a simple way to do this but I can't find it.
Any suggestions?

Thanks!

Tim

__
R-help@stat.math.ethz.ch 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] dpss.taper for spectral estimation

2006-06-15 Thread Rouyer Tristan
Hello R users,

I'm running R version 2.2.1 with a fedora core 4 linux os.

I want to use dpss (discrete prolate spheroidal sequences) tapers for 
consistent spectral estimation. Such tapers can be computed using the 
dpss.taper() function from the waveslim package (Brandon Whitcher 2004).
The function computes the tapers, but I didn't manage to get the eigenvalues 
which are associated with.
The documentation indicates 6 values for the output of this function and I 
only get one.
How can I get these eigenvalues ?

Thanks in advance for your help,

Tristan

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

2006-06-15 Thread bogdan romocea
This works, though I'm not sure why symbols() complains about
axes=FALSE while fulfilling the request.

a - matrix(sample(1:5,100,replace=TRUE),nrow=10)
rownames(a) - c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
colnames(a) - c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
x - y - z - vector()
for (i in 1:nrow(a)) {
  x - c(x,rep(rownames(a)[i],ncol(a)))
  y - c(y,colnames(a))
  z - c(z,a[i,])
}

xp - as.numeric(as.factor(x))
yp - as.numeric(as.factor(y))
symbols(xp,yp,z,inches=0.2,bg=khaki,axes=FALSE)
axis(1,at=1:length(unique(x)),labels=sort(unique(x)))
axis(2,at=1:length(unique(y)),labels=sort(unique(y)))
box()
text(xp,yp,labels=z)



On 6/15/06, Albert Vilella [EMAIL PROTECTED] wrote:
 Thanks Bogdan for the reply,

 I almost got it working, but in my case, the rownames and colnames are
 strings, not numbers, and I guess that this is a problem when using your
 snippet:

 a -
 matrix(sample(1:5,100,replace=TRUE),nrow=10,dimnames=list(1:10,5*1:10))
 rownames(a) =
 c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
 colnames(a) =
 c(aed,fde,fda,yxj,ijk,ddd,gcd,sbe,adc,asd)
 x - y - z - vector()
 for (i in 1:nrow(a)) {
  x - c(x,rep(rownames(a)[i],ncol(a)))
  y - c(y,colnames(a))
  z - c(z,a[i,])
 }
 symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
 text(as.numeric(x),as.numeric(y),labels=z)

  symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
 Error in plot.window(xlim, ylim, log, asp, ...) :
need finite 'xlim' values
 In addition: Warning messages:
 1: NAs introduced by coercion
 2: NAs introduced by coercion
 3: no finite arguments to min; returning Inf
 4: no finite arguments to max; returning -Inf
 5: no finite arguments to min; returning Inf
 6: no finite arguments to max; returning -Inf

 Any guess?

 Thanks in advance,

Albert.

 On Wed, 2006-06-14 at 16:47 -0400, bogdan romocea wrote:
  Here's an example. By the way, I find that it's more convenient (where
  applicable) to keep the data in 3 vectors/factors rather than one
  matrix/data frame.
 
  a - matrix(sample(1:5,100,replace=TRUE),nrow=10,dimnames=list(1:10,5*1:10))
  x - y - z - vector()
  for (i in 1:nrow(a)) {
x - c(x,rep(rownames(a)[i],ncol(a)))
y - c(y,colnames(a))
z - c(z,a[i,])
  }
  symbols(as.numeric(x),as.numeric(y),z,inches=0.2,bg=khaki)
  text(as.numeric(x),as.numeric(y),labels=z)
 
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On Behalf Of Albert Vilella
   Sent: Tuesday, June 13, 2006 7:11 AM
   To: r-help@stat.math.ethz.ch
   Subject: [R] bubbleplot for matrix
  
   Hi all,
  
   I would like to ask if it is possible to use bubbleplot for a 20x20
   matrix, instead of a dataframe with factors in columns.
  
   The idea would be to get a tabular representation with bubbles like in
   Rnews_2006_2 article, which look very nice.
  
   Thanks in advance,
  
   Albert.
  
   __
   R-help@stat.math.ethz.ch 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] Simulation / bayesian model

2006-06-15 Thread Chuck Cleland
Ahmed Elhabti wrote:
 Hi,

   (In the bayesian model, this program makes estimate the value of theta (tn)
   with the empirical method.)

   I want to know how one can repeat this program 100 times, before to have 
 100 estimated values of tn.

   This is the program:

   a-1 
 theta-rexp(50,a)
 x-rpois(length(theta),theta)
   t-rexp(a)
   xn-rpois(1,t)
   tn-(1+xn)*mean(x)/(1+mean(x))
   tn

  my.tn - function(){
a - 1
theta - rexp(50,a)
x - rpois(length(theta),theta)
t - rexp(a)
xn - rpois(1,t)
tn - (1+xn)*mean(x)/(1+mean(x))
return(tn)
  }

  replicate(100, my.tn())
   [1] 0.5575221 0.5192308 1.0099010 1.2954545
   [5] 0.4949495 1.0099010 0.5238095 0.4791667
   [9] 1.8494624 1.4693878 0.5098039 0.8235294
  [13] 0.5495495 0.4565217 0.5726496 1.4042553
  [17] 0.5798319 2.2826087 1.0909091 1.000
  [21] 0.5327103 0.4623656 1.0291262 0.7804878
  [25] 1.4536082 0.9690722 0.9795918 0.889
  [29] 0.5049505 0.5762712 0.4680851 0.4623656
  [33] 0.5327103 1.3516484 0.9247312 0.4505495
  [37] 0.889 0.5238095 1.7394958 0.5614035
  [41] 0.5412844 0.5454545 1.0099010 0.4382022
  [45] 0.444 0.500 0.9898990 0.444
  [49] 0.9795918 1.778 0.5192308 1.0196078
  [53] 0.4505495 0.5454545 1.4693878 2.2300885
  [57] 0.5238095 0.5098039 1.8021978 1.9591837
  [61] 0.4047619 1.0654206 0.5283019 0.4680851
  [65] 0.5652174 2.5490196 1.1735537 1.0566038
  [69] 2.1308411 2.5728155 0.4186047 1.0099010
  [73] 0.4897959 1.3695652 0.4897959 1.0825688
  [77] 0.5145631 0.4382022 1.0476190 0.5145631
  [81] 0.5535714 0.4565217 0.5238095 0.4680851
  [85] 0.4736842 0.5098039 0.5327103 1.9381443
  [89] 0.5454545 0.5238095 0.5412844 0.4117647
  [93] 0.444 1.1379310 0.5327103 1.0990991
  [97] 0.4382022 0.444 1.1803279 0.5967742

?replicate

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

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 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] Compact sums in functions definitions

2006-06-15 Thread JeeBee

Hi Alessandro,

The problem is that arr/x isn't quite doing what you
thought it was.
arr / x is something like
c(arr[1] / x[1], arr[2] / x[2], arr[1] / x[3], ...)
What I mean is, it divides arr[i] by x[i] and tries to lengthen
arr by repeating itself (because it is shorter than x). It warns
in case length(x) is not a multiple of length(arr).
(or the other way around if arr was longer than x)

I made a nice one for you:
g - function(x) rowSums( t(t(1/x)) %*% arr )

It is likely someone else can do it much nicer (shorter),
my R knowledge still has to be increased ...

JeeBee.


On Thu, 15 Jun 2006 18:55:15 +0200, Alessandro Antonucci wrote:

 I'm trying to make more compact the definition
 of a function as for example:
 
 f - function(x) 2/x+3/x
 
 by simply defining the array of coefficients
 
 arr = c(2,3)
 
 and setting:
 
 g - function(x) sum((arr/x))
 
 Everything seems to work fine because the values returned 
 by f and g result coincident for different values of their
 argument, but when I try to plot the function g using:
 
 x = seq(-1,1,.01)
 plot(x,g(x))
 
 I receive the errors/warnings:
 
Error in xy.coords(x, y, xlabel, ylabel, log) : 
'x' and 'y' lengths differ
In addition: Warning message:
longer object length
is not a multiple of shorter object length in: b/t 
Execution halted
 
 Any idea about that?
 
 Thanks.
 
 Alessandro

__
R-help@stat.math.ethz.ch 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] flipping a plot vertically?

2006-06-15 Thread François Pinard
[Tim Brown]

This seems like an obvious question but I can't find the answer in the 
par help document --- I'd like to make a plot where the 0,0 point is 
in the top left of the screen rather than bottom left... .  [...] Any 
suggestions?

You might retry your plot, adding an ylim=c(HIGHEST, LOWEST) argument,
that is, listing the maximum before the minimum.  For example:

   plot(1:10, ylim=c(10, 1))

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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

2006-06-15 Thread davidr
apply(log(P), 2, diff)

David L. Reiner
Rho Trading Securities, LLC
Chicago  IL  60605
312-362-4963

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wong, Kim
Sent: Thursday, June 15, 2006 11:30 AM
To: Petr Pikal; Jacques VESLOT
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] help with table partition


Hi, thank you all for the help.

The split function works very well.

I have an additional question.  If I have a matrix of prices (row = 30,
col = 2) in matrix P

P:

30 40
31.5 42




32 43

What is the quickest way to get a new matrix, where each entry is the
ln(Pt/Pt-1)?

I have no prob doing this using a loop, but that might not be most
efficient if my table is huge.  Moreover, I've read the apply/lapply
functions, but I could not get the right parameters to use.

Thank you all for help.
K.


-Original Message-
From: Petr Pikal [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 15, 2006 10:35 AM
To: Wong, Kim
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] help with table partition

Hi

maybe ?split and ?t is what you want

mat-matrix(rnorm(1000), 100,10)

mat.s-split(data.frame(mat), rep(1:5, each=20)) 
#splits mat to list with 5 eqal submatrices

lapply(mat.s,t)
# transpose matrices in list

gives you a list of transposed tables, which is probably better than 
separate tables. Just change rep(1:5,each=20) to rep (1:170, 
each=366).

or
a quicker one without data frame

mat - matrix(rnorm(62220*73), 62220,73)

dim(mat) - c(366,73,170)
mat.i - array(0,dim=c(73,366,170))
for (i in 1:170) mat[ , , i] - t(mat[ , , i])

HTH
Petr





On 15 Jun 2006 at 9:38, Wong, Kim wrote:

Date sent:  Thu, 15 Jun 2006 09:38:29 -0400
From:   Wong, Kim [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] help with table partition

 Hi,
 
 
 
 I have a test_table where the dim is 62220 by 73 (row by col)
 
 
 
 I would like to partition the rows into 170 equal parts (170 tables
 where each is of dim 366 by 73), and rearrange them horizontally. The
 source codes I have:
 
 
 
 for (i in 1:170) {
 
 c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
 
   }
 
 
 
 Unfortunately, using for loop and cbind for a table of this size
 causes long running time.  What is the most efficient way to get the
 table that I want? 
 
 
 
 Thanks for any help.
 
 K.
 
 
 
 
 -
 CONFIDENTIALITY NOTICE: This message and any attachments
 rel...{{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

Petr Pikal
[EMAIL PROTECTED]


-
CONFIDENTIALITY NOTICE: This message and any attachments\ re...{{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] Compact sums in functions definitions

2006-06-15 Thread JeeBee


Slightly better:

h - function(x) rowSums( as.matrix(1/x) %*% arr )


On Thu, 15 Jun 2006 19:41:12 +0200, JeeBee wrote:

 
 Hi Alessandro,
 
 The problem is that arr/x isn't quite doing what you
 thought it was.
 arr / x is something like
 c(arr[1] / x[1], arr[2] / x[2], arr[1] / x[3], ...)
 What I mean is, it divides arr[i] by x[i] and tries to lengthen
 arr by repeating itself (because it is shorter than x). It warns
 in case length(x) is not a multiple of length(arr).
 (or the other way around if arr was longer than x)
 
 I made a nice one for you:
 g - function(x) rowSums( t(t(1/x)) %*% arr )
 
 It is likely someone else can do it much nicer (shorter),
 my R knowledge still has to be increased ...
 
 JeeBee.
 
 
 On Thu, 15 Jun 2006 18:55:15 +0200, Alessandro Antonucci wrote:
 
 I'm trying to make more compact the definition
 of a function as for example:
 
 f - function(x) 2/x+3/x
 
 by simply defining the array of coefficients
 
 arr = c(2,3)
 
 and setting:
 
 g - function(x) sum((arr/x))
 
 Everything seems to work fine because the values returned 
 by f and g result coincident for different values of their
 argument, but when I try to plot the function g using:
 
 x = seq(-1,1,.01)
 plot(x,g(x))
 
 I receive the errors/warnings:
 
Error in xy.coords(x, y, xlabel, ylabel, log) : 
'x' and 'y' lengths differ
In addition: Warning message:
longer object length
is not a multiple of shorter object length in: b/t 
Execution halted
 
 Any idea about that?
 
 Thanks.
 
 Alessandro
 
 __
 R-help@stat.math.ethz.ch 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] log returns (was: Re: help with table partition)

2006-06-15 Thread Gabor Grothendieck
Please use a descriptive subject and not tag onto a prior thread
for new topics.

Assuming the first row is time 1 and the second row is time 2 and
so on try:

diff(log(P))


On 6/15/06, Wong, Kim [EMAIL PROTECTED] wrote:

 Hi, thank you all for the help.

 The split function works very well.

 I have an additional question.  If I have a matrix of prices (row = 30,
 col = 2) in matrix P

 P:

 30 40
 31.5 42
 
 
 

 32 43

 What is the quickest way to get a new matrix, where each entry is the
 ln(Pt/Pt-1)?

 I have no prob doing this using a loop, but that might not be most
 efficient if my table is huge.  Moreover, I've read the apply/lapply
 functions, but I could not get the right parameters to use.

 Thank you all for help.
 K.


 -Original Message-
 From: Petr Pikal [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 15, 2006 10:35 AM
 To: Wong, Kim
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] help with table partition

 Hi

 maybe ?split and ?t is what you want

 mat-matrix(rnorm(1000), 100,10)

 mat.s-split(data.frame(mat), rep(1:5, each=20))
 #splits mat to list with 5 eqal submatrices

 lapply(mat.s,t)
 # transpose matrices in list

 gives you a list of transposed tables, which is probably better than
 separate tables. Just change rep(1:5,each=20) to rep (1:170,
 each=366).

 or
 a quicker one without data frame

 mat - matrix(rnorm(62220*73), 62220,73)

 dim(mat) - c(366,73,170)
 mat.i - array(0,dim=c(73,366,170))
 for (i in 1:170) mat[ , , i] - t(mat[ , , i])

 HTH
 Petr





 On 15 Jun 2006 at 9:38, Wong, Kim wrote:

 Date sent:  Thu, 15 Jun 2006 09:38:29 -0400
 From:   Wong, Kim [EMAIL PROTECTED]
 To: r-help@stat.math.ethz.ch
 Subject:[R] help with table partition

  Hi,
 
 
 
  I have a test_table where the dim is 62220 by 73 (row by col)
 
 
 
  I would like to partition the rows into 170 equal parts (170 tables
  where each is of dim 366 by 73), and rearrange them horizontally. The
  source codes I have:
 
 
 
  for (i in 1:170) {
 
  c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
 
}
 
 
 
  Unfortunately, using for loop and cbind for a table of this size
  causes long running time.  What is the most efficient way to get the
  table that I want?
 
 
 
  Thanks for any help.
 
  K.
 
 
 
 
  -
  CONFIDENTIALITY NOTICE: This message and any attachments
  rel...{{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

 Petr Pikal
 [EMAIL PROTECTED]


 -
 CONFIDENTIALITY NOTICE: This message and any attachments rel...{{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-help@stat.math.ethz.ch 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] flipping a plot vertically?

2006-06-15 Thread Tim Brown
That works great.  Thanks.

Any idea how to get the x axis numbers to go 
along the top instead of the bottom?

tim

At 11:46 AM 6/15/2006, you wrote:
[Tim Brown]

This seems like an obvious question but I can't 
find the answer in the par help document --- 
I'd like to make a plot where the 0,0 point is 
in the top left of the screen rather than 
bottom left... .  [...] Any suggestions?

You might retry your plot, adding an ylim=c(HIGHEST, LOWEST) argument,
that is, listing the maximum before the minimum.  For example:

   plot(1:10, ylim=c(10, 1))

--
François Pinard   http://pinard.progiciels-bpi.ca

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

2006-06-15 Thread yohannes alazar
Thank you very much this does the work exactlly.
regards Hannes


On 6/15/06, Adaikalavan Ramasamy [EMAIL PROTECTED] wrote:

 If your df contains your data, try

 tmp - cbind( paste(df[ ,1], df[ ,2], sep=:),
   paste(df[ ,3], df[ ,4], sep=:) )
 tmp - t( apply(tmp, 1, sort) )

 out - data.frame( do.call(rbind, strsplit( tmp[,1], split=: )),
do.call(rbind, strsplit( tmp[,2], split=: )) )
 colnames(out) - colnames(df)
 out

 Regards, Adai



 On Wed, 2006-06-14 at 16:35 +0100, yohannes alazar wrote:
  First I would really like to thank the mailing list for help I got in
 the
  past, as a new to R I am really needing some support on hoe to code the
  following problem.
 
 
 
  I am trying to sort some data I have in a big file. The file has 4
 columns
  and 19000 rows. An example of it looks like this:-
 
 
 
  G 0.892   A 0.108
 
  G 0.883   T  0.117
 
  T  0.5   C 0.5
 
  A 0.617   G 0.383
 
  G 0.925   A 0.075
 
  A 0.967   G 0.033
 
  C 0.883   T  0.117
 
  C 0.633   T  0.367
 
  G 0.95 A 0.05
 
  C 0.742   G 0.258
 
  G 0.875   T  0.125
 
  T  0.167   C 0.833
 
  C 0.792   A 0.208
 
 
 
  Columns one and three are alphabets while three and four are their
  corresponding values.
 
  I wanted to sort this data so that my first and third columns are in
  alphabetic order. For example in the first row the order is G then
 A.
  This is not in alphabetic order therefore we swap them along with their
  values and it becomes:
 
   A0.108   G 0.892
 
  Row two looks fine but row three needs the same rearrangement as row
 one.
  And the final out put looks like:
 
  A 0.108   G 0.892
 
  G 0.883   T  0.117
 
  C 0.5   T  0.5
 
  A 0.617   G 0.383
 
  A 0.075   G 0.925
 
  A 0.967   G 0.033
 
  C 0.883   T  0.117
 
  C 0.633   T  0.367
 
  A 0.05 G 0.95
 
  C 0.742   G 0.258
 
  G 0.875   T  0.125
 
  C 0.833   T  0.167
 
  A 0.208   C 0.792
 
  Please some help with the relevant command names or a technique to code
 this
  task.
 
  Thank you in advance
 
  Regards Hannes
 
[[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] flipping a plot vertically?

2006-06-15 Thread Chuck Cleland
plot(runif(20), xaxt=n, ylim=c(1,0))
axis(side = 3)

Tim Brown wrote:
 That works great.  Thanks.
 
 Any idea how to get the x axis numbers to go 
 along the top instead of the bottom?
 
 tim
 
 At 11:46 AM 6/15/2006, you wrote:
 [Tim Brown]

 This seems like an obvious question but I can't 
 find the answer in the par help document --- 
 I'd like to make a plot where the 0,0 point is 
 in the top left of the screen rather than 
 bottom left... .  [...] Any suggestions?
 You might retry your plot, adding an ylim=c(HIGHEST, LOWEST) argument,
 that is, listing the maximum before the minimum.  For example:

   plot(1:10, ylim=c(10, 1))

 --
 François Pinard   http://pinard.progiciels-bpi.ca
 
 __
 R-help@stat.math.ethz.ch 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] flipping a plot vertically?

2006-06-15 Thread Berton Gunter
 
 Any idea how to get the x axis numbers to go 
 along the top instead of the bottom?
 

Use xaxt = 'n' in your plot call (?par for details) to suppress plotting of
the axis and then add the axis via a call to axis().

If you do a lot of plotting, you may wish to purchase a copy of Murrell's R
GRAPHICS or VR's MASS. At the very least, do read the relevant sections of
an Introduction to R and the Reference Manual, as I believe this sort of
thing is covered there.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Tim Brown
 Sent: Thursday, June 15, 2006 11:18 AM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] flipping a plot vertically?
 
 That works great.  Thanks.
 
 Any idea how to get the x axis numbers to go 
 along the top instead of the bottom?
 
 tim
 
 At 11:46 AM 6/15/2006, you wrote:
 [Tim Brown]
 
 This seems like an obvious question but I can't 
 find the answer in the par help document --- 
 I'd like to make a plot where the 0,0 point is 
 in the top left of the screen rather than 
 bottom left... .  [...] Any suggestions?
 
 You might retry your plot, adding an ylim=c(HIGHEST, LOWEST) 
 argument,
 that is, listing the maximum before the minimum.  For example:
 
plot(1:10, ylim=c(10, 1))
 
 --
 François Pinard   http://pinard.progiciels-bpi.ca
 
 __
 R-help@stat.math.ethz.ch 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] SSPIR problem

2006-06-15 Thread michela . cameletti
Dear R-Users,
I'm using SSPIR package for a spatio-temporal application.
Is it possible to modify the structure of the involved matrixes (Fmat,
Gmat, Vmat,Wmat)?
I want to create a model like this

#y(t)=k*theta(t)+epsilon(t)
#theta(t)=h*theta(t-1)+eta(t)
#epsilon(t) N(0,V) V=sigma2*I
#eta(t) N(0,W)W=sigma2_eta

where the state variable theta has dimension 1(p=1) and at each time time
the observed variable y has dimension equal to d=3. Moreover I want to use
white noise errors.
But with the command
SS(y) where y is my nXd data matrix (d=observations at each time,
n=numbers of time points)
I obtain a different model.

Can you help me please?
Thanks in advance
Michela

__
R-help@stat.math.ethz.ch 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] Standard Deviation Distribution - solved

2006-06-15 Thread davidr
It turns out that I was confused by Weisstein's double use of the variable s.
sigma^2 = N*(observed s)/(N-1), hence constant in the function. So

 sddist - function(s,s0,n) {
  sig2 - n*s0*s0/(n-1)
  2*(n/(2*sig2))^((n-1)/2) / gamma((n-1)/2) * exp(-n*s*s/(2*sig2)) * s^(n-2)
}

gives the plots on the web page I cited.

Thanks to Ed Pegg Jr. at MathWorld for clarifying.

David L. Reiner
Rho Trading Securities, LLC
Chicago  IL  60605
312-362-4963

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

2006-06-15 Thread michela . cameletti
Dear R-Users,
I'm using SSPIR package for a spatio-temporal application.
Is it possible to modify the structure of the involved matrixes (Fmat,
Gmat, Vmat,Wmat)?
I want to create a model like this

#y(t)=k*theta(t)+epsilon(t)
#theta(t)=h*theta(t-1)+eta(t)
#epsilon(t) N(0,V) V=sigma2*I
#eta(t) N(0,W)W=sigma2_eta

where the state variable theta has dimension 1(p=1) and at each time time
the observed variable y has dimension equal to d=3. Moreover I want to use
white noise errors.
But with the command
SS(y) where y is my nXd data matrix (d=observations at each time,
n=numbers of time points)
I obtain a different model.

Can you help me please?
Thanks in advance
Michela

__
R-help@stat.math.ethz.ch 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] Problem with Fortran 95 code in R

2006-06-15 Thread Zhu Wang
Dear helpers:

I am trying to call some Fortran 95 code with R-2.3.0 but had problem as 
below. Any pointers would be appreciated. Thanks, Zhu Wang

On Linux,
R CMD SHLIB rfh.f
R
 dyn.load(rfh.so)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library '/home/zwang/rf/rfh.so':
 /home/zwang/rf/rfh.so: undefined symbol: _gfortran_allocate

On Unix,
R CMD SHLIB rfh.f
R
 dyn.load(rfh.so)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library '/home/zwang/rf/rfh.so':
 ld.so.1: /usr/local/R-2.3.0/lib/R/bin/exec/R: fatal: relocation error: 
file /home/zwang/rf/rfh.so: symbol __f90_allocate2: referenced symbol 
not found

__
R-help@stat.math.ethz.ch 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] Histbackback and adding color

2006-06-15 Thread Harshal D Dedhia
I am trying to plot two histograms using histbackback and then adding
color to each of the samples. The code I have seen on the R graph
gallery suggests the following method of using histbackback
 
require(Hmisc)

age - rnorm(1000,50,10)
sex - sample(c('female','male'),1000,TRUE)
out - histbackback(split(age, sex), probability=TRUE, xlim=c(-.06,.06),
main = 'Back to Back Histogram')


#! just adding color 
barplot(-out$left, col=red , horiz=TRUE, space=0, add=TRUE,
axes=FALSE)
barplot(out$right, col=blue, horiz=TRUE, space=0, add=TRUE,
axes=FALSE)
I get the following message when I execute the snippet to add color
Warning messages:
1: parameter add could not be set in high-level plot() function 
2: parameter add could not be set in high-level plot() function 
 
Any help would be appreciated.
 

[[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] flipping a plot vertically?

2006-06-15 Thread Tim Brown

__
R-help@stat.math.ethz.ch 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] more function in R?

2006-06-15 Thread Heidi Savin
I'm an R newbie and I just have a simple question.

I'm using interactive R on a linux box and I'm trying to find out if there's
a more or a less function. The data I want to look at is larger then my
screen size and all I end up seeing is the last fews line of data. Is there
a way that I can paginate through the data and the results of my summary
functions?

thanks,
Heidi

[[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] more function in R?

2006-06-15 Thread Gabor Csardi
a - matrix(0, nr=1, nc=5)
page(a, method=print)

This works on Linux at least. Also, there might be a better way...
Gabor

On Thu, Jun 15, 2006 at 04:00:40PM -0400, Heidi Savin wrote:
 I'm an R newbie and I just have a simple question.
 
 I'm using interactive R on a linux box and I'm trying to find out if there's
 a more or a less function. The data I want to look at is larger then my
 screen size and all I end up seeing is the last fews line of data. Is there
 a way that I can paginate through the data and the results of my summary
 functions?
 
 thanks,
 Heidi
 
   [[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

-- 
Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK

__
R-help@stat.math.ethz.ch 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] MDS with missing data? (change topic - isomap)

2006-06-15 Thread context grey
Thanks for the isoMDS pointer.   I found one
implementation
of isomap at  
  http://user.cs.tu-berlin.de/~astro/kmethods
though the web page suggests the code may be immature.


--- Jari Oksanen [EMAIL PROTECTED] wrote:

 On Thu, 2006-06-15 at 07:13 +0300, Jari Oksanen
 wrote:
 
 
  
   1) use nonmetric/gradient descent MDS which
 seems to
   allow missing data, or
  
  Not the isoMDS function in MASS. if N(N-1) is a
 problem, then nonmetric 
  MDS may not be the solution.
 
 Sorry for the wrong information: isoMDS does handle
 NA. I remembered old
 times when I looked at the issue, but isoMDS changed
 since. Fine work!
 
 cheers, jari oksanen
 -- 
 Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu,
 Finland
 email [EMAIL PROTECTED], homepage
 http://cc.oulu.fi/~jarioksa/
 


__
R-help@stat.math.ethz.ch 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] more function in R?

2006-06-15 Thread Heidi Savin
This works great! Thanks you're a lifesaver.

On 6/15/06, Gabor Csardi [EMAIL PROTECTED] wrote:

 a - matrix(0, nr=1, nc=5)
 page(a, method=print)

 This works on Linux at least. Also, there might be a better way...
 Gabor

 On Thu, Jun 15, 2006 at 04:00:40PM -0400, Heidi Savin wrote:
  I'm an R newbie and I just have a simple question.
 
  I'm using interactive R on a linux box and I'm trying to find out if
 there's
  a more or a less function. The data I want to look at is larger then my
  screen size and all I end up seeing is the last fews line of data. Is
 there
  a way that I can paginate through the data and the results of my summary
  functions?
 
  thanks,
  Heidi
 
[[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

 --
 Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK


[[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] individual scales in random subset of pairwise distance survey

2006-06-15 Thread context grey

Hello,

I'm curious if anyone has encounted a version of this
problem
(and it's solution) involving finding a consistent set
of scales
for subsets of survey data.

The goal is to obtain peoples' rankings of pairwise
similarity of a large
number of items, on a 1..5 scale for example, and
average these
across people to use as input to MDS:
  How similar is object A to Bon a 1..5 scale ___
  How similar is object A to Con a 1..5 scale ___
etc.
  
Because there are many items, there are N(N-1)/2
pairs, so it is not
practical to show every pair to everyone.   Showing
people the
pairs corresponding to random subsets of the objects
seems desirable.

THe problem is that, a particular random subset might
by chance
contain objects that would all be rated 5 if one
were to see
the entire dataset.  When ranking pairs from this
subset, the scale
of 1..5 is different.  

If we ensure that each pair of people must see some
data in common,
then one can think about obtaining a set of scales,
one for each
person, that causes the data that is commonly ranked
to have
as similar scores as possible, summed across all pairs
of people.


Please let me know if you know of a standard procedure
for
this or any similar problems.

Thank you.

__
R-help@stat.math.ethz.ch 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] individual scales in random subset of pairwise distance survey

2006-06-15 Thread Gabor Grothendieck
Perhaps you could try clustering the objects.

# generate test data
set.seed(1)
n - 25 # number of items
mat - matrix(0, n, n)
# use different labelling scheme if  26 items
rownames(mat) - colnames(mat) - letters[1:n]
mat[lower.tri(mat)] - sample(5, n * (n-1)/2, TRUE)
mat - mat + t(mat) + diag(1, n)

# cluster and plot
plot(hclust(as.dist(mat)))


On 6/15/06, context grey [EMAIL PROTECTED] wrote:

 Hello,

 I'm curious if anyone has encounted a version of this
 problem
 (and it's solution) involving finding a consistent set
 of scales
 for subsets of survey data.

 The goal is to obtain peoples' rankings of pairwise
 similarity of a large
 number of items, on a 1..5 scale for example, and
 average these
 across people to use as input to MDS:
  How similar is object A to Bon a 1..5 scale ___
  How similar is object A to Con a 1..5 scale ___
 etc.

 Because there are many items, there are N(N-1)/2
 pairs, so it is not
 practical to show every pair to everyone.   Showing
 people the
 pairs corresponding to random subsets of the objects
 seems desirable.

 THe problem is that, a particular random subset might
 by chance
 contain objects that would all be rated 5 if one
 were to see
 the entire dataset.  When ranking pairs from this
 subset, the scale
 of 1..5 is different.

 If we ensure that each pair of people must see some
 data in common,
 then one can think about obtaining a set of scales,
 one for each
 person, that causes the data that is commonly ranked
 to have
 as similar scores as possible, summed across all pairs
 of people.


 Please let me know if you know of a standard procedure
 for
 this or any similar problems.

 Thank you.

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

2006-06-15 Thread Tolga Uzuner
Hi,

Does anyone know a package which prices simple one-touch options, say  
using Rmetrics ? I want something which simply has a discontinuous  
payoff if an asset touches a single level. No knock-in or knock-out  
features.

Thanks,
Tolga

__
R-help@stat.math.ethz.ch 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] individual scales in random subset of pairwise distance survey

2006-06-15 Thread Gabor Grothendieck
The diag(1,n) was not needed:


set.seed(1)
n - 25
mat - matrix(0, n, n)
rownames(mat) - colnames(mat) - letters[1:n]
mat[lower.tri(mat)] - sample(5, n * (n-1)/2, TRUE)
mat - mat + t(mat)
plot(hclust(as.dist(mat)))


On 6/15/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Perhaps you could try clustering the objects.

 # generate test data
 set.seed(1)
 n - 25 # number of items
 mat - matrix(0, n, n)
 # use different labelling scheme if  26 items
 rownames(mat) - colnames(mat) - letters[1:n]
 mat[lower.tri(mat)] - sample(5, n * (n-1)/2, TRUE)
 mat - mat + t(mat) + diag(1, n)

 # cluster and plot
 plot(hclust(as.dist(mat)))


 On 6/15/06, context grey [EMAIL PROTECTED] wrote:
 
  Hello,
 
  I'm curious if anyone has encounted a version of this
  problem
  (and it's solution) involving finding a consistent set
  of scales
  for subsets of survey data.
 
  The goal is to obtain peoples' rankings of pairwise
  similarity of a large
  number of items, on a 1..5 scale for example, and
  average these
  across people to use as input to MDS:
   How similar is object A to Bon a 1..5 scale ___
   How similar is object A to Con a 1..5 scale ___
  etc.
 
  Because there are many items, there are N(N-1)/2
  pairs, so it is not
  practical to show every pair to everyone.   Showing
  people the
  pairs corresponding to random subsets of the objects
  seems desirable.
 
  THe problem is that, a particular random subset might
  by chance
  contain objects that would all be rated 5 if one
  were to see
  the entire dataset.  When ranking pairs from this
  subset, the scale
  of 1..5 is different.
 
  If we ensure that each pair of people must see some
  data in common,
  then one can think about obtaining a set of scales,
  one for each
  person, that causes the data that is commonly ranked
  to have
  as similar scores as possible, summed across all pairs
  of people.
 
 
  Please let me know if you know of a standard procedure
  for
  this or any similar problems.
 
  Thank you.
 
  __
  R-help@stat.math.ethz.ch 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] plot two graphs with different length of data

2006-06-15 Thread Eric Hu
thank you, Joerg. I am able to use points() to add the new data in the
current plot.

Eric

On 6/13/06, Joerg van den Hoff [EMAIL PROTECTED] wrote:
 Eric Hu wrote:
  Hi I am trying to plot two data set in the same picture window without
  overlapping with each other. I am using the format plot(x1,y1,x2,y2)
  but get the following error message:
 
  plot(as.numeric(r0[,4]),as.numeric(r0[,7]),as.numeric(r0[,4]),as.numeric(r0[,7][ind[,1]]))
  Error in plot.window(xlim, ylim, log, asp, ...) :
  invalid 'ylim' value
 
  Can anyone tell me what went wrong? Thanks.
 
  Eric
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html


 matplot(cbind(x1,x2), cbind(y1,y2)) might be what you want.

 (if x1, x2 and y1,y2 are of equal length. otherwise pad the short  ones
 with NAs or use  `matplot' with type =n (to get the scaling of the plot
 right), followed by `plot(x1,y1), lines(x2,y2)')


__
R-help@stat.math.ethz.ch 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] running R in batch with stdin input

2006-06-15 Thread Eric Hu
Hi I have a R script that needs to run a few times for different
systems. I use R --no-save  r.script for one system. I am trying with
no luck to use R CMD BATCH to introduce an stdin input variable for
the script. I wonder if anyone can provide the correct usage to put
the variable in the command like R CMD BATCH r.script name_variable.

Thanks.

-Eric

In the r.script I have

name - readline(/dev/stdin)
r0 - read.table(/usr/local/surface/$name/$name_c_r)
...

I want to get at the end:

name - 1BRS
r0 - read.table(/usr/local/surface/1BRS/1BRS_c_r)
...

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


Re: [R] Touch options

2006-06-15 Thread Jeff Hammerbacher
Tolga,

You might be interested in the quantlib library: http://quantlib.org/.
Currently, a wrapper for R can be found at
http://dirk.eddelbuettel.com/code/rquantlib.html.

Regards,
Jeff Hammerbacher

On 6/15/06, Tolga Uzuner [EMAIL PROTECTED] wrote:

 Hi,

 Does anyone know a package which prices simple one-touch options, say
 using Rmetrics ? I want something which simply has a discontinuous
 payoff if an asset touches a single level. No knock-in or knock-out
 features.

 Thanks,
 Tolga

 __
 R-help@stat.math.ethz.ch 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] running R in batch with stdin input

2006-06-15 Thread Adaikalavan Ramasamy
?commandArgs



On Thu, 2006-06-15 at 16:05 -0700, Eric Hu wrote:
 Hi I have a R script that needs to run a few times for different
 systems. I use R --no-save  r.script for one system. I am trying with
 no luck to use R CMD BATCH to introduce an stdin input variable for
 the script. I wonder if anyone can provide the correct usage to put
 the variable in the command like R CMD BATCH r.script name_variable.
 
 Thanks.
 
 -Eric
 
 In the r.script I have
 
 name - readline(/dev/stdin)
 r0 - read.table(/usr/local/surface/$name/$name_c_r)
 ...
 
 I want to get at the end:
 
 name - 1BRS
 r0 - read.table(/usr/local/surface/1BRS/1BRS_c_r)
 ...
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch 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] Change the range of a 'ternaryplot'

2006-06-15 Thread Martínez Ovando Juan Carlos
Hi all

Does someone know how can I alter the range of some variables in a 
'ternaryplot' of the 'vcd' package, with the aim of make a zoom in some region 
of the plot?

Thank you in advance

Sincerely,

Juan Carlos


=== 
Juan Carlos Martínez Ovando 
Banco de México 
Dirección General de Investigación Económica
Cinco de Mayo No. 18, 4° Piso A 
Col. Centro, Del. Cuauhtémoc
06059, México D.F., MEXICO 
Tel.: +52 (55) 52.37.25.94 
Fax: +52 (55) 52.37.27.03 
e-mail: [EMAIL PROTECTED] 
=== 

2006, Año del Bicentenario del natalicio del Benemérito de las Américas, Don 
Benito Juárez García.

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