Re: [R] Problem with installing a package in R!

2010-08-08 Thread Peter Dalgaard
gagea wrote:
> Dear friends,
> 
> I am having problem with installing some packages in R in Ubuntu like
> "ISwR". Bellow is the outcome. Anybody can help me to solve this problem.
> Thanks a lot and sorry if it is very simple question. 
> 
> 
> install.packages("ISwr")

...ISwR..., I presume.

> Loading Tcl/Tk interface ... done
> trying URL 'http://probability.ca/cran/src/contrib/ISwR_2.0-5.tar.gz'
> Content type 'application/x-gzip' length 157441 bytes (153 Kb)
> opened URL
> ==
> downloaded 153 Kb
> 
> ERROR: failed to lock directory
> ‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9’ for modifying


> Try removing ‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9/00LOCK’

Did you try

rm -rf /home/ubuntu/R/i486-pc-linux-gnu-library/2.9/00LOCK

?

The lock dir is there to prevent two processes from messing with the
same files at the same time, but can remain if an installation
terminates prematurely.

Do you have the appropriate permissions? It ia not clear to me whether
that is supposed to be a user-level library or a system one. Is your
user name "ubuntu"? (And is ubuntu really still shipping 2.9.x?)


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] Extract values from data frame in R

2010-08-08 Thread David Winsemius


On Aug 9, 2010, at 2:16 AM, Alexander Eggel wrote:

Using R, I would like to find out which Samples (S1, S2, S3, S4, S5)  
fulfill
the following criteria:contain minimally one value (x, y or z)  
bigger than

4. Any ideas? Thanks, Alex.


data

 Sample   xy  z
1S1   -0.35.32.5
2S20.40.2   -1.2
3S31.2   -0.63.2
4S44.30.75.7
5S52.44.32.3



data$Sample[apply(data[, -1], 1, function(xyz) any(xyz > 4))]
[1] "S1" "S4" "S5"


David Winsemius, MD
West Hartford, CT

__
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] Extract values from data frame in R

2010-08-08 Thread Erik Iverson

On 08/09/2010 01:16 AM, Alexander Eggel wrote:

Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill
the following criteria:contain minimally one value (x, y or z) bigger than
4. Any ideas? Thanks, Alex.


data

   Sample   xy  z
1S1   -0.35.32.5
2S20.40.2   -1.2
3S31.2   -0.63.2
4S44.30.75.7
5S52.44.32.3


Untested:

Sample[apply(Sample[-1], 1, function(x) any(x) > 4)), "Sample"]

__
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] Extract values from data frame in R

2010-08-08 Thread Alexander Eggel
Using R, I would like to find out which Samples (S1, S2, S3, S4, S5) fulfill
the following criteria:contain minimally one value (x, y or z) bigger than
4. Any ideas? Thanks, Alex.

> data
  Sample   xy  z
1S1   -0.35.32.5
2S20.40.2   -1.2
3S31.2   -0.63.2
4S44.30.75.7
5S52.44.32.3

[[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] Good Book To Work Through This Summer

2010-08-08 Thread TGS
Dear R users,

I'm hoping to get a few suggestions about which books are good to follow along 
and learn R.

I'm hoping to spend the summer going through a good R book as it is applied in 
linear regression.

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


Re: [R] Invalid plot type '1'

2010-08-08 Thread Stephen Liu
Hi Erik,

I got it.  Thanks


On
R-Project
The R Manuals
http://www.r-project.org/

There are several manuals.  


Whether I should follow:-

An Introduction to R
http://www.r-project.org/


B.R.
Stephen L



- Original Message 
From: Erik Iverson 
To: Stephen Liu 
Cc: r-help@r-project.org
Sent: Mon, August 9, 2010 10:28:16 AM
Subject: Re: [R] Invalid plot type '1'

On 08/08/2010 09:14 PM, Stephen Liu wrote:
> Hi Erik,
>
> I followed following video;
>
> Statistics with R (part 3: plot and history tutorial)
> http://www.youtube.com/watch?v=NfH5peM1RtI&feature=related
>
> It is type = "1".
>
> A graph was generated there.  But I got an error msg
>

No, it was type = "l" (the letter 'el'), which is short for "lines" as seen in 
?plot.

Listen on the video:

Start at 2:45,

"type equals line 'l'" is what the presenter says... Clearly it is an "l" (the 
letter el).

Regardless, the official documentation for R is not YouTube videos.  ?plot 
clearly tells you what are valid values for the "type" parameter in plot.

>
> - Original Message 
> From: Erik Iverson
> To: Stephen Liu
> Cc: r-help@r-project.org
> Sent: Mon, August 9, 2010 9:55:51 AM
> Subject: Re: [R] Invalid plot type '1'
>
> On 08/08/2010 08:47 PM, Stephen Liu wrote:
>> Hi folks,
>>
>>> x
>> [1] 1 2 3 4 5
>>> y
>> [1]  6  7  8  9 10
>>
>>> plot(x,y, type = "1" )
>> Error in plot.xy(xy, type, ...) : invalid plot type '1'
>>
>>
>> I looked on man plot but unable to resolve.  Please help.  TIA
>
> You never say what you expect type = "1" (that's the digit "1") to do.
>
> Did you mean "l" instead of "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.


[R] R Base Code

2010-08-08 Thread nancy_shackelford

Hello all,

I need to imitate the 'q' function (qnorm, qweibull, etc) for Clark's 2Dt
distribution model.  I'm not skilled enough in R to code it myself, so I
thought I could find the base code for one of the existing 'q' functions and
just modify it.  However, I'm having trouble navigating through the R Source
Code on the CRAN website.  I've searched some forum and help sites, but I
can't find anything specific on locating function codes.  

I also read somewhere that Clark's 2Dt is available in the R distribution
functions, but I haven't found anything that confirms that.  

Help?

Thanks,

Nancy
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-Base-Code-tp2318112p2318112.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] Regular Expression

2010-08-08 Thread Michael Bedward
And my \\3 should have been a \\2 anyway !

On 9 August 2010 12:23, Michael Bedward  wrote:
> Was going to suggest gsub("^[0-9]+ (SPE )?([^ -])( -.*)?", "\\3", s)
> but I see Wu Gong beat me to the punch with a nicer one :)
>
> On 9 August 2010 12:13, Wu Gong  wrote:
>>
>> gsub(pattern = "^[0-9]+ (SPE )*(\\w+) - .*$", "\\2", dat)
>>
>

__
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] Regular Expression

2010-08-08 Thread Michael Bedward
Was going to suggest gsub("^[0-9]+ (SPE )?([^ -])( -.*)?", "\\3", s)
but I see Wu Gong beat me to the punch with a nicer one :)

On 9 August 2010 12:13, Wu Gong  wrote:
>
> gsub(pattern = "^[0-9]+ (SPE )*(\\w+) - .*$", "\\2", dat)
>

__
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] Invalid plot type '1'

2010-08-08 Thread Erik Iverson

On 08/08/2010 09:14 PM, Stephen Liu wrote:

Hi Erik,

I followed following video;

Statistics with R (part 3: plot and history tutorial)
http://www.youtube.com/watch?v=NfH5peM1RtI&feature=related

It is type = "1".

A graph was generated there.  But I got an error msg



No, it was type = "l" (the letter 'el'), which is short for "lines" as seen in 
?plot.


Listen on the video:

Start at 2:45,

"type equals line 'l'" is what the presenter says... Clearly it is an "l" (the 
letter el).


Regardless, the official documentation for R is not YouTube videos.  ?plot 
clearly tells you what are valid values for the "type" parameter in plot.




- Original Message 
From: Erik Iverson
To: Stephen Liu
Cc: r-help@r-project.org
Sent: Mon, August 9, 2010 9:55:51 AM
Subject: Re: [R] Invalid plot type '1'

On 08/08/2010 08:47 PM, Stephen Liu wrote:

Hi folks,


x

[1] 1 2 3 4 5

y

[1]  6  7  8  9 10


plot(x,y, type = "1" )

Error in plot.xy(xy, type, ...) : invalid plot type '1'


I looked on man plot but unable to resolve.  Please help.  TIA


You never say what you expect type = "1" (that's the digit "1") to do.

Did you mean "l" instead of "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] efficient matrix element comparison

2010-08-08 Thread Nikhil Kaza

How about

a <- which(row(matchM)!=matchM)
b <- matchM[a]
diag(collusionM[a,b]) <-1


Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.l...@gmail.com

On Aug 8, 2010, at 8:43 PM, david h shanabrook wrote:

It is a simple problem in that I simply want to convert the For loop  
to a more efficient method.  It simply loops through a large vector  
checking if the numeric element is not equal to the index of that  
element.  The following example demonstrates a simplified example:



rows <- 10
collusionM <- Matrix(0,10,10,sparse=TRUE)
matchM <- matrix(c(1,2,3,4,4,6,7,9,9,10))

for (j in 1:rows) if (j != matchM[j]) collusionM[j,matchM[j]] <-  
collusionM[j,matchM[j]]+1

collusionM

10 x 10 sparse Matrix of class "dgCMatrix"

[1,] . . . . . . . . . .
[2,] . . . . . . . . . .
[3,] . . . . . . . . . .
[4,] . . . . . . . . . .
[5,] . . . 1 . . . . . .
[6,] . . . . . . . . . .
[7,] . . . . . . . . . .
[8,] . . . . . . . . 1 .
[9,] . . . . . . . . . .
[10,] . . . . . . . . . .

Again, this works, I just need the for loop to be more efficient as  
in my application rows=37000, and I need to do this 100 times.


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.


__
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] Invalid plot type '1'

2010-08-08 Thread Stephen Liu
Hi Erik,

I followed following video;

Statistics with R (part 3: plot and history tutorial) 
http://www.youtube.com/watch?v=NfH5peM1RtI&feature=related

It is type = "1".

A graph was generated there.  But I got an error msg


B.R.
Stephen




- Original Message 
From: Erik Iverson 
To: Stephen Liu 
Cc: r-help@r-project.org
Sent: Mon, August 9, 2010 9:55:51 AM
Subject: Re: [R] Invalid plot type '1'

On 08/08/2010 08:47 PM, Stephen Liu wrote:
> Hi folks,
>
>> x
> [1] 1 2 3 4 5
>> y
> [1]  6  7  8  9 10
>
>> plot(x,y, type = "1" )
> Error in plot.xy(xy, type, ...) : invalid plot type '1'
>
>
> I looked on man plot but unable to resolve.  Please help.  TIA

You never say what you expect type = "1" (that's the digit "1") to do.

Did you mean "l" instead of "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] Regular Expression

2010-08-08 Thread Wu Gong

gsub(pattern = "^[0-9]+ (SPE )*(\\w+) - .*$", "\\2", dat)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Regular-Expression-tp2318086p2318101.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] Invalid plot type '1'

2010-08-08 Thread Erik Iverson

On 08/08/2010 08:47 PM, Stephen Liu wrote:

Hi folks,


x

[1] 1 2 3 4 5

y

[1]  6  7  8  9 10


plot(x,y, type = "1" )

Error in plot.xy(xy, type, ...) : invalid plot type '1'


I looked on man plot but unable to resolve.  Please help.  TIA


You never say what you expect type = "1" (that's the digit "1") to do.

Did you mean "l" instead of "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.


[R] Invalid plot type '1'

2010-08-08 Thread Stephen Liu
Hi folks,

> x
[1] 1 2 3 4 5
> y
[1]  6  7  8  9 10

> plot(x,y, type = "1" )
Error in plot.xy(xy, type, ...) : invalid plot type '1'


I looked on man plot but unable to resolve.  Please help.  TIA


B.R.
Stephen L



__
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] Need help on heatmap, K-means and hhierarchical clustering methods

2010-08-08 Thread Erik Iverson

On 08/08/2010 08:36 PM, meetsiddu1 wrote:


Hi folks,

I am new to the R software. I have been going through different materials to
know more about R.
I have the R software installed on my windows machine.I would like to know
the R source code for the following problems on iris flower data set.

I need to do the cluster analysis project with the iris data set. The goal
is to cluster the flowers
according to their Sepal.Length, Sepal.Width, Petal.Length, and Petal.Width
information. Eventually we want to see whether they fall into three
clusters, which
corresponds to the three species. and complete the following questions.

a. Make a heat map of the above dissimilarity matrix(iris data).
b. Cluster the iris data using K-Means methods with k=3
c. Cluster the iris data using an hierarchical clustering method of your
choice.
Plot the related dendrogram. Use the R functions hclust()and dist() (as well
as function daisy())

I am new to this forum as well. I hope you guys help out in finishing this
project.


This sounds like homework.  The list is not supposed to help with homework. The 
analyses seem fairly straight-forward.  If you have any more specific questions 
that are genuine sticking points, feel free to ask.  But it appears you haven't 
even tried to answer these questions on your own. What have you tried?


__
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] Regular Expression

2010-08-08 Thread Steven Kang
Hi all,

>From a list of strings, I desire to filter out the followings:
1. Digits at the beginning of the strings
2. Character "SPE" following the digits (if it exists)
3. Any characters followed by hyphen

The following produces the desired result, but would like to know whether
this can be done more efficiently.

Any suggestions would be much appreciated.


dat <- c("2148 SPE MAR - CCC", "9843 SPE ANN - BBB", "56748 LIF - AA", "3489
SPE GEN - CC", "4752473 MAR - AA", "980843 SPE PEN - CC")
> dat
[1] "2148 SPE MAR - CCC"  "9843 SPE ANN - BBB"  "56748 LIF - AA"  "3489
SPE GEN - CC"   "4752473 MAR - AA""980843 SPE PEN - CC"

dd <- sub(pattern = "^[0-9]+[[:blank:]]", "", dat)
dd <- sub(pattern = "SPE ", "", dd)
dd <- substr(x = dd, start = 1, stop = regexpr("-", dd) - 2)
> dd
[1] "MAR" "ANN" "LIF" "GEN" "MAR" "PEN"


-- 
Steven

[[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] Need help on heatmap, K-means and hhierarchical clustering methods

2010-08-08 Thread meetsiddu1

Hi folks,

I am new to the R software. I have been going through different materials to
know more about R.
I have the R software installed on my windows machine.I would like to know
the R source code for the following problems on iris flower data set.

I need to do the cluster analysis project with the iris data set. The goal
is to cluster the flowers
according to their Sepal.Length, Sepal.Width, Petal.Length, and Petal.Width
information. Eventually we want to see whether they fall into three
clusters, which
corresponds to the three species. and complete the following questions.

a. Make a heat map of the above dissimilarity matrix(iris data).
b. Cluster the iris data using K-Means methods with k=3
c. Cluster the iris data using an hierarchical clustering method of your
choice. 
Plot the related dendrogram. Use the R functions hclust()and dist() (as well
as function daisy())

I am new to this forum as well. I hope you guys help out in finishing this
project.

Please let me know if any further information is needed.

Thanks
Siddu

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-on-heatmap-K-means-and-hhierarchical-clustering-methods-tp2318085p2318085.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] efficient matrix element comparison

2010-08-08 Thread Henrique Dallazuanna
Try this:

Matrix(diag(duplicated(matchM)), sparse = TRUE)

On Sun, Aug 8, 2010 at 9:43 PM, david h shanabrook
wrote:

> It is a simple problem in that I simply want to convert the For loop to a
> more efficient method.  It simply loops through a large vector checking if
> the numeric element is not equal to the index of that element.  The
> following example demonstrates a simplified example:
>
> > rows <- 10
> > collusionM <- Matrix(0,10,10,sparse=TRUE)
> > matchM <- matrix(c(1,2,3,4,4,6,7,9,9,10))
> >
> > for (j in 1:rows) if (j != matchM[j]) collusionM[j,matchM[j]] <-
> collusionM[j,matchM[j]]+1
> > collusionM
> 10 x 10 sparse Matrix of class "dgCMatrix"
>
>  [1,] . . . . . . . . . .
>  [2,] . . . . . . . . . .
>  [3,] . . . . . . . . . .
>  [4,] . . . . . . . . . .
>  [5,] . . . 1 . . . . . .
>  [6,] . . . . . . . . . .
>  [7,] . . . . . . . . . .
>  [8,] . . . . . . . . 1 .
>  [9,] . . . . . . . . . .
> [10,] . . . . . . . . . .
>
> Again, this works, I just need the for loop to be more efficient as in my
> application rows=37000, and I need to do this 100 times.
>
> 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.
>



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


[R] efficient matrix element comparison

2010-08-08 Thread david h shanabrook
It is a simple problem in that I simply want to convert the For loop to a more 
efficient method.  It simply loops through a large vector checking if the 
numeric element is not equal to the index of that element.  The following 
example demonstrates a simplified example:

> rows <- 10
> collusionM <- Matrix(0,10,10,sparse=TRUE)
> matchM <- matrix(c(1,2,3,4,4,6,7,9,9,10))
> 
> for (j in 1:rows) if (j != matchM[j]) collusionM[j,matchM[j]] <- 
> collusionM[j,matchM[j]]+1
> collusionM
10 x 10 sparse Matrix of class "dgCMatrix"
 
 [1,] . . . . . . . . . .
 [2,] . . . . . . . . . .
 [3,] . . . . . . . . . .
 [4,] . . . . . . . . . .
 [5,] . . . 1 . . . . . .
 [6,] . . . . . . . . . .
 [7,] . . . . . . . . . .
 [8,] . . . . . . . . 1 .
 [9,] . . . . . . . . . .
[10,] . . . . . . . . . .

Again, this works, I just need the for loop to be more efficient as in my 
application rows=37000, and I need to do this 100 times.

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] p.adjust( , fdr)

2010-08-08 Thread Tal Galili
Hi Qing.
I believe what you are referring to is:
p.adjust(..., "BH")

The "fdr" option uses the method of Benjamini, Hochberg, and Yekutieli.
(Not the original Benjamini, Hochberg article)
It might be the method described here:
http://www.math.tau.ac.il/~ybenja/MyPapers/benjamini_yekutieli_ANNSTAT2001.pdf




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Aug 8, 2010 at 11:06 PM, qing chen  wrote:

> Hello,
>
> I am not sure about the p.adjust( , fdr). How do these adjusted p-values
> get?
> I have read papers of BH method. For independent case, we compare the
> ordered p-values with the alfa*i/m, where m is the number of tests. But I
> have checked that result based on the adjusted p-values is different with
> that by using the independent case method.
> Then how do the result of p.adjust( , fdr) come?
> And how can we interpret them?
> Thank you!
>
>
>
> Your truly, Qing Chen
>
>[[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] CRAN (and crantastic) updates this week

2010-08-08 Thread Crantastic
CRAN (and crantastic) updates this week

New packages


* cumSeg (1.0)
  Vito M.R. Muggeo
  http://crantastic.org/packages/cumSeg

  Estimation of number and location of change points in mean-shift
  (piecewise constant) models. Particularly useful to model genomic
  sequences of continuous measurements.

* GWASExactHW (1.0)
  Ian Painter
  http://crantastic.org/packages/GWASExactHW

  This package contains a function to do exact Hardy-Weinburg testing
  (using Fisher's test) for SNP genotypes as typically obtained in a
  Genome Wide Association Study (GWAS).

* HapEstXXR (0.1-3)
  Sven Knueppel
  http://crantastic.org/packages/HapEstXXR

  Haplotype-Based Analysis of Association for genetic traits

* MatrixModels (0.1-1)
  Doug and Martin
  http://crantastic.org/packages/MatrixModels

  Modelling with sparse and dense 'Matrix' matrices, using modular
  prediction and response module classes.

* mhurdle (0.1-0)
  Yves Croissant
  http://crantastic.org/packages/mhurdle

  

* MSToolkit (2.0)
  MSToolkit
  http://crantastic.org/packages/MSToolkit

  MSToolkit library for evaluating clinical trial design and analysis
  operating characteristics through simulation.

* nnc (1.10)
  Unknown
  http://crantastic.org/packages/nnc

  Computes nearest neighbour autocovariates

* optimx (0.84)
  John C. Nash
  http://crantastic.org/packages/optimx

  Provides a replacement and extension of the optim() function to unify
  and streamline optimization capabilities in R for smooth, possibly
  box constrained functions of several or many parameters

* SlimPLS (0.3)
  Ofer Lavi
  http://crantastic.org/packages/SlimPLS

  SlimPLS is an implementation of SlimPLS multivariate feature
  selection.


Updated packages


benchmark (0.3-1), Bolstad (0.2-18), bqtl (1.0-26), caret (4.47),
cmprskContin (1.7), combinat (0.0-8), corpcor (1.5.7), DatABEL
(0.9-0), depmixS4 (1.0-0), dismo (0.5-4), diveMove (1.1), DoE.base
(0.12), DOSim (2.0), flexmix (2.2-8), Flury (0.1-3), FrF2 (1.1-4),
Geneclust (1.0.1), GPseq (0.2), hexView (0.3-2), HMR (0.2.1), igraph
(0.5.4), iid.test (1.6), IsoGene (1.0-17), kknn (1.0-8), lpSolve
(5.6.5), Matrix (0.999375-43), MSBVAR (0.5.0), optparse (0.9.0),
pamctdp (0.1.8), PerformanceAnalytics (1.0.3), pmml (1.2.23), rainbow
(2.1), rattle (2.5.38), RcppArmadillo (0.2.5), realized (1.0),
RExcelInstaller (3.1-6), RInside (0.2.3), RQuantLib (0.3.3), Runuran
(0.15.0), siar (4.0.1), spBayes (0.1-9), svcR (1.6.5), tau (0.0-8),
timereg (1.3-5), ttime (1.2.4), ttime (1.2.3), twang (1.0-2), UsingR
(0.1-13), vegetarian (1.2), wgaim (0.99-2), WMCapacity (0.9.5.1), xts
(0.7-4)



This email provided as a service for the R community by
http://crantastic.org.

Like it?  Hate it?  Please let us know: crana...@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] Does anybody know how to control the appearance of the end of the line in lattice?

2010-08-08 Thread p_connolly
On Sun, 08-Aug-2010 at 12:49PM -0700, George Chen wrote:

|> Hi All,
|>
|> I am plotting vertical lines using xyplot in lattice and type="h".
|> It works well, but the problem is that the tops of the lines are
|> convex and the bottoms are concave.  Is there a way to flatten the
|> tops and bottoms?

The bottom isn't concave.  You've drawn a white line which has
semi-circular ends (as is the default) over the black one.

I'm having difficulty imagining what your real objective is, but if
you want to change the way the end of lines are drawn, it's simple in
base graphics using the 'lend' parameter (but it doesn't work with all
devices according to the help file for par).

If you are using xyplot because you want to use the neat things you
can do with lattice, I think you'll have to go about it a slightly
more complicated way.  Use lpolygon in a panel function to draw
polygons and fill them.

HTH



|>
|> Here's my code:
|>
|> Source<-matrix(1:30,10,3)
|> colnames(Source)<-c("x","y1","y2")
|> Source<-data.frame(Source)
|>
|> xyplot(y2+y1~x,
|>  data=Source,
|>  distribute.type=TRUE,
|>  type=c("h","h"),
|>  col=c("black","white"),
|> lwd=20)
|> graphics.off()
|>
|> Thanks.
|>
|> George Chen
|>
|> __
|> 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 Connolly
Plant & Food Research
Mt Albert
Auckland
New Zealand
Ph: +64-9 925 7079
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 5:54 PM, steven mosher  wrote:
> z<-as.zooreg(as.ts(g))
>> z
>          X12345 X34567 X56789
> 1989(1)      NA      3      6
> 1989(2)      NA      3      6
> 1989(3)      NA      3      6
> 1989(4)      NA      3      6
> 1989(5)      NA      3      6
> 1989(6)      NA      3      6
> 1989(7)      NA      3      6
> 1989(8)      NA      3      6
> 1989(9)      NA      3      6
> 1989(10)     NA      3      6
> 1989(11)     NA      3      6
> 1989(12)     NA      3      6
> 1990(1)       2      4      6
> 1990(2)       2      4      6
> 1990(3)       2      4      6
> 1990(4)       2      4      6
> 1990(5)       2      4      6
> 1990(6)       2      4      6
> 1990(7)       2      4      6
> 1990(8)       2      4      6
> 1990(9)       2      4      6
> 1990(10)      2      4      6
> 1990(11)      2      4      6
> 1990(12)      2      4      6
> 1991(1)      NA      5     NA
> 1991(2)      NA      5     NA
> 1991(3)      NA      5     NA
> 1991(4)      NA      5     NA
> 1991(5)      NA      5     NA
> 1991(6)      NA      5     NA
> 1991(7)      NA      5     NA
> 1991(8)      NA      5     NA
> 1991(9)      NA      5     NA
> 1991(10)     NA      5     NA
> 1991(11)     NA      5     NA
> 1991(12)     NA      5     NA
> 1992(1)       2     NA     NA
> 1992(2)       2     NA     NA
>
> ***
> The interesting this is the change from months to the (1)...

zooreg converts a ts series to one with a numeric index and the same frequency.

You can convert the index to "yearmon" class if you wish:

z<-as.zooreg(as.ts(g))
time(z) <- as.yearmon(time(z))

or

z <- aggregate(as.zooreg(as.ts(g)), as.yearmon, identity)
__
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] Data frame reordering to time series

2010-08-08 Thread steven mosher
Thanks again,

They worked for me as well. I did a simpler example with fewer years just to
show that it worked...( shorted here for display)

 f <- function(x) {
+dat <- x[-(1:2)]
+tim <- as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12,
"+"))
+zoo(c(as.matrix(dat)), tim)
+ }
> g<-do.call(cbind, by(Data, Data$Index, f))
> g
 X12345 X34567 X56789
Jan 1989 NA  3  6
Feb 1989 NA  3  6
Mar 1989 NA  3  6
Apr 1989 NA  3  6
May 1989 NA  3  6
Jun 1989 NA  3  6
Jul 1989 NA  3  6
Aug 1989 NA  3  6
Sep 1989 NA  3  6
Oct 1989 NA  3  6
Nov 1989 NA  3  6
Dec 1989 NA  3  6
Jan 1990  2  4  6
Feb 1990  2  4  6
Mar 1990  2  4  6
Apr 1990  2  4  6
May 1990  2  4  6
Jun 1990  2  4  6
Jul 1990  2  4  6
Aug 1990  2  4  6
Sep 1990  2  4  6
Oct 1990  2  4  6
Nov 1990  2  4  6
Dec 1990  2  4  6
Jan 1991 NA  5 NA

.

z<-as.zooreg(as.ts(g))
> z
 X12345 X34567 X56789
1989(1)  NA  3  6
1989(2)  NA  3  6
1989(3)  NA  3  6
1989(4)  NA  3  6
1989(5)  NA  3  6
1989(6)  NA  3  6
1989(7)  NA  3  6
1989(8)  NA  3  6
1989(9)  NA  3  6
1989(10) NA  3  6
1989(11) NA  3  6
1989(12) NA  3  6
1990(1)   2  4  6
1990(2)   2  4  6
1990(3)   2  4  6
1990(4)   2  4  6
1990(5)   2  4  6
1990(6)   2  4  6
1990(7)   2  4  6
1990(8)   2  4  6
1990(9)   2  4  6
1990(10)  2  4  6
1990(11)  2  4  6
1990(12)  2  4  6
1991(1)  NA  5 NA
1991(2)  NA  5 NA
1991(3)  NA  5 NA
1991(4)  NA  5 NA
1991(5)  NA  5 NA
1991(6)  NA  5 NA
1991(7)  NA  5 NA
1991(8)  NA  5 NA
1991(9)  NA  5 NA
1991(10) NA  5 NA
1991(11) NA  5 NA
1991(12) NA  5 NA
1992(1)   2 NA NA
1992(2)   2 NA NA


***
The interesting this is the change from months to the (1)...



On Sun, Aug 8, 2010 at 8:55 AM, Gabor Grothendieck
wrote:

> On Sun, Aug 8, 2010 at 11:21 AM, steven mosher 
> wrote:
> > Ok,
> > I'm a bit confused by what you mean by "regularly spaced"
> > After I do the  do.call I do get a data structure with all the times
> present
> > and every time has a NA or a data value.
> > Steve
> >
>
> regularly spaced means that every observation is one month later than
> the prior.  If there are missing 6 month chunks or missing entire
> years then the observations are not regularly spaced since there are
> some months not present.
>
> It works for me:
>
> > Id<-c(rep(67543,4),rep(12345,3),rep(89765,5))
> >  Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1))
> >  Values2<-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14)
> >  Values<-c(12,14,34,21,54,65,23,12,13,13,13,14)
> >
>  
> Data<-data.frame(Index=Id,Year=Years,Jan=Values,Feb=Values/2,Mar=Values2,Apr=Values2,Jun=Values,July=Values/3,Aug=Values2,Sep=Values,
> +  Oct=Values,Nov=Values,Dec=Values2)
> >
> > library(zoo)
> > f <- function(x) {
> +dat <- x[-(1:2)]
> +tim <- as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12,
> "+"))
> +zoo(c(as.matrix(dat)), tim)
> + }
> > do.call(cbind, by(Data, Data$Index, f))
> X12345X67543X89765
> Jan 1989NA 12.00NA
> Feb 1989NA  6.00NA
> Mar 1989NA 12.00NA
> Apr 1989NA 12.00NA
> May 1989NA 12.00NA
> Jun 1989NA  4.00NA
> Jul 1989NA 12.00NA
> Aug 1989NA 12.00NA
> Sep 1989NA 12.00NA
> Oct 1989NA 12.00NA
> Nov 1989NA 12.00NA
> Jan 1990NA 14.00NA
> Feb 1990NA  7.00NA
> Mar 1990NANANA
> Apr 1990NANANA
> May 1990NA 14.00NA
> Jun 1990NA  4.67NA
> Jul 1990NANANA
> Aug 1990NA 14.00NA
> Sep 1990NA 14.00NA
> Oct 1990NA 14.00NA
> Nov 1990NANANA
> Jan 1991 54.00 34.00 12.00
> Feb 1991 27.00 17.00  6.00
> Mar 1991NA 34.00NA
> Apr 1991NA 34.00NA
> May 1991 54.00 34.00 12.00
> Jun 1991 18.00 11.33  4.00
> Jul 1991NA 34.00NA
> Aug 1991 54.00 34.00 12.00
> Sep 1991 54.00 34.00 12.

Re: [R] Problem with installing a package in R!

2010-08-08 Thread Liviu Andronic
On Sun, 8 Aug 2010 13:55:28 -0700 (PDT)
gagea  wrote:
> ERROR: failed to lock directory
> ‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9’ for modifying
> Try removing ‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9/00LOCK’
> 
Are you installing from user? Perhaps try from root. 
Liviu

__
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] Problem with installing a package in R!

2010-08-08 Thread gagea

Dear friends,

I am having problem with installing some packages in R in Ubuntu like
"ISwR". Bellow is the outcome. Anybody can help me to solve this problem.
Thanks a lot and sorry if it is very simple question. 


install.packages("ISwr")

Loading Tcl/Tk interface ... done
trying URL 'http://probability.ca/cran/src/contrib/ISwR_2.0-5.tar.gz'
Content type 'application/x-gzip' length 157441 bytes (153 Kb)
opened URL
==
downloaded 153 Kb

ERROR: failed to lock directory
‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9’ for modifying
Try removing ‘/home/ubuntu/R/i486-pc-linux-gnu-library/2.9/00LOCK’

The downloaded packages are in
‘/tmp/RtmpFDg2LG/downloaded_packages’
Warning message:
In install.packages("ISwR") :
  installation of package 'ISwR' had non-zero exit status
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-installing-a-package-in-R-tp2317979p2317979.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] Does anybody know how to control the appearance of the end of the line in lattice?

2010-08-08 Thread Paul Murrell

Hi

On 9/08/2010 7:49 a.m., George Chen wrote:

Hi All,

I am plotting vertical lines using xyplot in lattice and type="h".
It works well, but the problem is that the tops of the lines are convex and the 
bottoms are concave.
Is there a way to flatten the tops and bottoms?


You want to control the graphical parameter called "lineend", but I 
don't think this is generally made available via trellis.par.set(). 
Also, trying to set a default value via the 'grid.pars' argument, or via 
a viewport with the 'draw.in' argument doesn't appear to work in this 
case (the lineend may be hard coded in the internal code somewhere). 
The following code (to be run AFTER your code) does the trick for your 
example ...


library(grid)
grid.gedit("segments", gp=gpar(lineend="butt"), grep=TRUE)

... though I believe this will also make the ends of the tick marks on 
the axes square (not obvious to the naked eye at the default size).


Paul


Here's my code:

Source<-matrix(1:30,10,3)
colnames(Source)<-c("x","y1","y2")
Source<-data.frame(Source)

xyplot(y2+y1~x,
data=Source,
distribute.type=TRUE,
type=c("h","h"),
col=c("black","white"),
 lwd=20)
graphics.off()

Thanks.

George Chen

__
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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~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] p.adjust( , fdr)

2010-08-08 Thread qing chen
Hello,

I am not sure about the p.adjust( , fdr). How do these adjusted p-values
get?
I have read papers of BH method. For independent case, we compare the
ordered p-values with the alfa*i/m, where m is the number of tests. But I
have checked that result based on the adjusted p-values is different with
that by using the independent case method.
Then how do the result of p.adjust( , fdr) come?
And how can we interpret them?
Thank you!



Your truly, Qing Chen

[[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] Does anybody know how to control the appearance of the end of the line in lattice?

2010-08-08 Thread George Chen
Hi All,

I am plotting vertical lines using xyplot in lattice and type="h".
It works well, but the problem is that the tops of the lines are convex and the 
bottoms are concave.
Is there a way to flatten the tops and bottoms?

Here's my code:

Source<-matrix(1:30,10,3)
colnames(Source)<-c("x","y1","y2")
Source<-data.frame(Source)

xyplot(y2+y1~x,
data=Source,
distribute.type=TRUE,
type=c("h","h"),
col=c("black","white"),
lwd=20)
graphics.off()

Thanks.

George Chen

__
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] pdf device (and sweave) with localized characters

2010-08-08 Thread Roman Luštrik
Dear list,

I'm trying to Sweave with localized characters in graph titles and axis
labels through a pdf device. I set pdf encoding through pdf.options(encoding
= "CP1250"). When I run my script through the command line like so: R CMD
Sweave report.Rnw, the localized characters turn into two dots. When I run
the same script through Sweave("report.Rnw) in Eclipse+StatET, localized
characters are there. Can someone explain what's going on?

You can check a full example on
http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters


Cheers,
Roman

-- 
In God we trust, all others bring data.

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

2010-08-08 Thread Wu Gong

Hi,

I assume you used boot package. Try this:

library(boot)
x <- rnorm(136)
fun <- function(x,ind){
x <- x[ind]
m <- mean(x[63:136])-mean(x[1:62])
m
}
boot.x<- boot(x, fun, R = 5000, sim = "ordinary")



-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Bootstrap-tp2317776p2317860.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] Problems with Treemaps in VCD & PORTFOLIO

2010-08-08 Thread David Epstein
Hi,

I am trying to create a treemap for a non-symmetric tree where some
branches have more sub-branches than others. I have tried tools in two
packages, but have encountered some problems that I hope more
experienced users on this list can help address. 

The PORTFOLIO package offers MAP.MARKET, but this provides only a single
depth of branching ("category") before rendering the leaves. I could
create combined-categories from multiple columns, but these would not be
nested--or even necessarily rendered close to each other. The "color"
option provides a similar workaround with similar shortcomings.

The VCD package offers MOSAIC, which may be flexible enough to be
tweaked into rendering treemaps. One problem that arises is the
rendering of empty cells as vertical or horizontal lines, which makes
reading the maps more difficult. Empty cells in my case do not convey
more information since they are rather intuitive. I would prefer not to
render them at all and use location, labeling, and color to make the
branching structure clear. Is this possible?

Are there other packages or options I should consider?


Thank you,
-david

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

2010-08-08 Thread marcellina79

I would like to bootstrap the difference between two mean costs (I have a
different number of observations in the two group costs under
consideration).

So, this is my script:
x <- datos$direct_costsUS

fun <- function(x){m=(mean(x[63:136])-mean(x[1:62]))
}

boot.x<- boot(x, 
   statistic = function(d, ind){fun(d[ind])}, 
   R = 5000, 
   sim = "ordinary") 
boot.ci(boot.x, conf = 0.95,type = c("norm","basic","perc","bca"))
Problem with bca
plot(boot.x)
 
 
This is the final result:
 
Bootstrap Statistics :
originalbiasstd. error
t1* 15.95379 -15.958754.792771
 
 
the bias sounds to me really strange.
Do you think my bootstrap procedure is working well?
Thanks a lot for your time.
Best Regards.
Marcella
 
 
 
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Bootstrap-tp2317776p2317776.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] package for measurement error models

2010-08-08 Thread David Winsemius
There is a MethComp package from Bendix Carstensen that does not seem  
to be on CRAN yet.


http://staff.pubhealth.ku.dk/~bxc/MethComp/

But it is on R-Forge:

https://r-forge.r-project.org/R/?group_id=364

--
David.

On Aug 7, 2010, at 4:50 PM, Christos Argyropoulos wrote:



I believe there was a fairly recent exchange (within the last 6  
months) about linear measurement error models/error-in-variable  
models/Deming regression/total least squares/orthogonal regression.   
Terry Therneau provided code for an R function that can estimate  
such models:


http://www.mail-archive.com/r-help@r-project.org/msg85070.html

If your knowledge of Fortran is up to the task, there is a Netlib  
package called ODRpack that can fit such models. Kind of surprising  
that no one has not written a R wrapper for this library (yet).


Christos



Date: Sat, 7 Aug 2010 11:21:01 -0400
From: carrieands...@gmail.com
To: R-help@r-project.org
Subject: [R] package for measurement error models

Hi,all,

I posted this question couple of days again, but haven't gotten any  
answers
back. I would like to post it again, and if you have any ideas,  
please let

me know. Any helps and suggestions are very much appreciated.

The problem is about linear regression with both y and x have  
measurement,
and the variance of errors are heterogeneous. The estimated  
regression
coefficient and its variance are of interest. Is any R package  
doing this

task ?

Thank you

Carrie--

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


David Winsemius, MD
West Hartford, CT

__
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] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:55 AM, Gabor Grothendieck
 wrote:
> On Sun, Aug 8, 2010 at 11:21 AM, steven mosher  wrote:
>> Ok,
>> I'm a bit confused by what you mean by "regularly spaced"
>> After I do the  do.call I do get a data structure with all the times present
>> and every time has a NA or a data value.
>> Steve
>>
>
> regularly spaced means that every observation is one month later than
> the prior.  If there are missing 6 month chunks or missing entire
> years then the observations are not regularly spaced since there are
> some months not present.
>


And here it is with as.ts


> Id<-c(rep(67543,4),rep(12345,3),rep(89765,5))
>  Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1))
>  Values2<-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14)
>  Values<-c(12,14,34,21,54,65,23,12,13,13,13,14)
>  
> Data<-data.frame(Index=Id,Year=Years,Jan=Values,Feb=Values/2,Mar=Values2,Apr=Values2,Jun=Values,July=Values/3,Aug=Values2,Sep=Values,
+  Oct=Values,Nov=Values,Dec=Values2)
>
> library(zoo)
> f <- function(x) {
+dat <- x[-(1:2)]
+tim <- as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12, "+"))
+zoo(c(as.matrix(dat)), tim)
+ }
> z <- do.call(cbind, by(Data, Data$Index, f))
> as.ts(z)
X12345X67543X89765
Jan 1989NA 12.00NA
Feb 1989NA  6.00NA
Mar 1989NA 12.00NA
Apr 1989NA 12.00NA
May 1989NA 12.00NA
Jun 1989NA  4.00NA
Jul 1989NA 12.00NA
Aug 1989NA 12.00NA
Sep 1989NA 12.00NA
Oct 1989NA 12.00NA
Nov 1989NA 12.00NA
Dec 1989NANANA
Jan 1990NA 14.00NA
Feb 1990NA  7.00NA
Mar 1990NANANA
Apr 1990NANANA
May 1990NA 14.00NA
Jun 1990NA  4.67NA
Jul 1990NANANA
Aug 1990NA 14.00NA
Sep 1990NA 14.00NA
Oct 1990NA 14.00NA
Nov 1990NANANA
Dec 1990NANANA
Jan 1991 54.00 34.00 12.00
Feb 1991 27.00 17.00  6.00
Mar 1991NA 34.00NA
Apr 1991NA 34.00NA
May 1991 54.00 34.00 12.00
Jun 1991 18.00 11.33  4.00
Jul 1991NA 34.00NA
Aug 1991 54.00 34.00 12.00
Sep 1991 54.00 34.00 12.00
Oct 1991 54.00 34.00 12.00
Nov 1991NA 34.00NA
Dec 1991NANANA
Jan 1992NA 21.00 13.00
Feb 1992NA 10.50  6.50
Mar 1992NA 21.00 13.00
Apr 1992NA 21.00 13.00
May 1992NA 21.00 13.00
Jun 1992NA  7.00  4.33
Jul 1992NA 21.00 13.00
Aug 1992NA 21.00 13.00
Sep 1992NA 21.00 13.00
Oct 1992NA 21.00 13.00
Nov 1992NA 21.00 13.00
Dec 1992NANANA
Jan 1993 65.00NA 13.00
Feb 1993 32.50NA  6.50
Mar 1993 65.00NANA
Apr 1993 65.00NANA
May 1993 65.00NA 13.00
Jun 1993 21.67NA  4.33
Jul 1993 65.00NANA
Aug 1993 65.00NA 13.00
Sep 1993 65.00NA 13.00
Oct 1993 65.00NA 13.00
Nov 1993 65.00NANA
Dec 1993NANANA
Jan 1994 23.00NA 13.00
Feb 1994 11.50NA  6.50
Mar 1994 23.00NA 13.00
Apr 1994 23.00NA 13.00
May 1994 23.00NA 13.00
Jun 1994  7.67NA  4.33
Jul 1994 23.00NA 13.00
Aug 1994 23.00NA 13.00
Sep 1994 23.00NA 13.00
Oct 1994 23.00NA 13.00
Nov 1994 23.00NA 13.00
Dec 1994NANANA
Jan 1995NANA 14.00
Feb 1995NANA  7.00
Mar 1995NANA 14.00
Apr 1995NANA 14.00
May 1995NANA 14.00
Jun 1995NANA  4.67
Jul 1995NANA 14.00
Aug 1995NANA 14.00
Sep 1995NANA 14.00
Oct 1995NANA 14.00
Nov 1995NANA 14.00

__
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] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:21 AM, steven mosher  wrote:
> Ok,
> I'm a bit confused by what you mean by "regularly spaced"
> After I do the  do.call I do get a data structure with all the times present
> and every time has a NA or a data value.
> Steve
>

regularly spaced means that every observation is one month later than
the prior.  If there are missing 6 month chunks or missing entire
years then the observations are not regularly spaced since there are
some months not present.

It works for me:

> Id<-c(rep(67543,4),rep(12345,3),rep(89765,5))
>  Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1))
>  Values2<-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14)
>  Values<-c(12,14,34,21,54,65,23,12,13,13,13,14)
>  
> Data<-data.frame(Index=Id,Year=Years,Jan=Values,Feb=Values/2,Mar=Values2,Apr=Values2,Jun=Values,July=Values/3,Aug=Values2,Sep=Values,
+  Oct=Values,Nov=Values,Dec=Values2)
>
> library(zoo)
> f <- function(x) {
+dat <- x[-(1:2)]
+tim <- as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12, "+"))
+zoo(c(as.matrix(dat)), tim)
+ }
> do.call(cbind, by(Data, Data$Index, f))
X12345X67543X89765
Jan 1989NA 12.00NA
Feb 1989NA  6.00NA
Mar 1989NA 12.00NA
Apr 1989NA 12.00NA
May 1989NA 12.00NA
Jun 1989NA  4.00NA
Jul 1989NA 12.00NA
Aug 1989NA 12.00NA
Sep 1989NA 12.00NA
Oct 1989NA 12.00NA
Nov 1989NA 12.00NA
Jan 1990NA 14.00NA
Feb 1990NA  7.00NA
Mar 1990NANANA
Apr 1990NANANA
May 1990NA 14.00NA
Jun 1990NA  4.67NA
Jul 1990NANANA
Aug 1990NA 14.00NA
Sep 1990NA 14.00NA
Oct 1990NA 14.00NA
Nov 1990NANANA
Jan 1991 54.00 34.00 12.00
Feb 1991 27.00 17.00  6.00
Mar 1991NA 34.00NA
Apr 1991NA 34.00NA
May 1991 54.00 34.00 12.00
Jun 1991 18.00 11.33  4.00
Jul 1991NA 34.00NA
Aug 1991 54.00 34.00 12.00
Sep 1991 54.00 34.00 12.00
Oct 1991 54.00 34.00 12.00
Nov 1991NA 34.00NA
Jan 1992NA 21.00 13.00
Feb 1992NA 10.50  6.50
Mar 1992NA 21.00 13.00
Apr 1992NA 21.00 13.00
May 1992NA 21.00 13.00
Jun 1992NA  7.00  4.33
Jul 1992NA 21.00 13.00
Aug 1992NA 21.00 13.00
Sep 1992NA 21.00 13.00
Oct 1992NA 21.00 13.00
Nov 1992NA 21.00 13.00
Jan 1993 65.00NA 13.00
Feb 1993 32.50NA  6.50
Mar 1993 65.00NANA
Apr 1993 65.00NANA
May 1993 65.00NA 13.00
Jun 1993 21.67NA  4.33
Jul 1993 65.00NANA
Aug 1993 65.00NA 13.00
Sep 1993 65.00NA 13.00
Oct 1993 65.00NA 13.00
Nov 1993 65.00NANA
Jan 1994 23.00NA 13.00
Feb 1994 11.50NA  6.50
Mar 1994 23.00NA 13.00
Apr 1994 23.00NA 13.00
May 1994 23.00NA 13.00
Jun 1994  7.67NA  4.33
Jul 1994 23.00NA 13.00
Aug 1994 23.00NA 13.00
Sep 1994 23.00NA 13.00
Oct 1994 23.00NA 13.00
Nov 1994 23.00NA 13.00
Jan 1995NANA 14.00
Feb 1995NANA  7.00
Mar 1995NANA 14.00
Apr 1995NANA 14.00
May 1995NANA 14.00
Jun 1995NANA  4.67
Jul 1995NANA 14.00
Aug 1995NANA 14.00
Sep 1995NANA 14.00
Oct 1995NANA 14.00
Nov 1995NANA 14.00

__
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] Integration under Tps

2010-08-08 Thread sam.e

Hi there, 

After many attempts at trying different methods I have used the Tps package
to interpolate between a number of measurements of field data, in this case
thickness of a sedimentary deposit. My input values are Longitude, Latitude
and Thickness and I have produced a valid contour map based on the Tps
results. I would like to determine the volume of the deposit but am having
difficulty in finding a way to interpolate under the spline. I have read
about packages such as Adapt but am not sure how to use these with the
outputs given by Tps or how to define or extract my functions from Tps.

Any help or advice would be much appreciated.

Thanks, 

Sam


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Integration-under-Tps-tp2317790p2317790.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] Data frame reordering to time series

2010-08-08 Thread steven mosher
Ok,

I'm a bit confused by what you mean by "regularly spaced"
After I do the  do.call I do get a data structure with all the times present
and every time has a NA or a data value.

Steve

On Sun, Aug 8, 2010 at 2:46 AM, Gabor Grothendieck
wrote:

> On Sun, Aug 8, 2010 at 2:01 AM, steven mosher 
> wrote:
> > In the real data the months are all complete, but the years can be
> missing.
> > So years can be missing up front, in the middle, at the end. but if a
> year
> > is present than every month has a value or NA.
> > To create regular R ts I had to plow through the data frame, collect a
> year
> > caluculate an index to put it into the final time series.
> >
> > I had tried zoo out and it handled the irregular spaced data, but a large
> > data structure of zoo objects had stumped me. espcially since I need to
> do
> > matching and selecting
> > of the zoo objects.
> > In the real data, there are about 7000 time series of 1500 months and
> those
> > 7000
> > get averaged and combined in different ways
>
> If there are missing years and you want to get a regularly spaced
> series out then use the zoo version of f (rather than the ts version of f)
> and if this is the last statement (same as before but assigning
> it to the variable z):
>
>   z <- do.call(cbind, by(Data, Data$Index, f))
>
> then to get a regularly spaced ts object just do this:
>
>   as.ts(z)
>
> or
>
>   as.zooreg(as.ts(z))
>
> to create a regularly spaced zooreg object.
>

[[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] subset of string by index

2010-08-08 Thread Marc Schwartz
On Aug 8, 2010, at 9:50 AM, david h shanabrook wrote:

> How can I get a substring based on the index into the string?
> 
> strM <- c("abcde", "cdefg")
> ind <- c(1,3,5)
> 
> I want to use ind to index into the strings so the result is:
> 
> strMind <- c("ace", "ceg")



Here is one way:

> apply(sapply(ind, function(i) substr(strM, i, i)), 
1, paste, collapse = "")
[1] "ace" "ceg"


and another:

> sapply(strsplit(strM, ""), 
 function(x) paste(x[ind], collapse = ""))
[1] "ace" "ceg"


A test using a replication of strM to create a much larger source vector 
suggests that the second method is meaningfully faster than the second.


Yet another option would be:

> gsub("^(.).(.).(.)$", "\\1\\2\\3", strM)
[1] "ace" "ceg"


and this is the fastest of the three on a large source vector by a factor of 
~10 over the second approach above.  However, it is less easily generalizable.

You might also want to look at Gabor's 'gsubfn' CRAN package to see if he is 
utilities there that may be relevant.

HTH,

Marc Schwartz

__
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] subset of string by index

2010-08-08 Thread david h shanabrook
How can I get a substring based on the index into the string?

strM <- c("abcde", "cdefg")
ind <- c(1,3,5)

I want to use ind to index into the strings so the result is:

strMind <- c("ace", "ceg")

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


Re: [R] plot the dependent variable against one of the predictors with other predictors as constant

2010-08-08 Thread Bert Gunter
> I am thinking about using 'predict' command to generate the prediction of z
> with the new data.frame but there should be a better way.

I'm puzzled. Why would you think that? This is the canonical way to do
predictions in R.

Bert Gunter
Genentech Nonclinical Statistics

__
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] subset of string by index

2010-08-08 Thread david h shanabrook
How can I get a substring based on the index into the string?

strM <- c("abcde", "cdefg")
ind <- c(1,3,5)

I want to use ind to index into the strings so the result is:

strMind <- c("ace", "ceg")

__
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] Importing arguments for use by functions in a script

2010-08-08 Thread EvansA

QUESTION:
Is there a way of passing arguments from an external file to a script so
that they can be used directly by functions within the script?

I have a series of interdependent functions. I wish to test the time for
processing various datasets.
I was initially doing something along the lines of the following (yes, I am
new to R):

rm(list= ls())
systime1<-system.time(source("seq_imp_fct.R"))
systime2<-system.time(source("pattern_fct.R"))
systime3<-system.time(source("AAdistribution_fct.R"))

# run function
systime101<-system.time(seqres<-seq_imp_fct("testprot.txt"))
systime102<-system.time(patres<-pattern_fct(pattern="SS{1,2}",sequences=seqres))
systime103<-system.time(AAres<-AAdistribution_fct(sequences=patres))


As my list is of functions is growing, I was attempting to write a script
that would allow me to semi-automate this.
I have created a table of function file names, variables to hold return
values, arguments

FunctionReturns Arguments
"seq_imp_fct.R" seqres  "testprot.txt"
"pattern_fct.R" patres  pattern="SS{1,2}",sequences=seqres
"AAdistribution_fct.R"  Aares   sequences=patres

which I am reading in:

funcs<-read.table("functions.txt",sep="\t",header=TRUE,colClasses =
"character")

> funcs
 Function   Returns   Arguments
1   seq_imp_fct.rseqres testprot.txt
2   pattern_fct.rpatres pattern=SS{1,2},sequences=seqres
3AAdistribution_fct.r Aares sequences=patres


###
# source functions and get system times
###

systimes<-data.frame()
nrows<-nrow(funcs)

i<-0
for(i in 1:nrows)
{
 
 func<-funcs[i,1]

 systime<-system.time(source(func))
 systimes[i,1]<-func
 systimes[i,2]<-"source"
 systimes[i,3]<-systime[1]
 systimes[i,4]<-systime[2]
 systimes[i,5]<-systime[3]
 
}

###
# run functions and get system times
###

ii<-i+1
iiend<-i*2
i<-0

for(ii in ii:iiend)
{
  i<-i+1
 
  func<-funcs[i,1]
  rets<-as.name(funcs[i,2])
  args<-funcs[i,3]
  
  # remove .R from function
  sfunc<-substring(func,1,((nchar(func))-2))
  
  # convert text string to an object
  ssfunc<-get(sfunc)

  # convert text string in rets to object pointer and run function
 
systemtime<-system.time(eval(call("<-",rets,call("<-",rets,(ssfunc(args))
  
  print(seqres)
 
  systimes[ii,1]<-func
  systimes[ii,2]<-"process"
  systimes[ii,3]<-systemtime[1]
  systimes[ii,4]<-systemtime[2]
  systimes[ii,5]<-systemtime[3]
 
} 


This works fine when doing the equivalent of:

systime101<-system.time(seqres<-seq_imp_fct("testprot.txt"))

But falls over when doing the "equivalent" of:
systime102<-system.time(patres<-pattern_fct(pattern="SS{1,2}",sequences=seqres))

Generating error:
Error in gregexpr(pattern, as.character(sequences[, 3]), perl = T) : 
argument "sequences" is missing, with no default
Timing stopped at: 0 0.01 0.02 

I don't want to have to customise the handling of arguments for each
function.
Is there a way around this?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Importing-arguments-for-use-by-functions-in-a-script-tp2317758p2317758.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Error on random forest variable importance estimates

2010-08-08 Thread Pierre Dubath

Hello Andy,

Thank you for your quick and helpful reply. I will try to follow your 
suggestions.


Also, thank you for the R implementation of random forest. It is very 
useful for our work.


Best,

Pierre

Liaw, Andy wrote:

From: Pierre Dubath

Hello,

I am using the R randomForest package to classify variable 
stars. I have 
a training set of 1755 stars described by (too) many 
variables. Some of 
these variables are highly correlated.


I believe that I understand how randomForest works and how 
the variable 
importance are evaluated (through variable permutations). Here are my 
questions.


1) variable importance error? Is there any ways to estimate 
the error on 
the "MeanDecreaseAccuracy"? In other words, I would like to know how 
significant are "MeanDecreaseAccuracy" differences (and display 
horizontal error bars in the VarImpPlot output).


If you really want to do it, one possibility is to do permutation test:
Permute your response, say, 1000 or 2000 times, run RF on each of these
permuted response, and use the importance measures as samples from the
null distribution.
 
I have notice that even with relatively large number of trees, I have 
variation in the importance values from one run to the next. 
Could this 
serve as a measure of the errors/uncertainties?


Yes.
 
2) how to deal with variable correlation? so far, I am iterating, 
selecting the most important variable first, removing all 
other variable 
that have a high correlation (say higher than 80%), taking the second 
most important variable left, removing variables with 
high-correlation 
with any of the first two variables, and so on... (also using some 
astronomical insight as to which variables are the most important!)


Is there a better way to deal with correlation in randomForest? (I 
suppose that using many correlated variables should not be a 
problem for 
randomForest, but it is for my understanding of the data and 
for other 
algorithms).


That depends a lot on what you're trying to do.  RF can tolerate
problematic data, but that doesn't mean it will magically give you good
answers.  Trying to draw conclusions about effects when there are highly
correlated (and worse, important) variables is a tricky business.
 
3) How many variables should eventually be used? I have made 
successive 
runs, adding one variable at a time from the most to the 
least important 
(not-too-correlated) variables. I then plot the error rate 
(err.rate) as 
a function of the number of variable used. As this number 
increase, the 
error first sharply decrease, but relatively soon it reaches 
a plateau .
I assume that the point of inflexion can be use to derive the minimum 
number of variable to be used. Is that a sensible approach? 
Is there any 
other suggestion? A measure of the error on "err.rate" would 
also here 
really help. Is there any idea how to estimate this? From the 
variation 
between runs or with the help of "importanceSD" somehow?


One approach is described in the following paper (in the Proceedings of
MCS 2004):
http://www.springerlink.com/content/9n61mquugf9tungl/

Best,
Andy
 

Thanks very much in advance for any help.

Pierre Dubath

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


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


__
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] Latex errors when checking package

2010-08-08 Thread Christian Hennig

Dear Ben,

thanks a lot! This did the trick (after adding "install" behind apt-get).

Regards,
Christian

On Fri, 6 Aug 2010, Ben Bolker wrote:


Christian Hennig  stats.ucl.ac.uk> writes:


LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
! Font T1/ptm/m/n/10=ptmr8t at 10.0pt not loadable: Metric (TFM) file not
found


 I'm guessing you're running Ubuntu.  If so,



suggests that you

sudo apt-get texlive-fonts-recommended

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



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

__
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] metafor and meta-analysis at arm-level

2010-08-08 Thread Angelo Franchini
Dear Wolfgang,

Is there any way for rma to add random effects only to each treatment arm,
but not to the control one?

Many thanks,
Angelo


On Thu, August 5, 2010 6:21 pm, Viechtbauer Wolfgang (STAT) wrote:
> Dear Angelo,
>
> rma(yi=o, sei=se, mods=~s+t-1, method="REML")
>
> is *a* way to run the arm-based pairwise meta-analysis. Whether it is the
> *correct* way is a question I cannot answer.
>
> lme(o~s+t-1, random=~t-1 | s, weights=(~ se^2))
>
> is a different model. First of all, it adds a random effect only to each
> treatment arm within each study, while the rma model above gives a random
> effect to each observation. Moreover, the lme model assumes that the
> sampling variances are only known up to a proportionality constant, while
> the rma model assumes that they are known exactly.
>
> Similarly,
>
> lm(formula = o ~ s + t - 1, weights = 1/se.o^2)
>
> assumes that the sampling variances are only known up to a proportionality
> constant, while rma (with method="FE") assumes that they are known
> exactly.
>
> For the same reason will
>
> rma(yi=e, sei=se, method="REML")
> lme(e~1, random=~1 | s, weights=(~ se.e^2))
>
> and
>
> rma(yi=e, sei=se.e, method="FE")
> lm(e~1, weights = 1/se.e^2)
>
> not give you the same results.
>
> Best,
>
> --
> Wolfgang Viechtbauerhttp://www.wvbauer.com/
> Department of Methodology and StatisticsTel: +31 (0)43 388-2277
> School for Public Health and Primary Care   Office Location:
> Maastricht University, P.O. Box 616 Room B2.01 (second floor)
> 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)
>
>
> Original Message
> From: Angelo Franchini [mailto:angelo.franch...@bristol.ac.uk]
> Sent: Wednesday, August 04, 2010 16:26
> To: Viechtbauer Wolfgang (STAT)
> Cc: 'Angelo Franchini'; r-help@r-project.org
> Subject: RE: [R] metafor and meta-analysis at arm-level
>
>> Hello Wolfgang.
>>
>> I'd appreciate if you could help me check whether I am doing the proper
>> thing to do an arm-level meta-analysis with metafor and what differences
>> there might be in trying to do the same with lme and lm.
>>
>> I am following the arm based model described in section 3.2 of the
>> Salanti's paper that you mentioned in your previous e-mail, namely:
>>
>> theta = B*eta + X*mu + W*beta
>>
>> where:
>> theta = vector of parameter for outcomes in treatment arms (theta_ij for
>> study i, treat. arm j)
>> eta= vector of parameter for outcomes in control arms (eta_i for
>> study i)
>> mu = vector of effects (treat. vs cont.) (mu_ij for study i, treat.
>> arm j)
>> beta   = vector of random effects (beta_ij for study i, treat. arm j)
>>
>>
>> In my specific case with a pairwise meta-analysis, I had my data
>> arranged
>> as in columns for the following variables: s t o se
>>
>> with
>> s as study/trial identifier
>> t as 0/1 for control/treatment arm
>> o as observed outcome in control or treatment arm
>> se as standard error of that outcome measure
>>
>> I then ran metafor as:
>> rma(yi=o, sei=se, mods=~s+t-1, method="REML")
>>
>> for random effects, and REML replaced by FE for fixed effects.
>>
>> Is that the correct way to run the arm-based pairwise meta-analysis?
>>
>> Shouldn't I be able to obtain similar results with LME for
>> random-effects
>> by using the command: lme(o~s+t-1, random=~t-1 | s, weights=(~ se^2))
>>
>> and for fixed-effects with:
>> lm(formula = o ~ s + t - 1, weights = 1/se.o^2)
>>
>>
>> For the trial-based pairwise meta-analysis I used:
>> data arranged as:
>> s e se
>>
>> with:
>> s study
>> e effect
>> se standard error
>>
>> and commands:
>> rma(yi=e, sei=se, method="REML")
>>
>> or
>>
>> lme(e~1, random=~1 | s, weights=(~ se.e^2))
>>
>> for random-effects, while for fixed-effects:
>> rma(yi=e, sei=se.e, method="FE")
>> lm(e~1, weights = 1/se.e^2)
>>
>> Does that make sense?
>>
>>
>> Many thanks for any comment/advice on this matter.
>> Best regards,
>> Angelo
>


-- 
NIHR Research Methods Training Fellow,
Department of Community Based Medicine
University of Bristol
25 Belgrave Road
Bristol BS8 2AA

Tel. 0779 265-6552

__
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] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 2:01 AM, steven mosher  wrote:
> In the real data the months are all complete, but the years can be missing.
> So years can be missing up front, in the middle, at the end. but if a year
> is present than every month has a value or NA.
> To create regular R ts I had to plow through the data frame, collect a year
> caluculate an index to put it into the final time series.
>
> I had tried zoo out and it handled the irregular spaced data, but a large
> data structure of zoo objects had stumped me. espcially since I need to do
> matching and selecting
> of the zoo objects.
> In the real data, there are about 7000 time series of 1500 months and those
> 7000
> get averaged and combined in different ways

If there are missing years and you want to get a regularly spaced
series out then use the zoo version of f (rather than the ts version of f)
and if this is the last statement (same as before but assigning
it to the variable z):

   z <- do.call(cbind, by(Data, Data$Index, f))

then to get a regularly spaced ts object just do this:

   as.ts(z)

or

   as.zooreg(as.ts(z))

to create a regularly spaced zooreg object.

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


Re: [R] Error in as.environment(pos): using 'as.environment(NULL)' isdefunct

2010-08-08 Thread Immanuel Seeger
Hello,
unfortunately I haven't gotten an answer up to now. You can see my
question/problem below in the first mail.
Is the given extract too unspecific?

I haven't solved the problem but I think that it's in the
handler.Berechnung function. Maybe I'm using wrong data-types (there are
vectors defined by tclVar and 'Zugehörigkeit' as a matrix defined by
tclArray). I'm new to R with TK and don't know if
tclvar(as.numeric(tclObj(...))) is the right code to set vectors and
matrices as textvariable.(see below in handler.Berechnung) 

Thanks!



-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Im Auftrag von Immanuel Seeger
Gesendet: Donnerstag, 5. August 2010 11:56
An: r-help@r-project.org
Betreff: [R] Error in as.environment(pos): using 'as.environment(NULL)'
isdefunct

Hello,
I’m using R 2.11.1 with Tinn-R 1.17.2.4.
I hope the given informations are enough (it’s my first entry here)

The as.environment(pos) error appears in using the following code which
should open a function in an other R-file.
Here some extractions of the code:



HZ<-tclVar(seq(length=a,from=1,by=0))#(a is defined by a
tkentry-element)
VZ<-tclVar(seq(length=a,from=1,by=0))
Aktivität<-tclVar(seq(length=a,from=1,by=0))
VKG<-tclVar(3)
Zugehörigkeit is a matrix.   

#The values can be changed by a tkentry-element.

handler.Berechnung<-function() {
tkconfigure(Ergebnisfenster,
textvariable=tclVar(test2(as.numeric(tclObj(VKG)),as.numeric(tclObj(HZ))
,as.numeric(tclObj(VZ)),as.numeric(tclObj(Aktivität)),as.numeric(tclObj(
tclArray1)
}

test2 <- local({source("C:/Berechnung_Funktion.R", local = TRUE)
environment(Berechnung) <- .GlobalEnv
Berechnung })

and:
Button<-tkframe(InputOutputfenster)
tkpack(Button, side='top')
tkpack(tkbutton(Button, text='compute optimal
solution',command=handler.Berechnung))

and the function in the other R-file:
Berechnung<-function(a,b,c,d,e) {…} 

Thanks!

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

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