Re: [R] problem with the ltm package - 3PL model

2008-02-28 Thread Dimitris Rizopoulos
Hi Xavier,

the reason you observe this feature is that in the 'constraint' 
argument you should specify the values under the additive 
parameterization, i.e., when in the second column of the matrix 
supplied in 'constraint' you specify 2, then you need to provide the 
easiness parameters (not the difficulty parameters) in the third 
column. Check the Details section of ?tpm() and the following for an 
illustration:

library(ltm)

fit - tpm(LSAT)
cf - coef(fit)

constr - rbind(
cbind(1:3, c(1,1,1), cf[1:3, 1]),
cbind(1:3, c(3,3,3), cf[1:3, 3]),
cbind(1:3, c(2,2,2), - cf[1:3, 2] * cf[1:3, 3])
)

fit2 - tpm(LSAT, constraint = constr)

coef(fit)[1:3, ]
coef(fit2)[1:3, ]

I hope it's more clear now.

Best,
Dimitris

ps, you may find more info regarding ltm as well as sample analyses 
files at the R wiki page: 
http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:ltm


Dimitris Rizopoulos
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

- Original Message - 
From: Xavier G. Ordóñez [EMAIL PROTECTED]
To: Dimitris Rizopoulos [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Thursday, February 28, 2008 2:28 AM
Subject: problem with the ltm package - 3PL model


Dear Dimitris:

I am working with ltm package. I have been analyzing a data with 3PL
model and I need to do two estimation.
In the first, the 40 items parameters are free, and the second the
estimation of the 1-10 items are fixed, those correspond to the last 
10 items
parameters of the first simulation. The remaining items parameters
(11-40) are free.

I have a problem, when I try to fix the ten items parameters in the 
second
simulation,the difficult parameters are not fixed. Why?.

I will like to know if you know the problem.

Thank you for your response,

Xavier G. Ordoñez

An example the process:

 para.est.I - tpm(Apli.sample.I,IRT.param = TRUE)
 par.est.I - coef(para.est.I)

Gussng Dffclt Dscrmn
V32  0.009 -2.453  0.747
V33  0.310  0.444  0.694
V34  0.327  0.873  1.036
V35  0.031 -3.067  0.343
V36  0.054 -0.934  1.130
V37  0.001 -1.991  0.582
V38  0.004 -1.686  0.571
V39  0.003 -2.470  0.910
V40  0.207  0.421  1.307
V41  0.114 -0.843  1.024

 fix.c - 
 cbind(rep(1:10),rep(1,10),matrix(as.vector(t(par.est.I[31:40,])[1,])))
 fix.b - 
 cbind(rep(1:10),rep(2,10),matrix(as.vector(t(par.est.I[31:40,])[2,])))
 fix.a - 
 cbind(rep(1:10),rep(3,10),matrix(as.vector(t(par.est.I[31:40,])[3,])))
 fixx - rbind(fix.c,fix.b,fix.a)

 para.est.II - tpm(Apli.sample.I,constraint = fixx,IRT.param = TRUE)

Gussng Dffclt Dscrmn
V2   0.009  3.284  0.747
V3   0.310 -0.640  0.694
V4   0.327 -0.843  1.036
V5   0.031  8.942  0.343
V6   0.054  0.827  1.130
V7   0.001  3.421  0.582
V8   0.004  2.953  0.571
V9   0.003  2.714  0.910
V10  0.207 -0.322  1.307
V11  0.114  0.823  1.024

 coef(para.est.II)[1:10,]==coef(para.est.I)[31:40,]

Gussng Dffclt Dscrmn
V2TRUE  FALSE   TRUE
V3TRUE  FALSE   TRUE
V4TRUE  FALSE   TRUE
V5TRUE  FALSE   TRUE
V6TRUE  FALSE   TRUE
V7TRUE  FALSE   TRUE
V8TRUE  FALSE   TRUE
V9TRUE  FALSE   TRUE
V10   TRUE  FALSE   TRUE
V11   TRUE  FALSE   TRUE 


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

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


Re: [R] ggplot2 boxplot confusion

2008-02-28 Thread ONKELINX, Thierry
Chris,

You need to specify position = identity

library(ggplot2)
series - c('C2','C4','C8','C10','C15','C20')
series - factor(series, levels = series)
ids - c('ID1','ID2','ID3')
mydata -
data.frame(SERIES=rep(series,30),ID=rep(ids,60),VALUE=rnorm(180), dummy
= factor(1))
ggplot(mydata, aes(y = VALUE, x = dummy)) + geom_boxplot(position =
identity) + facet_grid(SERIES ~ ID)

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Chris Friedl
Verzonden: woensdag 27 februari 2008 23:55
Aan: r-help@r-project.org
Onderwerp: Re: [R] ggplot2 boxplot confusion


Thierry

1.

ggplot(mydata, aes(y = VALUE, x = SERIES)) + geom_boxplot() +
facet_grid(.~
ID)

creates a grid with three ID columns (ID1, ID2, ID3) and six SERIES
columns
within each ID column with two boxplots in each ID column (C10, C2)
(C15,
C4), (C20, C8). I was aiming for a grid with ID columns and SERIES rows.

However if I try something like this:

ggplot(mydata, aes(y = VALUE, x = factor(1))) + geom_boxplot() +
facet_grid(SERIES ~ ID)

I get an error: 

Error: position_dodge requires the following missing aesthetics: x

Yet this works fine for a single boxplot (as you showed previously) if I
remove the facet_grid() command.

Any ideas?

Or perhaps my only recourse is to build this up programmtically, such
as:

(pseudo-ish code)
for id, ser in ids, series:
  dat - subset(mydata, (id %in% ids  ser %in% series)
  boxplot(dat) in grid position id, ser

Can I specify grid plotting grid by grid with ggplot or do I need to
look at
lattice graphics? (I'd like to stick with ggplot if I can)





ONKELINX, Thierry wrote:
 
 Chris,
 
 1.
 This will make more sense.
 
 ggplot(mydata, aes(y = VALUE, x = SERIES)) + geom_boxplot() +
 facet_grid(.~ ID) 
 
 2.
 Now I think I understand want you want. I'm affraid that won't be easy
 because you're trying to mix continuous variables with categorical
ones
 on the same scale. A density plot has two continuous scales: VALUE and
 it's density. The boxplot has a continuous scale (VALUE) and the other
 is categorical. Maybe Hadley knows a solution for your problem.
 
 Thierry
 
 

-- 
View this message in context:
http://www.nabble.com/ggplot2-boxplot-confusion-tp15706116p15725522.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] plot y1 and y2 on one graph

2008-02-28 Thread Jim Lemon
milton ruser wrote:
 Dear all
 
 I have a code like
 
 x-1:10
 y1-x+runif(10)*2
 y2-seq(0,50,length.out=10)+rnorm(10)*10
 
 par(mfrow=c(1,2))
 plot(y1~x)
 plot(y2~x)
 
 Now I would like to plot y1 and y2 on the same graph, with its two scales
 (y1 on left and y2 on rigth side).
 
Hi Miltinho,
twoord.plot in the plotrix package might do the job for you.

twoord.plot(x,y1,x,y2)

Jim

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


Re: [R] Kaiser-Meyer-Olkin

2008-02-28 Thread Chuck Cleland
On 2/28/2008 1:42 AM, Robert Kopp wrote:
 I am a beginner when it comes to using R, though fortunately I already know 
 something about statistics. I think factor analysis should be used sparingly, 
 but I occasionally use it. It doesn't seem to me that factanal() provides 
 Kaiser's Measure of Sampling Adequacy, which should be computed for factor 
 problems based on a small number of subjects, though perhaps it is elsewhere. 
 Does anyone know? (Better yet, is there a complete list of procedures that 
 can be performed by all available packages?)
 
 I have coded MSA in C++, so I could add it if it is not yet available. In 
 that case I suppose I should find out how to submit it.

   See this post from the archives:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/106430.html

   which I found using RSiteSearch(Kaiser sampling adequacy).  I don't 
know of a complete list of all procedures (functions) in all packages, 
but, among other things, RSiteSearch() is very useful when the question 
is, Is there a package or function to do X?

 Robert Tim Kopp
 http://analytic.tripod.com/
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] standard errors

2008-02-28 Thread threshold

Hi, guess my problem has simple solution. 
I want to extract ONLY Std. Errors of Max. Lik. estimates
(my_fit-mle(object,...)), the same as I can do with estimates by:
x-as. matrix(coef(my_fit)).
I could not find any function similar to 'coef(my_fit)', which extracts only
Standard Errors. So far all I can do is to type: summary(my_fit) and then
get the whole output (with Standard Eroros involved).

thank you in advance and best wishes, robert

-- 
View this message in context: 
http://www.nabble.com/standard-errors-tp15734141p15734141.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Calculating monthly var-cov matrix on non-overlapping rooling window basis

2008-02-28 Thread Henrique Dallazuanna
You can't calculate the var indeed of cov

On 28/02/2008, Megh Dal [EMAIL PROTECTED] wrote:
 Thanks Henrique for this mail. It works fine. However I need one more
 modification. When number of column is 1 then some error is coming :

  library(zoo)
  date.data = seq(as.Date(01/01/01, format =
 %m/%d/%y),as.Date(06/25/02, format = %m/%d/%y), by = 1)
  len = length(date.data)
  data1 = zoo(matrix(rnorm(len), nrow = len),  date.data )
  head(data1)

 2001-01-01 -1.5128990
 2001-01-02 -0.2939971
 2001-01-03  1.6387866
 2001-01-04 -0.8107857
 2001-01-05  0.7966224
 2001-01-06  0.6007594
 
  lapply(split(data1, format(index(data1), %m)), cov)
 Error in FUN(X[[1L]], ...) : supply both 'x' and 'y' or a matrix-like 'x'

 However I tried with an 'ifelse' condition :
  lapply(split(data1, format(index(data1), %m)), ifelse(dim(data1)[1]  1,
 cov, var))

 Still I am getting error. What to do?


 Henrique Dallazuanna [EMAIL PROTECTED] wrote:
 Perhaps something like this:

 lapply(split(data1, format(index(data1), %m)), cov)

 On 27/02/2008, Megh Dal wrote:
  let create a 'zoo' object :
 
  library(zoo)
  date.data = seq(as.Date(01/01/01, format = %m/%d/%y),
 as.Date(06/25/02, format = %m/%d/%y), by = 1)
  len = length(date.data)
  data1 = zoo(matrix(rnorm(2*len), nrow = len), date.data )
  head(data1)
 
  Now I want to create an 3 dimensional array (suppose name  var.cov)
 where, var.cov[,,i] gives the Variance-covariance matrix for i-th month of
 data1. That is I want to calculate monthly variance-covariance matrix on
 non-overlapping rolling window basis.
 
  Any suggestion?
 
 
 
  -
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O



  
 Looking for last minute shopping deals? Find them fast with Yahoo! Search.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


[R] calculate sd for each row on some columns of a dataframe

2008-02-28 Thread Albert Vilella
Hi,

I've got a dataframe like this:

df = 
data.frame(a=rnorm(100,1),b=rnorm(100,10),c=rnorm(100,100),d=rnorm(100,-100))

and I want to calculate sd1 for (a,b,c) for each entry, and sd2 for
(b,c,d) for each entry.

I don't seem to find the answer using aggregate or apply,

How can I do this?

Thanks in advance,

Cheers,

Albert.

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


Re: [R] standard errors

2008-02-28 Thread Duncan Murdoch
threshold wrote:
 Hi, guess my problem has simple solution. 
 I want to extract ONLY Std. Errors of Max. Lik. estimates
 (my_fit-mle(object,...)), the same as I can do with estimates by:
 x-as. matrix(coef(my_fit)).
 I could not find any function similar to 'coef(my_fit)', which extracts only
 Standard Errors. So far all I can do is to type: summary(my_fit) and then
 get the whole output (with Standard Eroros involved).

 thank you in advance and best wishes, robert

   
Use coef(summary(my_fit)).  Generally summary() methods don't just print 
results, they return them in a usable form too.

Duncan Murdoch

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


Re: [R] calculate sd for each row on some columns of a dataframe

2008-02-28 Thread Henrique Dallazuanna
Try this:

lapply(list(letters[1:3], letters[2:4]), function(x)apply(df[,x], 1, sd))

On 28/02/2008, Albert Vilella [EMAIL PROTECTED] wrote:
 Hi,

  I've got a dataframe like this:

  df = 
 data.frame(a=rnorm(100,1),b=rnorm(100,10),c=rnorm(100,100),d=rnorm(100,-100))

  and I want to calculate sd1 for (a,b,c) for each entry, and sd2 for
  (b,c,d) for each entry.

  I don't seem to find the answer using aggregate or apply,

  How can I do this?

  Thanks in advance,

  Cheers,

 Albert.

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



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


[R] Errors melt()ing data...

2008-02-28 Thread Neil Shephard
Hi,

I'm trying to melt() some data for subsequent cast()ing and am
encoutering errors.

The overall process requires a couple of casts()s and melt()s.

Start Session 1##
## I have the data in a (fully) melted format and can cast it fine...
 norm1[1:10,]
   Pool   SNP Sample.Name variable   value
1 1 rs1045485  CA0092 Height.1 0.003488853
2 1 rs1045485  CA0142 Height.2 0.333274200
3 1 rs1045485  CO0007 Height.2 0.396250961
4 1 rs1045485  CA0047 Height.2 0.535686831
5 1 rs1045485  CO0149 Height.2 0.296611673
6 1 rs1045485  CA0106 Height.2 0.786115546
7 1 rs1045485  CO0191 Height.1 0.669268523
8 1 rs1045485  CA0097 Height.2 0.609603217
9 1 rs1045485  CA0076 Height.1 0.004257584
101 rs1045485  CO0017 Height.2 0.589261427
## This gets the data
 t.norm1- cast(norm1, Sample.Name + SNP + Pool ~ variable, sum)
 t.norm1[1:10,]
   Sample.NameSNP PoolHeight.1  Height.2
1   CA0001  rs10454851 0.003311454 0.4789782
2   CA0001  rs10454871 0.001818583 0.5089827
3   CA0001 rs112125701 0.006078444 0.4496129
4   CA0001 rs130106271 0.008753049 0.5424499
5   CA0001rs131131 0.186821486 0.2294912
6   CA0001 rs134026161 0.012030235 0.4161610
7   CA0001   rs1705481 0.002425579 0.3111907
8   CA0001 rs175039081 0.002179705 0.3063292
9   CA0001  rs17997941 0.003632984 0.5049848
10  CA0001  rs17997961 0.389774160 0.000
## I now melt it and cast again to the desired format
 t  - melt(t.norm1, id = c(Sample.Name, SNP))
 cast.height.norm1 - cast(t, SNP ~ Sample.Name + variable, sum)
 cast.height.norm1[1:10,1:5]
  SNP CA0001_Height.1 CA0001_Height.2 CA0002_Height.1 CA0002_Height.2
1   rs1045485 0.003311454   0.4789782 0.401218142 0.343031163
2   rs1045487 0.001818583   0.5089827 0.007329439 0.453102612
3  rs11212570 0.006078444   0.4496129 0.015164118 0.434320814
4  rs13010627 0.008753049   0.5424499 0.013440474 0.463863778
5 rs13113 0.186821486   0.2294912 0.224865477 0.272916077
6  rs13402616 0.012030235   0.4161610 0.191099755 0.285744704
7rs170548 0.002425579   0.3111907 0.365986770 0.240187431
8  rs17503908 0.002179705   0.3063292 0.011100347 0.232259627
9   rs1799794 0.003632984   0.5049848 0.430635350 0.008364312
10  rs1799796 0.389774160   0.000 0.173564141 0.235928006
Finish Session 1##

This is the format that I'm aiming for and everythings worked fine.
However, I wish to derive two transformed variables (polar.1 and
polar.2) based on each row of t.norm1 and then melt() and cast() the
data into the same desired format.

Start Session 2##
## Now generate polar co-ordinates
t.norm1$polar.1 - log10(sqrt(t.norm1$Height.1^2 + t.norm1$Height.2^2))
t.norm1$polar.2 - atan((t.norm1$Height.2 / t.norm1$Height.1))
## And cast the polar data
 t - melt(subset(t.norm1, select= c(Sample.Name, SNP, Pool, polar.1, 
 polar.2)), id=c(Sample.Name, SNP))
Error in if (!missing(id.var)  !(id.var %in% varnames)) { :
  missing value where TRUE/FALSE needed
 traceback()
4: melt_check(data, id.var, measure.var)
3: melt.data.frame(as.data.frame(data), id = attr(data, idvars))
2: melt.cast_df(subset(t.norm1, select = c(Sample.Name, SNP,
   Pool, polar.1, polar.2)), id = c(Sample.Name, SNP),
   measure = c(polar.1, polar.2))
1: melt(subset(t.norm1, select = c(Sample.Name, SNP, Pool,
   polar.1, polar.2)), id = c(Sample.Name, SNP), measure =
c(polar.1,
   polar.2))
Finish Session 2##

As far as I can tell the error is occurring within melt_check() where
there is a check to see if the id.var is missing and whether the
id.var exists within the data frames names, both of which are true
since the subset() call works fine on its own...

Start Session 3##
 test - subset(t.norm1, select= c(Sample.Name, SNP, Pool, polar.1, 
 polar.2))
 names(test)
[1] Sample.Name SNP Poolpolar.1 polar.2
Start Session 3##

What I find particularly strange is that there isn't really any
difference between
Session 1
 t  - melt(t.norm1, id = c(Sample.Name, SNP))

and
Session 2
t - melt(subset(t.norm1, select= c(Sample.Name, SNP, Pool,
polar.1, polar.2)), id=c(Sample.Name, SNP))

..since I've done nothing to alter the Sample.Name and SNP
columns, all thats changing is the names of the two columns that are
the measure.var which in this instance is everything thats not defined
as being and id.var in the call to melt().

If anyone can provide any insight to what I'm doing wrong I'd be very grateful.

Thanks,

Neil
--
Email - [EMAIL PROTECTED] / [EMAIL PROTECTED]

__
R-help@r-project.org mailing list

Re: [R] standard errors

2008-02-28 Thread Henrique Dallazuanna
Try this:

coef(summary(fit))[,2]

On 28/02/2008, threshold [EMAIL PROTECTED] wrote:

  Hi, guess my problem has simple solution.
  I want to extract ONLY Std. Errors of Max. Lik. estimates
  (my_fit-mle(object,...)), the same as I can do with estimates by:
  x-as. matrix(coef(my_fit)).
  I could not find any function similar to 'coef(my_fit)', which extracts only
  Standard Errors. So far all I can do is to type: summary(my_fit) and then
  get the whole output (with Standard Eroros involved).

  thank you in advance and best wishes, robert

  --
  View this message in context: 
 http://www.nabble.com/standard-errors-tp15734141p15734141.html
  Sent from the R help mailing list archive at Nabble.com.

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



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Re: [R] standard errors

2008-02-28 Thread Achim Zeileis
On Thu, 28 Feb 2008, threshold wrote:

 Hi, guess my problem has simple solution.
 I want to extract ONLY Std. Errors of Max. Lik. estimates
 (my_fit-mle(object,...)), the same as I can do with estimates by:
 x-as. matrix(coef(my_fit)).
 I could not find any function similar to 'coef(my_fit)', which extracts only
 Standard Errors. So far all I can do is to type: summary(my_fit) and then
 get the whole output (with Standard Eroros involved).

vcov() is the extractor function that gets you the variance-covariance
matrix. Hence, sqrt(diag(vcov(obj))) gets you the standard errors.
Z

 thank you in advance and best wishes, robert

 --
 View this message in context: 
 http://www.nabble.com/standard-errors-tp15734141p15734141.html
 Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] ggplot2 boxplot confusion

2008-02-28 Thread Chris Friedl

Hey thanks Thierry! I learned two things here ... position=identity AND
x=dummy.

Can I ask where you learned these things. I've read a lot of the online
reference manual, the book, other presentations of ggplot2 and don't
recall seeing these, especially the x=dummy reference.

Does this come from experience with the previous gplot package? Perhaps I
should use that too?



ONKELINX, Thierry wrote:
 
 Chris,
 
 You need to specify position = identity
 
 library(ggplot2)
 series - c('C2','C4','C8','C10','C15','C20')
 series - factor(series, levels = series)
 ids - c('ID1','ID2','ID3')
 mydata -
 data.frame(SERIES=rep(series,30),ID=rep(ids,60),VALUE=rnorm(180), dummy
 = factor(1))
 ggplot(mydata, aes(y = VALUE, x = dummy)) + geom_boxplot(position =
 identity) + facet_grid(SERIES ~ ID)
 
 Thierry 
 
 

-- 
View this message in context: 
http://www.nabble.com/ggplot2-boxplot-confusion-tp15706116p15735720.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] standard errors

2008-02-28 Thread Bill.Venables
vcov(my_fit) should get you the whole variance matrix, so
sqrt(diag(vcov(my_fit))) should get you ONLY the standard errors. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of threshold
Sent: Thursday, 28 February 2008 9:06 PM
To: r-help@r-project.org
Subject: [R] standard errors


Hi, guess my problem has simple solution. 
I want to extract ONLY Std. Errors of Max. Lik. estimates
(my_fit-mle(object,...)), the same as I can do with estimates by:
x-as. matrix(coef(my_fit)).
I could not find any function similar to 'coef(my_fit)', which extracts
only
Standard Errors. So far all I can do is to type: summary(my_fit) and
then
get the whole output (with Standard Eroros involved).

thank you in advance and best wishes, robert

-- 
View this message in context:
http://www.nabble.com/standard-errors-tp15734141p15734141.html
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] Errors melt()ing data...

2008-02-28 Thread hadley wickham
Hi Neil,

  Start Session 2##
  ## Now generate polar co-ordinates
  t.norm1$polar.1 - log10(sqrt(t.norm1$Height.1^2 + t.norm1$Height.2^2))
  t.norm1$polar.2 - atan((t.norm1$Height.2 / t.norm1$Height.1))
  ## And cast the polar data
   t - melt(subset(t.norm1, select= c(Sample.Name, SNP, Pool, 
 polar.1, polar.2)), id=c(Sample.Name, SNP))
  Error in if (!missing(id.var)  !(id.var %in% varnames)) { :
   missing value where TRUE/FALSE needed
   traceback()
  4: melt_check(data, id.var, measure.var)
  3: melt.data.frame(as.data.frame(data), id = attr(data, idvars))
  2: melt.cast_df(subset(t.norm1, select = c(Sample.Name, SNP,
Pool, polar.1, polar.2)), id = c(Sample.Name, SNP),
measure = c(polar.1, polar.2))
  1: melt(subset(t.norm1, select = c(Sample.Name, SNP, Pool,
polar.1, polar.2)), id = c(Sample.Name, SNP), measure =
  c(polar.1,
polar.2))
  Finish Session 2##

  As far as I can tell the error is occurring within melt_check() where
  there is a check to see if the id.var is missing and whether the
  id.var exists within the data frames names, both of which are true
  since the subset() call works fine on its own...

  Start Session 3##
   test - subset(t.norm1, select= c(Sample.Name, SNP, Pool, polar.1, 
 polar.2))
   names(test)
  [1] Sample.Name SNP Poolpolar.1 polar.2
  Start Session 3##

  What I find particularly strange is that there isn't really any
  difference between
  Session 1
   t  - melt(t.norm1, id = c(Sample.Name, SNP))

  and
  Session 2
  t - melt(subset(t.norm1, select= c(Sample.Name, SNP, Pool,
  polar.1, polar.2)), id=c(Sample.Name, SNP))

  ..since I've done nothing to alter the Sample.Name and SNP
  columns, all thats changing is the names of the two columns that are
  the measure.var which in this instance is everything thats not defined
  as being and id.var in the call to melt().

  If anyone can provide any insight to what I'm doing wrong I'd be very 
 grateful.

I think the problem is that reshape adds some extra information to the
cast data.frame, but this info is no longer relevant when you've
removed some of the columns.  Try as.data.frame to strip off this
extra info.

 t - melt(subset(as.data.frame(t.norm1), select= c(Sample.Name,
SNP, Pool, polar.1, polar.2)), id=c(Sample.Name, SNP))

(Also, can't you get to cast.height.norm1 directly from norm1 ?
cast.height.norm1 - cast(norm1, SNP ~ Sample.Name + variable, sum)

Hadley

-- 
http://had.co.nz/

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


Re: [R] Errors melt()ing data...

2008-02-28 Thread Neil Shephard
Hi Hadley,

On Thu, Feb 28, 2008 at 1:15 PM, hadley wickham [EMAIL PROTECTED] wrote:

  I think the problem is that reshape adds some extra information to the
  cast data.frame, but this info is no longer relevant when you've
  removed some of the columns.  Try as.data.frame to strip off this
  extra info.

   t - melt(subset(as.data.frame(t.norm1), select= c(Sample.Name,
 SNP, Pool, polar.1, polar.2)), id=c(Sample.Name, SNP))


Thats done the trick, thank you very much.

  (Also, can't you get to cast.height.norm1 directly from norm1 ?
  cast.height.norm1 - cast(norm1, SNP ~ Sample.Name + variable, sum)

Yep, you can, but I need t.norm1 as an intermediate for deriving
polar.1 and polar.2 for each Sample.Name and SNP, although I wouldn't
be surprised if this can be done at the same time, as your reshape()
package is exceptionally flexible (and as you can probably tell, I'm
still climbing the R learning curve!).

In fact I think I shall sit down and work out how to do this!

Thanks for your help (again),

Neil
-- 
Email - [EMAIL PROTECTED] / [EMAIL PROTECTED]

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


[R] intermediate linkage clustering

2008-02-28 Thread yvo

Does anybody know how to do a intermediate linkage clustering in R? 
Is there a command allready developed? Which package do I have to load?
Thanks in advance
yvo
-- 
View this message in context: 
http://www.nabble.com/intermediate-linkage-clustering-tp15736379p15736379.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] unbalanced one-way ANOVA

2008-02-28 Thread Nauta, A.L.
Hi,
 
I have an unbalanced dataset on which I would like to perform a one-way anova 
test using R (aov). According to Wannacott and Wannacott (1990) p. 333, one-way 
anova with unbalanced data is possible with a few modifications in the 
anova-calculations. The modified anova calculations should take into account 
different sample sizes and a modified definition of the average. I was 
wondering if the aov-function in R is suitable for one-way anova on unbalanced 
data.
 
Thanks,
 
Ake Nauta

[[alternative HTML version deleted]]

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


[R] non parametric linear regression

2008-02-28 Thread Jeanne Vallet
Dear all, 

I am looking for if non parametric linear regression is available in R. The
method I wish to use is described in the help of statsdirect statistical
software like this : This is a distribution free method for investigating a
linear relationship between two variables Y (dependent, outcome) and X
(predictor, independent). The slope b of the regression (Y=bX+a) is
calculated as the median of the gradients from all possible pairwise
contrasts of your data. A confidence interval based upon
http://www.statsdirect.com/help/nonparametric_methods/kend.htm Kendall's t
is constructed for the slope. Non-parametric linear regression is much less
sensitive to extreme observations (outliers) than is
http://www.statsdirect.com/help/regression_and_correlation/sreg.htm simple
linear regression based upon the least squares method. If your data contain
extreme observations which may be erroneous but you do not have sufficient
reason to exclude them from the analysis then non-parametric linear
regression may be appropriate. This function also provides you with an
approximate two sided Kendall's rank correlation test for independence
between the variables. Technical Validation : Note that the two sided
confidence interval for the slope is the inversion of the two sided
Kendall's test. The approximate two sided P value for Kendall's t or tb is
given but the  http://www.statsdirect.com/help/distributions/pk.htm exact
quantile from Kendall's distribution is used to construct the confidence
interval, therefore, there may be slight disagreement between the P value
and confidence interval. If there are many ties then this situation is
compounded ( http://www.statsdirect.com/help/references/refs.htm Conover,
1999).

Thanks in advance!

 

Regards, 

Jeanne Vallet

PhD student,

Angers, France

 

 


[[alternative HTML version deleted]]

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


[R] cohesive blocks.. again

2008-02-28 Thread Simone Gabbriellini
hello,

I have a last question on cohesive blocks: if there are multiple links  
between some nodes in the graph, this is taken into account by  
cohesive blocks? or the multiple links are simply ignored?

thank you,
Simone

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


Re: [R] cohesive blocks.. again

2008-02-28 Thread Gabor Csardi
Simone, they are currently ignored. Just like edge direction.

Gabor

On Thu, Feb 28, 2008 at 03:17:24PM +0100, Simone Gabbriellini wrote:
 hello,
 
 I have a last question on cohesive blocks: if there are multiple links  
 between some nodes in the graph, this is taken into account by  
 cohesive blocks? or the multiple links are simply ignored?
 
 thank you,
 Simone
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] How to read HUGE data sets?

2008-02-28 Thread Emmanuel Charpentier
Jorge Iván Vélez a écrit :
 Dear R-list,
 
 Does somebody know how can I read a HUGE data set using R? It is a hapmap
 data set (txt format) which is around 4GB. After read it, I need to delete
 some specific rows and columns. I'm running R 2.6.2 patched over XP SP2
 using a 2.4 GHz Core 2-Duo processor and 4GB RAM. Any suggestion would be
 appreciated.

Hmmm... Unless you're running a 64-bits version of XP, you might be SOL
(nonwhistanding the astounding feats of the R Core Team, which managed
to be able to use about 3,5 GB of memory under 32-bits Windows) : your
*raw* data will eat more than the available memory. You might be lucky
if some of them can be abstracted (e. g. long character chains that can
be reduced to vectors), or get unlucky (large R storage overhead of
nonreducible data).

You might consider changing machines : get a 64-bit machine with gobs of
memory and cross your fingers. Note that, since R pointers are 64-bits
wide instead of 32-bits, data storage needs will inflate...

Depending of the real meaning of your data and the processing they need,
you might also consider storing your raw data in a SQL DBMS, reduce them
in SQL and read in R only the relevant part(s). There also  are some
contributed packages that might help in special situations : biglm, birch.

HTH,

Emmanuel Charpentier

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


Re: [R] Error in cor.default(x1, x2) : missing observations in cov/cor

2008-02-28 Thread Ken Spriggs

Thanks.  Your suggestion works. 


Daniel Malter wrote:
 
 Does the code below solve your problem? If you have NAs in the same rows,
 you have to use c or p as use= parameters. Otherwise you get the error
 you described.
 
  a=c(1,2,3,4,NA,6)
  b=c(2,4,3,5,NA,7)
  
  which(is.na(a))==which(is.na(b))
  
  cor(a,b) Error
  cor(a,b,use=all.obs) Error
  
  cor(a,b,use=complete.obs)  Does it. AND
  cor(a,b,use=pairwise.complete.obs)  Does it too.
 
 -
 cuncta stricte discussurus
 -
 
 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
 Auftrag von Ken Spriggs
 Gesendet: Wednesday, February 27, 2008 4:34 PM
 An: r-help@r-project.org
 Betreff: [R] Error in cor.default(x1, x2) : missing observations in
 cov/cor
 
 
 Hello,
 
 I'm trying to do cor(x1,x2) and I get the following error:
 Error in cor.default(x1, x2) : missing observations in cov/cor
 
 A few things:
 1.  I've used cor() many times and have never encountered this error.
 2.  length(x1) = length(x2)
 3.  is.numeric(x1) = is.numeric(x2) = TRUE
 4.  which(is.na(x1))  = which(is.na(x2)) = integer(0)   {the same goes for
 is.nan()}
 5.  I also try cor(x1,x2, use = all.obs) and get the same error.
 
 What can be going wrong?
 
 
 --
 View this message in context:
 http://www.nabble.com/Error-in-cor.default%28x1%2C-x2%29-%3A-missing-observa
 tions-in-cov-cor-tp15723848p15723848.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Error-in-cor.default%28x1%2C-x2%29-%3A-missing-observations-in-cov-cor-tp15723848p15738495.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error in cor.default(x1, x2) : missing observations in cov/cor

2008-02-28 Thread Ken Spriggs

Thanks.

 find(cor)
[1] package:fUtilities package:stats   



Rolf Turner-3 wrote:
 
 
 On 28/02/2008, at 11:11 AM, Ken Spriggs wrote:
 

 I get the following

 class(x1)
 [1] numeric
 class(x2)
 [1] numeric

 and:

 cor(x1,x2)
 Error in cor.default(x1, x2) : missing observations in cov/cor
 traceback()
 2: cor.default(x1, x2)
 1: cor(x1, x2)
 
 ``Clearly'' you must be using a non-standard cor.  As Peter Dalgaard
 pointed out, cor() is not generic and there is no such function as
 cor.default() in ``standard R''.
 
 Suggestions:
 
 * Try find(cor) to see what package you are actually using.
 
 * Detach that package from the search list --- or remove cor from  
 that position on
the search list --- then you'll get the ``standard R'' version of  
 cor() and all will be well.
 
   cheers,
 
   Rolf Turner
 
 ##
 Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Error-in-cor.default%28x1%2C-x2%29-%3A-missing-observations-in-cov-cor-tp15723848p15738523.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error in cor.default(x1, x2) : missing observations in cov/cor

2008-02-28 Thread Ken Spriggs

Here's what happened...

 stats::cor(x1,x2)
Error in stats::cor(x1, x2) : missing observations in cov/cor




Erik Iverson wrote:
 
 OK, that is not the definition of cor in the stats package.  Some add-on 
 package you are loading might be overwriting it.
 
 What happens if you do
 
 stats::cor(x1,x2)
 
 ?
 
 
 
 Ken Spriggs wrote:
 I get the following:
 
 cor
 function (x, y = NULL, use = all.obs, method = c(pearson, 
 kendall, spearman)) 
 {
 UseMethod(cor)
 }
 
 
 
 
 Erik Iverson wrote:
 What happens when you type cor at the R prompt?  Perhaps your calling 
 of the cor function is not calling the cor function in the stats
 package?



 Ken Spriggs wrote:
 Hello,

 I'm trying to do cor(x1,x2) and I get the following error:
 Error in cor.default(x1, x2) : missing observations in cov/cor

 A few things:
 1.  I've used cor() many times and have never encountered this error.
 2.  length(x1) = length(x2)
 3.  is.numeric(x1) = is.numeric(x2) = TRUE
 4.  which(is.na(x1))  = which(is.na(x2)) = integer(0)   {the same goes
 for
 is.nan()}
 5.  I also try cor(x1,x2, use = all.obs) and get the same error.

 What can be going wrong?


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



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

-- 
View this message in context: 
http://www.nabble.com/Error-in-cor.default%28x1%2C-x2%29-%3A-missing-observations-in-cov-cor-tp15723848p15738590.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] p-value in Spearman rank order

2008-02-28 Thread Anne-Katrin Link
Dear R-helpers,

I would like to do a Spearman rank order test, and used the cor() function 
with the method spearman. 
It gives me a number (correlation coefficient?) , but how can I get the 
p-value?
Thank you for the help in advance!

Regards, 
Anne-Katrin

-- 



[[alternative HTML version deleted]]

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


Re: [R] Plot Principal component analysis

2008-02-28 Thread David Winsemius
SNN [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]:

 
 Thanks for your help,
  Can R plot the data in 3 dimention, with different colors for each
  group ? 
 for exmple I would like to have the plot with respect to PC1, PC2
 and PC3. 
 

See if these answer your desires: 

http://www.jstatsoft.org/v08/i11/paper
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=44

-- 
David Winsemius

 SNN wrote:
 
 Hi,
 
 I have matrix of 300,000*115 (snps*individual). I ran the PCA on
 the covariance matrix which has a dimention oof 115*115. I have the
 first 100 individuals from group A and the rest of 15 individuals
 from group B. I need to plot the data in two and 3 dimentions with
 respect to PC1 and PC2 and (in 3D with respect to PC1, PC2 and
 PC3). I do not know how to have the plot ploting the first 100
 points corresponding to group A in red (for example) and the rest
 of the 15 points in Blue? i.e I want the each group in a diffrent
 color in the same plot. I appreciate if someone can help. 
 
 Thanks,
 


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


Re: [R] p-value in Spearman rank order

2008-02-28 Thread Gavin Simpson
On Thu, 2008-02-28 at 16:17 +0100, Anne-Katrin Link wrote:
 Dear R-helpers,
 
 I would like to do a Spearman rank order test, and used the cor() function 
 with the method spearman. 
 It gives me a number (correlation coefficient?) , but how can I get the 
 p-value?
 Thank you for the help in advance!

?cor.test

HTH

G

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

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


Re: [R] problem of subscript value from vector and list

2008-02-28 Thread John Kane
I think you are getting a rounding or truncating
problem in the printing 

Try print[lon[x]) 

and see what you get
--- Jingru Dai [EMAIL PROTECTED] wrote:

 Hi, everyone
 
 I got some problems when trying to subscript the
 value of vector and 
 list, by using calculated indices.
 Here is the vector I am generated
 lon-rep(0,886);lat-rep(0,691)
 for (i in 1:886){
 lon[i]-112+0.05*(i-1)
 }
 for (i in 691:1){
 lat[i]--44.5+0.05*(691-i)
 }
 For a given location of lon(xp) and lat(yp), I would
 like to calculate 
 the  position of them, and using that to get the
 value for the location 
 from one list.
 xp-c(112,112.05); yp-c(-10,-10.10)
 
 x-rep(0,length(xp)); y-rep(0,length(yp))
 for (i in 1:length(xp)){
 x[i]-(xp[i]-112)/0.05+1
 }
 for(j in 1:length(yp)){
 y[j]-(-10-yp[j])/0.05+1
 }
 So here the value of x and y should indicate the
 position where xp and 
 yp are in the vector lon and lat.  And it appears to
 be the right 
 number.  But when I tried to retrieve the value of
 lon using the 
 position, it returns the wrong value.  Here's the
 result I got
   x
 [1] 1 2
   lon[x]
 [1] 112 112
   lon[c(1,2)]
 [1] 112.00 112.05
   y
 [1] 1 3
   lat[y]
 [1] -10.00 -10.05
   lat[c(1,3)]
 [1] -10.0 -10.1
 
 I have no idea why it returns the wrong value when I
 subscripts by x, 
 while it works perfectly fine when I subscripts with
 the value of x 
 directly.  Is there any special rule of subscripts? 
 My version of R is 
 2.5.1.
 Thanks a lot
 
 Jingru Dai
  
  School of Mathematical Sciences
  Rm 454, Building 28
  Monash University, 3800
  Victoria, Australia
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] problem with creation of eSet

2008-02-28 Thread James W. MacDonald
Hi Manisha,

This is a Bioconductor-specific question. Please repost on the bioc 
listserv:

[EMAIL PROTECTED]

Best,

Jim



Manisha Brahmachary wrote:
 Hi,
 
  
 
  I am having troubles with creating an eSet and would appreciate any help on
 the following problem.
 
  
 
 I am trying to create an eSet  using the following code 
 
  
 
 pd - read.table(file=pdata.txt,header =TRUE,row.names=1);
 
 colnames(pd) - c(type,tumor,time,id);
 
 pdN - list(type =
 Cellline/xenograft,tumor=primary,secondary,cellline,time =
 0hr,1hr,2hr,4hr, id = 1,2,3,4,5,6,7,8,9)
 
 # Initialize exprSet object
 
 pD - new(phenoData, pData=pd, varLabels=pdN);
 
 # This is my eSet!!!
 
 metastasis.eset - new(exprSet, exprs=as.matrix(geneExpr.log),
 phenoData=pD)
 
  
 
 I get the following error:
 
  
 
 The phenoData class is deprecated, use AnnotatedDataFrame (with
 ExpressionSet) instead
 
  
 
  
 
 Can someone suggest me how to use the new method AnnotatedDataFrame to create
 eSet?
 
  
 
  
 
 Thanks
 
  
 
 Manisha
 
  
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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


Re: [R] Error in cor.default(x1, x2) : missing observations in cov/cor

2008-02-28 Thread Erik Iverson
So you did have NAs in your data?

what do

  any(is.na(x1))

and

  any(is.na(x2))

give?



Ken Spriggs wrote:
 Thanks.  Your suggestion works. 
 
 
 Daniel Malter wrote:
 Does the code below solve your problem? If you have NAs in the same rows,
 you have to use c or p as use= parameters. Otherwise you get the error
 you described.

  a=c(1,2,3,4,NA,6)
  b=c(2,4,3,5,NA,7)
  
  which(is.na(a))==which(is.na(b))
  
  cor(a,b) Error
  cor(a,b,use=all.obs) Error
  
  cor(a,b,use=complete.obs)  Does it. AND
  cor(a,b,use=pairwise.complete.obs)  Does it too.

 -
 cuncta stricte discussurus
 -

 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
 Auftrag von Ken Spriggs
 Gesendet: Wednesday, February 27, 2008 4:34 PM
 An: r-help@r-project.org
 Betreff: [R] Error in cor.default(x1, x2) : missing observations in
 cov/cor


 Hello,

 I'm trying to do cor(x1,x2) and I get the following error:
 Error in cor.default(x1, x2) : missing observations in cov/cor

 A few things:
 1.  I've used cor() many times and have never encountered this error.
 2.  length(x1) = length(x2)
 3.  is.numeric(x1) = is.numeric(x2) = TRUE
 4.  which(is.na(x1))  = which(is.na(x2)) = integer(0)   {the same goes for
 is.nan()}
 5.  I also try cor(x1,x2, use = all.obs) and get the same error.

 What can be going wrong?


 --
 View this message in context:
 http://www.nabble.com/Error-in-cor.default%28x1%2C-x2%29-%3A-missing-observa
 tions-in-cov-cor-tp15723848p15723848.html
 Sent from the R help mailing list archive at Nabble.com.

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

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




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


[R] [R-pkgs] New Package: geozoo. High-Dimensional Geometric Objects

2008-02-28 Thread Barret Schloerke
 Dear useRs,

I'd like to announce a new package called geozoo, short for geometric
zoo. It's a compilation of functions to produce high-dimensional
geometric objects, including hypercubes and hyperspheres, Boy's
surface, the hyper torus and a selection of polytopes.  For a complete
list, as well as images and movies, visit
http://streaming.stat.iastate.edu/~dicook/geometric-data/http://streaming.stat.iastate.edu/%7Edicook/geometric-data/
.

This package makes extensive use of GGobi (http://ggobi.org) and the
rggobi package (http://ggobi.org/rggobi) to visualise these objects,
so if you'd like to practice your high-dimensional visualisation
skills, give it a shot!

Any feedback (questions, suggestions, bug-reports, etc.) is very welcome.

Thanks,
Barret Schloerke

[[alternative HTML version deleted]]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] compress data on read, decompress on write

2008-02-28 Thread Ramon Diaz-Uriarte
Dear All,

I'd like to be able to have R store (in a list component) a compressed
data set, and then write it out uncompressed. gzcon and gzfile work in
exactly the opposite direction. What would be a good way to handle
this?

Details:
--

We have a package that uses C; part of the C output is a large sparse
matrix. This is never manipulated directly by R, but always by the C
code. However, we need to store that data somewhere (inside an R
object) for further calls to the functions in our package. We'd like
to store that matrix as part of the R object (say, as an element of a
list). Ideally, it would be stored in as compressed a way as possible.
Then, when we need to use that information, it would be decompressed
and passed to the C function.

I guess one way to do it is to have C deal with the compression and
uncompression (e.g., using zlib or the bzip2 libraries) and then use
readBin, etc, from R. But, if I can, I'd like to avoid our C code
having to call zlib, etc, so as to make our package easily portable.


Thanks,

R.

-- 
Ramon Diaz-Uriarte
Statistical Computing Team
Structural Biology and Biocomputing Programme
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz

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


Re: [R] non parametric linear regression

2008-02-28 Thread Greg Snow
These methods are more commonly called robust regression or resistant
regression (it is not really non-parametric since you are trying to
estimate the slope which is a parameter, just not of a normal
distribution).

There are many methods for doing robust regressions, the book Modern
Applied Statistics with S (MASS) has a good discussion on some different
techniques.

Running the command:

 RSiteSearch(median regression)

Gives several hits, one of which is the mblm function in the mblm
package which, based on its description, does the calculations you
mention.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Jeanne Vallet
 Sent: Thursday, February 28, 2008 7:07 AM
 To: r-help@r-project.org
 Subject: [R] non parametric linear regression
 
 Dear all, 
 
 I am looking for if non parametric linear regression is 
 available in R. The method I wish to use is described in the 
 help of statsdirect statistical software like this : This is 
 a distribution free method for investigating a linear 
 relationship between two variables Y (dependent, outcome) and 
 X (predictor, independent). The slope b of the regression 
 (Y=bX+a) is calculated as the median of the gradients from 
 all possible pairwise contrasts of your data. A confidence 
 interval based upon 
 http://www.statsdirect.com/help/nonparametric_methods/kend.ht
 m Kendall's t is constructed for the slope. Non-parametric 
 linear regression is much less sensitive to extreme 
 observations (outliers) than is 
 http://www.statsdirect.com/help/regression_and_correlation/sr
 eg.htm simple linear regression based upon the least squares 
 method. If your data contain extreme observations which may 
 be erroneous but you do not have sufficient reason to exclude 
 them from the analysis then non-parametric linear regression 
 may be appropriate. This function also provides you with an 
 approximate two sided Kendall's rank correlation test for 
 independence between the variables. Technical Validation : 
 Note that the two sided confidence interval for the slope is 
 the inversion of the two sided Kendall's test. The 
 approximate two sided P value for Kendall's t or tb is given 
 but the  
 http://www.statsdirect.com/help/distributions/pk.htm exact 
 quantile from Kendall's distribution is used to construct the 
 confidence interval, therefore, there may be slight 
 disagreement between the P value and confidence interval. If 
 there are many ties then this situation is compounded ( 
 http://www.statsdirect.com/help/references/refs.htm Conover, 1999).
 
 Thanks in advance!
 
  
 
 Regards, 
 
 Jeanne Vallet
 
 PhD student,
 
 Angers, France
 
  
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] compress data on read, decompress on write

2008-02-28 Thread Christos Hatzis
Ramon,

If you are looking for a solution to your specific application (as opposed
to a general compression/ decompression mechanism), it might be worth
checking out the Matrix package, which has facilities for storing and
manipulating sparse matrices.  The sparseMatrix class stores matrices in the
triplet representation (i.e. only indices and values of the non-zero
elements) and this affords great compression ratios, depending on the size
and degree of sparseness of the matrix.

-Christos 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Ramon Diaz-Uriarte
 Sent: Thursday, February 28, 2008 1:18 PM
 To: [EMAIL PROTECTED]
 Subject: [R] compress data on read, decompress on write
 
 Dear All,
 
 I'd like to be able to have R store (in a list component) a 
 compressed data set, and then write it out uncompressed. 
 gzcon and gzfile work in exactly the opposite direction. What 
 would be a good way to handle this?
 
 Details:
 --
 
 We have a package that uses C; part of the C output is a 
 large sparse matrix. This is never manipulated directly by R, 
 but always by the C code. However, we need to store that data 
 somewhere (inside an R
 object) for further calls to the functions in our package. 
 We'd like to store that matrix as part of the R object (say, 
 as an element of a list). Ideally, it would be stored in as 
 compressed a way as possible.
 Then, when we need to use that information, it would be 
 decompressed and passed to the C function.
 
 I guess one way to do it is to have C deal with the 
 compression and uncompression (e.g., using zlib or the bzip2 
 libraries) and then use readBin, etc, from R. But, if I can, 
 I'd like to avoid our C code having to call zlib, etc, so as 
 to make our package easily portable.
 
 
 Thanks,
 
 R.
 
 --
 Ramon Diaz-Uriarte
 Statistical Computing Team
 Structural Biology and Biocomputing Programme Spanish 
 National Cancer Centre (CNIO) http://ligarto.org/rdiaz
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


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


[R] [R-pkgs] surv2sample 0.1-2

2008-02-28 Thread David Kraus
Dear useRs,

There is a new version 0.1-2 of the package surv2sample available on CRAN.  
Users of the previous versions should update because a bug in the function  
cif2.ks has been fixed.

General information about the package:

surv2sample provides various two-sample tests for right-censored survival  
data. Three main areas and corresponding methods are:

* comparison of two survival distributions
   - surv2.logrank: weighted logrank tests and their combinations (max, sum)
   - surv2.neyman: Neyman's smooth test and its data-driven version
   - surv2.ks: Kolmogorov–Smirnov, Cramér–von Mises and Anderson–Darling  
test

* comparison of two cumulative incidence functions for competing risks data
   - cif: estimation and plotting of cumulative incidence functions
   - cif2.logrank: logrank-type test for subdistribution hazards
   - cif2.neyman: Neyman's smooth test and its data-driven version
   - cif2.ks: Kolmogorov–Smirnov test
   - cif2.int: integrated-difference test

* goodness of fit tests of the proportional rate assumption (proportional  
hazards or proportional odds functions in two samples)
   - proprate2: estimation based on the simplified partial likelihood
   - proprate2.ks: Kolmogorov–Smirnov test
   - proprate2.neyman: Neyman's smooth test and its data-driven version
   - proprate2.gs: Gill–Schumacher type test

See http://www.davidkraus.net/surv2sample/ for details and references.

Best regards,

-- 
David Kraus

Institute of Information Theory and Automation
Pod Vodarenskou vezi 4
CZ-18208 Prague 8
Czechia

[EMAIL PROTECTED]
http://www.davidkraus.net/

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


Re: [R] Loading user defined functions autometically each time I start R

2008-02-28 Thread Patrick Connolly
On Wed, 27-Feb-2008 at 10:06AM +, [EMAIL PROTECTED] wrote:

|  I wrote some user defined function for my own. Now I want to get a 
| mechanism
|  so that every time I start R, those function will automatically be 
| loaded in
|  R without manually copying pasting. Can gurus here pls tell me how to do
|  that? Or I have to build my own packages bundled with those functions.
| 
| These instructions are for Windows, there may be a slight difference on 
| other platforms.
| 
| In R_HOME\etc you should have a file named RProfile.site.
| 
| Inside this file, you can define a .First function, which sources your 
| functions, e.g.
| 
| .First - function()
| {
| source(c://myfunction.r)
| }

Those functions will end up in each working directory you use.  Unless
you have only a small number of those functions, that will produce a
lot of unnecessary duplication.  You can avoid that by saving those
functions in a .RData type file, and then something like:

attach(/path/to/file/.RData)

There's no need for a .First file.  Having that line in your .Rprofile
will be sufficient.

It would be tidier to make them into a package, but the above will
work easily enough.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] compress data on read, decompress on write

2008-02-28 Thread Prof Brian Ripley
One solution is likely to be the Omegahat package Rcompression.

Otherwise, R does have internal facilities to do internal (gzip) 
compression and decompression (e.g. see the end of 
src/main/connections.c), and you could make creative use of serialization 
to do the compression.

On Thu, 28 Feb 2008, Ramon Diaz-Uriarte wrote:

 Dear All,

 I'd like to be able to have R store (in a list component) a compressed
 data set, and then write it out uncompressed. gzcon and gzfile work in
 exactly the opposite direction. What would be a good way to handle
 this?

 Details:
 --

 We have a package that uses C; part of the C output is a large sparse
 matrix. This is never manipulated directly by R, but always by the C
 code. However, we need to store that data somewhere (inside an R
 object) for further calls to the functions in our package. We'd like
 to store that matrix as part of the R object (say, as an element of a
 list). Ideally, it would be stored in as compressed a way as possible.
 Then, when we need to use that information, it would be decompressed
 and passed to the C function.

 I guess one way to do it is to have C deal with the compression and
 uncompression (e.g., using zlib or the bzip2 libraries) and then use
 readBin, etc, from R. But, if I can, I'd like to avoid our C code
 having to call zlib, etc, so as to make our package easily portable.

As from R 2.7.0 you will be able to make use of zlib on effectively all 
platforms, since it has a public interface on Windows.


 Thanks,

 R.

 --
 Ramon Diaz-Uriarte
 Statistical Computing Team
 Structural Biology and Biocomputing Programme
 Spanish National Cancer Centre (CNIO)
 http://ligarto.org/rdiaz

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

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


[R] Collapse an array

2008-02-28 Thread Gang Chen
Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I want  
to collapse the first 3 dimensions of X to make a 2-D array Y with  
dimensions (dx*dy*dz, dp). Instead of awkward looping, what is a good  
way to do this? Is there a similar function like reshape in Matlab?

Thanks,
Gang

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


[R] use of step.gam (from package 'gam') and superassignment inside functions

2008-02-28 Thread Megan Ferguson
Hello,

I am using the function step.gam() from the 'gam' package (header info 
from library(help=gam) included below) and have come across some 
behavior that I cannot understand.  In short, I have written a function 
that 1) creates a dataframe, 2) calls gam() to create a gam object, then 
3) calls step.gam() to run stepwise selection on the output from gam(). 
  When I do this, gam() can successfully build the model, but step.gam() 
is unable to see the dataframe that was created in my personal function 
and upon which my gam model was built.  I've included stand-alone code 
below that will recreate the error.  My code shows that this behavior 
doesn't occur with step().  If I use the superassignment operator - 
to define the dataframe gam.jack in the example below, I do not get an 
error.  It seems like gam() finds gam.jack in the local environment of 
fxn, but step.gam() is looking only in the global environment for 
gam.jack.  If anyone has further insight into what is going on here, I'd 
really appreciate it!

***Header info from library(help=gam)***

 Information on package 'gam'

Description:

Package:   gam
Title: Generalized Additive Models
Date:  2006-07-11
Version:   0.98
Author:Trevor Hastie
Description:   Functions for fitting and working with generalized 
additive models, as described in chapter 7
of Statistical Models in S (Chambers and Hastie (eds), 
1991), and Generalized Additive
Models (Hastie and Tibshirani, 1990).
Maintainer:Trevor Hastie [EMAIL PROTECTED]
Depends:   R (= 2.0), stats, splines
Suggests:  akima
License:   GPL2.0
Packaged:  Wed Dec 27 10:24:21 2006; hornik
Built: R 2.6.0; i386-pc-mingw32; 2007-10-05 17:00:44; windows
***End of header for library gam***


***Code that produces the error inserted below***

library(gam)

rm(list = ls())
data(gam.data)
fxn - function() {
 gam.jack - gam.data[sample(1:100, 50), ]
 print(summary(gam.jack))
 gam.object - gam(y~x+z, data=gam.jack)
 print(summary(gam.object))
 step.object - step.gam(gam.object, 
scope=list(x=~1+x+s(x,4)+s(x,6)+s(x,12),z=~1+z+s(z,4)))
}
fxn()
print(summary(gam.jack))


rm(list= ls())
data(swiss)
fxn - function() {
   swiss.jack - swiss[sample(1:nrow(swiss), 20), ]
   lm1 - lm(Fertility ~ ., data = swiss.jack)
   slm1 - step(lm1)
}
fxn()

***End of code***

-- 
Megan C. Ferguson
Southwest Fisheries Science Center
8604 La Jolla Shores Dr.
La Jolla, CA 92037
(858)546-7118 W
(858)546-7003 Fax
[EMAIL PROTECTED]

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


[R] question regarding using weights in the hierarchical/ kmeans clustering process

2008-02-28 Thread eugen pircalabelu
Hi R users!

I have a bit of a problem with using an hierarchical clustering algorithm:

 a-c(1:15)
 b-rep(seq(1:3), 5)
 c-rnorm(15, 0,1)
 d-c(sample(1:100, 15, replace=T))
 e-c(sample(1:100, 15, replace=T))
 f-c(sample(1:100, 15, replace=T))
 data-data.frame(a,b,c,d,e,f)
 q-data.frame(data$d, data$e, data$f)
 q-scale(q)


What i want to do is to use an hierarchical cluster analysis on q data.frame, 
but using data$c as a weighting variable, could it be done? or is there a 
package that would  let me use my weights in the clustering process, but an 
hierarchical process?

Another question:
say i wanted to t.test data$d, data$e but having again data$c as weights, how 
could it be done? 

and the last 2 questions:
1. how can i weight a whole dataframe in order for me to keep my weights for a 
specific analysis, like cluster or t.test or any other analysis that does not 
let me incorporate a weight option? I am looking for something like in spss 
where i can weight a whole data frame and use it for a subsequent analysis, or 
something like the survey package from R but one that offers flexibility to use 
any analysis that i want (i saw that survey package offers limited connectivity 
 to such  analyses ) 
 2. why does a kmeans cluster analysis offer a  multitude  of different results?
I tried both several times 
cclust(scale(q), 3, verbose=T)
kmeans(scale(q), 3)
 and they both seem vary unstable even with this small data.frame with respect 
to the cluster sizing, and i don't  know why? Does it always behave  like this 
? 

Thank you and have a great day!!

   
-

[[alternative HTML version deleted]]

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


Re: [R] Collapse an array

2008-02-28 Thread Henrique Dallazuanna
Try this also:

apply(x, 4, rbind)

On 28/02/2008, Gang Chen [EMAIL PROTECTED] wrote:
 Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I want
  to collapse the first 3 dimensions of X to make a 2-D array Y with
  dimensions (dx*dy*dz, dp). Instead of awkward looping, what is a good
  way to do this? Is there a similar function like reshape in Matlab?

  Thanks,
  Gang

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



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Re: [R] Collapse an array

2008-02-28 Thread Gang Chen
Thanks a lot for all the suggestions!

Gang


On Feb 28, 2008, at 3:20 PM, Henrique Dallazuanna wrote:

 Try this also:

 apply(x, 4, rbind)

 On 28/02/2008, Gang Chen [EMAIL PROTECTED] wrote:
 Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I want
  to collapse the first 3 dimensions of X to make a 2-D array Y with
  dimensions (dx*dy*dz, dp). Instead of awkward looping, what is a  
 good
  way to do this? Is there a similar function like reshape in Matlab?

  Thanks,
  Gang

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


[R] Large loops hang?

2008-02-28 Thread Minimax
Dear useRs,

Suppose we have loop:

res - c()
for (i in 1:10) {
x - rnorm(2)
res - c(res,x[2]-x[1])
}

and this loop for 10^5 cases runs about - for example 5 minutes.

When I add one zero (10^6) this loop will not end overnight but probably
hangs. This occurs regardless of calculated statistics in such 
simulation, always above 10^5 times. Nested loops do not help.

Any suggestions for collecting larger amount of Monte Carlo data ?

Regards

Minimax

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


Re: [R] Large loops hang?

2008-02-28 Thread Benilton Carvalho

have you tried

res - rnorm(10^6)-rnorm(10^6)

?

it take 0.5 sec for me...

b

On Feb 28, 2008, at 3:30 PM, Minimax wrote:


Dear useRs,

Suppose we have loop:

res - c()
for (i in 1:10) {
x - rnorm(2)
res - c(res,x[2]-x[1])
}

and this loop for 10^5 cases runs about - for example 5 minutes.

When I add one zero (10^6) this loop will not end overnight but  
probably

hangs. This occurs regardless of calculated statistics in such
simulation, always above 10^5 times. Nested loops do not help.

Any suggestions for collecting larger amount of Monte Carlo data ?

Regards

Minimax

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


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


[R] EMM: how to make forecast using EMM methods?

2008-02-28 Thread Michael
Hi all,

We followed some books and sample codes and did some EMM estimation,
only to find it won't be able to generate forecast.

This is because in the stochastic volatility models we are estimating,
the volatilities are latent variables, and we want to forecast 1-step
ahead or h-step ahead volatilities.

So it is nice to have the system estimated, but we couldn't get it to
forecast at all.

There is a Reprojection Method described in the original EMM paper,
but let's say we reproject to a GARCH(1,1) model, then only the
GARCH(1, 1) parameters are significant, which basically means we
degrade the SV model into a GARCH model. There is no way to do the
forecast...

Could anybody give some pointers?

Thanks!

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


[R] datetime on x-axis of plot

2008-02-28 Thread joshv

Hello, I'm reading Time Series Analysis and its Applilcations with R Examples
and I have a question...

I notice that in the book there are timeseries plots but without the x-axis
being labeled with dates.  They are just numbers 1,...50,...100, etc.  How
do I get the date to show up on the x-axis?

Here is my dateframe:

 head(myData, 5)
   
1 2008-01-30 08:30   7.00
2 2008-01-30 08:32   9.25
3 2008-01-30 08:34   5.50
4 2008-01-30 08:36   5.00
5 2008-01-30 08:38 -26.25
  
(Also, I have searched using Rseek.org and not found anything to help me. 
Any searching advice would be greatly appreciated.)

-- 
View this message in context: 
http://www.nabble.com/datetime-on-x-axis-of-plot-tp15745910p15745910.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Replacing plot symbols w/ subject IDs in xyplot()

2008-02-28 Thread David Afshartous


All, 

How does one replace plot symbols with say subject IDs when using xyplot? Or
superimpose them next to plot symbols?  I searched the archives under
various key words but haven't had much.  Any suggestions or links much
appreciated.  Sample code below.

David





junk.frm = data.frame(ID = rep(1:16, each = 2), x, y, z = rep(c(D, P),
16))
y = c( 0.4,  0.6, -0.1,  0.3,  0.3, -0.2,  0.7,  0.7,  0.2,  0.0,  0.9,
-0.1,  0.6, -1.1,  0.8, -1.0,  0.4,  0.1,  0.7, -0.2, -0.1, -0.1,  2.2,
0.7,  1.1,  0.2, -0.2, -0.9,  0.4,  0.1, -0.3, -0.4)
x = c(4.1000,  4.9600,  1.2000,  3.9000,  3.1875,  1.9000,  1.8625,
0.7650,  1.5750,  2.4700,  1.6250,  1.5500,  2.3125,  1.3125,  1.0600,
-0.5500,  1.1000,  0.0200, -0.0375,  3.4600,  2.5250,  2.0950,  0.8000,
1.6050, -0.4150, -0.7300,  1.1550,  1.4850,  2.2000,  2.2500,  0.6000,
2.1000)
xyplot(y ~ x , data = junk.frm[junk.frm$z ==D,], type = c(g, p,
smooth), pch = 20)

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


Re: [R] How to read HUGE data sets?

2008-02-28 Thread jebyrnes

Sounds like you want to use the filehash package which was written for just
such problems

http://yusung.blogspot.com/2007/09/dealing-with-large-data-set-in-r.html
http://cran.r-project.org/web/packages/filehash/index.html


or maybe the ff package
http://cran.r-project.org/web/packages/ff/index.html

-- 
View this message in context: 
http://www.nabble.com/How-to-read-HUGE-data-sets--tp15729830p15746400.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] [R-SIG-Finance] EMM: how to make forecast using EMM methods?

2008-02-28 Thread elton wang
I've heard opinions that GARCH/SV volatility models
are not better on forecasting than simple exponential
moving average volatilities or even rolling window
historical vol.
Any practitioners mind comment?

--- Michael [EMAIL PROTECTED] wrote:

 Hi all,
 
 We followed some books and sample codes and did some
 EMM estimation,
 only to find it won't be able to generate forecast.
 
 This is because in the stochastic volatility models
 we are estimating,
 the volatilities are latent variables, and we want
 to forecast 1-step
 ahead or h-step ahead volatilities.
 
 So it is nice to have the system estimated, but we
 couldn't get it to
 forecast at all.
 
 There is a Reprojection Method described in the
 original EMM paper,
 but let's say we reproject to a GARCH(1,1) model,
 then only the
 GARCH(1, 1) parameters are significant, which
 basically means we
 degrade the SV model into a GARCH model. There is no
 way to do the
 forecast...
 
 Could anybody give some pointers?
 
 Thanks!
 
 ___
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-sig-finance
 -- Subscriber-posting only. 
 -- If you want to post, subscribe first.
 



  

Looking for last minute shopping deals?

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


Re: [R] How to read HUGE data sets?

2008-02-28 Thread Roland Rau
Hi,

Jorge Iván Vélez wrote:
 Dear R-list,
 
 Does somebody know how can I read a HUGE data set using R? It is a hapmap
 data set (txt format) which is around 4GB. After read it, I need to delete
 some specific rows and columns. I'm running R 2.6.2 patched over XP SP2

in such a case, I would recommend not to use R in the beginning. Try to 
use awk[1] to cut out the correct rows and columns. If the resulting 
data are still very large, I would suggest to read it into a Database 
System. My experience is limited in that respect: I only used SQLite. 
But in conjunction with the RSQLite package, I was managed all my big 
data problems.

Check http://www.ibm.com/developerworks/library/l-awk1.html to get you 
smoothly started with awk.

I hope this helps,
Roland

[1] I think the gawk implementation offers most options (e.g. for 
timing) but I recently used mawk on Windows XP and it was way faster (or 
was it nawk?). If you don't have experience in some language such as 
perl, I'd say it is much easier to learn awk than perl.

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


Re: [R] [R-SIG-Finance] EMM: how to make forecast using EMM methods?

2008-02-28 Thread Michael
Well, at this moment, I just want to know how to do the forecast. We
have spent so much time studying the estimation part...

now the coefficients are there, estimated, how to do the forecast?

On Thu, Feb 28, 2008 at 1:35 PM, elton wang [EMAIL PROTECTED] wrote:
 I've heard opinions that GARCH/SV volatility models
  are not better on forecasting than simple exponential
  moving average volatilities or even rolling window
  historical vol.
  Any practitioners mind comment?



  --- Michael [EMAIL PROTECTED] wrote:

   Hi all,
  
   We followed some books and sample codes and did some
   EMM estimation,
   only to find it won't be able to generate forecast.
  
   This is because in the stochastic volatility models
   we are estimating,
   the volatilities are latent variables, and we want
   to forecast 1-step
   ahead or h-step ahead volatilities.
  
   So it is nice to have the system estimated, but we
   couldn't get it to
   forecast at all.
  
   There is a Reprojection Method described in the
   original EMM paper,
   but let's say we reproject to a GARCH(1,1) model,
   then only the
   GARCH(1, 1) parameters are significant, which
   basically means we
   degrade the SV model into a GARCH model. There is no
   way to do the
   forecast...
  
   Could anybody give some pointers?
  
   Thanks!
  
   ___
   [EMAIL PROTECTED] mailing list
   https://stat.ethz.ch/mailman/listinfo/r-sig-finance
   -- Subscriber-posting only.
   -- If you want to post, subscribe first.
  



   
 
  Looking for last minute shopping deals?

  ___
  [EMAIL PROTECTED] mailing list
  https://stat.ethz.ch/mailman/listinfo/r-sig-finance
  -- Subscriber-posting only.
  -- If you want to post, subscribe first.


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


Re: [R] p-value in Spearman rank order

2008-02-28 Thread Liviu Andronic
On 2/28/08, Anne-Katrin Link [EMAIL PROTECTED] wrote:
  I would like to do a Spearman rank order test, and used the cor() function
  with the method spearman.
  It gives me a number (correlation coefficient?) , but how can I get the
  p-value?

You're probably looking for rcorr() from Hmisc. It gives the
correlation, missing values and p-values. Check [1] and [2] for
examples and several explanations. There is also a nice plot [3].

Hope this is of help,
Liviu

[1] http://oit.utk.edu/scc/RforSASSPSSusers.pdf
[2] http://www.statmethods.net/stats/correlations.html
[3] http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=137

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


Re: [R] compress data on read, decompress on write

2008-02-28 Thread Ramon Diaz-Uriarte
Dear Christos,

Thanks for your reply. Actually, I should have been more careful with
language: its not really a sparse matrix, but rather a ragged array
that results from a more compact representation we though of for the
hidden states in a Hidden Markov Model in many runs of MCMC. However,
it might make sense for us to check sparseMatrix and see how its done
there.

Thanks,

R

On Thu, Feb 28, 2008 at 7:49 PM, Christos Hatzis
[EMAIL PROTECTED] wrote:
 Ramon,

  If you are looking for a solution to your specific application (as opposed
  to a general compression/ decompression mechanism), it might be worth
  checking out the Matrix package, which has facilities for storing and
  manipulating sparse matrices.  The sparseMatrix class stores matrices in the
  triplet representation (i.e. only indices and values of the non-zero
  elements) and this affords great compression ratios, depending on the size
  and degree of sparseness of the matrix.

  -Christos



   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On Behalf Of Ramon Diaz-Uriarte
   Sent: Thursday, February 28, 2008 1:18 PM
   To: [EMAIL PROTECTED]
   Subject: [R] compress data on read, decompress on write
  
   Dear All,
  
   I'd like to be able to have R store (in a list component) a
   compressed data set, and then write it out uncompressed.
   gzcon and gzfile work in exactly the opposite direction. What
   would be a good way to handle this?
  
   Details:
   --
  
   We have a package that uses C; part of the C output is a
   large sparse matrix. This is never manipulated directly by R,
   but always by the C code. However, we need to store that data
   somewhere (inside an R
   object) for further calls to the functions in our package.
   We'd like to store that matrix as part of the R object (say,
   as an element of a list). Ideally, it would be stored in as
   compressed a way as possible.
   Then, when we need to use that information, it would be
   decompressed and passed to the C function.
  
   I guess one way to do it is to have C deal with the
   compression and uncompression (e.g., using zlib or the bzip2
   libraries) and then use readBin, etc, from R. But, if I can,
   I'd like to avoid our C code having to call zlib, etc, so as
   to make our package easily portable.
  
  
   Thanks,
  
   R.
  
   --
   Ramon Diaz-Uriarte
   Statistical Computing Team
   Structural Biology and Biocomputing Programme Spanish
   National Cancer Centre (CNIO) http://ligarto.org/rdiaz
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  






-- 
Ramon Diaz-Uriarte
Statistical Computing Team
Structural Biology and Biocomputing Programme
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz

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


Re: [R] datetime on x-axis of plot

2008-02-28 Thread AA
see the zoo package. It has all the plotting for timeseries.
It has a nice Vignette too.
Also have a look at timeseries functions in Rmetrics.
(Rmetrics.org).

Good luck.
AA.
- Original Message - 
From: joshv [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Thursday, February 28, 2008 4:04 PM
Subject: [R] datetime on x-axis of plot



 Hello, I'm reading Time Series Analysis and its Applilcations with R 
 Examples
 and I have a question...

 I notice that in the book there are timeseries plots but without the 
 x-axis
 being labeled with dates.  They are just numbers 1,...50,...100, etc.  How
 do I get the date to show up on the x-axis?

 Here is my dateframe:

 head(myData, 5)

 1 2008-01-30 08:30   7.00
 2 2008-01-30 08:32   9.25
 3 2008-01-30 08:34   5.50
 4 2008-01-30 08:36   5.00
 5 2008-01-30 08:38 -26.25

 (Also, I have searched using Rseek.org and not found anything to help me.
 Any searching advice would be greatly appreciated.)

 -- 
 View this message in context: 
 http://www.nabble.com/datetime-on-x-axis-of-plot-tp15745910p15745910.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] How to read HUGE data sets?

2008-02-28 Thread Gabor Grothendieck
read.table's colClasses= argument can take a NULL for those columns
that you want
ignored.  Also see the skip= argument.  ?read.table .

The sqldf package can read a subset of rows and columns (actually any
sql operation)
from a file larger than R can otherwise handle.  It will automatically
set up a temporary
SQLite database for you, load the file into the database without going
through R and
extract just the data you want into R and then automatically delete
the database.  All this
can be done in 2 lines of code.  See example 6 on the home page:
http://sqldf.googlecode.com

On Thu, Feb 28, 2008 at 12:03 AM, Jorge Iván Vélez
[EMAIL PROTECTED] wrote:
 Dear R-list,

 Does somebody know how can I read a HUGE data set using R? It is a hapmap
 data set (txt format) which is around 4GB. After read it, I need to delete
 some specific rows and columns. I'm running R 2.6.2 patched over XP SP2
 using a 2.4 GHz Core 2-Duo processor and 4GB RAM. Any suggestion would be
 appreciated.

 Thanks in advance,

 Jorge

[[alternative HTML version deleted]]

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


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


[R] Plotting Dendrogram Help Getting Plot to Display Neatly

2008-02-28 Thread ngottlieb
I have done a cluster analysis doing:

1-clusNorth -hclust(dist(Artorious)^2, method=ward)
2-clusNorth$labels -Artorious$Name   ## to show the case names and not
numbers
3-dend1 - as.dendrogram(clusNorth)
4-plot(dend1)

My Dendrogram is now showing the names of my cases in the dataframe on
the x axis

1OMNICELL INC COM  
2GETTY IMAGES INC COM 
3 INTERCONTINENTALEXCHANGE IN COM
4 OPTIONSXPRESS HLDGS INC COM  
5  SUPERIOR WELL SVCS INC COM 
6 HCP INC COM  
7  SENIOR HSG PPTYS TR SH BEN INT  
8 NATIONWIDE HEALTH PPTYS INC COM  
9DUKE REALTY CORP COM NEW  
10   HEALTH CARE REIT INC COM  
11   POWERSHARES QQQ TRUST UNIT SER 1  
12   FLEXTRONICS INTL LTD ORD  
13 VENTAS INC COM


However with 60 cases the names above are not fitting neatly into plot.
Can someone advice on plot
Parameters to fix the size of dendrogram and see the full names on X
axis?

Thanks.

Neil




This information is being sent at the recipient's reques...{{dropped:16}}

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


Re: [R] compress data on read, decompress on write

2008-02-28 Thread Gregory Warnes

You might look at storing the data using R's raw data type...

-G


On Feb 28, 2008, at 5:38PM , Ramon Diaz-Uriarte wrote:

 Dear Christos,

 Thanks for your reply. Actually, I should have been more careful with
 language: its not really a sparse matrix, but rather a ragged array
 that results from a more compact representation we though of for the
 hidden states in a Hidden Markov Model in many runs of MCMC. However,
 it might make sense for us to check sparseMatrix and see how its done
 there.

 Thanks,

 R

 On Thu, Feb 28, 2008 at 7:49 PM, Christos Hatzis
 [EMAIL PROTECTED] wrote:
 Ramon,

  If you are looking for a solution to your specific application  
 (as opposed
  to a general compression/ decompression mechanism), it might be  
 worth
  checking out the Matrix package, which has facilities for storing  
 and
  manipulating sparse matrices.  The sparseMatrix class stores  
 matrices in the
  triplet representation (i.e. only indices and values of the non-zero
  elements) and this affords great compression ratios, depending on  
 the size
  and degree of sparseness of the matrix.

  -Christos



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Ramon Diaz- 
 Uriarte
 Sent: Thursday, February 28, 2008 1:18 PM
 To: [EMAIL PROTECTED]
 Subject: [R] compress data on read, decompress on write

 Dear All,

 I'd like to be able to have R store (in a list component) a
 compressed data set, and then write it out uncompressed.
 gzcon and gzfile work in exactly the opposite direction. What
 would be a good way to handle this?

 Details:
 --

 We have a package that uses C; part of the C output is a
 large sparse matrix. This is never manipulated directly by R,
 but always by the C code. However, we need to store that data
 somewhere (inside an R
 object) for further calls to the functions in our package.
 We'd like to store that matrix as part of the R object (say,
 as an element of a list). Ideally, it would be stored in as
 compressed a way as possible.
 Then, when we need to use that information, it would be
 decompressed and passed to the C function.

 I guess one way to do it is to have C deal with the
 compression and uncompression (e.g., using zlib or the bzip2
 libraries) and then use readBin, etc, from R. But, if I can,
 I'd like to avoid our C code having to call zlib, etc, so as
 to make our package easily portable.


 Thanks,

 R.

 --
 Ramon Diaz-Uriarte
 Statistical Computing Team
 Structural Biology and Biocomputing Programme Spanish
 National Cancer Centre (CNIO) http://ligarto.org/rdiaz

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








 -- 
 Ramon Diaz-Uriarte
 Statistical Computing Team
 Structural Biology and Biocomputing Programme
 Spanish National Cancer Centre (CNIO)
 http://ligarto.org/rdiaz

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

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


Re: [R] Replacing plot symbols w/ subject IDs in xyplot()

2008-02-28 Thread Deepayan Sarkar
On 2/28/08, David Afshartous [EMAIL PROTECTED] wrote:


  All,

  How does one replace plot symbols with say subject IDs when using xyplot? Or
  superimpose them next to plot symbols?  I searched the archives under
  various key words but haven't had much.  Any suggestions or links much
  appreciated.  Sample code below.

demo(lattice) has an example.

-Deepayan

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


Re: [R] datetime on x-axis of plot

2008-02-28 Thread Don MacQueen
Is the date part of your data a POSIXct object?

If so,

   plot( myData[,1], myData[,2] )

will label the x axis with dates.

See the help pages for date-time class objects:
   ?POSIXt

(POSIXt includes both POSIXct and POSIXlt; I tend to prefer POSIXct 
and find it the easier of the two to work with, overall)

-Don

At 1:04 PM -0800 2/28/08, joshv wrote:
Hello, I'm reading Time Series Analysis and its Applilcations with R Examples
and I have a question...

I notice that in the book there are timeseries plots but without the x-axis
being labeled with dates.  They are just numbers 1,...50,...100, etc.  How
do I get the date to show up on the x-axis?

Here is my dateframe:

  head(myData, 5)
   
1 2008-01-30 08:30   7.00
2 2008-01-30 08:32   9.25
3 2008-01-30 08:34   5.50
4 2008-01-30 08:36   5.00
5 2008-01-30 08:38 -26.25

(Also, I have searched using Rseek.org and not found anything to help me.
Any searching advice would be greatly appreciated.)

--
View this message in context: 
http://www.nabble.com/datetime-on-x-axis-of-plot-tp15745910p15745910.html
Sent from the R help mailing list archive at Nabble.com.

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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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


Re: [R] unbalanced one-way ANOVA

2008-02-28 Thread Douglas Bates
On Thu, Feb 28, 2008 at 7:52 AM, Nauta, A.L. [EMAIL PROTECTED] wrote:
 Hi,

  I have an unbalanced dataset on which I would like to perform a one-way 
 anova test using R (aov). According to Wannacott and Wannacott (1990) p. 333, 
 one-way anova with unbalanced data is possible with a few modifications in 
 the anova-calculations. The modified anova calculations should take into 
 account different sample sizes and a modified definition of the average. I 
 was wondering if the aov-function in R is suitable for one-way anova on 
 unbalanced data.

Yes.

The analysis of variance is performed in R by fitting a linear model
created from indicator variables for the levels of the factor.  This
validity of this approach does not depend on balance in the data.

The formulas given in an introductory textbook are almost never the
way that results are computed in practice.  I think we would all be
better off if they didn't even give these misleading formulas.

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


[R] tutorial on codetools

2008-02-28 Thread Christophe Genolini
Hi the list 

Is there any tutorial to learn codetools ? It seems to be a very 
interesting pacakge, but the help gives not that much detail, and there 
is not that much examples provided...

Christophe

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


[R] write.csv +RMySQL request

2008-02-28 Thread Tristan Casey
Hello,

I am relatively new to R and learning its ins and outs. As part of a website I 
am building, I need to read and write csv files directly from an SQL database. 
Basically I want to convert R variables (dataframes) into CSV format, store 
them as another R variable (as a properly formatted text string suitable for 
csv reading) and then send this to one row in a database.

The SQL part is fine, the problem arises because I cannot capture the output of 
write.csv! It posts to the terminal when file= is used, however I also want 
to store it. Does anyone have any ideas?

Thanks in advance!



_


e%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641_t=762955845_r=tig_OCT07_m=EXT
[[alternative HTML version deleted]]

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


[R] Getting multiple tables when using table(dataframe) to tabulate data

2008-02-28 Thread obradoa

I am having hard time tabulating data in a dataframe, and getting a single
table for an answer. I am trying to tabulate all counts for given
status on a given date. 


I have a data frame such as:


 delta_ts   status count
1  2008-02-27   CLOSED 3
2  2008-02-27  NEW56
3  2008-02-27 RESOLVED 5
4  2008-02-21 ASSIGNED 1
5  2008-02-21 ASSIGNED 1
6  2008-02-21  NEW 2
7  2008-02-21 RESOLVED 0
8  2008-02-22 ASSIGNED 0
9  2008-02-22   CLOSED 0
10 2008-02-22  NEW 6
11 2008-02-22 RESOLVED 1
12 2008-02-23 ASSIGNED 2
13 2008-02-23   CLOSED 1
14 2008-02-23  NEW12
15 2008-02-23 RESOLVED 0
16 2008-02-24 ASSIGNED 7
17 2008-02-24   CLOSED 4
18 2008-02-24  NEW16
19 2008-02-24 RESOLVED 2
20 2008-02-25 ASSIGNED 2
21 2008-02-25   CLOSED 6
22 2008-02-25  NEW22
23 2008-02-25 RESOLVED 5
24 2008-02-26 ASSIGNED 6
25 2008-02-26   CLOSED 8
26 2008-02-26  NEW38
27 2008-02-26 RESOLVED 3
28 2008-02-28   CLOSED 3
29 2008-02-28  NEW56
30 2008-02-28 RESOLVED 5


When I do table on that frame I get a long list that looks like this: 


 table(data)
, , count = 0

status
delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   01
  2008-02-221  1   00
  2008-02-230  0   01
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   00
  2008-02-280  0   00


and so on all the way up to 

, , count = 56

status
delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   00
  2008-02-220  0   00
  2008-02-230  0   00
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   10
  2008-02-280  0   10
 


What I actually want is for my counts to be properly tabulated in one single
table that looks something like this.


delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-212  5   915

and so on... 


Any ideas what I am doing wrong? 

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Getting-multiple-tables-when-using-table%28dataframe%29-to-tabulate-data-tp15750098p15750098.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] write.csv +RMySQL request

2008-02-28 Thread jim holtman
?capture.output

myoutput - capture.output(write.csv(...))

On Thu, Feb 28, 2008 at 7:34 PM, Tristan Casey [EMAIL PROTECTED] wrote:
 Hello,

 I am relatively new to R and learning its ins and outs. As part of a website 
 I am building, I need to read and write csv files directly from an SQL 
 database. Basically I want to convert R variables (dataframes) into CSV 
 format, store them as another R variable (as a properly formatted text string 
 suitable for csv reading) and then send this to one row in a database.

 The SQL part is fine, the problem arises because I cannot capture the output 
 of write.csv! It posts to the terminal when file= is used, however I also 
 want to store it. Does anyone have any ideas?

 Thanks in advance!



 _


 e%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641_t=762955845_r=tig_OCT07_m=EXT
[[alternative HTML version deleted]]

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


Re: [R] [R-SIG-Finance] EMM: how to make forecast using EMM methods?

2008-02-28 Thread Michael
Hi Guy,

Thanks for your help! Yes, we have the coefficient estimated using
EMM. And we followed those papers.

Just want to check my understanding about your suggestion:

Do you mean that after we obtain the estimated coefficients,

we run one simulation to obtain the whole sequence of latent variable
(the volatility time series, from time 0 to time t+1),

where time t is today, and t+1 is tomorrow(one step forecast);

And that's one simulation.

And we run such simulation for N times, let's say N=1,

and obtain 1 such volatility time series, each ending at time t+1,

and then we take average of the 1 data points at t+1,

the average will be the mean-forecast of the volatility tomorrow(i.e.
that's the one step forecast that we want)...

Am I right in doing these procedures?

Thanks



On Thu, Feb 28, 2008 at 4:30 PM, Guy Yollin
[EMAIL PROTECTED] wrote:
 Michael,

  If I understand correctly, you've used some EMM algorithms to estimate
  the parameters of a stochastic volatility model.

  If this is the case you should now be able to use Monte Carlo methods to
  generate forecasts from your model.

  That is, you will generate random variables (according to the
  specifications of your model), feed them into your model and hence
  simulate your stochastic volatility process.

  Note sure what references you have been using but perhaps these would be
  helpful:

  Gallant, Hsieh and Tauchen (1997). Estimation of stochastic volatility
  models with diagnostics, Journal of Econometrics, 81, 159-192.

  Andersen, T.G. H.-J. Chung, and B.E. Sorensen (1999). Efficient Method
  of Moments Estimation of a Stochastic Volatility Model: A Monte Carlo
  Study, Journal of Econometrics, 91, 61-87.

  Best,

  -- G




  -Original Message-
  From: [EMAIL PROTECTED]

 [mailto:[EMAIL PROTECTED] On Behalf Of Michael
  Sent: Thursday, February 28, 2008 12:56 PM
  To: [EMAIL PROTECTED]; r-help


 Subject: [R-SIG-Finance] EMM: how to make forecast using EMM methods?

  Hi all,

  We followed some books and sample codes and did some EMM estimation,
  only to find it won't be able to generate forecast.

  This is because in the stochastic volatility models we are estimating,
  the volatilities are latent variables, and we want to forecast 1-step
  ahead or h-step ahead volatilities.

  So it is nice to have the system estimated, but we couldn't get it to
  forecast at all.

  There is a Reprojection Method described in the original EMM paper,
  but let's say we reproject to a GARCH(1,1) model, then only the
  GARCH(1, 1) parameters are significant, which basically means we
  degrade the SV model into a GARCH model. There is no way to do the
  forecast...

  Could anybody give some pointers?

  Thanks!



 ___
  [EMAIL PROTECTED] mailing list
  https://stat.ethz.ch/mailman/listinfo/r-sig-finance
  -- Subscriber-posting only.
  -- If you want to post, subscribe first.


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


Re: [R] Getting multiple tables when using table(dataframe) to tabulate data

2008-02-28 Thread jim holtman
Is this what you want?

 tapply(x$count, list(x$delta_ts, x$status), sum)
   ASSIGNED CLOSED NEW RESOLVED
2008-02-212 NA   20
2008-02-220  0   61
2008-02-232  1  120
2008-02-247  4  162
2008-02-252  6  225
2008-02-266  8  383
2008-02-27   NA  3  565
2008-02-28   NA  3  565


On Thu, Feb 28, 2008 at 8:22 PM, obradoa [EMAIL PROTECTED] wrote:

 I am having hard time tabulating data in a dataframe, and getting a single
 table for an answer. I am trying to tabulate all counts for given
 status on a given date.


 I have a data frame such as:


 delta_ts   status count
 1  2008-02-27   CLOSED 3
 2  2008-02-27  NEW56
 3  2008-02-27 RESOLVED 5
 4  2008-02-21 ASSIGNED 1
 5  2008-02-21 ASSIGNED 1
 6  2008-02-21  NEW 2
 7  2008-02-21 RESOLVED 0
 8  2008-02-22 ASSIGNED 0
 9  2008-02-22   CLOSED 0
 10 2008-02-22  NEW 6
 11 2008-02-22 RESOLVED 1
 12 2008-02-23 ASSIGNED 2
 13 2008-02-23   CLOSED 1
 14 2008-02-23  NEW12
 15 2008-02-23 RESOLVED 0
 16 2008-02-24 ASSIGNED 7
 17 2008-02-24   CLOSED 4
 18 2008-02-24  NEW16
 19 2008-02-24 RESOLVED 2
 20 2008-02-25 ASSIGNED 2
 21 2008-02-25   CLOSED 6
 22 2008-02-25  NEW22
 23 2008-02-25 RESOLVED 5
 24 2008-02-26 ASSIGNED 6
 25 2008-02-26   CLOSED 8
 26 2008-02-26  NEW38
 27 2008-02-26 RESOLVED 3
 28 2008-02-28   CLOSED 3
 29 2008-02-28  NEW56
 30 2008-02-28 RESOLVED 5


 When I do table on that frame I get a long list that looks like this:


  table(data)
 , , count = 0

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   01
  2008-02-221  1   00
  2008-02-230  0   01
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   00
  2008-02-280  0   00


 and so on all the way up to

 , , count = 56

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   00
  2008-02-220  0   00
  2008-02-230  0   00
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   10
  2008-02-280  0   10



 What I actually want is for my counts to be properly tabulated in one single
 table that looks something like this.


 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-212  5   915

 and so on...


 Any ideas what I am doing wrong?

 Thanks!
 --
 View this message in context: 
 http://www.nabble.com/Getting-multiple-tables-when-using-table%28dataframe%29-to-tabulate-data-tp15750098p15750098.html
 Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


Re: [R] Large loops hang?

2008-02-28 Thread jim holtman
If you really want to do a loop, then preallocate your storage.  You
were dynamically allocating each time through (or there abouts):

 system.time({
+ res - numeric(10)
+ for (i in 1:10) {
+x - rnorm(2)
+res[i] - x[2] - x[1]
+}
+ })
   user  system elapsed
   2.750.023.10

On Thu, Feb 28, 2008 at 3:30 PM, Minimax [EMAIL PROTECTED] wrote:
 Dear useRs,

 Suppose we have loop:

 res - c()
 for (i in 1:10) {
x - rnorm(2)
res - c(res,x[2]-x[1])
}

 and this loop for 10^5 cases runs about - for example 5 minutes.

 When I add one zero (10^6) this loop will not end overnight but probably
 hangs. This occurs regardless of calculated statistics in such
 simulation, always above 10^5 times. Nested loops do not help.

 Any suggestions for collecting larger amount of Monte Carlo data ?

 Regards

 Minimax

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


Re: [R] Getting multiple tables when using table(dataframe) to tabulate data

2008-02-28 Thread Gabor Grothendieck
Try this:

xtabs(count ~., data)

Also look at ?ftable, ?prop.table, ?reshape and the reshape package.

On Thu, Feb 28, 2008 at 8:22 PM, obradoa [EMAIL PROTECTED] wrote:

 I am having hard time tabulating data in a dataframe, and getting a single
 table for an answer. I am trying to tabulate all counts for given
 status on a given date.


 I have a data frame such as:


 delta_ts   status count
 1  2008-02-27   CLOSED 3
 2  2008-02-27  NEW56
 3  2008-02-27 RESOLVED 5
 4  2008-02-21 ASSIGNED 1
 5  2008-02-21 ASSIGNED 1
 6  2008-02-21  NEW 2
 7  2008-02-21 RESOLVED 0
 8  2008-02-22 ASSIGNED 0
 9  2008-02-22   CLOSED 0
 10 2008-02-22  NEW 6
 11 2008-02-22 RESOLVED 1
 12 2008-02-23 ASSIGNED 2
 13 2008-02-23   CLOSED 1
 14 2008-02-23  NEW12
 15 2008-02-23 RESOLVED 0
 16 2008-02-24 ASSIGNED 7
 17 2008-02-24   CLOSED 4
 18 2008-02-24  NEW16
 19 2008-02-24 RESOLVED 2
 20 2008-02-25 ASSIGNED 2
 21 2008-02-25   CLOSED 6
 22 2008-02-25  NEW22
 23 2008-02-25 RESOLVED 5
 24 2008-02-26 ASSIGNED 6
 25 2008-02-26   CLOSED 8
 26 2008-02-26  NEW38
 27 2008-02-26 RESOLVED 3
 28 2008-02-28   CLOSED 3
 29 2008-02-28  NEW56
 30 2008-02-28 RESOLVED 5


 When I do table on that frame I get a long list that looks like this:


  table(data)
 , , count = 0

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   01
  2008-02-221  1   00
  2008-02-230  0   01
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   00
  2008-02-280  0   00


 and so on all the way up to

 , , count = 56

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   00
  2008-02-220  0   00
  2008-02-230  0   00
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   10
  2008-02-280  0   10



 What I actually want is for my counts to be properly tabulated in one single
 table that looks something like this.


 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-212  5   915

 and so on...


 Any ideas what I am doing wrong?

 Thanks!
 --
 View this message in context: 
 http://www.nabble.com/Getting-multiple-tables-when-using-table%28dataframe%29-to-tabulate-data-tp15750098p15750098.html
 Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


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


[R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
I used ?image function to do that, like below :

require(grDevices) # for colours
x - y - seq(-4*pi, 4*pi, len=27)
r - sqrt(outer(x^2, y^2, +))
image(x, y, r, col=gray((0:32)/32))

However my next problem to add a color pallet for color description [as shown 
in following link]. If anyone here tell me how to do that, it will be good for 
me.

Regards,




Megh Dal [EMAIL PROTECTED] wrote:  Hi all,

Can anyone here please tell me whether is it possible to produce a chart 
displayed in http://www.datawolf.blogspot.com/ in R for visualizing 
multivariate time series? If possible how?


Regards,


-



-


   
-

[[alternative HTML version deleted]]

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


Re: [R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread jim holtman
Try something like this:

require(grDevices) # for colours
x - y - seq(-4*pi, 4*pi, len=27)
r - sqrt(outer(x^2, y^2, +))
image(x, y, r, col=gray((0:32)/32))
colors - colorRampPalette(c('red', 'yellow', 'blue'))  # create you
color spectrum
image(x,y,r, col=colors(100))


On Thu, Feb 28, 2008 at 9:28 PM, Megh Dal [EMAIL PROTECTED] wrote:
 I used ?image function to do that, like below :

 require(grDevices) # for colours
 x - y - seq(-4*pi, 4*pi, len=27)
 r - sqrt(outer(x^2, y^2, +))
 image(x, y, r, col=gray((0:32)/32))

 However my next problem to add a color pallet for color description [as shown 
 in following link]. If anyone here tell me how to do that, it will be good 
 for me.

 Regards,




 Megh Dal [EMAIL PROTECTED] wrote:  Hi all,

 Can anyone here please tell me whether is it possible to produce a chart 
 displayed in http://www.datawolf.blogspot.com/ in R for visualizing 
 multivariate time series? If possible how?


 Regards,


 -



 -



 -

[[alternative HTML version deleted]]

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do it.

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


[R] Two Way ANOVA

2008-02-28 Thread Keith Jones
Hi,

I am using the:

pcf.aov-aov(meas~op+part, data=pcf.ex2),

command to perform a two way ANOVA.  When I save the:

sumpcf- summary.aov(pcf.aov),

result of the summary.aov command in a variable I need to access the 
individual pieces of information in the summary.  The summary appears 
to be a list and I am having a hard time finding a way to get at the 
information in the summary.  Could some one tell me how to go about 
it.

Thanks,

Keith Jones

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


Re: [R] Hmisc xYplot won't do conditioning on factors?

2008-02-28 Thread Ivan Adzhubey
Hi,

Since nobody replied, I'd rather post this self-reply for the sake of 
documenting the solution.

It appears that xYplot, unlike standard xyplot (or coplot to that matter) 
does not accept factors as x variable in formula. With x converted to numeric 
everything worked as expected. This small discrepancy was not documented on 
xYplot help page.

--Ivan


On Tuesday 26 February 2008 07:47:14 pm Ivan Adzhubey wrote:
 Hi,

 I am trying to replace (lattice) standard xyplot with xYplot variant from
 Hmisc package to be able to add error bars to my plots. However, this does
 not work, e.g:

 library(lattice)
 d - data.frame(
   SKU=gl(3, 1, 21, labels=c(a, b, c)),
   Weekday=gl(7, 3, 21),
   QCRate=runif(21))

 xyplot(QCRate ~ Weekday | SKU, data=d)

 (this plots nice 3 panels as per a,b,c conditionals)

 library(Hmisc)

  xYplot(QCRate ~ Weekday | SKU, data=d)

 Error in Summary.factor(1:7, na.rm = TRUE) :
   range not meaningful for factors

 Is there a workaround?

 Thanks,
 Ivan

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


Re: [R] Two Way ANOVA

2008-02-28 Thread Peter Alspach
Keith

Try names(sumpcf) or str(sumpcf).  That should help you find what you
want.

Incidentally, simply summary(pcf.aov) will do - R uses the appropriate
method based on the type of object.

HTH 

Peter Alspach


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Keith Jones
 Sent: Friday, 29 February 2008 3:46 p.m.
 To: r-help@r-project.org
 Subject: [R] Two Way ANOVA
 
 Hi,
 
 I am using the:
 
 pcf.aov-aov(meas~op+part, data=pcf.ex2),
 
 command to perform a two way ANOVA.  When I save the:
 
 sumpcf- summary.aov(pcf.aov),
 
 result of the summary.aov command in a variable I need to 
 access the individual pieces of information in the summary.  
 The summary appears to be a list and I am having a hard time 
 finding a way to get at the information in the summary.  
 Could some one tell me how to go about it.
 
 Thanks,
 
 Keith Jones
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

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


Re: [R] Plot Principal component analysis

2008-02-28 Thread SNN

Thanks for your help.
I downloaded the scatterplot3d package.

 plot3d(pr$x, col = c(red, blue)[c(rep(1, 100), rep(2, 15))], pch=20)
where pr$x is the object of the PCA. this works but the graph does not look
good.

the other option that I tried is 

scatterplot3d(pr$x, type=p, highlight.3d=T, pch=16) where the graph looks
much nicer but i do not know how to have each group with a different color.

Does anyone know how to do it?



SNN wrote:
 
 Hi,
 
 I have matrix of 300,000*115 (snps*individual). I ran the PCA on the
 covariance matrix which has a dimention oof 115*115. I have the first 100
 individuals from group A and the rest of 15 individuals from group B. I
 need to plot the data in two and 3 dimentions with respect to PC1 and PC2
 and (in 3D with respect to PC1, PC2 and PC3). I do not know how to have
 the plot ploting the first 100 points corresponding to group A in red (for
 example) and the rest of the 15 points in Blue? i.e I want the each group
 in a diffrent color in the same plot. I appreciate if someone can help.
 
 Thanks,
 

-- 
View this message in context: 
http://www.nabble.com/Plot-Principal-component-analysis-tp15700123p15751493.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] quantile-residual plot

2008-02-28 Thread Roslina Zakaria
Hi,
What is quantile residuals?
Thank you so much in advance.


  

Be a better friend, newshound, and

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


Re: [R] quantile-residual plot

2008-02-28 Thread Peter Dunn
 What is quantile residuals?
See

Dunn, Peter K. and Smyth, Gordon K. (1996). Randomized Quantile 
Residuals. Journal of Computational and Graphical Statistics, 
volume 5, issue 3, 236–244.

Or see ?qresid in R package  statmod.

P.

-- 
Dr Peter Dunn  |  dunn at usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

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


Re: [R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
Hi Jim, i think you could not get my point. I did not want to put red-blue 
color there. I want to put a pallet which will describe the values of r. please 
have a look on following : 
http://bp0.blogger.com/_k3l6qPzizGs/RvDVglPknRI/AKo/itlWOvuuOtI/s1600-h/pairwise_kl_window60.png.
 Please see how a color pallate is added on the right side of this plot 
describing the value of red color, value of blue color etc.
   
  Is there any solution?
   
  Regards,

jim holtman [EMAIL PROTECTED] wrote:
  Try something like this:

require(grDevices) # for colours
x - y - seq(-4*pi, 4*pi, len=27)
r - sqrt(outer(x^2, y^2, +))
image(x, y, r, col=gray((0:32)/32))
colors - colorRampPalette(c('red', 'yellow', 'blue')) # create you
color spectrum
image(x,y,r, col=colors(100))


On Thu, Feb 28, 2008 at 9:28 PM, Megh Dal wrote:
 I used ?image function to do that, like below :

 require(grDevices) # for colours
 x - y - seq(-4*pi, 4*pi, len=27)
 r - sqrt(outer(x^2, y^2, +))
 image(x, y, r, col=gray((0:32)/32))

 However my next problem to add a color pallet for color description [as shown 
 in following link]. If anyone here tell me how to do that, it will be good 
 for me.

 Regards,




 Megh Dal wrote: Hi all,

 Can anyone here please tell me whether is it possible to produce a chart 
 displayed in http://www.datawolf.blogspot.com/ in R for visualizing 
 multivariate time series? If possible how?


 Regards,


 -



 -



 -

 [[alternative HTML version deleted]]

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve? Tell me what you want to
do, not how you want to do it.


   
-

[[alternative HTML version deleted]]

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


Re: [R] write.csv +RMySQL request

2008-02-28 Thread Prof Brian Ripley
On Thu, 28 Feb 2008, jim holtman wrote:

 ?capture.output

 myoutput - capture.output(write.csv(...))

It would be better to write directly to a text connection: see the 'file' 
argument to write.csv.

 On Thu, Feb 28, 2008 at 7:34 PM, Tristan Casey [EMAIL PROTECTED] wrote:
 Hello,

 I am relatively new to R and learning its ins and outs. As part of a website 
 I am building, I need to read and write csv files directly from an SQL 
 database. Basically I want to convert R variables (dataframes) into CSV 
 format, store them as another R variable (as a properly formatted text 
 string suitable for csv reading) and then send this to one row in a database.

 The SQL part is fine, the problem arises because I cannot capture the output 
 of write.csv! It posts to the terminal when file= is used, however I also 
 want to store it. Does anyone have any ideas?

 Thanks in advance!

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

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


Re: [R] p-value in Spearman rank order

2008-02-28 Thread Daniel Malter
Has your question been answered yet?

x=c(1,2,4,3,6,8)
y=c(3,2,5,7,4,6)

cor.test(x,y,method=spearman)

And that's how you extract the p-value:

cor.test(x,y,method=s)$p.value

Cheers,
Daniel


--
Abstrakthelfer helfen wenig
--

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von Anne-Katrin Link
Gesendet: Thursday, February 28, 2008 10:17 AM
An: r-help@r-project.org
Betreff: [R] p-value in Spearman rank order

Dear R-helpers,

I would like to do a Spearman rank order test, and used the cor() function
with the method spearman. 
It gives me a number (correlation coefficient?) , but how can I get the
p-value?
Thank you for the help in advance!

Regards,
Anne-Katrin

-- 



[[alternative HTML version deleted]]

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

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


[R] How to export tables in list separately using write.table or sink?

2008-02-28 Thread Lauri Nikkinen
R users,

My intention is to take factors out of DF, create list of tables and
export these tables separately using write.table or sink function.
write.table writes tables out as DF:s, should I use sink instead?

Here is my example:

a - data.frame(indx =1:20,
var1 =rep(c(I20, I40, A50, B60), each=5),
var1_lab= rep(c(cat, dog, mouse, horse), each=5),
var2 =rep(c(B20, X40, D50, G60), each=5),
var2_lab= rep(c(car, bicycle, train, bus), each=5))

g - unlist(lapply(a, is.factor))
g - a[g]
g.tablist - lapply(g, function(x) table(x, g$var1))

for (i in g.tablist) write.table(i , paste(Sys.Date(), i, sep=))

Warning messages:
1: In if (file == ) file - stdout() else if (is.character(file)) { :
  the condition has length  1 and only the first element will be used
2: In file(file, ifelse(append, a, w)) :

or using lapply

lapply(g.tablist, function(i) write.table(i , paste(Sys.Date(), i, sep=)))
$var1
NULL

$var1_lab
NULL

$var2
NULL

$var2_lab
NULL

Warning messages:
1: In if (file == ) file - stdout() else if (is.character(file)) { :
  the condition has length  1 and only the first element will be used
2: In file(file, ifelse(append, a, w)) :

#or
for (i in g.tablist) { sink(paste(i, .txt., sep=))
   sink()}

Warning messages:
1: In file(file, ifelse(append, a, w)) :
  only first element of 'description' argument used
2: In file(file, ifelse(append, a, w)) :
  only first element of 'description' argument used
3: In file(file, ifelse(append, a, w)) :
  only first element of 'description' argument used
4: In file(file, ifelse(append, a, w)) :
  only first element of 'description' argument used

Thanks,
Lauri

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


[R] How to convert the user coordinate system in R graph to normal coordinate system whose origin is the upper-left cornner of the drawing area?

2008-02-28 Thread Guohui Ding
Dear friends,

  The user coordiante system in the R graphics is easy to understand as
it simply corresponds to the range of values on the axes of the plot.
However, sometimes, we want to kown the coordinates of a region in other
system, e.g., the normal coordinate system whose origin is the the
upper-left cornner of the drawing area which is used to set the hot regions
in the HTML image maps. Is there any suggestion?

 For example, I execute the code,

 png(x.png,  width = 480, height = 480,
+ pointsize = 12, bg = white, res = 100);
 plot(0, xlim=c(0, 100), ylim = c(0,100), type=n)
 rect(0, 0, 100, 100)
 points(0, 0, col = 'red')
 dev.off()

I will get a figure named x.png. The resolution of this figure is 100 dpi
and the width and height are 480 pixels when I opened it with Photoshop.
When I move the cursor to the point drawed by points(0, 0, col = 'red'), I
can find the position of this point is about (87, 376) [(x, y)]. I want to
know how to convert the (0, 0) in the user coordinate system to this value?

I look forward to hearing from you.

-- 
ADDRESS: Bioinformatics Center, Shanghai Institutes for Biological Sciences,
Chinese Academy of Sciences
320 Yueyang Road, Shanghai 200031, P.R.China
TELEPHONE: 86-21-54920086

[[alternative HTML version deleted]]

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