Re: [R] Help on Multiple Structural break unit root test

2010-06-07 Thread Matthieu Stigler

Dear Eric

This test is unfortunately AFAIK not implemented in R. You can 
nevertheless use the similar Zivot and Andrews test in package urca.

library(urca)
?ur.za

Best

Matthieu

Le 06. 06. 10 12:00, r-help-requ...@r-project.org a écrit :

Message: 24
Date: Sat, 5 Jun 2010 15:45:29 +0100
From: ERIC AIDOO
To:r-help@r-project.org
Subject: [R] Help on Multiple Structural break unit root test
Message-ID:

Content-Type: text/plain

Help.
Please am search for R package that will enable me to
perform Lumsdain and Papell unit root test with multiple structural break or
minimum LM unit root test with multiple structural break

thank you



__
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] barchart but with boxes

2010-06-07 Thread Deepayan Sarkar
On Sun, Jun 6, 2010 at 11:53 PM, Daisy Englert Duursma
 wrote:
> Hello r-help.
>
> I have been working on making a graph and have several solutions but
> they are tedious at best.
>
> Here is an example dataset:
>
> catg<-(c(1,2,3,2,4,3,2,1,4,3,1))
> min<-(c(1,2,3,3,4,5,6,6,3,2,1))
> max <-(c(10,6,8,6,7,3,10,9,10,8,9))
> cbind(min,max,catg)
>
> What I want to create is a basically a bar chart,  but I define the
> min (min) and max (max) for the bars.
> These bars are separated into three categories (catg). Within each
> category the bars are allowed to overlap. I set the bars to have a
> transparent color so that I can see agreement of the  items within a
> category based on the darkness of color.
>
> One method I came up with, is to use ggplot2 and geom_tile but then I
> have to give x,y coordinates for every corner of every box.
> Considering the size of my real datasets, and not this little example
> dataset, this seems annoying.
>
> I could even just graph lines with the defined min and max. With that
> I could make the lines thick and achieve the effect I am looking for.
>
> Hopefully I have missed an obvious method to graph this.

One option to look at is segplot() in the latticeExtra package.

-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] Computing day-over-day log return for a matrix containing multiple time series

2010-06-07 Thread Patrick Burns

Actually the 'apply' is not necessary.

The original poster has stocks as rows
rather than the customary columns, so
the following should suffice:

retmat <- diff(log(t(pricemat)))

Questions that are specifically financial
should be sent to r-sig-finance (you need
to subscribe before posting).

On 07/06/2010 07:12, sayan dasgupta wrote:

Hope this helps

a<- matrix(runif(150),nrow=3,ncol=50)
p2r<- function(x) 100 * diff(log(x))
  t(apply(a,1,function(x){p2r(c(x))}))




On Mon, Jun 7, 2010 at 8:41 AM, Anyi Zhu  wrote:


Hi all,



Thanks a lot for anyone's help in advance.



I am trying to find a way to compute the day-to-day return (log return)
from
a n x r matrix containing, n different stocks and price quotes over r days.
The time series of prices are already split by using unstack function.






For the result, I would like to see a n x (r-1) matrix, where by each entry
is the day-over-day return of each stock.



I tried to look into the zoo package, however it seems to give only the


plots but not the actual data.



take a look at
vignette("zoo-quickref",package="zoo")
It gives an exact solution to your problem







Would apply function work in this case?



Thanks a lot!


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



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



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

__
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] average two sets of columns

2010-06-07 Thread Yuan Jian
Hi R experts.

how can I average two sets of columns?

dd <- data.frame(b = c("chr2", "chr1", "chrY", "chr13", "chrX"),  
  w=11:15, x = 1:5, y = c(8, 3, 9, 9,7), 
   z = c(1, 1, 1, 2, 8))
expected result for mean(w,x) and mean(y,z) is
1  chr2 6  4.5
2  chr1 7  2
3  chrY 8  5
4 chr13 9  5.5
5  chrX 10 7.5

Yu




  
[[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] Subsetting subsets of data.frames

2010-06-07 Thread Jeff08

Hey Everyone,

I have been stumped by this all day.

Basically, I have a data.frame of multiple columns. Of concern are "id" &
"date"

For some reason, oftentimes there are duplicates of data with the same date.

I would like to remove the duplicates per different id (removing duplicate
dates for the entire data.frame would leave nothing since different id's all
have the same dates)

subset(x,!duplicated(x$date_)) works for just one ID, but i am having
trouble figuring out how to apply this to each subset of IDs (and retaining
the original data.frame structure) 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Subsetting-subsets-of-data-frames-tp2245556p2245556.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] ols function in rms package

2010-06-07 Thread Mark Seeto
Hello,

I have a couple of questions about the ols function in Frank Harrell's rms
package.

Is there any way to specify variables by their column number in the data
frame rather than by the variable name?

For example,

library(rms)
x1 <- rnorm(100, 0, 1)
x2 <- rnorm(100, 0, 1)
x3 <- rnorm(100, 0, 1)
y <- x2 + x3 + rnorm(100, 0, 5)
d <- data.frame(x1, x2, x3, y)
rm(x1, x2, x3, y)
lm(y ~ d[,2] + d[,3], data = d)  # This works
ols(y ~ d[,2] + d[,3], data = d) # Gives error
Error in if (!length(fname) || !any(fname == zname)) { :
  missing value where TRUE/FALSE needed

However, this works:
ols(y ~ x2 + d[,3], data = d)

The reason I want to do this is to program variable selection for
bootstrap model validation.

A related question: does ols allow "y ~ ." notation?

lm(y ~ ., data = d[, 2:4])  # This works
ols(y ~ ., data = d[, 2:4]) # Gives error
Error in terms.formula(formula) : '.' in formula and no 'data' argument

Thanks for any help you can give.

Regards,
Mark
-- 
Mark Seeto
Statistician

National Acoustic Laboratories 
A Division of Australian Hearing

126 Greville Street
Chatswood NSW 2067 Australia
P +61 2 9412 6800
F +61 2 9411 8273

__
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] paste together a string object later to be utilized in a function

2010-06-07 Thread moleps islon
I'm sorry for not clearer describing my motive with this--

So this is what I'm trying to do- Take a survival object and utilize
it in ggplot.

ggkm<-function(time,event,stratum) {


m2s<-Surv(time,as.numeric(event))

fit <- survfit(m2s ~ stratum)

f$time<-fit$time

f$surv<-fit$surv


f$strata<-c(rep(names(fit$strata[1]),fit$strata[1]),rep(names(fit$strata[2]),fit$strata[2]))

f$upper<-fit$upper
f$lower<-fit$lower

r<-ggplot 
(f,aes(x=time,y=surv,fill=strata,group=strata))+geom_line()+geom_ribbon(aes(ymin=lower,ymax=upper),alpha=0.3)
return(r)
}


My problem is that I can have more than two strata, and I would like
the function to automatically detect the number of strata. Hence a
quick hack as to how I can create f$strata when I dont know the number
of strata would be appreciated.


The 
paste("rep(names(fit$strata[",1:length(fit$strata),"]),fit$strata[",1:length(fit$strata),"])",sep="")
is as close as I get. However this results in multiple strings and I
havent discovered yet how I can pass this so f$strata is created. This
could easily be done in stata appending to a macro, but as I am a
recent convertee I dont know how  to do this in R. (yet...?)


Regards,

//M

On Mon, Jun 7, 2010 at 2:50 AM, Joris Meys  wrote:
> Wild guess, but it looks like you are looking at :
>
>> ts <- list(a=1:5)
>> names(ts$a) <- letters[1:5]
>> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
>>
>> sapply(v,function(x){eval(parse(,text=x))})
> $`rep(names(ts$a[1]),ts$a[1])`
> [1] "a"
>
> $`rep(names(ts$a[2]),ts$a[2])`
> [1] "b" "b"
>
> $`rep(names(ts$a[3]),ts$a[3])`
> [1] "c" "c" "c"
>
> $`rep(names(ts$a[4]),ts$a[4])`
> [1] "d" "d" "d" "d"
>
> $`rep(names(ts$a[5]),ts$a[5])`
> [1] "e" "e" "e" "e" "e"
>
>> assign("test",eval(parse(text=v[3])))
>> test
> [1] "c" "c" "c"
>>
>
> Cheers
> Joris
>
> On Sun, Jun 6, 2010 at 9:51 PM, moleps  wrote:
>> Dear r-listers,
>>
>> I need to pass a string to a function. However the length of the string is 
>> dependent on the length of a vector.
>>
>>
>> b<-length(h)
>> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
>>
>>
>> Is it possible somehow to pass this as an argument to a function later on ?
>>
>>
>>
>> Regards,
>>
>> //M
>>
>> __
>> 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.
>>
>
>
>
> --
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>

__
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] average two sets of columns

2010-06-07 Thread Dennis Murphy
Hi:

Using the plyr package,

summarise(dd, b = b, wx = (w + x)/2, yz = (y + z)/2)
  b wx  yz
1  chr2  6 4.5
2  chr1  7 2.0
3  chrY  8 5.0
4 chr13  9 5.5
5  chrX 10 7.5

HTH,
Dennis

On Sun, Jun 6, 2010 at 9:53 PM, Yuan Jian  wrote:

> Hi R experts.
>
> how can I average two sets of columns?
>
> dd <- data.frame(b = c("chr2", "chr1", "chrY", "chr13", "chrX"),
>   w=11:15, x = 1:5, y = c(8, 3, 9, 9,7),
>z = c(1, 1, 1, 2, 8))
> expected result for mean(w,x) and mean(y,z) is
> 1  chr2 6  4.5
> 2  chr1 7  2
> 3  chrY 8  5
> 4 chr13 9  5.5
> 5  chrX 10 7.5
>
> Yu
>
>
>
>
>
>[[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.
>
>

[[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] Computing day-over-day log return for a matrix containing multiple time series

2010-06-07 Thread Gabor Grothendieck
You can use diff.zoo like this:

library(zoo)
z <- zoo(matrix(1:24, 6))
z
diff(log(z))

# also try
diff(z, arith = FALSE)  - 1

See ?diff.zoo
and read the three zoo vignettes (pdf documents):
vignette(package = "zoo") # lists them
vignette("zoo")
etc.


On Sun, Jun 6, 2010 at 11:11 PM, Anyi Zhu  wrote:
> Hi all,
>
>
>
> Thanks a lot for anyone's help in advance.
>
>
>
> I am trying to find a way to compute the day-to-day return (log return) from
> a n x r matrix containing, n different stocks and price quotes over r days.
> The time series of prices are already split by using unstack function.
>
>
>
> For the result, I would like to see a n x (r-1) matrix, where by each entry
> is the day-over-day return of each stock.
>
>
>
> I tried to look into the zoo package, however it seems to give only the
> plots but not the actual data.
>
>
>
> Would apply function work in this case?
>
>
>
> Thanks a lot!
>
>
>        [[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] Loading an image/picture (png/jpeg/...) to screen...

2010-06-07 Thread Oliver
Joris Meys  gmail.com> writes:

> 
> There might be a way doing that in R, but if you really need to take
> measures of a picture in some standardized way, I suggest you take a
> look at ImageJ. More than R that seems the right tool for the job.
> Some people have been experimenting with connecting ImageJ and R, but
> even without connection a simple text file can get the data where it
> has to be.
[...]

OK, maybe that helps; I just tried around...

...first want to try a pure R-way.

But this might be a fallback.

Thanks.
   Oliver

__
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 an image/picture (png/jpeg/...) to screen...

2010-06-07 Thread Gregoire Pau
The package EBImage provides general purpose functionality for the 
reading, writing, analysis and displaying of images.


> library(EBImage)
> x = readImage('lena.gif')
> display(x)

ImageJ is OK to carry out some image processing operations. But if you 
need to perform quantitative image analysis or model/analyse images with 
statistical models, then R + EBImage is a simple and powerful alternative.


Images are just matrices.

Kind regards,

Greg
---
Gregoire Pau
EMBL Research Officer
http://www.embl.de/~gpau/


Oliver wrote:

baptiste auguie  googlemail.com> writes:


Hi,

Try this,

library(png)
example(readPNG)

[...]


If "rasterImage" would be available, I think this would be the right hint.

But it isn't.

So I can load the pic, but not display it. :(


Ciao,
  Oliver

__
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] Subsetting subsets of data.frames

2010-06-07 Thread Uwe Ligges

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Uwe Ligges

On 07.06.2010 09:01, Jeff08 wrote:


Hey Everyone,

I have been stumped by this all day.

Basically, I have a data.frame of multiple columns. Of concern are "id"&
"date"

For some reason, oftentimes there are duplicates of data with the same date.

I would like to remove the duplicates per different id (removing duplicate
dates for the entire data.frame would leave nothing since different id's all
have the same dates)

subset(x,!duplicated(x$date_)) works for just one ID, but i am having
trouble figuring out how to apply this to each subset of IDs (and retaining
the original data.frame structure)


__
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] paste together a string object later to be utilized in a function

2010-06-07 Thread Joris Meys
It helps if you provide sample data, so we can try some things out
ourselves. Right now, I can't run your function without guessing how
your data might look like.

Yet, try something like this :
> ts <- list(a=1:5)

> names(ts$a) <- letters[1:5]

> n <- length(names(ts$a))

> tmp <- sapply(1:n,function(i){rep(names(ts$a[i]),ts$a[i])})

> strata <- unlist(tmp)
> strata
 [1] "a" "b" "b" "c" "c" "c" "d" "d" "d" "d" "e" "e" "e" "e" "e"

Cheers
Joris



On Mon, Jun 7, 2010 at 10:26 AM, moleps islon  wrote:
> I'm sorry for not clearer describing my motive with this--
>
> So this is what I'm trying to do- Take a survival object and utilize
> it in ggplot.
>
> ggkm<-function(time,event,stratum) {
>
>
>    m2s<-Surv(time,as.numeric(event))
>
>    fit <- survfit(m2s ~ stratum)
>
>    f$time<-fit$time
>
>    f$surv<-fit$surv
>
>    
> f$strata<-c(rep(names(fit$strata[1]),fit$strata[1]),rep(names(fit$strata[2]),fit$strata[2]))
>
>    f$upper<-fit$upper
>    f$lower<-fit$lower
>
>    r<-ggplot 
> (f,aes(x=time,y=surv,fill=strata,group=strata))+geom_line()+geom_ribbon(aes(ymin=lower,ymax=upper),alpha=0.3)
>    return(r)
> }
>
>
> My problem is that I can have more than two strata, and I would like
> the function to automatically detect the number of strata. Hence a
> quick hack as to how I can create f$strata when I dont know the number
> of strata would be appreciated.
>
>
> The 
> paste("rep(names(fit$strata[",1:length(fit$strata),"]),fit$strata[",1:length(fit$strata),"])",sep="")
> is as close as I get. However this results in multiple strings and I
> havent discovered yet how I can pass this so f$strata is created. This
> could easily be done in stata appending to a macro, but as I am a
> recent convertee I dont know how  to do this in R. (yet...?)
>
>
> Regards,
>
> //M
>
> On Mon, Jun 7, 2010 at 2:50 AM, Joris Meys  wrote:
>> Wild guess, but it looks like you are looking at :
>>
>>> ts <- list(a=1:5)
>>> names(ts$a) <- letters[1:5]
>>> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
>>>
>>> sapply(v,function(x){eval(parse(,text=x))})
>> $`rep(names(ts$a[1]),ts$a[1])`
>> [1] "a"
>>
>> $`rep(names(ts$a[2]),ts$a[2])`
>> [1] "b" "b"
>>
>> $`rep(names(ts$a[3]),ts$a[3])`
>> [1] "c" "c" "c"
>>
>> $`rep(names(ts$a[4]),ts$a[4])`
>> [1] "d" "d" "d" "d"
>>
>> $`rep(names(ts$a[5]),ts$a[5])`
>> [1] "e" "e" "e" "e" "e"
>>
>>> assign("test",eval(parse(text=v[3])))
>>> test
>> [1] "c" "c" "c"
>>>
>>
>> Cheers
>> Joris
>>
>> On Sun, Jun 6, 2010 at 9:51 PM, moleps  wrote:
>>> Dear r-listers,
>>>
>>> I need to pass a string to a function. However the length of the string is 
>>> dependent on the length of a vector.
>>>
>>>
>>> b<-length(h)
>>> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
>>>
>>>
>>> Is it possible somehow to pass this as an argument to a function later on ?
>>>
>>>
>>>
>>> Regards,
>>>
>>> //M
>>>
>>> __
>>> 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.
>>>
>>
>>
>>
>> --
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Applied mathematics, biometrics and process control
>>
>> tel : +32 9 264 59 87
>> joris.m...@ugent.be
>> ---
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] Robust Asymptotic Statistics (RobASt)

2010-06-07 Thread Dr. Matthias Kohl

Dear Alex,

after installation of ROptRegTS there should be a folder "scripts" in 
the package directory of ROptRegTS which includes some further examples.
If you are assuming normal errors you should switch to package RobRex 
which is "optimized" for normal errors. There you will also find a 
folder "scripts" in the package directory.


In general, multivariate regression should work. But, I have to admit 
that we didn't try many multivariate examples so far. Beside that, the 
user interface is still rudimentary at the moment and some ideas which 
will clearly reduce computation time (as in the case of package RobLox) 
are unfortunately not yet implemented.


So, if you are willing to accept these drawbacks I will be glad to give 
you a hand to get our estimators to work for your data.


Best,
Matthias


On 06.06.2010 06:47, Alex Weslowski wrote:

Hi all,

Other than:
http://www.stamats.de/F2006.r

Are there other good simple examples out there of using the ROptRegTS
package (part of the RobASt project)? I'm hoping to plug it in for
multivariate regression. Or is this not a good idea? Just trying to
find out how it compares to rlm, lts, glm, etc. Hopefully this makes
sense, I'm new to the world of statistics and R.

Thanks!

St0x

__
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.
   


--
Dr. Matthias Kohl
www.stamats.de

__
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] prettyR

2010-06-07 Thread Jim Lemon

On 06/07/2010 02:49 AM, Iasonas Lamprianou wrote:

Hi all,
does anyone have any practical examples of how this command can be used in 
prettyR?
add.value.labels(x,value.labels)

I mean, can we have the SPSS style of using numbers and/or labels if we want to?

Thank you for your time


Hi Jason,
The value labels used in prettyR are mainly to help those users who are 
importing SPSS .sav files and want to see the value labels displayed in 
the output of some functions. Thus if you import an SPSS dataset with 
add.value.labels=TRUE, functions like "brkdn" will display those labels.


The add.value.labels function just lets the user add value labels to 
variables that don't have any.


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.


[R] prewhiten

2010-06-07 Thread nuncio m
HI all.,
I have some univariate time series that need to be prewhitened. HOw this can
be performed in R.
I am thinking of to fit an ARIMA model and substract this from the original
series. Is this the correct way
THanks in advance
nuncio

-- 
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804

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

2010-06-07 Thread Iasonas Lamprianou

Thank you, 

I'll have a go and if I have more questions I'll probably come back to you...


Dr. Iasonas Lamprianou


Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539


Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk


--- On Mon, 7/6/10, Jim Lemon  wrote:

> From: Jim Lemon 
> Subject: Re: [R] prettyR
> To: "Iasonas Lamprianou" 
> Cc: r-help@r-project.org
> Date: Monday, 7 June, 2010, 12:01
> On 06/07/2010 02:49 AM, Iasonas
> Lamprianou wrote:
> > Hi all,
> > does anyone have any practical examples of how this
> command can be used in prettyR?
> > add.value.labels(x,value.labels)
> > 
> > I mean, can we have the SPSS style of using numbers
> and/or labels if we want to?
> > 
> > Thank you for your time
> > 
> Hi Jason,
> The value labels used in prettyR are mainly to help those
> users who are importing SPSS .sav files and want to see the
> value labels displayed in the output of some functions. Thus
> if you import an SPSS dataset with add.value.labels=TRUE,
> functions like "brkdn" will display those labels.
> 
> The add.value.labels function just lets the user add value
> labels to variables that don't have any.
> 
> 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] prettyR

2010-06-07 Thread Iasonas Lamprianou
Thank you, 

I'll have a go and if I have more questions I'll probably come back to you...

Dr. Iasonas Lamprianou


Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539


Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk


--- On Mon, 7/6/10, Joris Meys  wrote:

> From: Joris Meys 
> Subject: Re: [R] prettyR
> To: "Iasonas Lamprianou" 
> Cc: r-help@r-project.org
> Date: Monday, 7 June, 2010, 2:05
> Very simple as explained in the help
> files:
> 
> > X <- 1:5
> > X
> [1] 1 2 3 4 5
> 
> > add.value.labels(X,letters[1:5])
> [1] 1 2 3 4 5
> attr(,"value.labels")
> a b c d e
> 1 2 3 4 5
> > X
> [1] 1 2 3 4 5
> 
> X didn't change.
> 
> > X <- add.value.labels(X,letters[1:5])
> > X
> [1] 1 2 3 4 5
> attr(,"value.labels")
> a b c d e
> 1 2 3 4 5
> >
> X changed. Mind you, those value labels are only read by
> functions
> that use it. functions like names(), colnames(), rownames()
> and the
> likes won't use those labels.
> 
> If you really want to use a kind of labels that works in
> almost every
> situation, just use factors.
> 
> Cheers
> Joris
> 
> 
> On Sun, Jun 6, 2010 at 6:49 PM, Iasonas Lamprianou 
> wrote:
> > Hi all,
> > does anyone have any practical examples of how this
> command can be used in prettyR?
> > add.value.labels(x,value.labels)
> >
> > I mean, can we have the SPSS style of using numbers
> and/or labels if we want to?
> >
> > Thank you for your time
> >
> > Jason
> >
> >
> > Dr. Iasonas Lamprianou
> >
> >
> > Assistant Professor (Educational Research and
> Evaluation)
> > Department of Education Sciences
> > European University-Cyprus
> > P.O. Box 22006
> > 1516 Nicosia
> > Cyprus
> > Tel.: +357-22-713178
> > Fax: +357-22-590539
> >
> >
> > Honorary Research Fellow
> > Department of Education
> > The University of Manchester
> > Oxford Road, Manchester M13 9PL, UK
> > Tel. 0044  161 275 3485
> > iasonas.lampria...@manchester.ac.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.
> >
> 
> 
> 
> -- 
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process
> control
> 
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> 




__
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] barchart but with boxes

2010-06-07 Thread Jim Lemon

On 06/07/2010 04:53 PM, Daisy Englert Duursma wrote:

Hello r-help.

I have been working on making a graph and have several solutions but
they are tedious at best.

Here is an example dataset:

catg<-(c(1,2,3,2,4,3,2,1,4,3,1))
min<-(c(1,2,3,3,4,5,6,6,3,2,1))
max<-(c(10,6,8,6,7,3,10,9,10,8,9))
cbind(min,max,catg)

What I want to create is a basically a bar chart,  but I define the
min (min) and max (max) for the bars.
These bars are separated into three categories (catg). Within each
category the bars are allowed to overlap. I set the bars to have a
transparent color so that I can see agreement of the  items within a
category based on the darkness of color.

One method I came up with, is to use ggplot2 and geom_tile but then I
have to give x,y coordinates for every corner of every box.
Considering the size of my real datasets, and not this little example
dataset, this seems annoying.

I could even just graph lines with the defined min and max. With that
I could make the lines thick and achieve the effect I am looking for.


Hi Daisy,
How about this?

offset<-c(-0.1,-0.1,-0.1,0,-0.1,0,0.1,0,0,0.1,0.1)
plot(0,xlim=c(0.5,4.5),ylim=c(0,10),type="n")
segments(catg+offset,min,catg+offset,max,lwd=5,col=3)

You can program a function to calculate the offsets if you want to do 
lots of these.


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] prewhiten

2010-06-07 Thread Achim Zeileis

On Mon, 7 Jun 2010, nuncio m wrote:


HI all.,
I have some univariate time series that need to be prewhitened. HOw this can
be performed in R.


That depends on what exactly you want to do for prewhtening. For example, 
if you want to prewhiten using an AR(1) model, you could apply ar() and 
then extract the residuals:

  ar(x, order.max = 1, aic = FALSE, method = ..., demean = ...)$resid
and set the remaining arguments based on your preferences/needs. This can 
also be used for multivariate series.



I am thinking of to fit an ARIMA model and substract this from the original
series.


Then you could use the residuals from arima()...

Best,
Z


Is this the correct way
THanks in advance
nuncio

--
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804

[[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] barchart but with boxes

2010-06-07 Thread ONKELINX, Thierry
Dear Daisy,

This is easy woth ggplot2. Use geom_crossbar() and set the middle bar at
the minimum of maximum.

library(ggplot2)
dataset <- data.frame(catg = (c(1,2,3,2,4,3,2,1,4,3,1)), 
min = (c(1,2,3,3,4,5,6,6,3,2,1)), 
max = (c(10,6,8,6,7,3,10,9,10,8,9)))
ggplot(dataset, aes(x = catg, y = min, ymin = min, ymax = max)) +
geom_crossbar(fill = "red", alpha = 0.2, fatten = 1)

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
  

> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens Jim Lemon
> Verzonden: maandag 7 juni 2010 13:27
> Aan: Daisy Englert Duursma
> CC: r-help@r-project.org
> Onderwerp: Re: [R] barchart but with boxes
> 
> On 06/07/2010 04:53 PM, Daisy Englert Duursma wrote:
> > Hello r-help.
> >
> > I have been working on making a graph and have several 
> solutions but 
> > they are tedious at best.
> >
> > Here is an example dataset:
> >
> > catg<-(c(1,2,3,2,4,3,2,1,4,3,1))
> > min<-(c(1,2,3,3,4,5,6,6,3,2,1))
> > max<-(c(10,6,8,6,7,3,10,9,10,8,9))
> > cbind(min,max,catg)
> >
> > What I want to create is a basically a bar chart,  but I define the 
> > min (min) and max (max) for the bars.
> > These bars are separated into three categories (catg). Within each 
> > category the bars are allowed to overlap. I set the bars to have a 
> > transparent color so that I can see agreement of the  items 
> within a 
> > category based on the darkness of color.
> >
> > One method I came up with, is to use ggplot2 and geom_tile 
> but then I 
> > have to give x,y coordinates for every corner of every box.
> > Considering the size of my real datasets, and not this 
> little example 
> > dataset, this seems annoying.
> >
> > I could even just graph lines with the defined min and max. 
> With that 
> > I could make the lines thick and achieve the effect I am 
> looking for.
> >
> Hi Daisy,
> How about this?
> 
> offset<-c(-0.1,-0.1,-0.1,0,-0.1,0,0.1,0,0,0.1,0.1)
> plot(0,xlim=c(0.5,4.5),ylim=c(0,10),type="n")
> segments(catg+offset,min,catg+offset,max,lwd=5,col=3)
> 
> You can program a function to calculate the offsets if you 
> want to do lots of these.
> 
> 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.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
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] Greek letters and formatted text

2010-06-07 Thread S Ellison
The ?plotmath page and the example " ## How to combine "math" and numeric 
variables :"  should be helpful...?



>>> Thomas Bschorr  05/06/2010 10:36:42 >>>
Hi,

I desperately try to do s.th. like

m=1.23455
sig=0.84321

plot(1,1)

text(0.8,1,sprintf("=%1.2f±%1.2f",m,sig))

where actually the greek letter should appear for Sigma.
I have tried all sorts of combinations with expression and paste etc. but could 
not work it out. Maybe someone has an idea and can help me.

Thanks a lot+

Thomas

__
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.

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] Computing day-over-day log return for a matrix containing multiple time series

2010-06-07 Thread Anyi Zhu
I did not realise making a zoo object is that convenient. Thanks a lot
Gabor.


-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: June-07-10 5:20 AM
To: anyi@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] Computing day-over-day log return for a matrix containing
multiple time series

You can use diff.zoo like this:

library(zoo)
z <- zoo(matrix(1:24, 6))
z
diff(log(z))

# also try
diff(z, arith = FALSE)  - 1

See ?diff.zoo
and read the three zoo vignettes (pdf documents):
vignette(package = "zoo") # lists them
vignette("zoo")
etc.


On Sun, Jun 6, 2010 at 11:11 PM, Anyi Zhu  wrote:
> Hi all,
>
>
>
> Thanks a lot for anyone's help in advance.
>
>
>
> I am trying to find a way to compute the day-to-day return (log return)
from
> a n x r matrix containing, n different stocks and price quotes over r
days.
> The time series of prices are already split by using unstack function.
>
>
>
> For the result, I would like to see a n x (r-1) matrix, where by each
entry
> is the day-over-day return of each stock.
>
>
>
> I tried to look into the zoo package, however it seems to give only the
> plots but not the actual data.
>
>
>
> Would apply function work in this case?
>
>
>
> Thanks a lot!
>
>
>        [[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] Polar coordinate

2010-06-07 Thread ogbos okike
Greetings to you all.
 I have two datasets - Time and magnitude. For a particular location, the
magnitude of the parameter varies with time. I wish to obtain a polar
coordinate distribution of time (0-24h) and magnitudes so as to visualize
how magnitude varies with different times of the day (e.g., morning,
midnight hours).
I have searched for "polar coordinates in R" but could not get helpful
hints. I would be most grateful if anyone could advise me on where to start.

Thank you.
Ogbos

[[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] R2HTML problem

2010-06-07 Thread Joris Meys
Err, sorry, forget my previous message. It has nothing to do with
Tinn-R or Eclipse. If you save that code in a file and you use the
source command in the console, you get the same output. Tinn-R and
Eclipse both source the code to R instead of sending it line by line.

To get what you want, you need to use the HTML() function on all
output you want to get correctly into the frame:

HTMLStart(getwd(),HTMLframe=FALSE, Title="My report",autobrowse=FALSE)
HTML(as.title("This is my first title"))
x <- 1
y<- 2
HTML(x+y)
HTMLStop()

This works from Tinn-R, Eclipse and by sourcing the file at the command line.

Cheers
Joris


On Mon, Jun 7, 2010 at 2:00 PM, Joris Meys  wrote:
> It must be something with your version of R, I tried it both in
> Eclipse and in Tinn-R, and I get exactly what should come out (see
> attached file). Try updating R and R2HTML first, the problem might be
> there somewhere.
>
> Cheers
> Joris
>
> On Mon, Jun 7, 2010 at 1:31 PM, Iago Conde  wrote:
>> I installed the whole eclipse and StatET thing... I try the R2HTML example
>>
>> library(R2HTML)
>>
>> HTMLStart(getwd(),HTMLframe=FALSE, Title="My report",autobrowse=FALSE)
>> as.title("This is my first title")
>> x <- 1
>> y<- 2
>> x+y
>> HTMLStop()
>>
>>
>> and still doesnt work, when I open the index html file... the title is "My
>> report" and the HTMLStop() message of
>> "Generated on: Mon Jun 07 13:36:24 2010 - R2HTML" also appears on the web
>> browser... but nothing else.
>> On Mon, Jun 7, 2010 at 3:09 AM, Joris Meys  wrote:
>>>
>>> Take a look at eclipse :
>>> http://www.splusbook.com/R_Eclipse_StatET.pdf
>>>
>>> And yes, your program should work. The editor doesn't do anything else
>>> but sending your code to R. It is R that decides what to do with it.
>>>
>>> Cheers
>>> Joris
>>>
>>> On Sun, Jun 6, 2010 at 7:25 PM, RGtk2User  wrote:
>>> >
>>> > Which editor could I use on Windows? The program that already works with
>>> > TinnR... will work with this new editor? Thanks!
>>> >
>>> > On Sat, Jun 5, 2010 at 11:40 PM, Joris FA Meys [via R] <
>>> >
>>> > ml-node+2244582-437396255-277...@n4.nabble.com
>>> >> wrote:
>>> >
>>> >> Tinn-R is using the R2HTML package itself for communication with R.
>>> >> You could ask JC Faria who wrote Tinn-R what exactly is going on
>>> >> there. You might get more help here :
>>> >> http://sourceforge.net/projects/tinn-r/support
>>> >>
>>> >> Personally, I'd just use a different editor in this case. I love
>>> >> Tinn-R, but it's no use programming in an editor that interacts with
>>> >> your code.
>>> >>
>>> >> Cheers
>>> >> Joris
>>> >>
>>> >> On Sat, Jun 5, 2010 at 4:57 PM, RGtk2User <[hidden
>>> >> email]>
>>> >> wrote:
>>> >>
>>> >> >
>>> >> > Im developing an application with R and Gtk+. It's just a simple GUI
>>> >> which
>>> >> > helps new users to interactuate with R. Thing is, when you do a
>>> >> statistical
>>> >> > analysis, I also want to provide a HTML report, but HTMLStart doesnt
>>> >> > work
>>> >>
>>> >> > propperly when executing from TinnR. It does create the file but not
>>> >> empty,
>>> >> > I've tried some examples from different websites, and it's always the
>>> >> same..
>>> >> > it works if I execute it from the R prompt, but doesnt when it comes
>>> >> > to
>>> >> > execute it from TinnR. So, any ideas? Im trying to divide the
>>> >> > internal
>>> >> code
>>> >> > of the HTMLStart function to find out where it crashes, but I couldnt
>>> >> find
>>> >> > it yet. Thanks in advance
>>> >> >
>>> >> > __
>>> >> > [hidden email]
>>> >> > 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.
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Ghent University
>>> >> Faculty of Bioscience Engineering
>>> >> Department of Applied mathematics, biometrics and process control
>>> >>
>>> >> tel : +32 9 264 59 87
>>> >> [hidden email] 
>>> >> ---
>>> >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>> >>
>>> >> __
>>> >> [hidden email]
>>> >> 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 message @
>>> >> http://r.789695.n4.nabble.com/R2HTML-problem-tp2244294p2244582.html
>>> >> To unsubscribe from R2HTML problem, click here< (link removed) ==>.
>>> >>
>>> >>
>>> >>
>>> >
>>> > --
>>> > View this message in context:
>>> > http://r.7

Re: [R] Wrong symbol rendering in plots (Ubuntu)

2010-06-07 Thread Yvonnick Noel

Hello Ben,

Does the workaround pointed out later in the thread you're
responding to (from the last paragraph of a very long 'Note'
section of ?pdf) help?
   
Well, I did not try to edit my fonts.conf but I feel this is not a PDF 
issue. I have no problem to have greek letters correctly rendered in 
Ubuntu 10.04 (with LaTeX, or OpenOffice Math for instance with a PDF 
export). This only appears in R plots.


Note that other symbols do not render well too. I put a PDF output of 
demo(plotmath) here:


http://yvonnick.noel.free.fr/wrongsymbolsinubuntu.pdf

Thank you.

Yvonnick

> sessionInfo()
R version 2.11.0 (2010-04-22)
i486-pc-linux-gnu

locale:
 [1] LC_CTYPE=fr_FR.utf8   LC_NUMERIC=C
 [3] LC_TIME=fr_FR.utf8LC_COLLATE=fr_FR.utf8
 [5] LC_MONETARY=C LC_MESSAGES=fr_FR.utf8
 [7] LC_PAPER=fr_FR.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.utf8 LC_IDENTIFICATION=C

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

__
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] fit data with y = x^-1

2010-06-07 Thread Leo Leo
Dear list,

I am getting weired with fitting data with a 1/x-polynomial. Suggest I have
the following data:

x <- c(1,2,3,4,5,6,7)
y <- c(100,20,4,2,1,.3,.1)

I may fit this with a linear model

fit1 = lm(y ~ I(x))

Getting plot out of this model I applied
library(polynom)
pol1 = polynomial(fit1$coefficients)
f1 = as.function(pol1)

plot(x,y)
lines(x, f1(x), col = 2)

Clearly, this model appears insufficient. Therefore I intended to aplly
fit2 = lm(y ~ I(1/x))
pol2 = polynomial(fit2$coefficients)
f2 = as.function(pol2)
lines(x, f2(x), col = 3)

as this would be much more pleasant. However, the second model does not work
at all.


Does anyone know about how to correctly fit an x^-1-polynomial to my data
cloud?


Many thanks in advance,


behelfsadresse

[[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] raw data form .CEL file

2010-06-07 Thread aabid

Hi 
I am new in using R. I am facing problem getting the raw data like the mean
value, standard deviation value form the .CEL file.
Please help me, how can I get these raw information from a .CEL file into an
exel file?

Thanks  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/raw-data-form-CEL-file-tp2245796p2245796.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] Computing day-over-day log return for a matrix containing multiple time series

2010-06-07 Thread Anyi Zhu
Thanks a lot Sayan, I'll give it a try and let you know how it goes.

 

 

 

From: sayan dasgupta [mailto:kitt...@gmail.com] 
Sent: June-07-10 2:13 AM
To: anyi@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] Computing day-over-day log return for a matrix containing
multiple time series

 

Hope this helps

a <- matrix(runif(150),nrow=3,ncol=50)
p2r <- function(x) 100 * diff(log(x))
 t(apply(a,1,function(x){p2r(c(x))}))





On Mon, Jun 7, 2010 at 8:41 AM, Anyi Zhu  wrote:

Hi all,



Thanks a lot for anyone's help in advance.



I am trying to find a way to compute the day-to-day return (log return) from
a n x r matrix containing, n different stocks and price quotes over r days.
The time series of prices are already split by using unstack function.




For the result, I would like to see a n x (r-1) matrix, where by each entry
is the day-over-day return of each stock.



I tried to look into the zoo package, however it seems to give only the

plots but not the actual data.

take a look at 
vignette("zoo-quickref",package="zoo")
It gives an exact solution to your problem

 




Would apply function work in this case?



Thanks a lot!


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

 


[[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] Odp: Subsetting subsets of data.frames

2010-06-07 Thread Petr PIKAL
Hi

some example would be helpful.

r-help-boun...@r-project.org napsal dne 07.06.2010 09:01:27:

> 
> Hey Everyone,
> 
> I have been stumped by this all day.
> 
> Basically, I have a data.frame of multiple columns. Of concern are "id" 
&
> "date"
> 
> For some reason, oftentimes there are duplicates of data with the same 
date.
> 
> I would like to remove the duplicates per different id (removing 
duplicate
> dates for the entire data.frame would leave nothing since different id's 
all
> have the same dates)
> 
> subset(x,!duplicated(x$date_)) works for just one ID, but i am having

However if above works on one id so use split sapply/lapply approach. 
Split your data according to id and use sapply or lapply wit above 
function for splitted object. I believe this is what ddply does so maybe 
it can be used too.

Regards
Petr

> trouble figuring out how to apply this to each subset of IDs (and 
retaining
> the original data.frame structure) 
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Subsetting-
> subsets-of-data-frames-tp2245556p2245556.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] Subsetting subsets of data.frames

2010-06-07 Thread jim holtman
subset(x, !duplicated(paste(x$id, x$date))

On Mon, Jun 7, 2010 at 3:01 AM, Jeff08  wrote:
>
> Hey Everyone,
>
> I have been stumped by this all day.
>
> Basically, I have a data.frame of multiple columns. Of concern are "id" &
> "date"
>
> For some reason, oftentimes there are duplicates of data with the same date.
>
> I would like to remove the duplicates per different id (removing duplicate
> dates for the entire data.frame would leave nothing since different id's all
> have the same dates)
>
> subset(x,!duplicated(x$date_)) works for just one ID, but i am having
> trouble figuring out how to apply this to each subset of IDs (and retaining
> the original data.frame structure)
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Subsetting-subsets-of-data-frames-tp2245556p2245556.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.
>



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

What is the problem that you are trying to solve?

__
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] Odp: fit data with y = x^-1

2010-06-07 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 07.06.2010 14:28:58:

> Dear list,
> 
> I am getting weired with fitting data with a 1/x-polynomial. Suggest I 
have
> the following data:
> 
> x <- c(1,2,3,4,5,6,7)
> y <- c(100,20,4,2,1,.3,.1)
> 
> I may fit this with a linear model
> 
> fit1 = lm(y ~ I(x))

fit1 = lm(y ~ x)
is enough

> 
> Getting plot out of this model I applied
> library(polynom)
> pol1 = polynomial(fit1$coefficients)
> f1 = as.function(pol1)
> 
> plot(x,y)
> lines(x, f1(x), col = 2)

why not

plot(x,y)
lines(x, fitted(fit))


> 
> Clearly, this model appears insufficient. Therefore I intended to aplly
> fit2 = lm(y ~ I(1/x))
> pol2 = polynomial(fit2$coefficients)
> f2 = as.function(pol2)
> lines(x, f2(x), col = 3)

The same applies here

fit3 = lm(y ~ I(1/x^3))
lines(x, fitted(fit3))

seems to give quite reasonable output.

Regards
Petr

> 
> as this would be much more pleasant. However, the second model does not 
work
> at all.
> 
> 
> Does anyone know about how to correctly fit an x^-1-polynomial to my 
data
> cloud?
> 
> 
> Many thanks in advance,
> 
> 
> behelfsadresse
> 
>[[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] raw data form .CEL file

2010-06-07 Thread Joris Meys
All questions about manipulations of sequence data (guess that's the
CEL file you're talking about...)  can better be asked on the specific
mailing list of BioConductor :
http://www.bioconductor.org/docs/mailList.html

And please, don't swear in church any more. We don't put things in
Excel files. This is about R, not about Micro$oft.

Cheers
Joris

On Mon, Jun 7, 2010 at 1:20 PM, aabid  wrote:
>
> Hi
> I am new in using R. I am facing problem getting the raw data like the mean
> value, standard deviation value form the .CEL file.
> Please help me, how can I get these raw information from a .CEL file into an
> exel file?
>
> Thanks
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/raw-data-form-CEL-file-tp2245796p2245796.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.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] Onequestion

2010-06-07 Thread Ben Bolker
Xiongqing Zhang  yahoo.com> writes:

> 
> 
> Dear Mr. or Ms.,
>  
> I used the R-software to run the zero-inflatoin negative binomial model, but I
could not get the results.
> And the error message is "solve.default(as.matrix(fit$gaussian)) ". In the
model, I introduced 3 dummy
> variables. I do not know the reasons fully.
>  

  We can't possibly help if you don't tell us specifically what you did.
Please read the posting guide!  Tell us what packages you are using,
show us your data (or make up a small data set that shows the same
problem), and show us what commands you tried. "Reproducible example"
is the key.

  Ben Bolker

__
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] open files from ftp site

2010-06-07 Thread Benoit Wastine

Hello,
I'm running R 2.10.1 on Windows XP.
I'd like to read some files from a ftp site, but I don't how to do it. 
I've tried the functions url, download.file but each time I have a 
message "cannot open URL 'ftp://ftp.cea.fr'" .. and I don't kwow why ..

Thanks for the help
Benoit

--
Benoit Wastine
Laboratoire des Sciences du Climat et de l’Environnement (LSCE/IPSL)
CEA-CNRS-UVSQ
CE Saclay
Orme des merisiers
Bât 703 - Pte 13A
91191 Gif sur Yvette Cedex
France

Tel : 33 (0)1 69 08 21 97
Fax : 33 (0)1 69 08 77 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] ols function in rms package

2010-06-07 Thread Frank E Harrell Jr

On 06/06/2010 10:49 PM, Mark Seeto wrote:

Hello,

I have a couple of questions about the ols function in Frank Harrell's rms
package.

Is there any way to specify variables by their column number in the data
frame rather than by the variable name?

For example,

library(rms)
x1<- rnorm(100, 0, 1)
x2<- rnorm(100, 0, 1)
x3<- rnorm(100, 0, 1)
y<- x2 + x3 + rnorm(100, 0, 5)
d<- data.frame(x1, x2, x3, y)
rm(x1, x2, x3, y)
lm(y ~ d[,2] + d[,3], data = d)  # This works
ols(y ~ d[,2] + d[,3], data = d) # Gives error
Error in if (!length(fname) || !any(fname == zname)) { :
   missing value where TRUE/FALSE needed

However, this works:
ols(y ~ x2 + d[,3], data = d)

The reason I want to do this is to program variable selection for
bootstrap model validation.

A related question: does ols allow "y ~ ." notation?

lm(y ~ ., data = d[, 2:4])  # This works
ols(y ~ ., data = d[, 2:4]) # Gives error
Error in terms.formula(formula) : '.' in formula and no 'data' argument

Thanks for any help you can give.

Regards,
Mark


Hi Mark,

It appears that you answered the questions yourself.  rms wants real 
variables or transformations of them.  It makes certain assumptions 
about names of terms.   The y ~ . should work though; sometime I'll have 
a look at that.


But these are the small questions compared to what you really want.  Why 
do you need variable selection, i.e., what is wrong with having 
insignificant variables in a model?  If you indeed need variable 
selection see if backwards stepdown works for you.  It is built-in to 
rms bootstrap validation and calibration functions.


Frank

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

__
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] Patch for legend.position={left,top,bottom} in ggplot2

2010-06-07 Thread Karsten Loesing
Hi Hadley and everyone,

here's a patch for ggplot2 that fixes the behavior of
opts(legend.position={left,top,bottom}). If you try the following code
in an unmodified ggplot2

options(warn = -1)
suppressPackageStartupMessages(library("ggplot2"))
data <- data.frame(
x = c(1, 2, 3, 4, 5, 6),
y = c(2, 3, 4, 3, 4, 5),
colour = c(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE))
ggplot(data, aes(x = x, y = y, colour = colour)) +
geom_line() + opts(title = "title", legend.position = "right")
ggplot(data, aes(x = x, y = y, colour = colour)) +
geom_line() + opts(title = "title", legend.position = "left")
ggplot(data, aes(x = x, y = y, colour = colour)) +
geom_line() + opts(title = "title", legend.position = "top")
ggplot(data, aes(x = x, y = y, colour = colour)) +
geom_line() + opts(title = "title", legend.position = "bottom")

you'll see that plots 2 to 4 are broken.

I think I located the bug in surround_viewports() where the graphical
elements are placed into the grid. If we increment all rows and columns
of the graphical elements for positions "left", "top", and "bottom" by
1, those graphs look sane again. I assume that a new first row and
column were added at some point in the development, but only the
parameters for the default position "right" were adjusted. Here's the patch:


--- ggplot2-orig2   2010-06-07 13:14:35.0 +0200
+++ ggplot2 2010-06-07 15:22:33.0 +0200
@@ -7003,27 +7003,27 @@
 )
   } else if (position == "left") {
 viewports <- vpList(
-  vp("panels", 2, 3),
-  vp("legend_box", 2, 1),
-  vp("ylabel", 2, 2),
-  vp("xlabel", 3, 3),
-  vp("title", 1, 3)
+  vp("panels", 3, 4),
+  vp("legend_box", 3, 2),
+  vp("ylabel", 3, 3),
+  vp("xlabel", 4, 4),
+  vp("title", 2, 4)
 )
   } else if (position == "top") {
 viewports <- vpList(
-  vp("panels", 3, 2),
-  vp("legend_box", 2, 2),
-  vp("ylabel", 3, 1),
-  vp("xlabel", 4, 2),
-  vp("title", 1, 2)
+  vp("panels", 4, 3),
+  vp("legend_box", 3, 3),
+  vp("ylabel", 4, 2),
+  vp("xlabel", 5, 3),
+  vp("title", 2, 3)
 )
   } else if (position == "bottom") {
 viewports <- vpList(
-  vp("panels", 2, 2),
-  vp("legend_box", 4, 2),
-  vp("ylabel", 2, 1),
-  vp("xlabel", 3, 2),
-  vp("title", 1, 2)
+  vp("panels", 3, 3),
+  vp("legend_box", 5, 3),
+  vp("ylabel", 3, 2),
+  vp("xlabel", 4, 3),
+  vp("title", 2, 3)
 )
   } else {
 viewports <- vpList(


Best,
--Karsten

__
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] Test

2010-06-07 Thread Ted Harding
Greetings Moderators!
I moderated the message below just now (one of two identical
test messages). I rejected it, with a covering note to the
author (John Munroe , who does not appear
to be subscribed to the list) that I was doing so because
approving it would serve no useful purpose, and pointing out
that it had been held because the message headers matched a
filter rule, probably because it was (a) from gmail.com and
(b) sent via nabble.

I then also ticked the box for it to be forwarded to r-help-owner,
expecting that my covering note would accompany it. Since that did
not happen, I'm now adding an explanation!

I would suspect that John Munro has been trying to get through
to R-help, and failing, as the most likely explanation for
sending test messages.

I feel this sort of thing is adding weight to the case for
trying to alleviate the severity with which mailman treats
messages from this kind of origin. What do others think?

Ted.

On 07-Jun-10 13:26:49, John Munroe wrote:
> 
> Test
> -- 
> View this message in context:
> http://r.789695.n4.nabble.com/Test-tp2245933p2245933.html
> Sent from the R help mailing list archive at Nabble.com.
> 


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 07-Jun-10   Time: 14:59:49
-- XFMail --

__
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] Test

2010-06-07 Thread Ted Harding
Apologoes for sending a message to R-help that should have gone
to the moderators' mailing-list. I had overlooked that the "From:"
in the MIME-attached messsage was different from the "From:" in
the covering message, and I replied to the wrong address.
Ted.

On 07-Jun-10 14:00:02, Ted Harding wrote:
> Greetings Moderators!
> [...]


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 07-Jun-10   Time: 15:12:26
-- XFMail --

__
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 predicted values for time series.

2010-06-07 Thread Erin Hodgess
Dear R People:

I found the following code on the Internet:

> x <- co2
> m <- HoltWinters(x, alpha=.1, beta=0, gamma=0)
> p <- predict(m, n.ahead=240, prediction.interval=T)
> plot(m, predicted.values=p)
>

and it works fine.

My question:  is there an equivalent for ARIMA objects, please?  When
I tried, I got the following:
> x.arima <- arima(x,order=c(1,0,0))
> p1 <- predict(x.arima,n.ahead=6,prediction.interval=T)
> plot(x.arima,predicted.values=p1)
Error in xy.coords(x, y, xlabel, ylabel, log) :
  'x' is a list, but does not have components 'x' and 'y'
> plot(x,predicted.values=p1)
Warning messages:
1: In plot.window(xlim, ylim, log, ...) :
  "predicted.values" is not a graphical parameter
2: In title(main = main, xlab = xlab, ylab = ylab, ...) :
  "predicted.values" is not a graphical parameter
3: In axis(1, ...) : "predicted.values" is not a graphical parameter
4: In axis(2, ...) : "predicted.values" is not a graphical parameter
5: In box(...) : "predicted.values" is not a graphical parameter
>

Thanks in advance for any help!

Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.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] graphical representation of a correlation between 3 variables (~30 datapoints)

2010-06-07 Thread Georg Ehret
Dear Ms and Mr R,
 I am seeking a visually appealing presentation of 3 variables (~30
datapoints) that are correlated and that should to into the same direction.
The objective is to show that they do go in the same direction and what
differences there might be while also giving an idea of the values of the
variables.  I had done this with simple bargraphs for 6 datapoints in the
past, but for 30 this is too much. Anyone a good idea how to get this job
nicely done?

Thanking you and best regards, Georg.
##
Georg Ehret
Johns Hopkins Baltimore

[[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] graphical representation of a correlation between 3 variables (~30 datapoints)

2010-06-07 Thread Erik Iverson

reproducible example needed.

Georg Ehret wrote:

Dear Ms and Mr R,
 I am seeking a visually appealing presentation of 3 variables (~30
datapoints) that are correlated and that should to into the same direction.
The objective is to show that they do go in the same direction and what
differences there might be while also giving an idea of the values of the
variables.  I had done this with simple bargraphs for 6 datapoints in the
past, but for 30 this is too much. Anyone a good idea how to get this job
nicely done?

Thanking you and best regards, Georg.
##
Georg Ehret
Johns Hopkins Baltimore

[[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] Generalized DCC GARCH ML estimation

2010-06-07 Thread Matthieu Stigler
Dear Anonymous

I suggest you to have a look on the code in package ccgarch, which might 
help you in seeing how this have been done. A useful information would 
be to know what kind of optimization algorithm the authors use.

best

Matthieu


Le 07. 06. 10 12:00, r-help-requ...@r-project.org a écrit :
> Message: 24
> Date: Sun, 6 Jun 2010 10:17:50 -0700 (PDT)
> From: drinky_1
> To:r-help@r-project.org
> Subject: [R] Generalized DCC GARCH ML estimation
> Message-ID:<1275844670290-2245135.p...@n4.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> Hi everyone,
>
> I want to do a maximum likelihood estimation for the Generalized Dynamic
> Conditional Correlation (GDCC) Model of Hafner and Franses (2009), but I
> don't know how exactly. I hope you can help me. This is what I have so far.
>
> Well first of all Hafner models the conditional covariance matrix H_t as
> follows:
> H=D*R*D, where D is a diagonal matrix with the square root of the estimated
> univariate GARCH variances, R is a correlation matrix:
> R_t=diag(Q_t)^(-1/2)*Q_t*diag(Q_t)^(-1/2) and
> Q_t=S(1-mean(a)2-mean(b)2)+ aa' * (eps_(t-1)*eps')+ bb'*Q_(t-1)
>
> a and b are parameter vectors and S is the sample correlation matrix of the
> eps.
>
> There is a two-step estimation method, but I  only need the second step.
>
> So first of all I want to calculate the correlations
>
> gdcc=function (dvar,alpha,beta)
> {
>
> T=dim(dvar)[1]
> N=dim(dvar)[2]
>
> uncR=cor(dvar)
> R=list()
>
> Q=list()
> Q[[1]]=uncR
> R[[1]]=diag(diag(uncR)^(-1/2))%*%uncR%*%diag(diag(uncR)^(-1/2))
>
>
> for (i in 2:T)
> {
>
> Q[[i]]=uncR*(1-mean(alpha)2-mean(beta)2)+tcrossprod(alpha)*tcrossprod(dvar[i-1,])+tcrossprod(beta)*Q[[i-1]]
>
>
> R[[i]]=diag(diag(Q[[i]])^(-1/2))%*%Q[[i]]%*%diag(diag(Q[[i]])^(-1/2))
>
> GDCC[i,]=as.vector(R[[i]])
> }
>
> GDCC
> }
>
> and the log-likelihood function is as follows:
>
> loglik.gdcc2=function (alpha,beta,dvar)
> {
>  T<- dim(dvar)[1]
>  N<- dim(dvar)[2]
>  GDCC=gdcc(dvar,alpha,beta)
>  lf<- numeric(N)
>  for (i in 1:T) {
>  R<- matrix(GDCC[i,], N, N)
>  invR<- solve(R)
>  lf[i]<- 0.5 * (log(det(R)) + sum(dvar[i, ] * crossprod(invR,
>  dvar[i, ])))
>  }
>  -sum(lf)
>
> }
>
> I want to use the nlm method. How can I estimate the parameter vectors a and
> b? I really would appreciate it if anyone could help me.
>
> Thank you very much.
> Best regards, drinky_1
>


[[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] graphical representation of a correlation between 3 variables (~30 datapoints)

2010-06-07 Thread Jorge Ivan Velez
Hi Georg,

Take a look at ?pairs as well as [1] and [2].

HTH,
Jorge

[1] http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=159
[2] http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=149


On Mon, Jun 7, 2010 at 11:16 AM, Georg Ehret <> wrote:

> Dear Ms and Mr R,
> I am seeking a visually appealing presentation of 3 variables (~30
> datapoints) that are correlated and that should to into the same direction.
> The objective is to show that they do go in the same direction and what
> differences there might be while also giving an idea of the values of the
> variables.  I had done this with simple bargraphs for 6 datapoints in the
> past, but for 30 this is too much. Anyone a good idea how to get this job
> nicely done?
>
> Thanking you and best regards, Georg.
> ##
> Georg Ehret
> Johns Hopkins Baltimore
>
>[[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.
>

[[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] Polar coordinate

2010-06-07 Thread Charles C. Berry

On Mon, 7 Jun 2010, ogbos okike wrote:


Greetings to you all.
I have two datasets - Time and magnitude. For a particular location, the
magnitude of the parameter varies with time. I wish to obtain a polar
coordinate distribution of time (0-24h) and magnitudes so as to visualize
how magnitude varies with different times of the day (e.g., morning,
midnight hours).
I have searched for "polar coordinates in R" but could not get helpful
hints. I would be most grateful if anyone could advise me on where to start.


Do a better search.

RSiteSearch("polar")

Google 'polar coordinate CRAN'

Google 'polar coordinate rforge'

And if these are not useful, you need to say why none of the functions for 
manipulating or plotting polar coordinates served your purpose.


Chuck




Thank you.
Ogbos

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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 predicted values for time series. Solution

2010-06-07 Thread Erin Hodgess
Dear R People:

A very fine solution exists in the "forecast" package, by using plot.forecast.

Thanks though!

Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.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] Howto modify a drawn graph with igraph

2010-06-07 Thread Uwe Ligges

See ?plot.igraph, example:

plot(g, layout=mlayout,
vertex.label.color = "red",
vertex.color = "green",
vertex.frame.color = "blue",
edge.color = "orange",
edge.width = 1 + (1:18)/2
)

Uwe Ligges



On 06.06.2010 17:58, Etienne Cuvelier wrote:

Hello,
I am using the igraph package, and I wonder how to add or modify
informations on a drawn graph.

Example:
library(igraph)
M <- matrix( nc=12, nr=12 , 0)
M[ 1,]=c(0,1,0,0,1,1,0,0,0,0,0,0)
M[ 2,]=c(1,0,1,1,1,0,0,0,0,0,0,0)
M[ 3,]=c(0,1,0,0,0,1,1,0,0,0,0,0)
M[ 4,]=c(0,1,0,0,0,1,0,0,0,0,0,0)
M[ 5,]=c(1,1,0,0,0,0,0,0,0,0,0,0)
M[ 6,]=c(1,0,1,1,0,0,0,0,0,0,0,0)
M[ 7,]=c(0,0,1,0,0,0,0,1,1,0,0,1)
M[ 8,]=c(0,0,0,0,0,0,1,0,1,0,0,1)
M[ 9,]=c(0,0,0,0,0,0,1,1,0,0,1,1)
M[10,]=c(0,0,0,0,0,0,0,0,0,0,1,0)
M[11,]=c(0,0,0,0,0,0,1,0,1,0,0,0)
M[12,]=c(0,0,0,0,0,0,0,1,1,0,0,0)
g <- graph.adjacency( M,mode="undirected" )
mlayout= layout.kamada.kawai(g)
plot(g,layout=mlayout)

#And now howto add a weight associated on edges on the "picture"?
#Or howto change the color of an edge, or a vertice?

Thanks for help.


Etienne

__
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] Computing day-over-day log return for a matrix containingmultiple time series

2010-06-07 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of sayan dasgupta
> Sent: Sunday, June 06, 2010 11:13 PM
> To: anyi@gmail.com
> Cc: r-help@r-project.org
> Subject: Re: [R] Computing day-over-day log return for a 
> matrix containingmultiple time series
> 
> Hope this helps
> 
> a <- matrix(runif(150),nrow=3,ncol=50)
> p2r <- function(x) 100 * diff(log(x))
>  t(apply(a,1,function(x){p2r(c(x))}))

The following expressions compute the same
thing as that t(apply(...)) does:
  100 * (log(a[,-1]) - log(a[,-ncol(a)]))
or
  100 * log(a[,-1]/a[,-ncol(a)])

The [,-1] (all but the first column) and
[,-ncol(a)] (all but the last column) is
a way to work with lagged data.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> 
> 
> 
> On Mon, Jun 7, 2010 at 8:41 AM, Anyi Zhu  wrote:
> 
> > Hi all,
> >
> >
> >
> > Thanks a lot for anyone's help in advance.
> >
> >
> >
> > I am trying to find a way to compute the day-to-day return 
> (log return)
> > from
> > a n x r matrix containing, n different stocks and price 
> quotes over r days.
> > The time series of prices are already split by using 
> unstack function.
> >
> 
> >
> >
> > For the result, I would like to see a n x (r-1) matrix, 
> where by each entry
> > is the day-over-day return of each stock.
> >
> >
> >
> > I tried to look into the zoo package, however it seems to 
> give only the
> >
> plots but not the actual data.
> >
> take a look at
> vignette("zoo-quickref",package="zoo")
> It gives an exact solution to your problem
> 
> 
> 
> >
> >
> >
> > Would apply function work in this case?
> >
> >
> >
> > Thanks a lot!
> >
> >
> >[[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.
> >
> 
>   [[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] Multiply Two Dataframes

2010-06-07 Thread Bert Jacobs
 

 

Hi,

I have the following two dataframes (Df1 and Df2):

Df1 has a layout like

 

ID Location  Var1 Var2 Var3 . Var20

A  Loc2  1   11.   1

A  Loc1  0   10.   1

B  Loc1  0   00.   0   

A  Loc3  1   01.   0

C  Loc3  1   01.   0

B  Loc2  0   00.   1   

D .

..

 

 

Df2 has a layout like

ID Var1 Var2 Var3 ..  Var20

A   0.2 0.30.2      0.15

B   0.1 0.1 0.1  .0.1   

C00   0 .   0.50

D .

.

 

And I like to have the following result

ID Location  Var1  Var2   Var3 .Var20

A  Loc2  0.2 0.3  0.2   . 0.15

A  Loc1  00.3  0  . 0.15

B  Loc1  00 0  . 0   

A  Loc3  0.2 00.2   .  0

C  Loc3  0   00  .   0

B  Loc2  0   00  .   0.1   

D .

..

 

Is this easy doable in R? I've tried to figure it out with mapply but
without result.

Thanks for helping me out.

Bert

 

 


[[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] Multiply Two Dataframes

2010-06-07 Thread ONKELINX, Thierry
Dear Bert,

The easiest thing would be to merge both datasets and then multiply the 
corresponding columns.

both <- merge(df1, df2)
both[, 3:22] * both[, 23:42]

HTH,

Thierry

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org namens Bert Jacobs
Verzonden: ma 7-6-2010 20:29
Aan: r-help@r-project.org
Onderwerp: [R] Multiply Two Dataframes
 
 

 

Hi,

I have the following two dataframes (Df1 and Df2):

Df1 has a layout like

 

ID Location  Var1 Var2 Var3 . Var20

A  Loc2  1   11.   1

A  Loc1  0   10.   1

B  Loc1  0   00.   0   

A  Loc3  1   01.   0

C  Loc3  1   01.   0

B  Loc2  0   00.   1   

D .

..

 

 

Df2 has a layout like

ID Var1 Var2 Var3 ..  Var20

A   0.2 0.30.2      0.15

B   0.1 0.1 0.1  .0.1   

C00   0 .   0.50

D .

.

 

And I like to have the following result

ID Location  Var1  Var2   Var3 .Var20

A  Loc2  0.2 0.3  0.2   . 0.15

A  Loc1  00.3  0  . 0.15

B  Loc1  00 0  . 0   

A  Loc3  0.2 00.2   .  0

C  Loc3  0   00  .   0

B  Loc2  0   00  .   0.1   

D .

..

 

Is this easy doable in R? I've tried to figure it out with mapply but
without result.

Thanks for helping me out.

Bert

 

 


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


Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

[[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] exepath error in seqaln

2010-06-07 Thread yangfan1
Hi everyone, 

I am using bio3d package for some sequence analysis because of its nice 
integrated MUSCLE execution. However, I have been encountering some errors 
while I was running seqaln function, which calls for installed MUSCLE program. 
In my case, I stored the MUSCLE program on the desktop with pathway of 
"./Desktop/muscle/src/muscle". I had no problem running MUSCLE directly from 
terminal. However, when I'm calling the exepath in R, it keeps giving me error 
messages. Below are some errors I have encountered. Your help will be much 
appreciated. 

> aa<-read.fasta("./R/test.fa", rm.dup=F)

> aln<-seqaln(aa, exepath="/Users/Fan/Desktop/muscle/src/muscle", 
> file="aa_muscle.fa", protein=T) 
/Users/Fan/Desktop/muscle/src/musclemuscle -in 
/var/folders/v9/v95dzKP2E9SAkmd7m4T8dE+++TQ/-Tmp-//RtmpKUJVlZ/file618fb492 -out 
aa_muscle.fa  -stable -seqtype protein/bin/sh: 
/Users/Fan/Desktop/muscle/src/musclemuscle: No such file or directory 
Error in file(file, "r") : cannot open the connection 
In addition: Warning message: 
In file(file, "r") : 
  cannot open file 'aa_muscle.fa': No such file or directory  
 
I have also noticed that the example file from bio3d/seqaln does not have 
quotation marks for the exepath. But it returned a different error message.

> aln<-seqaln(aa, exepath=/Users/Fan/Desktop/muscle/src/muscle, 
> file="aa_muscle.fa", protein=T) 
Error: unexpected '/' in "aln<-seqaln(aa, exepath=/" 
or > aln<-seqaln(aa, exepath=Users/Fan/Desktop/muscle/src/muscle, 
file="aa_muscle.fa", protein=T) 
Error in paste(exepath, "muscle -in ", toaln, " -out ", file, " ", extra.args,  
:  
  object 'Users' not found

Thank you for your help ahead of time! 

Best wishes.

Fan
  
[[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] paste together a string object later to be utilized in a function

2010-06-07 Thread Greg Snow
Does the collapse argument to the paste function do what you want?  Possibly 
nested inside another paste.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of moleps
> Sent: Sunday, June 06, 2010 1:51 PM
> To: r-help@r-project.org
> Subject: [R] paste together a string object later to be utilized in a
> function
> 
> Dear r-listers,
> 
> I need to pass a string to a function. However the length of the string
> is dependent on the length of a vector.
> 
> 
> b<-length(h)
> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
> 
> 
> Is it possible somehow to pass this as an argument to a function later
> on ?
> 
> 
> 
> Regards,
> 
> //M
> 
> __
> 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 with seting up comparison

2010-06-07 Thread Bart Joosen

Hi,

I tried on this, but couldn't figure it out:
Suppose I have a dataframe as follows:
dat <- data.frame(Day=rep(rep(c(1,2), each=4),2), Animal = rep(c(1,2),
each=8), Count=c(rnorm(8, 100), rnorm(8,90)))

2 animals are being examined on 2 different days. Count is the result.

Now I need to point out whether or not there is a difference between the
days.
I did this by an ANOVA test, while first converting the animal and day to a
factor variable:
dat$Animal <- as.factor(dat$Animal)
dat$Day <- as.factor(dat$Day)
mod <- lm(Count ~Animal * Day,dat)
anova(mod)

Now I have to check for difference within the animal, to see if there is a
difference in count for each day. (In my real data, I have 35 animals, with
4 days, and 4 results).
I thought about a Tukey HSD test, but this compares every day of every
animal with every other day of every other animal. (TukeyHSD(aov(mod)))

Any idea about which function (or model for lm) to use to only compare days
within every animal?

Best regards

Bart


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-seting-up-comparison-tp2246106p2246106.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] as.integer

2010-06-07 Thread aledanda

Hi,

Is there a way to recursively change the variables imported with
read.table(..) - and then attached with attach(..) - from as.factor to
as.integer?
I have about 9 variables that are now recognized as factors but I need to do
statistics on them so I need to change them in as.integer. It works, but I
wonder if there is a way to to this for all the variables in one go. 

Thanks a lot for your help

Ale
-- 
View this message in context: 
http://r.789695.n4.nabble.com/as-integer-tp2245987p2245987.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] Source of chickwts data

2010-06-07 Thread Chirok Han
I'm not sure if this is the right mailing list. My apologies if I'm
sending the question to the wrong mailing list.
(The r-packages list moderator suggested using the R-help list.)

My question is about the "chickwts" data in the datasets package.
According to help(chickwts), the source of the data is

 Anonymous (1948) Biometrika, 35, 214.

But this reference seems irrelevant.
(See http://www.jstor.org/stable/i315414.)

The help document also gives "McNeil, D. R. (1977) Interactive Data
Analysis. New York: Wiley" as a reference, but unfortunately my local
library does not keep the book. Could someone please help me find the
correct source of the data?

Many thanks.

Chirok

__
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] classification algorithms with distance matrix

2010-06-07 Thread sidahmed BENABDERRAHMANE

Dear all,

I have a problem when using some classification functions (Kmeans, PAM, 
FANNY...)  with a distance matrix, and i would to understand how it 
proceeds for the positioning of centroids after one execution step.


In fact, in the classical formulation of the algorithm, after each step, 
to re-position the center, it calculates the distance between any 
elements of the old cluster and its center, or in my case I used  a 
distance matrix , so I do not understand how the algorithm can 
recalculates the distance between the newly generated center and other 
elements of the cluster knowing that the new center does not appear in 
the distance matrix and there is no way to calculate the distance 
between him and the elements of a cluster. ?


Thank you for your help.

Sid., LORIA
France.

__
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 parse out string separated by special character

2010-06-07 Thread xin wei

hi, everyone:
i have a data frame with one single character column as followings:
DS_xxx_yyy_24hr_zzz_1
DS_xxx_yyy_24hr_zzz_2
DS_xxx_yyy_24hr_zzz_3
DS_xxx_yyy_24hr_zzz_4
DS_xxx_yyy_24hr_zzz_1
DS_xxx_yyy_24hr_zzz_2
DS_xxx_yyy_24hr_zzz_3
DS_xxx_yyy_24hr_zzz_4
DS_xxx_yyy_24hr_zzz_1

i need to parse out the time part like the followings:
name   time
DS_xxx_yyy_24hr_zzz_1  24hr
DS_xxx_yyy_24hr_zzz_2  24hr  
DS_xxx_yyy_24hr_zzz_3  24hr
DS_xxx_yyy_24hr_zzz_4  24hr
DS_xxx_yyy_24hr_zzz_1  24hr
DS_xxx_yyy_24hr_zzz_2  24hr
DS_xxx_yyy_24hr_zzz_3  24hr
DS_xxx_yyy_24hr_zzz_4  24hr
DS_xxx_yyy_24hr_zzz_1  24hr

what function should I look at?
i have tried: strsplit(data, '_') and get a giant list which is not what i
need.

thanks in advance

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-parse-out-string-separated-by-special-character-tp2246301p2246301.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] mgcv

2010-06-07 Thread Dipa Hari


Hello Sir,
I am using mgcv package for my data. 
My model is y~x1+f(x2),I want to find out the function f(x2) . 
Following is the code.
 
sm1=gam(y~x1+s(x2),family=binomial, f) 
summary(sm1) 
plot(sm1,residuals=TRUE, xlab="AGE",pch=20) 
  
In this plot I am getting S(x2,1.93) on y axixs 
How should I get the function for x2 from this plot.or Is there anyother 
procedure in R  to get this function or value for that particular function.for 
example f(x2)= log(x2) so from that plot how can I get this kind of formula for 
x2 variable? 
How can I find variance covariance matrix  for that model and confidence 
interval for that model ? I tried delta method but I am not getting result.
Hope you understand my question? 
Thanks  
 
 


  
[[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] Loading an image/picture (png/jpeg/...) to screen...

2010-06-07 Thread Greg Snow
Once you have your image displayed in a plot, look at the updateusr function in 
the TeachingDemos package for a way to modify the coordinate system to what you 
want so that using locator() gives the results that you want.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of oliver
> Sent: Sunday, June 06, 2010 5:46 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Loading an image/picture (png/jpeg/...) to screen...
> 
> Hello,
> 
> 
> how can I load an external picture/image file to screen?
> 
> I want to use locator() then to get coordinates of that picture...
> ...in other words I want to use R to do some measurements on a picture.
> 
> Therefore I need to load the image into R display,
> and that displaying needs to work together with locator().
> 
> 
> How to do it best?
> 
> At the moment I need to be able to read in *.png files,
> but if *.jpeg or other formats also will be supporttzed, this would be
> fine.
> 
> __
> 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] Very OT: World Cup Statistics

2010-06-07 Thread Paul

Hello,

Sorry for the very Off TOpic post, but I need some data on past football 
(soccer) world cups.  I'd like to find (or calculate) the time to the 
first goal of each match (where a goal was scored).


I''ve looked at the uefa website and can't find what I want, maybe 
someone here can help ?


Thanks

Paul.

__
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] Transforming list to data frame with corresponding columns

2010-06-07 Thread LCOG1

Hi all, 
   Consider the following.


a<-list(c("MHsub","MHsub","SFD","Duplex"))
b<-list(c("MHsub","MHsub","SFD"))
c<-list(c("MHpark","SFD","SFD"))
d<-list(c("MultiFam","MultiFam","MultiFam","Duplex"))

all<-list(a,b,c,d)
names(all)<-c("5","6","7","8")
all2<-list()
for(i in 1:length(all)){
all2[[i]]<-table(unlist(all[i]))
}
names(all2)<-names(all)

What i want to do is to put each of the elements of the list into a data
frame where the element represents a row and each vector is accounted for,
for all types within the entire list.  So where there isnt a particular
vector a 0 is noted so that the final product looks like this:


SFD Mhsub   Duplex  MultiFam
5   1  11   0
6   1  10   0
7   1  10   0
8   0  01   1 

Thanks for the insights.  
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246423.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] how to parse out string separated by special character

2010-06-07 Thread Henrique Dallazuanna
Try this:

 gsub(".*_(.*)_.*_.*", "\\1", s)


On Mon, Jun 7, 2010 at 2:21 PM, xin wei  wrote:

>
> hi, everyone:
> i have a data frame with one single character column as followings:
> DS_xxx_yyy_24hr_zzz_1
> DS_xxx_yyy_24hr_zzz_2
> DS_xxx_yyy_24hr_zzz_3
> DS_xxx_yyy_24hr_zzz_4
> DS_xxx_yyy_24hr_zzz_1
> DS_xxx_yyy_24hr_zzz_2
> DS_xxx_yyy_24hr_zzz_3
> DS_xxx_yyy_24hr_zzz_4
> DS_xxx_yyy_24hr_zzz_1
>
> i need to parse out the time part like the followings:
> name   time
> DS_xxx_yyy_24hr_zzz_1  24hr
> DS_xxx_yyy_24hr_zzz_2  24hr
> DS_xxx_yyy_24hr_zzz_3  24hr
> DS_xxx_yyy_24hr_zzz_4  24hr
> DS_xxx_yyy_24hr_zzz_1  24hr
> DS_xxx_yyy_24hr_zzz_2  24hr
> DS_xxx_yyy_24hr_zzz_3  24hr
> DS_xxx_yyy_24hr_zzz_4  24hr
> DS_xxx_yyy_24hr_zzz_1  24hr
>
> what function should I look at?
> i have tried: strsplit(data, '_') and get a giant list which is not what i
> need.
>
> thanks in advance
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-parse-out-string-separated-by-special-character-tp2246301p2246301.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

[[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] Color scale graphic

2010-06-07 Thread Greg Snow
Do you just want a rectangle with different vertical color bands?  Then look at 
the image function.  Do you want a small rectangle that goes the length of the 
x-axis with these color bands, but gives room for another plot above that?  
Then look at the subplot function (TeachingDemos package) along with the image 
function.

If neither of those help, give us a better description and/or example of what 
you want your plot to look like.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Diogo_Silva
> Sent: Saturday, June 05, 2010 6:03 PM
> To: r-help@r-project.org
> Subject: [R] Color scale graphic
> 
> 
> Hello
> 
> Recently, I've been dealing with a seemingly simple problem. I have a
> table
> with two columns filled with values from a test I made (say, amount of
> precipitation and Months measured). Now, instead of plotting a typical
> linear graphic with precipitation on the y-axis and the months in the
> x-axys, I would like to "convert" the values of precipitation in a
> color
> gradient, resulting in a vertical gradient throughout the x-axis. In
> this
> way, months with higher precipitation would appear reddish while lower
> precipitation would appear blueish, for example. Despite being a simple
> problem (basically converting the y-values in a color gradient), I have
> failed to find a way of doing this.
> 
> If someone knows how to solve this, either using R or other program,
> please
> lend me a hand.
> 
> Thanks for your attention
> Diogo
> --
> View this message in context: http://r.789695.n4.nabble.com/Color-
> scale-graphic-tp2244657p2244657.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] as.integer

2010-06-07 Thread Erik Iverson

1) Give us a reproducible example.

2) You probably don't want to use attach.

3) Yes there is a way, but without an example, it's hard to say what 
will work.  Assume a data.frame called df, maybe something like the 
following, which is untested...


df[is.factor(df)] <- lapply(df[is.factor(df)], function(x) 
as.numeric(as.character(x)))




aledanda wrote:

Hi,

Is there a way to recursively change the variables imported with
read.table(..) - and then attached with attach(..) - from as.factor to
as.integer?
I have about 9 variables that are now recognized as factors but I need to do
statistics on them so I need to change them in as.integer. It works, but I
wonder if there is a way to to this for all the variables in one go. 


Thanks a lot for your help

Ale


__
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] Help with seting up comparison

2010-06-07 Thread Greg Snow
Are you interested in only those 35 animals (not every going to look at any 
other animals other than those 35, but you want to predict what will happen for 
those 35)? Or are the 35 animals a sample of a larger population of animals?

If the later (seems the most likely case) then you probably want to use a mixed 
effects model (nlme or lme4 packages) with animal as a random effect, then just 
look at the fixed effect of day.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Bart Joosen
> Sent: Monday, June 07, 2010 9:14 AM
> To: r-help@r-project.org
> Subject: [R] Help with seting up comparison
> 
> 
> Hi,
> 
> I tried on this, but couldn't figure it out:
> Suppose I have a dataframe as follows:
> dat <- data.frame(Day=rep(rep(c(1,2), each=4),2), Animal = rep(c(1,2),
> each=8), Count=c(rnorm(8, 100), rnorm(8,90)))
> 
> 2 animals are being examined on 2 different days. Count is the result.
> 
> Now I need to point out whether or not there is a difference between
> the
> days.
> I did this by an ANOVA test, while first converting the animal and day
> to a
> factor variable:
> dat$Animal <- as.factor(dat$Animal)
> dat$Day <- as.factor(dat$Day)
> mod <- lm(Count ~Animal * Day,dat)
> anova(mod)
> 
> Now I have to check for difference within the animal, to see if there
> is a
> difference in count for each day. (In my real data, I have 35 animals,
> with
> 4 days, and 4 results).
> I thought about a Tukey HSD test, but this compares every day of every
> animal with every other day of every other animal. (TukeyHSD(aov(mod)))
> 
> Any idea about which function (or model for lm) to use to only compare
> days
> within every animal?
> 
> Best regards
> 
> Bart
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-with-
> seting-up-comparison-tp2246106p2246106.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] classification algorithms with distance matrix

2010-06-07 Thread Peter Langfelder
On Mon, Jun 7, 2010 at 9:05 AM, sidahmed BENABDERRAHMANE
 wrote:
> Dear all,
>
> I have a problem when using some classification functions (Kmeans, PAM,
> FANNY...)  with a distance matrix, and i would to understand how it proceeds
> for the positioning of centroids after one execution step.
>
> In fact, in the classical formulation of the algorithm, after each step, to
> re-position the center, it calculates the distance between any elements of
> the old cluster and its center, or in my case I used  a distance matrix , so
> I do not understand how the algorithm can recalculates the distance between
> the newly generated center and other elements of the cluster knowing that
> the new center does not appear in the distance matrix and there is no way to
> calculate the distance between him and the elements of a cluster. ?
>

In my understading PAM stands for Partitioning Around Medoids. The
medoid of a cluster is the object with the smallest mean distance to
all other objects in the cluster. In each iteration, all objects are
assigned to their nearest medoid, and the medoids are updated if
necessary. The distance matrix is never recalculated. Someone please
correct me if I'm wrong.

Peter

__
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] as.integer

2010-06-07 Thread Greg Snow
Usually when read.table converts numbers to factors it means that there is a 
problem in the data file, an extra character somewhere.  It is best to fix the 
problem in the source data (or a copy of the source data) so that the data 
imports properly rather than try to fix it post hoc.  If that is not an option, 
then you can specify the colClasses argument to read.table to make sure that it 
reads the data into the type of variable that you want.  If you really need the 
post read.table solution, then lapply will run the same function (as.integer) 
on each column of a data frame (element of a list).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of aledanda
> Sent: Monday, June 07, 2010 8:05 AM
> To: r-help@r-project.org
> Subject: [R] as.integer
> 
> 
> Hi,
> 
> Is there a way to recursively change the variables imported with
> read.table(..) - and then attached with attach(..) - from as.factor to
> as.integer?
> I have about 9 variables that are now recognized as factors but I need
> to do
> statistics on them so I need to change them in as.integer. It works,
> but I
> wonder if there is a way to to this for all the variables in one go.
> 
> Thanks a lot for your help
> 
> Ale
> --
> View this message in context: http://r.789695.n4.nabble.com/as-integer-
> tp2245987p2245987.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 parse out string separated by special character

2010-06-07 Thread Greg Snow
Look at the strapply function in the gsubfn package.  It may do what you want.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of xin wei
> Sent: Monday, June 07, 2010 11:21 AM
> To: r-help@r-project.org
> Subject: [R] how to parse out string separated by special character
> 
> 
> hi, everyone:
> i have a data frame with one single character column as followings:
> DS_xxx_yyy_24hr_zzz_1
> DS_xxx_yyy_24hr_zzz_2
> DS_xxx_yyy_24hr_zzz_3
> DS_xxx_yyy_24hr_zzz_4
> DS_xxx_yyy_24hr_zzz_1
> DS_xxx_yyy_24hr_zzz_2
> DS_xxx_yyy_24hr_zzz_3
> DS_xxx_yyy_24hr_zzz_4
> DS_xxx_yyy_24hr_zzz_1
> 
> i need to parse out the time part like the followings:
> name   time
> DS_xxx_yyy_24hr_zzz_1  24hr
> DS_xxx_yyy_24hr_zzz_2  24hr
> DS_xxx_yyy_24hr_zzz_3  24hr
> DS_xxx_yyy_24hr_zzz_4  24hr
> DS_xxx_yyy_24hr_zzz_1  24hr
> DS_xxx_yyy_24hr_zzz_2  24hr
> DS_xxx_yyy_24hr_zzz_3  24hr
> DS_xxx_yyy_24hr_zzz_4  24hr
> DS_xxx_yyy_24hr_zzz_1  24hr
> 
> what function should I look at?
> i have tried: strsplit(data, '_') and get a giant list which is not
> what i
> need.
> 
> thanks in advance
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-
> parse-out-string-separated-by-special-character-tp2246301p2246301.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] Source of chickwts data

2010-06-07 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Chirok Han
> Sent: Monday, June 07, 2010 9:51 AM
> To: r-help
> Subject: [R] Source of chickwts data
> 
> I'm not sure if this is the right mailing list. My apologies if I'm
> sending the question to the wrong mailing list.
> (The r-packages list moderator suggested using the R-help list.)
> 
> My question is about the "chickwts" data in the datasets package.
> According to help(chickwts), the source of the data is
> 
>  Anonymous (1948) Biometrika, 35, 214.
> 
> But this reference seems irrelevant.
> (See http://www.jstor.org/stable/i315414.)
> 
> The help document also gives "McNeil, D. R. (1977) Interactive Data
> Analysis. New York: Wiley" as a reference, but unfortunately my local
> library does not keep the book. Could someone please help me find the
> correct source of the data?

McNeil's book, page 30, attributes it to
  "Anonymous query, Biometrics, 1948, page 214"

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> Many thanks.
> 
> Chirok
> 
> __
> 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] mgcv

2010-06-07 Thread Joris Meys
predict(sm1,type="terms",terms="s(x2)")

see ?predict.gam

Cheers
Joris

On Mon, Jun 7, 2010 at 7:25 PM, Dipa Hari  wrote:
>
>
> Hello Sir,
> I am using mgcv package for my data.
> My model is y~x1+f(x2),I want to find out the function f(x2) .
> Following is the code.
>
> sm1=gam(y~x1+s(x2),family=binomial, f)
> summary(sm1)
> plot(sm1,residuals=TRUE, xlab="AGE",pch=20)
>
> In this plot I am getting S(x2,1.93) on y axixs
> How should I get the function for x2 from this plot.or Is there anyother 
> procedure in R  to get this function or value for that particular 
> function.for example f(x2)= log(x2) so from that plot how can I get this kind 
> of formula for x2 variable?
> How can I find variance covariance matrix  for that model and confidence 
> interval for that model ? I tried delta method but I am not getting result.
> Hope you understand my question?
> Thanks
>
>
>
>
>
>        [[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.
>
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] Transforming list to data frame with corresponding columns

2010-06-07 Thread Henrique Dallazuanna
Try this:

`colnames<-`(do.call(rbind, lapply(all2, '[', nm <-
unique(unlist(sapply(all2, names), nm)

On Mon, Jun 7, 2010 at 4:20 PM, LCOG1  wrote:

>
> Hi all,
>   Consider the following.
>
>
> a<-list(c("MHsub","MHsub","SFD","Duplex"))
> b<-list(c("MHsub","MHsub","SFD"))
> c<-list(c("MHpark","SFD","SFD"))
> d<-list(c("MultiFam","MultiFam","MultiFam","Duplex"))
>
> all<-list(a,b,c,d)
> names(all)<-c("5","6","7","8")
> all2<-list()
> for(i in 1:length(all)){
> all2[[i]]<-table(unlist(all[i]))
> }
> names(all2)<-names(all)
>
> What i want to do is to put each of the elements of the list into a data
> frame where the element represents a row and each vector is accounted for,
> for all types within the entire list.  So where there isnt a particular
> vector a 0 is noted so that the final product looks like this:
>
>
>SFD Mhsub   Duplex  MultiFam
> 5   1  11   0
> 6   1  10   0
> 7   1  10   0
> 8   0  01   1
>
> Thanks for the insights.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246423.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

[[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] paste together a string object later to be utilized in a function

2010-06-07 Thread moleps
Sorry for bothering all of you. In the end it turned out to be much simpler 
than I thought. Takes a while to get used to the vectorizing idea. 



require(survival)
require(ggplot2)

ggkm<-function(time,event,stratum) {

stratum<-as.factor(stratum)
m2s<-Surv(time,as.numeric(event))

fit <- survfit(m2s ~ stratum)

w<-fit$time

k<-fit$surv
o<-length(levels(stratum))
strata<-c(rep(names(fit$strata[1:o]),fit$strata[1:o]))

upper<-fit$upper
lower<-fit$lower
f<-data.frame(w,k,strata,upper,lower)

r<-ggplot 
(f,aes(x=w,y=k,fill=strata,group=strata))+geom_line(aes(color=strata))+geom_ribbon(aes(ymin=lower,ymax=upper),alpha=0.3)+xlim(0,fit$maxtime)+ylim(0,1)

r<-r+scale_fill_brewer(f$strata,palette="Set1")+scale_color_brewer(f$strata,palette="Set1")
return(r)
}





data(lung)
with(lung,ggkm(time,status,sex))

with(lung,ggkm(time,status,pat.karno))





//M





On 7. juni 2010, at 22.31, Greg Snow wrote:

> Does the collapse argument to the paste function do what you want?  Possibly 
> nested inside another paste.
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
> 
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
>> project.org] On Behalf Of moleps
>> Sent: Sunday, June 06, 2010 1:51 PM
>> To: r-help@r-project.org
>> Subject: [R] paste together a string object later to be utilized in a
>> function
>> 
>> Dear r-listers,
>> 
>> I need to pass a string to a function. However the length of the string
>> is dependent on the length of a vector.
>> 
>> 
>> b<-length(h)
>> v<-paste("rep(names(ts$a[",1:b,"]),ts$a[",1:b,"])",sep="")
>> 
>> 
>> Is it possible somehow to pass this as an argument to a function later
>> on ?
>> 
>> 
>> 
>> Regards,
>> 
>> //M
>> 
>> __
>> 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] Very OT: World Cup Statistics

2010-06-07 Thread Albyn Jones
Paul

The FIFA database doesn't have times that goals are scored either.
The best I have found is at http://www.worldcup-history.com/, but you
have to check individual match reports for the times that goals are
scored.

albyn

On Mon, Jun 07, 2010 at 09:50:34PM +0100, Paul wrote:
> Hello,
>
> Sorry for the very Off TOpic post, but I need some data on past football 
> (soccer) world cups.  I'd like to find (or calculate) the time to the first 
> goal of each match (where a goal was scored).
>
> I''ve looked at the uefa website and can't find what I want, maybe someone 
> here can help ?
>
> Thanks
>
> Paul.
>
> __
> 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] Borders on a polygon

2010-06-07 Thread beloitstudent

Hi, I am trying to do some shading in R and am using the polygon() setting. 
I want the border on the top and bottom of the polygon, but not on the left
and right.  Is there a way to do this in R?  Thanks in advance!

beloitstudent
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Borders-on-a-polygon-tp2246646p2246646.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] Very OT: World Cup Statistics

2010-06-07 Thread Daniel Malter

these websites seem to have the data. though I have not checked for
completeness. the rsssf in particular is seems to be concerned with
collecting and archiving these kinds of football data:

http://www.rsssf.com/tablesw/worldcup.html

http://wapedia.mobi/en/1930_FIFA_World_Cup_Group_1

hope that helps,
daniel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Very-OT-World-Cup-Statistics-tp2246551p2246730.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] Source of chickwts data

2010-06-07 Thread Chirok Han
Many thanks. That's the right one.
It would be better corrected in the next version of R.

Thanks again.
Chirok

On Tue, Jun 8, 2010 at 6:01 AM, William Dunlap  wrote:
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Chirok Han
>> Sent: Monday, June 07, 2010 9:51 AM
>> To: r-help
>> Subject: [R] Source of chickwts data
>>
>> I'm not sure if this is the right mailing list. My apologies if I'm
>> sending the question to the wrong mailing list.
>> (The r-packages list moderator suggested using the R-help list.)
>>
>> My question is about the "chickwts" data in the datasets package.
>> According to help(chickwts), the source of the data is
>>
>>  Anonymous (1948) Biometrika, 35, 214.
>>
>> But this reference seems irrelevant.
>> (See http://www.jstor.org/stable/i315414.)
>>
>> The help document also gives "McNeil, D. R. (1977) Interactive Data
>> Analysis. New York: Wiley" as a reference, but unfortunately my local
>> library does not keep the book. Could someone please help me find the
>> correct source of the data?
>
> McNeil's book, page 30, attributes it to
>  "Anonymous query, Biometrics, 1948, page 214"
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>>
>> Many thanks.
>>
>> Chirok
>>
>> __
>> 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] Transforming list to data frame with corresponding columns

2010-06-07 Thread LCOG1

Henrique,
  The last message gave me exactly what i needed.  Im still not sure whats 
going on, i will need to reference the do.call function some more.  Thanks for 
your help.


Josh Roll
Lane Council of Governments
Transportation Planner
Office: 541-682-2454
Cell: 406-671-5069
jr...@lcog.org
www.lcog.org


From: Henrique Dallazuanna [via R] 
[mailto:ml-node+2246612-389423334-103...@n4.nabble.com]
Sent: Monday, June 07, 2010 2:31 PM
To: ROLL Josh F
Subject: Re: Transforming list to data frame with corresponding columns

Try this:

`colnames<-`(do.call(rbind, lapply(all2, '[', nm <-
unique(unlist(sapply(all2, names), nm)

On Mon, Jun 7, 2010 at 4:20 PM, LCOG1 <[hidden 
email]> wrote:

>
> Hi all,
>   Consider the following.
>
>
> a<-list(c("MHsub","MHsub","SFD","Duplex"))
> b<-list(c("MHsub","MHsub","SFD"))
> c<-list(c("MHpark","SFD","SFD"))
> d<-list(c("MultiFam","MultiFam","MultiFam","Duplex"))
>
> all<-list(a,b,c,d)
> names(all)<-c("5","6","7","8")
> all2<-list()
> for(i in 1:length(all)){
> all2[[i]]<-table(unlist(all[i]))
> }
> names(all2)<-names(all)
>
> What i want to do is to put each of the elements of the list into a data
> frame where the element represents a row and each vector is accounted for,
> for all types within the entire list.  So where there isnt a particular
> vector a 0 is noted so that the final product looks like this:
>
>
>SFD Mhsub   Duplex  MultiFam
> 5   1  11   0
> 6   1  10   0
> 7   1  10   0
> 8   0  01   1
>
> Thanks for the insights.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246423.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> [hidden email] 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

[[alternative HTML version deleted]]


__
[hidden email] 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 message @ 
http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246612.html
To unsubscribe from Transforming list to data frame with corresponding columns, 
click here< (link removed) ==>.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246619.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] Desolve package: How to pass thousand of parameters to C compiled code?

2010-06-07 Thread cmmu_mile
Hi,

I have used DeSolve package for my ODE problem regarding infectious disease 
transmission and currently am trying to pass lots (roughly a thousand) of model 
parameters to the C compiled model (I have to use C compiled code instead of R 
code purely because of the speed).

I can't go define it one by one as it gonna take ages to finish and also quite 
difficult to revise. I have read the instructions in "Writing Code in Compiled 
Languages", which is very well written, but still have no clue on how to 
proceed.

Please can anyone suggest the best way to go about this, and also the places 
where I can find examples of DeSolve C compiled code.

Thank you very much in advance.

Nar Pun
CMMU/MUTH

--
This message was sent on behalf of cmmu_m...@yahoo.com at openSubscriber.com
http://www.opensubscriber.com/messages/r-help@r-project.org/topic.html

__
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] Borders on a polygon

2010-06-07 Thread Sean Anderson
On Mon, Jun 7, 2010 at 6:55 PM, beloitstudent wrote:
> [...] I am trying to do some shading in R and am using the polygon() setting.
> I want the border on the top and bottom of the polygon, but not on the left
> and right. [...]

One way would be to add the borders after as lines. For example:

plot.new()
polygon(c(0,1,1,0), c(0,0,1,1), col = "yellow", border = NA)
lines(c(0,1), c(0,0))
lines(c(0,1), c(1,1))

__
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] barchart but with boxes

2010-06-07 Thread Daisy Englert Duursma
Thanks to all,

I did eventually come up with a solution which involved sub-setting
the data first into categories, making an empty plot, and then
plotting rectangles.  I really like the ggplot2 and I will use that
next time.

My ugly script is below

Thanks,
Daisy


plot(1, xlim=c(5,45),ylim=c(0,10),xlab="Year",ylab="+/- 1 \u03c3 Mean
Patch Size (ha)",axes=F,type="n")
title(main = list("Patch Size Agreement", cex=1.4))
axis(2)
box()
mtext(c(2010,2030,2050,2070),side=1,line = 1, at=c(10,20,30,40))
position<-seq(10, 40, length.out=4 )
xlef<-position-2.5
xrig <-position+2.5

for(i in 1:nrow(sub00)){
min_y<-sub00$minsd_ha[i]
max_y<-sub00$maxsd_ha[i]
xleft<-xlef[1]
xrigh<-xrig[1]
rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 
0, 0, alpha=0.03))
}

for(i in 1:nrow(sub01)){
min_y<-sub01$minsd_ha[i]
max_y<-sub01$maxsd_ha[i]
xleft<-xlef[2]
xrigh<-xrig[2]
rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 
0, 0, alpha=0.03))
}


for(i in 1:nrow(sub02)){
min_y<-sub02$minsd_ha[i]
max_y<-sub02$maxsd_ha[i]
xleft<-xlef[3]
xrigh<-xrig[3]
rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 
0, 0, alpha=0.03))
}


for(i in 1:nrow(sub03)){
min_y<-sub03$minsd_ha[i]
max_y<-sub03$maxsd_ha[i]
xleft<-xlef[4]
xrigh<-xrig[4]
rect(xleft, min_y, xrigh, max_y,border = NA,col=rgb(0, 
1, 0, alpha=0.03))
}

__
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] color of histgram in Psych package (pairs.panels)

2010-06-07 Thread elaine kuo
Hello,

I searched the archives but found no answers.
How to modify the hisgram color of function pairs.panels of Psych package ?

I tried col() but it was the line color modified.

Thanks.

Elaine

[[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] Ignoring missing elements in data.frame()

2010-06-07 Thread Scott Chamberlain
Hi Joris,

Thanks very much. I think the %in% ls() was the key. I just needed to know
how to select elements that existed  in ls().

Scott

On Sat, Jun 5, 2010 at 4:22 PM, Joris Meys  wrote:

> Hi,
>
> One possible way to get around it is using following idea :
> X1 <- rnorm(10)
> X2 <- rnorm(10)
>
> Names <- c("X1","X2","X3")
> Names <- Names[Names %in% ls()]
>
> n <- length(Names)
> p <- 10   #length of each object
> output <- matrix(NA,ncol=n,nrow=p)
>
> for(i in 1:n){
>output[,i] <- get(Names[i])
> }
> output <- as.data.frame(output)
> names(output) <- Names
>
> You can also use an eval-parse construct like this :
> ## Alternative
> Names <- c("X1","X2","X3")
> Names <- Names[Names %in% ls()]
> Names <- paste(Names,collapse=",")
> expr = paste("output <- data.frame(",Names,")",sep="")
> eval(parse(text=expr))
>
> Both are not really the most optimal solution, but do work. It would
> be better if you made a list or matrix beforehand and then save the
> results of the calculations in that list or matrix whenever the
> calculation turns out to give a result.
>
> Cheers
> Joris
>
> On Sat, Jun 5, 2010 at 1:23 AM, Scott Chamberlain 
> wrote:
> > Hello, I am trying to make a data frame from many elements after
> > running a function which creates many elements, some of which may not
> > end up being real elements due to errors or missing data. For example,
> > I have the following three elements p1s, p2s, and p3s. p9s did not
> > generate the same data as there was an error in the function for some
> > reason. I currently have to delete p9s from the data.frame() command
> > to get the data.frame to work.  How can I make a data frame by somehow
> > ignoring elements (e.g., p9s) that do not exist, without having to
> > delete each missing element from data.frame()? The below is an example
> > of the code.
> >
> >> p1s
> >  statistic parameter p.value
> > [1,] 3.606518  153   0.0004195377
> >> p2s
> >  statistic parameter p.value
> > [1,] -3.412436 8 0.009190015
> >> p3s
> >  statistic parameter p.value
> > [1,] 1.543685  599   0.1231928
> >
> >> t(data.frame(t(p1s),t(p2s),t(p3s),t(p9s)))
> > Error in t(p9s) : object 'p9s' not found
> >
> >
> > Thanks, Scott Chamberlain
> > Rice University
> > Houston, TX
> >
> > __
> > 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.
> >
>
>
>
> --
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
>

[[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] Matrix to "database" -- best practices/efficiency?

2010-06-07 Thread Jonathan Greenberg
I have a matrix of, say, M and N dimensions:

my_matrix=matrix(c(1:60),nrow=6,ncol=10)

I have two "id" vectors corresponding to the rows and columns, e.g.:

id_m=seq(10,60,by=10)
id_n=seq(100,1000,by=100)

I would like to create a "proper" database (let's say a data.frame for
this example -- i'm going to be loading these into an SQLite database,
but we'll leave that complication out of this discussion for now) of m
x n rows, and 3 columns, where the 3 columns relate to the values from
m, n, and my_matrix respectively, e.g. a single row follows the form:

c(id_m[a],id_n[b],my_matrix[a,b])

I can, of course, for-loop this thing with an if-then, e.g.:

***

for (a in 1:length(id_m))
{
for (b in 1:length(id_n))
{
if ((a==1) && (b==1))
{
my_database=c(id_m[a],id_n[b],my_matrix[a,b])
} else
{   

my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
}
}
}

***

But my gut is telling me this is an incredibly inefficient way of
doing this -- is there a faster approach to doing this same process?
Thanks!

--j

__
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 statistical program 2.10.0

2010-06-07 Thread Datta, Ronjon
Hi,
I just need to know where the R was developed, for a journal article citation.

Thanks
Ronjon

[[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] Filtering out a data.frame

2010-06-07 Thread Jeff08

Sample Data.Frame format

Name is Returns.nodup

X   id ticker  date_ adjClose totret RankStk
427225 427225 00174410AHS 2001-11-1321.661001235


"id" uniquely defines a row


What I am trying to do is filter out id's that have less than 1500 data
points (by date)

First, I used

total<-by(Returns.nodup, Returns.nodup$id,nrow)

which subsetted by ID and calculated the number of data points for each ID

Now I am trying to figure out a way to use this to filter out the original
data.frame (Returns.nodup)

I have tried using the following, but it is VERY slow:

z<-unlist(lapply(1:length(y), function(i) which(a$id==y[i]) ))
Returns.filtered<-Returns.nodup[z,]

Is there a faster way to do this?





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Filtering-out-a-data-frame-tp2246814p2246814.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] About lm.ridge in the MASS package

2010-06-07 Thread baghaliforo...@yahoo.com
Hi,

I had a questions about doing ridge regression in R. 

Why is it that when I try this on datasets with more predictors than samples 
(p>n) using lambda=0, it still finds coefficients for all predictors? I thought 
when lambda=0, it should be like ordinary regression and therefore not find 
coefficients for all due to singularity? 

I would greatly appreciate your help.

Thank you,

--James K.

__
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] Adding in Missing Data

2010-06-07 Thread Jeff08

Sample Data.Frame format

Name is Returns.names

X   id ticker  date_ adjClose totret RankStk
427225 427225 00174410AHS 2001-11-1321.661001235


"id" uniquely defines a row


What I am trying to do is add missing data for each ID.

Important Information: Date is not continuous, the data points are for
trading days, so weekends/certain holidays are off

x<-unique(Returns.names$date_) gives me the list of all the possible trading
days.

For days that are missing, I would like to add a row for that date & the
same totret as the previous day.

I cant think of an easy way to do this


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Adding-in-Missing-Data-tp2246825p2246825.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 statistical program 2.10.0

2010-06-07 Thread Erik Iverson

Datta, Ronjon wrote:

Hi,
I just need to know where the R was developed, for a journal article citation.


There's a function for that!

citation()

__
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] Filtering out a data.frame

2010-06-07 Thread Erik Iverson

Jeff08 wrote:

Sample Data.Frame format

Name is Returns.nodup

X   id ticker  date_ adjClose totret RankStk
427225 427225 00174410AHS 2001-11-1321.661001235


"id" uniquely defines a row


What I am trying to do is filter out id's that have less than 1500 data
points (by date)

First, I used

total<-by(Returns.nodup, Returns.nodup$id,nrow)

which subsetted by ID and calculated the number of data points for each ID

Now I am trying to figure out a way to use this to filter out the original
data.frame (Returns.nodup)

I have tried using the following, but it is VERY slow:

z<-unlist(lapply(1:length(y), function(i) which(a$id==y[i]) ))
Returns.filtered<-Returns.nodup[z,]

Is there a faster way to do this?



Most likely, yes.  But without a reproducible example, it's difficult to think 
about the problem.  Can you please give us one?


If not, you can probably cobble something together using ?table and ?%in% I'm 
guessing.


__
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 statistical program 2.10.0

2010-06-07 Thread Jorge Ivan Velez
Hi Ronjon,

>From citation():

> citation()

To cite R in publications use:

  R Development Core Team (2010). R: A language and environment for
statistical computing.
  R Foundation for Statistical Computing, Vienna, Austria. ISBN
3-900051-07-0, URL
  http://www.R-project.org.

A BibTeX entry for LaTeX users is

  @Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Development Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2010},
note = {{ISBN} 3-900051-07-0},
url = {http://www.R-project.org},
  }

We have invested a lot of time and effort in creating R, please cite it when
using it for
data analysis. See also ‘citation("pkgname")’ for citing R packages.

HTH,
Jorge


On Tue, Jun 8, 2010 at 12:03 AM, Datta, Ronjon <> wrote:

> Hi,
> I just need to know where the R was developed, for a journal article
> citation.
>
> Thanks
> Ronjon
>
>[[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.
>

[[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] Matrix to "database" -- best practices/efficiency?

2010-06-07 Thread Gabor Grothendieck
Try this:

> mm <- matrix(1:6, 3, dimnames = list(LETTERS[1:3], letters[1:2]))
> mm
  a b
A 1 4
B 2 5
C 3 6
> library(reshape)
> melt(mm)
  X1 X2 value
1  A  a 1
2  B  a 2
3  C  a 3
4  A  b 4
5  B  b 5
6  C  b 6


On Mon, Jun 7, 2010 at 10:33 PM, Jonathan Greenberg
 wrote:
> I have a matrix of, say, M and N dimensions:
>
> my_matrix=matrix(c(1:60),nrow=6,ncol=10)
>
> I have two "id" vectors corresponding to the rows and columns, e.g.:
>
> id_m=seq(10,60,by=10)
> id_n=seq(100,1000,by=100)
>
> I would like to create a "proper" database (let's say a data.frame for
> this example -- i'm going to be loading these into an SQLite database,
> but we'll leave that complication out of this discussion for now) of m
> x n rows, and 3 columns, where the 3 columns relate to the values from
> m, n, and my_matrix respectively, e.g. a single row follows the form:
>
> c(id_m[a],id_n[b],my_matrix[a,b])
>
> I can, of course, for-loop this thing with an if-then, e.g.:
>
> ***
>
> for (a in 1:length(id_m))
> {
>        for (b in 1:length(id_n))
>        {
>                if ((a==1) && (b==1))
>                {
>                        my_database=c(id_m[a],id_n[b],my_matrix[a,b])
>                } else
>                {
>                        
> my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
>                }
>        }
> }
>
> ***
>
> But my gut is telling me this is an incredibly inefficient way of
> doing this -- is there a faster approach to doing this same process?
> Thanks!
>
> --j
>
> __
> 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] Adding in Missing Data

2010-06-07 Thread Erik Iverson

Jeff08 wrote:

Sample Data.Frame format

Name is Returns.names

X   id ticker  date_ adjClose totret RankStk
427225 427225 00174410AHS 2001-11-1321.661001235


"id" uniquely defines a row


What I am trying to do is add missing data for each ID.

Important Information: Date is not continuous, the data points are for
trading days, so weekends/certain holidays are off

x<-unique(Returns.names$date_) gives me the list of all the possible trading
days.

For days that are missing, I would like to add a row for that date & the
same totret as the previous day.

I cant think of an easy way to do this



See this thread...

http://www.opensubscriber.com/message/r-h...@stat.math.ethz.ch/6986471.html

specifically the last post by Gabor.

__
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] Matrix to "database" -- best practices/efficiency?

2010-06-07 Thread Jorge Ivan Velez
Hi Jonathan,

Following Gabor Grothendieck's advice, try also:

mm <- matrix(1:6, 3, dimnames = list(LETTERS[1:3], letters[1:2]))
as.data.frame.table(mm)

HTH,
Jorge


On Mon, Jun 7, 2010 at 10:33 PM, Jonathan Greenberg <> wrote:

> I have a matrix of, say, M and N dimensions:
>
> my_matrix=matrix(c(1:60),nrow=6,ncol=10)
>
> I have two "id" vectors corresponding to the rows and columns, e.g.:
>
> id_m=seq(10,60,by=10)
> id_n=seq(100,1000,by=100)
>
> I would like to create a "proper" database (let's say a data.frame for
> this example -- i'm going to be loading these into an SQLite database,
> but we'll leave that complication out of this discussion for now) of m
> x n rows, and 3 columns, where the 3 columns relate to the values from
> m, n, and my_matrix respectively, e.g. a single row follows the form:
>
> c(id_m[a],id_n[b],my_matrix[a,b])
>
> I can, of course, for-loop this thing with an if-then, e.g.:
>
> ***
>
> for (a in 1:length(id_m))
> {
>for (b in 1:length(id_n))
>{
>if ((a==1) && (b==1))
>{
>my_database=c(id_m[a],id_n[b],my_matrix[a,b])
>} else
>{
>
>  my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
>}
>}
> }
>
> ***
>
> But my gut is telling me this is an incredibly inefficient way of
> doing this -- is there a faster approach to doing this same process?
> Thanks!
>
> --j
>
> __
> 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.
>

[[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] Matrix to "database" -- best practices/efficiency?

2010-06-07 Thread Bill.Venables
I think what you are groping for is something like this

my_matrix <- matrix(1:60, nrow = 6)
id_a <- seq(10,60,by=10)
id_b <- seq(100,1000,by=100)
my_database <- cbind(
  expand.grid(id_a = id_a, id_b = id_b),
  mat = as.vector(my_matrix)
)


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Jonathan Greenberg
Sent: Tuesday, 8 June 2010 12:34 PM
To: r-help
Subject: [R] Matrix to "database" -- best practices/efficiency?

I have a matrix of, say, M and N dimensions:

my_matrix=matrix(c(1:60),nrow=6,ncol=10)

I have two "id" vectors corresponding to the rows and columns, e.g.:

id_m=seq(10,60,by=10)
id_n=seq(100,1000,by=100)

I would like to create a "proper" database (let's say a data.frame for
this example -- i'm going to be loading these into an SQLite database,
but we'll leave that complication out of this discussion for now) of m
x n rows, and 3 columns, where the 3 columns relate to the values from
m, n, and my_matrix respectively, e.g. a single row follows the form:

c(id_m[a],id_n[b],my_matrix[a,b])

I can, of course, for-loop this thing with an if-then, e.g.:

***

for (a in 1:length(id_m))
{
for (b in 1:length(id_n))
{
if ((a==1) && (b==1))
{
my_database=c(id_m[a],id_n[b],my_matrix[a,b])
} else
{   

my_database=rbind(my_database,c(id_m[a],id_n[b],my_matrix[a,b]))
}
}
}

***

But my gut is telling me this is an incredibly inefficient way of
doing this -- is there a faster approach to doing this same process?
Thanks!

--j

__
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] Help with seting up comparison

2010-06-07 Thread Bart Joosen

Greg,


the animals are a sample of a larger population, as you guessed.

I used lmer to estimate the effects:


> lmer(Count~Animal | Day, dat)
Linear mixed model fit by REML 
Formula: Count ~ Animal | Day 
   Data: dat 
  AIC  BIC logLik deviance REMLdev
 1554 1574   -772 15421544
Random effects:
 Groups   NameVariance   Std.Dev.  Corr  
 Day  (Intercept) 1.7707e-02 0.1330678   
  Animal  4.0287e-05 0.0063472 1.000 
 Residual 2.0917e+00 1.4462790   
Number of obs: 430, groups: Day, 4

Fixed effects:
Estimate Std. Error t value
(Intercept)   4.2423 0.1257   33.76


But how does this help me to state that there is no effect within an animal?
anova doesn't seems to work (gives an empty table)
I'm sorry, but I have no experience with lme models, only lm.


Thanks for your time


Bart



> From: greg.s...@imail.org
> To: bartjoo...@hotmail.com; r-help@r-project.org
> Date: Mon, 7 Jun 2010 14:54:47 -0600
> Subject: RE: [R] Help with seting up comparison
> 
> Are you interested in only those 35 animals (not every going to look at any 
> other animals other than those 35, but you want to predict what will happen 
> for those 35)? Or are the 35 animals a sample of a larger population of 
> animals?
> 
> If the later (seems the most likely case) then you probably want to use a 
> mixed effects model (nlme or lme4 packages) with animal as a random effect, 
> then just look at the fixed effect of day.
> 
> Hope this helps,
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
> 
> 
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> > project.org] On Behalf Of Bart Joosen
> > Sent: Monday, June 07, 2010 9:14 AM
> > To: r-help@r-project.org
> > Subject: [R] Help with seting up comparison
> > 
> > 
> > Hi,
> > 
> > I tried on this, but couldn't figure it out:
> > Suppose I have a dataframe as follows:
> > dat <- data.frame(Day=rep(rep(c(1,2), each=4),2), Animal = rep(c(1,2),
> > each=8), Count=c(rnorm(8, 100), rnorm(8,90)))
> > 
> > 2 animals are being examined on 2 different days. Count is the result.
> > 
> > Now I need to point out whether or not there is a difference between
> > the
> > days.
> > I did this by an ANOVA test, while first converting the animal and day
> > to a
> > factor variable:
> > dat$Animal <- as.factor(dat$Animal)
> > dat$Day <- as.factor(dat$Day)
> > mod <- lm(Count ~Animal * Day,dat)
> > anova(mod)
> > 
> > Now I have to check for difference within the animal, to see if there
> > is a
> > difference in count for each day. (In my real data, I have 35 animals,
> > with
> > 4 days, and 4 results).
> > I thought about a Tukey HSD test, but this compares every day of every
> > animal with every other day of every other animal. (TukeyHSD(aov(mod)))
> > 
> > Any idea about which function (or model for lm) to use to only compare
> > days
> > within every animal?
> > 
> > Best regards
> > 
> > Bart
> > 
> > 
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Help-with-
> > seting-up-comparison-tp2246106p2246106.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.
  
_
Hotmail: betrouwbare e-mail met krachtige spambescherming.

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