Re: [R] Reshape2, melt, order of categorical variable and ggplot2

2012-10-07 Thread David Winsemius

On Oct 7, 2012, at 1:40 PM, Stathis Kamperis wrote:

> Hello everyone,
> 
> I have the following data frame:
> 
>> df
>   V1 V2  V3
> 1   bench1_10  16675   16678
> 2   bench1_10  16585   16672
> 3  bench1_100 183924  185563
> 4  bench1_100 169310  184806
> 5  bench1_300 514430  516834
> 6  bench1_300 510743  514062
> 7  bench1_500 880146  877882
> 8  bench1_500 880146  857359
> 9   bench1_1k 880146 1589600
> 10  bench1_1k 880146 1709990
>> 
> 
> I'd like to melt it by using id=V1:
> 
>> mdf <- melt(df)
> Using V1 as id variables
>> mdf
>   V1 variable   value
> 1   bench1_10   V2   16675
> 2   bench1_10   V2   16585
> 3  bench1_100   V2  183924
> 4  bench1_100   V2  169310
> 5  bench1_300   V2  514430
> 6  bench1_300   V2  510743
> 7  bench1_500   V2  880146
> 8  bench1_500   V2  880146
> 9   bench1_1k   V2  880146
> 10  bench1_1k   V2  880146
> 11  bench1_10   V3   16678
> 12  bench1_10   V3   16672
> 13 bench1_100   V3  185563
> 14 bench1_100   V3  184806
> 15 bench1_300   V3  516834
> 16 bench1_300   V3  514062
> 17 bench1_500   V3  877882
> 18 bench1_500   V3  857359
> 19  bench1_1k   V3 1589600
> 20  bench1_1k   V3 1709990
>> 
> 
> My problem is that V1 in mdf has bench1_1k before bench1_500 and so
> on. This is a problem because when I try to plot the results with:
> 
> p <- ggplot(mdf, aes(x=mdf$V1, y=mdf$value))
> p <- p + geom_point(aes(colour=factor(mdf$variable)))
> p
> 
> I get bench1_1k in the horizontal axis before say bench1_500.
> 
> Is there any way to have V1 in mdf "sorted" just like in df ? Or do I
> have to rename my files from bench1_1k to bench1_1000 and be done ?

In all likelihood you need to review the care and feeding of the factor beasts 
under your care. The alpha ordering is the default and that will put 
"bench1_1k" in the middle. You canchange the levels however.

?levels

-- 

David Winsemius, MD
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reshape2, melt, order of categorical variable and ggplot2

2012-10-07 Thread Jim Holtman
use the 'levels' option on 'factor' to define the explicit order of the 
factors.  This mightbwork on you data:

df$V1 <- factor(df$V1, levels = unique(df$V1))

Sent from my iPad

On Oct 7, 2012, at 16:40, Stathis Kamperis  wrote:

> Hello everyone,
> 
> I have the following data frame:
> 
>> df
>   V1 V2  V3
> 1   bench1_10  16675   16678
> 2   bench1_10  16585   16672
> 3  bench1_100 183924  185563
> 4  bench1_100 169310  184806
> 5  bench1_300 514430  516834
> 6  bench1_300 510743  514062
> 7  bench1_500 880146  877882
> 8  bench1_500 880146  857359
> 9   bench1_1k 880146 1589600
> 10  bench1_1k 880146 1709990
>> 
> 
> I'd like to melt it by using id=V1:
> 
>> mdf <- melt(df)
> Using V1 as id variables
>> mdf
>   V1 variable   value
> 1   bench1_10   V2   16675
> 2   bench1_10   V2   16585
> 3  bench1_100   V2  183924
> 4  bench1_100   V2  169310
> 5  bench1_300   V2  514430
> 6  bench1_300   V2  510743
> 7  bench1_500   V2  880146
> 8  bench1_500   V2  880146
> 9   bench1_1k   V2  880146
> 10  bench1_1k   V2  880146
> 11  bench1_10   V3   16678
> 12  bench1_10   V3   16672
> 13 bench1_100   V3  185563
> 14 bench1_100   V3  184806
> 15 bench1_300   V3  516834
> 16 bench1_300   V3  514062
> 17 bench1_500   V3  877882
> 18 bench1_500   V3  857359
> 19  bench1_1k   V3 1589600
> 20  bench1_1k   V3 1709990
>> 
> 
> My problem is that V1 in mdf has bench1_1k before bench1_500 and so
> on. This is a problem because when I try to plot the results with:
> 
> p <- ggplot(mdf, aes(x=mdf$V1, y=mdf$value))
> p <- p + geom_point(aes(colour=factor(mdf$variable)))
> p
> 
> I get bench1_1k in the horizontal axis before say bench1_500.
> 
> Is there any way to have V1 in mdf "sorted" just like in df ? Or do I
> have to rename my files from bench1_1k to bench1_1000 and be done ?
> 
> Best regards,
> Stathis
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] aov(HSuccess ~ different VegIndexes)

2012-10-07 Thread Jhope
Hi R-listers, 

I would like to do an ANOVA with HSuccess ~ each individual Vegetation index
(0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m) and alternatively
HSuccess ~ HTLIndex (-5-(-1m), 0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m). 

I'm not sure how to write the script for it. I have tried: 

> summary(aov(HSuccess ~ ((data.to.analyze$Veg
> breaks=c(0,5,10,15,20,25,30,35)), data=data.to.analyze)
Error: unexpected symbol in "summary(aov(HSuccess ~ ((data.to.analyze$Veg
breaks"

AND

>summary(aov(HSuccess ~ VegIndex$0-5, VegIndex$6-10 + VegIndex$11-15 +
VegIndex$16-20 + VegIndex$21-25 + VegIndex$26-30 + VegIndex$31-35,
data=data.to.analyze)
Error: unexpected numeric constant in "summary(aov(HSuccess ~ VegIndex$0"

Any suggestions on how to do this? 

Jean



--
View this message in context: 
http://r.789695.n4.nabble.com/aov-HSuccess-different-VegIndexes-tp4645386.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] aov() usage

2012-10-07 Thread Jhope
Hi R-listers, 

I am wondering if the function aov() in plyr is appropriate for two
different types of tests:

1) > summary(aov(EDI ~ VegIndex, data=data.to.analyze))

AND

2) > summary(aov(HSuccess ~ VegIndex + Aeventexhumed +
VegIndex:Aeventexhumed, data=data.to.analyze))

the later inclusive of an interaction of the two explanatory variables.

This is for obtaining P value and F statistics. 

Please advise, Jean



--
View this message in context: 
http://r.789695.n4.nabble.com/aov-usage-tp4645380.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] first and second derivative calculation

2012-10-07 Thread jeemba2012
I have a similar problem .
Here are functions I know that work properly
## PAnnuity function definition
PAnnuity <- function(A,y,m,n)
{
  f<-(A/(y/m))*(1-1/((1+y/m)^n))
}

##BondPrice function
BondPrice <- function(c,y,m,n)
{
  B <-100
  f<-PAnnuity((c/m)*B,y,m,n) + B /((1+y/m)^n)
}


My function of question is which uses the latter function is
Co <- function(c,y,m,n)
{
  f<- D(D(as.expression(BondPrice(c,y,m,n)),"y"),"y")/BondPrice(c,y,m,n)
}

when I test it using 
convexity <- C0(0.09, 0.10, 2, 10)
>[1] 0.

I believe it is passing the parameters and taking the derivative of a
constant. 
How do I get the 2nd Derivative and then pass the parameters for evaluation.

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/first-and-second-derivative-calculation-tp1126069p4645388.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] warning in summary(aov())

2012-10-07 Thread Jhope
Thank you Michael, 



Another new and useful function for me. In brief, str() gave me:

$ Aeventexhumed: chr  "A" "A" "A" "A" ...
$ Aeventexhumed: Factor w/ 4 levels "","A","B","C": 2 2 2 2 2 2 2 2 2 2 ...

I think on the data sheet there are two columns for Aeventexhumed and only
one of them was converted to a factor. Factor is correct so as you suggested
I will just leave it. 

Thanks! Jean



--
View this message in context: 
http://r.789695.n4.nabble.com/warning-in-summary-aov-tp4645253p4645376.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] Why do I get different results for type III anova using the drop1 or Anova command?

2012-10-07 Thread C. Weiner

Dear experts,

I just noticed that I get different results conducting type III anova 
using drop1 or the Anova command from the car package. I suppose I made 
a mistake and hope you can offer me some help. I have no idea where I 
got wrong and would be very grateful for explaination as R is new 
terrain for me.
If I run the commands in line, they produce the same results. But if I 
run them in seperate windows, they produce different results.


What I did in easy words:
Opened R prompt, ran parts 0 and 1-> got result 1
Opened new R prompt, ran parts 0 and 2 ->got result 2, ran part 1 
following part 2, got result 2a


Why are the results different when they are run seperately and why do 
the commands produce the same results when running one after the other? 
Which results can I rely on? I based my script on:
http://mcfromnz.wordpress.com/2011/03/0 ... explained/ 
 
but I surely made mistakes.


Thanks for help.
Kind regards,
Christiane



#0
library(car)
P<-read.table("rhoPgegenrhoAgewichtet-mit Befruchtungssystem0912.txt", 
sep="\t",dec=",", header=T,encoding="latin1")

summary(P)
str(P)

#1
modD3 <- lm(P$rhoPug ~ P$rhoAg*P$dprime*P$Befruchtungssystem, data=P)

Anova(modD3,contrasts=list(rhoAg=contr.sum, dprime=contr.poly), 
type="III") ###liefert dieses Ergebnis, wenn der Befehl als erster läuft

#Response: P$rhoPug
# Sum Sq Df F value Pr(>F)
#(Intercept) 0.07719 1 4.5075 0.03530 *
#P$rhoAg 0.00687 1 0.4014 0.52730
#P$dprime 0.00176 1 0.1029 0.74882
#P$Befruchtungssystem 0.00250 1 0.1461 0.70280
#P$rhoAg:P$dprime 0.00931 1 0.5439 0.46193
#P$rhoAg:P$Befruchtungssystem 0.1 1 0.0004 0.98343
#P$dprime:P$Befruchtungssystem 0.00108 1 0.0630 0.80214
#P$rhoAg:P$dprime:P$Befruchtungssystem 0.00206 1 0.1205 0.72893
#Residuals 2.70584 158


#2
options(contrasts = c("contr.sum","contr.poly")) #liefert ein anderes 
Ergebnis als der Befehl oben, wenn der obere Befehl NICHT gelaufen ist

modD3 <- lm(P$rhoPug ~ P$rhoAg*P$dprime*P$Befruchtungssystem, data=P)
drop1(modD3,.~.,test="F") # type III SS and F Test
P$rhoPug ~ P$rhoAg * P$dprime * P$Befruchtungssystem
Df Sum of Sq RSS AIC F value Pr(F)
 2.7058 -667.35
P$rhoAg 1 0.0131973 2.7190 -668.54 0.7706 0.3814 !!
P$dprime 1 0.0002240 2.7061 -669.34 0.0131 0.9091 !!
P$Befruchtungssystem 1 0.0025022 2.7083 -669.20 0.1461 0.7028 !!
P$rhoAg:P$dprime 1 0.0283677 2.7342 -667.62 1.6565 0.2000 !!
P$rhoAg:P$Befruchtungssystem 1 0.074 2.7058 -669.35 0.0004 0.9834
P$dprime:P$Befruchtungssystem 1 0.0010790 2.7069 -669.29 0.0630 0.8021
P$rhoAg:P$dprime:P$Befruchtungssystem 1 0.0020641 2.7079 -669.22 0.1205 
0.7289



#2a (command is the same as in 1, but results are different if the 
command is run after the one above)
Anova(modD3,contrasts=list(Befruchtungssystem="contr.sum", 
dprime="contr.poly"), type="III") #liefert in nachstehend nach dem 
2.Befehl dieses Ergebnis
#Response: P$rhoPug #also jetzt dasselbe wie drop1, aber nicht dasselbe, 
das

#der exakt gleich Befehl alleine geliefert hätte. Was
#stimmt den nun? Wo liegt mein Fehler?
# Sum Sq Df F value Pr(>F)
#(Intercept) 0.06877 1 4.0158 0.04679 *
#P$rhoAg 0.01320 1 0.7706 0.38136
#P$dprime 0.00022 1 0.0131 0.90909
#P$Befruchtungssystem 0.00250 1 0.1461 0.70280
#P$rhoAg:P$dprime 0.02837 1 1.6565 0.19997
#P$rhoAg:P$Befruchtungssystem 0.1 1 0.0004 0.98343
#P$dprime:P$Befruchtungssystem 0.00108 1 0.0630 0.80214
#P$rhoAg:P$dprime:P$Befruchtungssystem 0.00206 1 0.1205 0.72893
#Residuals 2.70584 158

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 remove the obs column in R?

2012-10-07 Thread killerkarthick
>From the following image I need to remove the obs column for my documentation
purpose.Please reply me..
 



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-remove-the-obs-column-in-R-tp4645382.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] Reshape2, melt, order of categorical variable and ggplot2

2012-10-07 Thread Stathis Kamperis
Hello everyone,

I have the following data frame:

> df
   V1 V2  V3
1   bench1_10  16675   16678
2   bench1_10  16585   16672
3  bench1_100 183924  185563
4  bench1_100 169310  184806
5  bench1_300 514430  516834
6  bench1_300 510743  514062
7  bench1_500 880146  877882
8  bench1_500 880146  857359
9   bench1_1k 880146 1589600
10  bench1_1k 880146 1709990
>

I'd like to melt it by using id=V1:

> mdf <- melt(df)
Using V1 as id variables
> mdf
   V1 variable   value
1   bench1_10   V2   16675
2   bench1_10   V2   16585
3  bench1_100   V2  183924
4  bench1_100   V2  169310
5  bench1_300   V2  514430
6  bench1_300   V2  510743
7  bench1_500   V2  880146
8  bench1_500   V2  880146
9   bench1_1k   V2  880146
10  bench1_1k   V2  880146
11  bench1_10   V3   16678
12  bench1_10   V3   16672
13 bench1_100   V3  185563
14 bench1_100   V3  184806
15 bench1_300   V3  516834
16 bench1_300   V3  514062
17 bench1_500   V3  877882
18 bench1_500   V3  857359
19  bench1_1k   V3 1589600
20  bench1_1k   V3 1709990
>

My problem is that V1 in mdf has bench1_1k before bench1_500 and so
on. This is a problem because when I try to plot the results with:

p <- ggplot(mdf, aes(x=mdf$V1, y=mdf$value))
p <- p + geom_point(aes(colour=factor(mdf$variable)))
p

I get bench1_1k in the horizontal axis before say bench1_500.

Is there any way to have V1 in mdf "sorted" just like in df ? Or do I
have to rename my files from bench1_1k to bench1_1000 and be done ?

Best regards,
Stathis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error - function join()

2012-10-07 Thread Jhope
Hi R-listers, 

In plyr I am using coding I have used before but an error seems to be
apparent. Has the function "join" been replaced by another word? I tried
this before and it didn't work and then worked for me. But now it is not
working again. 

Please advise, Jean

> data.to.analyze <- join(responses, envir, by="QuadratEvent")
Error: could not find function "join"



--
View this message in context: 
http://r.789695.n4.nabble.com/Error-function-join-tp4645369.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] variances of random effects in coxme

2012-10-07 Thread Hugo Varet
Dear R users,

I'm using the function coxme of the package coxme in order to build Cox
models with complex random effects. Unfortunately, I sometimes get
surprising estimations of the variances of the random effects.

I ran models with different fixed covariates but always with the same 3
random effects defined by the argument
varlist=coxmeMlist(list(mat1,mat2,mat3), rescale = F, pdcheck = F,
positive=F). I get a few times exactly the same estimations of the
parameters of the random effects whereas the fixed effects of the models
are different:

Random effects
 Group Variable Std DevVariance
 idp   Vmat.1   0.1000 0.0100
   Vmat.2   0.02236068 0.0005
   Vmat.3   0.02449490 0.0006

The variances are round figures, so I have the feeling that the algorithm
didn't succeed in fitting the model.

Has anyone ever faced to this problem?

Thanks,

Hugo

[[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] Reading labels for very large heatmaps

2012-10-07 Thread JIMonroe
Jean,

It's definitely bigger now, but my axes are cut-off.  As in your example, I
had them drawn after generating the heatmap, but the image does not seem to
be centered.  I think even part of the heatmap is getting cut off, which
wasn't happening until I explicitly set the width and height of the pdf. 
Here is my code

> pdf("Apo_Mut_Boot.pdf", width=200, height=200)
> heatmap(x=as.matrix((Apo_Mut)), col =
> colorRampPalette(c("white","black"))(256),
> zlim=c(min(Apo_Mut),max(Apo_Mut)),add = FALSE, xaxs = "i", yaxs =
> "i",xaxt= "n", yaxt = "n", xlab="residue", ylab="residue",
> main="Apo-Mutant",revC=TRUE, Rowv = as.dendrogram(blah2), Colv =
> as.dendrogram(blah2), reorderfun = function(d,w) rev(reorder(d,w)), 
> oldstyle = FALSE,cexRow=0.01,cexCol=0.01,symm=TRUE )
> axis(1, at=1:919, labels=RowCol, las=2, cex=0.01)
> axis(4, at=1:919, labels=RowCol, las=2, cex=0.01)
> box()
> graphics.off()

Jacob



--
View this message in context: 
http://r.789695.n4.nabble.com/Reading-labels-for-very-large-heatmaps-tp4644739p4645391.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] Robust regression for ordered data

2012-10-07 Thread Prof Brian Ripley

On 08/10/2012 00:37, Bert Gunter wrote:

Have you checked the Robust task view on CRAN?? Would seem that that
should have been the first place to look.


It is still a conceptual question.  I presume this means an ordered 
response, and then we need to know what is meant by 'regression'.


If you tell us precisely what robust method you want to know about, you 
may get help about whether it is available in R.   But I surmise that 
you need rather to be looking at ordinal regression (polr in MASS, for 
example), and you will not find that in the 'Robust' task view.   In the 
task view, 'robust' is  a technical term and I don't think 'Elko Fried' 
is using it in the sense the author of the task view is.




-- Bert

On Sun, Oct 7, 2012 at 3:30 PM, Eiko Fried  wrote:

Thank you Jeff! Please ignore the first of my two questions then, and
apologies for not making it clear that my second question was about R.

(2) "Are there ways of using robust regressions with ordered data" ... in
R?

Thank you


On 7 October 2012 18:26, Jeff Newmiller  wrote:


This does not appear to be a question about R. You should post in a list
or forum dedicated to discussing statistics theory, such as
stats.stackoverflow.com.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live
Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.

Eiko Fried  wrote:


I have two regressions to perform - one with a metric DV (-3 to 3), the
other with an ordered DV (0,1,2,3).

Neither normal distribution not homoscedasticity is given. I have a two
questions:

(1) Some sources say robust regression take care of both lack of normal
distribution and heteroscedasticity, while others say only of normal
distribution. What is true?
(2) Are there ways of using robust regressions with ordered data, or is
that only possible for metric DVs?

Thanks
Torvon

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







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

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


Re: [R] problem with convergence in mle2/optim function

2012-10-07 Thread Adam Zeilinger

Dear R Help,

Thank you to those who responded to my questions about mle2/optim 
convergence.  A few responders pointed out that the optim error seems to 
arise when either one of the probabilities P1, P2, or P3 become negative 
or infinite.  One suggested examining the exponential terms within the 
P1 and P2 equations.


I may have made some progress along these lines.  The exponential terms 
in the equations for P1 and P2 go to infinity at certain (large) values 
of t. The exponential terms can be found in lines 1, 5, and 7 in the P1 
and P2 expressions below.  Here is some example code:


###
# P1 and P2 equations
P1 <- expression((p1*((-1 + exp(sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2)))*t))*((-mu2)*(mu2 - p1 + p2) +
  mu1*(mu2 + 2*p2)) - mu2*sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2))) -
  exp(sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)))*t)*
  mu2*sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2))) +
  2*exp((1/2)*(mu1 + mu2 + p1 + p2 + sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2*t)*mu2*
  sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)/
  exp((1/2)*(mu1 + mu2 + p1 + p2 + sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2*t)/(2*(mu2*p1 + mu1*(mu2 + p2))*
  sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)
P2 <- expression((p2*((-1 + exp(sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2)))*t))*(-mu1^2 + 2*mu2*p1 +
  mu1*(mu2 - p1 + p2)) - mu1*sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2))) -
  exp(sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)))*t)*
  mu1*sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2))) +
  2*exp((1/2)*(mu1 + mu2 + p1 + p2 + sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2*t)*mu1*
  sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)/
  exp((1/2)*(mu1 + mu2 + p1 + p2 + sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2*t)/(2*(mu2*p1 + mu1*(mu2 + p2))*
  sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)

# Vector of t values
tv <- c(1:200)

# 'true' parameter values
p1t = 2; p2t = 2; mu1t = 0.001; mu2t = 0.001

# Function to calculate probabilities from 'true' parameter values
psim <- function(x){
  params <- list(p1 = p1t, p2 = p2t, mu1 = mu1t, mu2 = mu2t, t = x)
  eval.P1 <- eval(P1, params)
  eval.P2 <- eval(P2, params)
  P3 <- 1 - eval.P1 - eval.P2
  c(x, matrix(c(eval.P1, eval.P2, P3), ncol = 3))
}
pdat <- sapply(tv, psim, simplify = TRUE)
Pdat <- as.data.frame(t(pdat))
names(Pdat) <- c("time", "P1", "P2", "P3")

matplot(Pdat[,-1], type = "l", xlab = "time", ylab = "Probability",
col = c("black", "brown", "blue"),
lty = c(1:3), lwd = 2, ylim = c(0,1))
legend("topright", c("P1", "P2", "P3"),
   col = c("black", "brown", "blue"),
   lty = c(1:3), lwd = 2)
Pdat[160:180,] # psim function begins to return "NaN" at t = 178

# exponential terms in P1 and P2 expressions are problematic
params <- list(p1 = p1t, p2 = p2t, mu1 = mu1t, mu2 = mu2t, t = 178)

exp1 <- expression(exp(sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2)))*t))
eval(exp1, params) # returns Inf at t = 178

exp2 <- expression(exp((1/2)*(mu1 + mu2 + p1 + p2 +
  sqrt((mu1 + mu2 + p1 + p2)^2 -
  4*(mu2*p1 + mu1*(mu2 + p2*t))
eval(exp2, params) # also returns Inf at t = 178
##

The time step at which the exponential terms go to infinity depends on 
the values of the parameters p1, p2, mu1, mu2.  It seems that the 
convergence problems may be due to these exponential terms going to 
infinity.  Thus my convergence problem appears to be an overflow problem?


Unfortunately, I'm not sure where to go from here.  Due to the 
complexity of the P1 and P2 equations, there's no clear way to rearrange 
the equations to eliminate t from the exponential terms.


Does anyone have any suggestions on how to address this problem? 
Perhaps there is a way to bound p1, p2, mu1, and mu2 to avoid the 
exponential terms going to infinity?  Or bound P1 and P2?


Any suggestions would be greatly appreciated.

Adam Zeilinger



On 10/5/2012 3:06 AM, Berend Hasselman wrote:


On 05-10-2012, at 07:12, Adam Zeilinger wrote:


Hello R Help,

I am trying solve an MLE convergence problem: I would like to estimate four 
parameters, p1, p2, mu1, mu2, which relate to the probabilities, P1, P2, P3, of 
a multinomial (trinomial) distribution.  I am using the mle2() function and 
feeding it a time series dataset composed of four columns: time point, number 
of successes in category 1, number of successes in category 2, and number of 
success in category 3.  The column headers are: t, n1, n2, and n3.

The mle2() function converges occasionally, and I need to improve the rate of convergence when used 
in a stochastic simulation, with multiple stochastically generated datasets.  Whe

Re: [R] a merge() problem

2012-10-07 Thread Prof Brian Ripley

On 08/10/2012 02:57, Peter Ehlers wrote:

On 2012-10-07 14:44, Sam Steingold wrote:

* Peter Ehlers  [2012-10-07 10:03:42 -0700]:

On 2012-10-07 08:34, Sam Steingold wrote:

I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---

x <- data.frame(a=c(1,2,3),b=c(4,5,6))
y <- data.frame(b=c(1,2),a=c("a","b"))
merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))

a ba
1 1 4a
2 2 5b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".


The 'suffixes' argument refers to _non-by_ names only (as per ?merge).


yes, but "a" in "y" is _not_ a by-name.


Yes, it is.
The set of by-names is the union of names specified by by.x and by.y,
in your case: c("a", "b").
I suppose that a case could be made that ?merge does not spell that
out sufficiently explicitly.


It does in 'Details' (and where else would there be such a detail?) 
E.g. in R 2.15.1:


 If the remaining columns in the data frames have any common names,
 these have ‘suffixes’ (‘".x"’ and ‘".y"’ by default) appended to
 try to make the names of the result unique.  If this is not
 possible, an error is thrown.

Note *remaining*, and read what comes before that.



Peter Ehlers

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



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

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


[R] nlminb problem, convergence error code = 1

2012-10-07 Thread zugi young
Hi, I was trying to do a multi-level modeling of the data using the nlme
package. I encounter the following message:

> addRandomSlopeRange<- lme(FAN.range ~ CHN.range + Age + Block.T,
data=data.block, random = ~CHN.range|CHI, method = "ML", na.action=na.omit)

Error in lme.formula(FAN.range ~ CHN.range + Age + Block.T, data =
data.block,  :
  nlminb problem, convergence error code = 1
  message = iteration limit reached without convergence (10)

I get this error message only when FAN.range or FAN.avg is used as the
dependent variable.

> head(data.block)
  Block.N Block.T  CHI Age  CHN.avg  FAN.avg  CHN.min  FAN.min   CHN.max
1   3AICF C003 765 8.676307 7.257332 7.619782 5.033533  9.428432
2  25AICF C003 765 8.227647 6.475297 4.853860 4.452857 10.430625
3  32AICF C003 765 8.381634 6.720497 6.700553 4.977628  9.049861
4  50AICF C003 765 8.113471 6.037453 6.294747 4.958514  9.593018
5  59AICF C003 765 8.301553 7.444806 7.587508 4.808462 10.975600
6  61AICF C003 765 7.895683 6.319403 4.455857 4.198858 11.331577
FAN.max CHN.rate FAN.rate   CHN.dur  FAN.dur CHN.range FAN.range
1  9.995912 2.09 2.394000 0.633 1.984000  1.808650  4.962380
2  8.296612 2.53 2.91 1.580 1.335000  5.576765  3.843754
3  9.275749 2.46 2.767500 0.820 1.862500  2.349308  4.298121
4  7.914313 2.604286 3.112500 1.053 1.206250  3.298271  2.955799
5 11.436886 2.26 2.73 1.330 2.20  3.388092  6.628425
6 10.865545 3.00 2.77 1.000 1.526667  6.875720  6.87

The following work fine:
addRandomSlopeAvg<- lme(CHN.avg ~ FAN.avg + Age + Block.T, data=data.block,
random = ~FAN.avg|CHI, method = "ML", na.action=na.omit)
addRandomSlopeRange<- lme(CHN.range ~ FAN.range + Age + Block.T,
data=data.block, random = ~FAN.range|CHI, method = "ML", na.action=na.omit)
addRandomSlopeMin<- lme(FAN.min ~ CHN.min + Age + Block.T, data=data.block,
random = ~CHN.min|CHI, method = "ML", na.action=na.omit)
addRandomSlopeMax<- lme(FAN.max ~ CHN.max + Age + Block.T, data=data.block,
random = ~CHN.max|CHI, method = "ML", na.action=na.omit)

It is really strange that the script runs fine for minimum and maximum
values but not for the average. Does anyone have an insight?

[[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] Removing header from a matrix

2012-10-07 Thread David L Carlson
These are just column names, but if you want to remove them, it is easy:

> X1 <- c(20, 100)
> X2 <- c(25, 90)
> X3 <- c(40, 80)
> U <- cbind(X1, X2, X3)
> U
  X1 X2 X3
[1,]  20 25 40
[2,] 100 90 80
> colnames(U) <- NULL
> U
 [,1] [,2] [,3]
[1,]   20   25   40
[2,]  100   90   80


--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Dereje Bacha
> Sent: Sunday, October 07, 2012 10:13 PM
> To: r-help@r-project.org
> Subject: [R] Removing header from a matrix
> 
> I have three column vectors (X1, X2, X3).
> X1  X2  X3
>20   25  40
>100 90  80
> I want to put them as one matrix of dimention 2 by 3,  but remove
> headers(X1,X2,X3) from the matrix. I wrote
> as follows
> 
> U<-cbind (X1,X2,X3)
> 
> the headers are there. I need help please. Thanks
> Dereje
>   [[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] Removing header from a matrix

2012-10-07 Thread Jeff Newmiller
You need to clarify what you have and what you want. Please use the dput() 
function to create a reproducible example that we can enter into R to make 
suggestions about. [1]

There are a couple of possible things that could be going on here, and what you 
have given so far is ambiguous.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Dereje Bacha  wrote:

>I have three column vectors (X1, X2, X3).�
>��� X1� X2� X3 
>�� 20�� 25� 40
>�� 100 90� 80
>I want to put them as one matrix of dimention 2 by 3, �but remove
>headers(X1,X2,X3) from the matrix. I wrote
>as follows
>
>U<-cbind (X1,X2,X3)
>
>the headers are there. I need help please. Thanks
>Dereje
>   [[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] Removing header from a matrix

2012-10-07 Thread Dereje Bacha
I have three column vectors (X1, X2, X3). 
    X1  X2  X3 
   20   25  40
   100 90  80
I want to put them as one matrix of dimention 2 by 3,  but remove 
headers(X1,X2,X3) from the matrix. I wrote
as follows

U<-cbind (X1,X2,X3)

the headers are there. I need help please. Thanks
Dereje
[[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] a merge() problem

2012-10-07 Thread Peter Ehlers

On 2012-10-07 14:44, Sam Steingold wrote:

* Peter Ehlers  [2012-10-07 10:03:42 -0700]:

On 2012-10-07 08:34, Sam Steingold wrote:

I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---

x <- data.frame(a=c(1,2,3),b=c(4,5,6))
y <- data.frame(b=c(1,2),a=c("a","b"))
merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))

a ba
1 1 4a
2 2 5b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".


The 'suffixes' argument refers to _non-by_ names only (as per ?merge).


yes, but "a" in "y" is _not_ a by-name.


Yes, it is.
The set of by-names is the union of names specified by by.x and by.y,
in your case: c("a", "b").
I suppose that a case could be made that ?merge does not spell that
out sufficiently explicitly.

Peter Ehlers

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multinomial MCMCglmm

2012-10-07 Thread Ben Bolker
Vaniscotte  gmail.com> writes:

> 
> Dear all,
> 
> I would like to add mixed effects in a multinomial model and I am trying
> to use MCMCglmm for that.
  
 [snip]

> > "ill-conditioned G/R structure: use proper priors if you haven't or 
> rescale data if you have"
> 
> I guess that the problem comes from the nature of my observations which
> are frequencies instead of 0/1 per unit
> 
> Does someone know if a multinomial model fitted with MCMCglmm can handle
> those frequencies table and how to specify the good G/R variance
> structures?
> 

  (1) you should probably post this to r-sig-mixed-mod...@r-project.org
instead (and try to post only once ...)

  (2) multinomial models generally require *integer* responses (although
not necessarily 0/1); if you don't have a natural "denominator", you may
have to think a bit harder about this (a Dirichlet distribution would be
the natural way to model frequencies that sum to 1)

  (3) have you read the course notes vignette that comes with MCMCglmm?

  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.


Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread arun


HI,

Sorry, I complicated a code where it was not required at all.
Just using colnames(dat1)[4:6] or names(dat1)[4:6] should work if the species 
columns are adjacent to each other.


reshape(dat1,varying=4:6,v.name="Sp-value",times=colnames(dat1)[4:6],timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")
#or
reshape(dat1,varying=4:6,v.name="Sp-value",times=names(dat1)[4:6],timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")
A.K.


From: Andrea Goijman 
To: arun  
Cc: Rui Barradas ; R help  
Sent: Sunday, October 7, 2012 7:16 PM
Subject: Re: [R] Presence/ absence data from matrix to single column


Ill try this one as well.

And I guess the one below is not going  to work, because all my species have 
different names.

Thanks!

#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)

On Sun, Oct 7, 2012 at 3:02 PM, arun  wrote:

Hi,
>I guess you are not talking about the melt() method.
>dat1<-read.table(text="
>
>Year    Route    Point    Sp1    Sp2    Sp3
>2004    123    123-1    0    1    0
>2004    123    123-2    0    1    1
>2004    123    123-10    1    1    0
>",header=TRUE,sep="",stringsAsFactors=FALSE)
>
>
>#If all the Sp columns are located next to another as shown in your example 
>dataset, then you can also try this:
>name1<-unlist(strsplit(paste(colnames(dat1)[4:6],collapse=" ")," "))
>reshape(dat1,varying=4:6,v.name="Sp-value",times=name1,timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")
>
>
>A.K.
>
>
>
>
>
>
>- Original Message -
>
>From: Rui Barradas 
>To: agoijman 
>Cc: r-help@r-project.org
>Sent: Sunday, October 7, 2012 2:32 PM
>Subject: Re: [R] Presence/ absence data from matrix to single column
>
>Hello,
>
>I haven't been following this thread but apparently the answer to your
>worries is no.
>You can use a combination of names() and grep() to sort it out.
>something like
>
>#nms <- names(adat)
>nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))
>
>pattern <- "^Sp[[:digit:]]+$"
>whichCols <- grep(pattern, nms)
>whichNames <- nms[whichCols]
>
>reshape(..., varying = whichCols, times = whichNames, ...)
>
>
>Hope this helps,
>
>Rui Barradas
>Em 07-10-2012 15:35, agoijman escreveu:
>> The problem with that, is that I just wrote an example of my database, but I
>> have around 250 species and more than 500 sites. In the approach you show
>> me, it looks like I have to enter every species name and sites individually,
>> right?
>>
>>
>>
>> --
>> View this message in context: 
>> http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.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.
>
>


-- 

---Lic. Andrea Paula Goijman
Grupo Ecología y Gestión Ambiental de la Biodiversidad
IRB - INTA Castelar, Argentina
agoij...@cnia.inta.gov.arhttp://inta.gob.ar/personas/goijman.andrea/


PhD Candidate
Georgia Cooperative Fish and Wildlife Research Unit

D.B. Warnell School of Forestry and Natural Resources
University of Georgia
Athens, GA 30602 USA
Tel. +706.206.4805
andre...@uga.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Presence/ absence data from matrix to single column

2012-10-07 Thread Rui Barradas

Hello,

If all your species have different names, you can allways try one of
1. if the non-species follow a pattern, negate those columns and you'll 
have the species columns.

2. are the species the last columns? Use positional referencing.

Rui Barradas
Em 08-10-2012 00:16, Andrea Goijman escreveu:

Ill try this one as well.

And I guess the one below is not going  to work, because all my species
have different names.

Thanks!

#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)
On Sun, Oct 7, 2012 at 3:02 PM, arun  wrote:


Hi,
I guess you are not talking about the melt() method.
dat1<-read.table(text="
YearRoutePointSp1Sp2Sp3
2004123123-1010
2004123123-2011
2004123123-10110
",header=TRUE,sep="",stringsAsFactors=FALSE)


#If all the Sp columns are located next to another as shown in your
example dataset, then you can also try this:
name1<-unlist(strsplit(paste(colnames(dat1)[4:6],collapse=" ")," "))
reshape(dat1,varying=4:6,v.name
="Sp-value",times=name1,timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")

A.K.






- Original Message -
From: Rui Barradas 
To: agoijman 
Cc: r-help@r-project.org
Sent: Sunday, October 7, 2012 2:32 PM
Subject: Re: [R] Presence/ absence data from matrix to single column

Hello,

I haven't been following this thread but apparently the answer to your
worries is no.
You can use a combination of names() and grep() to sort it out.
something like

#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)


Hope this helps,

Rui Barradas
Em 07-10-2012 15:35, agoijman escreveu:

The problem with that, is that I just wrote an example of my database,

but I

have around 250 species and more than 500 sites. In the approach you show
me, it looks like I have to enter every species name and sites

individually,

right?



--
View this message in context:

http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.html

Sent from the R help mailing list archive at Nabble.com.

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.

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






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


[R] dist based kmeans clustering

2012-10-07 Thread eliza botto

Dear useRs,

i have a matrix X and i generated a distance matrix of X, let us call it Y. I 
did hierarchical clustering of Y and got some results. I just wanted to know 
that can i use the same distance matrix "Y" in Kmeans clustering? If not, then 
how can i use my own distance matrix for kmeans clustering? 

thanks in advance..
eliza

  
[[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] Robust regression for ordered data

2012-10-07 Thread Jeff Newmiller
I don't know about the topic of your question. Have you used the RSiteSearch 
function to research it yourself?
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Eiko Fried  wrote:

>Thank you Jeff! Please ignore the first of my two questions then, and
>apologies for not making it clear that my second question was about R.
>
>(2) "Are there ways of using robust regressions with ordered data" ...
>in
>R?
>
>Thank you
>
>
>On 7 October 2012 18:26, Jeff Newmiller 
>wrote:
>
>> This does not appear to be a question about R. You should post in a
>list
>> or forum dedicated to discussing statistics theory, such as
>> stats.stackoverflow.com.
>>
>---
>> Jeff NewmillerThe .   .  Go
>Live...
>> DCN:Basics: ##.#.   ##.#.  Live
>> Go...
>>   Live:   OO#.. Dead: OO#.. 
>Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#. 
>rocks...1k
>>
>---
>> Sent from my phone. Please excuse my brevity.
>>
>> Eiko Fried  wrote:
>>
>> >I have two regressions to perform - one with a metric DV (-3 to 3),
>the
>> >other with an ordered DV (0,1,2,3).
>> >
>> >Neither normal distribution not homoscedasticity is given. I have a
>two
>> >questions:
>> >
>> >(1) Some sources say robust regression take care of both lack of
>normal
>> >distribution and heteroscedasticity, while others say only of normal
>> >distribution. What is true?
>> >(2) Are there ways of using robust regressions with ordered data, or
>is
>> >that only possible for metric DVs?
>> >
>> >Thanks
>> >Torvon
>> >
>> >   [[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] Robust regression for ordered data

2012-10-07 Thread Bert Gunter
Have you checked the Robust task view on CRAN?? Would seem that that
should have been the first place to look.

-- Bert

On Sun, Oct 7, 2012 at 3:30 PM, Eiko Fried  wrote:
> Thank you Jeff! Please ignore the first of my two questions then, and
> apologies for not making it clear that my second question was about R.
>
> (2) "Are there ways of using robust regressions with ordered data" ... in
> R?
>
> Thank you
>
>
> On 7 October 2012 18:26, Jeff Newmiller  wrote:
>
>> This does not appear to be a question about R. You should post in a list
>> or forum dedicated to discussing statistics theory, such as
>> stats.stackoverflow.com.
>> ---
>> Jeff NewmillerThe .   .  Go Live...
>> DCN:Basics: ##.#.   ##.#.  Live
>> Go...
>>   Live:   OO#.. Dead: OO#..  Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
>> ---
>> Sent from my phone. Please excuse my brevity.
>>
>> Eiko Fried  wrote:
>>
>> >I have two regressions to perform - one with a metric DV (-3 to 3), the
>> >other with an ordered DV (0,1,2,3).
>> >
>> >Neither normal distribution not homoscedasticity is given. I have a two
>> >questions:
>> >
>> >(1) Some sources say robust regression take care of both lack of normal
>> >distribution and heteroscedasticity, while others say only of normal
>> >distribution. What is true?
>> >(2) Are there ways of using robust regressions with ordered data, or is
>> >that only possible for metric DVs?
>> >
>> >Thanks
>> >Torvon
>> >
>> >   [[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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread Andrea Goijman
Ill try this one as well.

And I guess the one below is not going  to work, because all my species
have different names.

Thanks!

#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)
On Sun, Oct 7, 2012 at 3:02 PM, arun  wrote:

> Hi,
> I guess you are not talking about the melt() method.
> dat1<-read.table(text="
> YearRoutePointSp1Sp2Sp3
> 2004123123-1010
> 2004123123-2011
> 2004123123-10110
> ",header=TRUE,sep="",stringsAsFactors=FALSE)
>
>
> #If all the Sp columns are located next to another as shown in your
> example dataset, then you can also try this:
> name1<-unlist(strsplit(paste(colnames(dat1)[4:6],collapse=" ")," "))
> reshape(dat1,varying=4:6,v.name
> ="Sp-value",times=name1,timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")
>
> A.K.
>
>
>
>
>
>
> - Original Message -
> From: Rui Barradas 
> To: agoijman 
> Cc: r-help@r-project.org
> Sent: Sunday, October 7, 2012 2:32 PM
> Subject: Re: [R] Presence/ absence data from matrix to single column
>
> Hello,
>
> I haven't been following this thread but apparently the answer to your
> worries is no.
> You can use a combination of names() and grep() to sort it out.
> something like
>
> #nms <- names(adat)
> nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))
>
> pattern <- "^Sp[[:digit:]]+$"
> whichCols <- grep(pattern, nms)
> whichNames <- nms[whichCols]
>
> reshape(..., varying = whichCols, times = whichNames, ...)
>
>
> Hope this helps,
>
> Rui Barradas
> Em 07-10-2012 15:35, agoijman escreveu:
> > The problem with that, is that I just wrote an example of my database,
> but I
> > have around 250 species and more than 500 sites. In the approach you show
> > me, it looks like I have to enter every species name and sites
> individually,
> > right?
> >
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.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.
>
>


-- 
---
Lic. Andrea Paula Goijman
Grupo Ecología y Gestión Ambiental de la Biodiversidad
IRB - INTA Castelar, Argentina
agoij...@cnia.inta.gov.ar
 
http://inta.gob.ar/personas/goijman.andrea/

PhD Candidate
Georgia Cooperative Fish and Wildlife Research Unit
D.B. Warnell School of Forestry and Natural Resources
University of Georgia
Athens, GA 30602 USA
Tel. +706.206.4805
andre...@uga.edu

[[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] Robust regression for ordered data

2012-10-07 Thread Eiko Fried
Thank you Jeff! Please ignore the first of my two questions then, and
apologies for not making it clear that my second question was about R.

(2) "Are there ways of using robust regressions with ordered data" ... in
R?

Thank you


On 7 October 2012 18:26, Jeff Newmiller  wrote:

> This does not appear to be a question about R. You should post in a list
> or forum dedicated to discussing statistics theory, such as
> stats.stackoverflow.com.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> Eiko Fried  wrote:
>
> >I have two regressions to perform - one with a metric DV (-3 to 3), the
> >other with an ordered DV (0,1,2,3).
> >
> >Neither normal distribution not homoscedasticity is given. I have a two
> >questions:
> >
> >(1) Some sources say robust regression take care of both lack of normal
> >distribution and heteroscedasticity, while others say only of normal
> >distribution. What is true?
> >(2) Are there ways of using robust regressions with ordered data, or is
> >that only possible for metric DVs?
> >
> >Thanks
> >Torvon
> >
> >   [[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] Robust regression for ordered data

2012-10-07 Thread Jeff Newmiller
This does not appear to be a question about R. You should post in a list or 
forum dedicated to discussing statistics theory, such as 
stats.stackoverflow.com.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Eiko Fried  wrote:

>I have two regressions to perform - one with a metric DV (-3 to 3), the
>other with an ordered DV (0,1,2,3).
>
>Neither normal distribution not homoscedasticity is given. I have a two
>questions:
>
>(1) Some sources say robust regression take care of both lack of normal
>distribution and heteroscedasticity, while others say only of normal
>distribution. What is true?
>(2) Are there ways of using robust regressions with ordered data, or is
>that only possible for metric DVs?
>
>Thanks
>Torvon
>
>   [[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] a merge() problem

2012-10-07 Thread Sam Steingold
> * Peter Ehlers  [2012-10-07 10:03:42 -0700]:
>
> On 2012-10-07 08:34, Sam Steingold wrote:
>> I know it does not look very good - using the same column names to mean
>> different things in different data frames, but here you go:
>> --8<---cut here---start->8---
>>> x <- data.frame(a=c(1,2,3),b=c(4,5,6))
>>> y <- data.frame(b=c(1,2),a=c("a","b"))
>>> merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))
>>a ba
>> 1 1 4a
>> 2 2 5b
>> 3 3 6 
>> Warning message:
>> In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
>>column name 'a' is duplicated in the result
>> --8<---cut here---end--->8---
>> why is the suffixes argument ignored?
>> I mean, I expected that the second "a" to be "a.y".
>
> The 'suffixes' argument refers to _non-by_ names only (as per ?merge).

yes, but "a" in "y" is _not_ a by-name.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://americancensorship.org
http://think-israel.org http://www.memritv.org http://mideasttruth.com
Save time: send elected officials to jail directly, bypassing the office.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Robust regression for ordered data

2012-10-07 Thread Eiko Fried
I have two regressions to perform - one with a metric DV (-3 to 3), the
other with an ordered DV (0,1,2,3).

Neither normal distribution not homoscedasticity is given. I have a two
questions:

(1) Some sources say robust regression take care of both lack of normal
distribution and heteroscedasticity, while others say only of normal
distribution. What is true?
(2) Are there ways of using robust regressions with ordered data, or is
that only possible for metric DVs?

Thanks
Torvon

[[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] Presence/ absence data from matrix to single column

2012-10-07 Thread David L Carlson
You should keep the context of your thread intact for those of us using
email instead of Nabble.

The locations were not listed individually anywhere in the reshape()
command. I listed Point as the id variable so reshape would use that to
create row names, but if you delete idvar="Point", reshape will give each
row a consecutive number followed by the species name or number.

I did list the species names individually in the times= argument to make
things a bit clearer since reshape() can be a confusing command at first.
But this would work as well:

reshape(adat, varying=4:6, v.name="Sp-value", 
  times=names(adat)[4:6], idvar="Point", 
  timevar="Sp-name", direction="long")

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> Date: Sun, 7 Oct 2012 07:35:42 -0700 (PDT)
> From: agoijman 
> To: r-help@r-project.org
> Subject: Re: [R] Presence/ absence data from matrix to single column
> 
> 
> The problem with that, is that I just wrote an example of my database, but
I
> have around 250 species and more than 500 sites. In the approach you show
> me, it looks like I have to enter every species name and sites
individually,
> right?
> 
> 
> --
> View this message in context:
http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-co
lumn-tp4645271p4645331.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.
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of David L Carlson
> > Sent: Saturday, October 06, 2012 10:25 PM
> > To: 'Jim Lemon'; 'agoijman'
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Presence/ absence data from matrix to single column
> > 
> > Also reshape() will work:
> > 
> > adat<-data.frame(Year=rep(2004,3),Route=rep(123,3),
> >   Point=c("123-1","123-2","123-10"),Sp1=c(0,0,1),
> >   Sp2=c(1,1,1),Sp3=c(0,1,0))
> > reshape(adat, varying=4:6, v.name="Sp-value",
> >   times=c("Sp1", "Sp2", "Sp3"), idvar="Point",
> >   timevar="Sp-name", direction="long")
> > 
> > --
> > David L Carlson
> > Associate Professor of Anthropology
> > Texas A&M University
> > College Station, TX 77843-4352
> > 
> > 
> > > -Original Message-
> > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > > project.org] On Behalf Of Jim Lemon
> > > Sent: Saturday, October 06, 2012 7:36 PM
> > > To: agoijman
> > > Cc: r-help@r-project.org
> > > Subject: Re: [R] Presence/ absence data from matrix to single column
> > >
> > > On 10/07/2012 01:03 AM, agoijman wrote:
> > > > I've been trying to reshape this database but haven't succeed at
> > it.
> > > I tried
> > > > using loops but can't get it right. I just want to reshape my
> > > database from
> > > > this matrix, to the one below, with only one column of data.
> > > >
> > > > YearRoute   Point   Sp1 Sp2 Sp3
> > > > 2004123 123-1   0   1   0
> > > > 2004123 123-2   0   1   1
> > > > 2004123 123-10  1   1   0
> > > >
> > > > What I want:
> > > >
> > > > YearRoute   Point
> > > > 2004123 123-1   Sp1 0
> > > > 2004123 123-2   Sp1 0
> > > > 2004123 123-10  Sp1 1
> > > > 2004123 123-1   Sp2 1
> > > > 2004123 123-2   Sp2 1
> > > > 2004123 123-10  Sp2 1
> > > > 2004123 123-1   Sp3 0
> > > > 2004123 123-2   Sp3 1
> > > > 2004123 123-10  Sp3 0
> > > >
> > > >
> > > Hi agoijman,
> > > You can do this using the rep_n_stack function.
> > >
> > > adat<-data.frame(Year=rep(2004,3),Route=rep(123,3),
> > >   Point=c("123-1","123-2","123-10"),Sp1=c(0,0,1),
> > >   Sp2=c(1,1,1),Sp3=c(0,1,0))
> > > library(prettyR)
> > > rep_n_stack(adat,c("Sp1","Sp2","Sp3"),
> > >   stack.names=c("Sp-names","Sp-values"))
> > >
> > > 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-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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 htt

Re: [R] Testing volatility cluster (heteroscedasticity) in stock return?

2012-10-07 Thread R. Michael Weylandt
On Sun, Oct 7, 2012 at 7:59 PM, Eko andryanto Prakasa
 wrote:
> Hi Michael,
>
> I'm sorry for the mistake..
> i don't know if it's not permitted to sent the same message to both (r-help 
> and r-sig)
> Thank's a lot for the information...
>
> Eko
>

No worries, it's a common enough first mistake. In the future, this
(and most of your previous postings) is definitely a
"finance-specific" question, so it should go there only.

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] gam error message: matrix not +ve definite

2012-10-07 Thread R. Michael Weylandt
On Sun, Oct 7, 2012 at 3:00 PM, garth  wrote:
> Hello,
>
> I'm running a multimodel analysis which involves fitting several GAM models
> as implemented in package mgcv.  The issue I'm having is that when I try to
> fit my model, gam gives me the following error message: 'Error in
> initial.sp(w * X, S, off) : S[[2]] matrix is not +ve definite.' The strange
> part of this is that the error message stops my model fitting function when
> run on a linux platform, but not on my local windows machine. Ordinarily I
> would just run the analysis on my local machine, but I need to run this from
> the linux machine to take advantage of the much larger computing capacity.
> The version of mgcv(1.7-21) and R (2.15.1) is the same on both machines.
>
> The data set to which the model if fitted is too large to post here but it
> contains 2209 observations, and the model is of the form: gam(Response~Year
> + s(Dayofyear,k=5,bs='cc') + s(Longitude,Latitude,k=4) +
> s(Coast_distance,k=4), family=Gamma('log'), data=dat, gamma=1.4)
>
> I realize this is a very particular question, but any help would be really
> appreciated.
> Thanks,
> Dan.
>

It's a bit of a shot in the dark, but might it reflect data that is
"close" to not being non-positive-definite and differences in BLAS?

The only other think I'd try would be a

update.packages(checkBuilt = TRUE, ask = FALSE)

to just update every package you've got installed. It might not be
that the error is from mgcv proper, but rather a dependency thereof
which is in different versions between the machines.

Also, I note you're posting through Nabble. Nabble actually only
mirrors the R-Help mailing list, so we (the majority of respondents
who don't use Nabble) don't get a forum view, but rather only emails
of individual posts. The net result of this is that we don't see
context of your follow-up postings unless you specifically include it,
but it's much appreciated if you do. I believe there might also be a
button which does so automatically, but I'll leave finding that to
you.


Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] BioConductor package: 'oligo'

2012-10-07 Thread R. Michael Weylandt
Hi Franklin,

As you note, this is a bioconductor package, and they have a separate
mailing list for support (fully of terribly knowledgeable and
responsive folks) I know it's somewhat unpleasant to be told to look
elsewhere after you've spent a good amount of time on it already, but
I think it's worth your time to repost to that list:
http://www.bioconductor.org/help/mailing-list/mailform/

Cheers,
Michael

On Sun, Oct 7, 2012 at 5:22 PM, Johnson, Franklin Theodore
 wrote:
> Dear Help,
>
>
>
> After loading the pd.Citrus library and checking the DataFrame, I ran
>> the R code for:
>>
>> 1) 'oligo'
>>
>>
>>
>> {> library(pd.citrus)
>> Loading required package: RSQLite
>> Loading required package: DBI
>> > data(pmSequence)
>>
>> > show(pmSequence)
>> DataFrame with 341730 rows and 2 columns
>> fid sequence
>>  
>> 1 990 GCGGAACGATGGCGATGGCTA
>> 2 991 CGACGGGTTGCCTTCGGAGCTAAAT
>> 3 992 TACTGCAGAAGACCATTACCCTACA
>> 4 993 TCACATAGCTGTGCAAGGACCGTAT
>> 5 994 TCGCCTAGCAAAGCTGCCAGCATGT
>> 6 995 TTACGTCTACGTGGTGGTGCTAAGA
>> 7 996 CCGAACGACCTGTTGGACCAAAGCA
>> 8 999 AAGCTAGTCTAGCTCCACCGACGGC
>> 9 1000 CACCGGTGACGTGCCGGTCGC
>> ... ... ...
>> 341722 963599 AAATTCGACACTTTACTGAGA
>> 341723 963790 GGATGCCCTCCGGTAATTGAATCAT
>> 341724 963802 GTTCAGCTCAAACCCTACATAGAGA
>> 341725 963818 GGATGTCTCAACCAGCTGGTT
>> 341726 963841 GAGAAGATGTTCAGAGGGCCCTACA
>> 341727 963859 GGTGCAGTTCGACTCTAAGTTTGCT
>> 341728 963863 AAACACGGTTATTCATCTGCGAAAC
>> 341729 963874 GATGCTCTTCATTGGGAGGCAGCGA
>> 341730 963889 ATTGATACAGCCTTCTCTGCAGTAA
>> > getwd()
>> [1] "C:/Users/franklin.johnson.PW50-WEN/Desktop/GSE33964_citrus epi
>> cells/exData"}
>>
>> {library(oligo)
>> > celFiles<-list.celfiles("exData", full.names=TRUE)
>> > affyCit<-read.celfiles("GSM839728_GF_28mm_EC-1.CEL",
>> "GSM839729_GF_28mm_EC-2.CEL", "GSM839730_GF_28mm_EC-3.CEL",
>> "GSM839731_GF_28mm_PC-1.CEL", "GSM839732_GF_28mm_PC-2.CEL",
>> "GSM839733_GF_28mm_PC-3.CEL", "GSM839734_GF_41mm_EC-1.CEL",
>> "GSM839735_GF_41mm_EC-2.CEL", "GSM839736_GF_41mm_EC-3.CEL",
>> "GSM839737_GF_41mm_PC-1.CEL", "GSM839738_GF_41mm_PC-2.CEL",
>> "GSM839739_GF_41mm_PC-3.CEL", pkgname="pd.citrus")
>> Platform design info loaded.
>> Reading in : GSM839728_GF_28mm_EC-1.CEL
>> Reading in : GSM839729_GF_28mm_EC-2.CEL
>> Reading in : GSM839730_GF_28mm_EC-3.CEL
>> Reading in : GSM839731_GF_28mm_PC-1.CEL
>> Reading in : GSM839732_GF_28mm_PC-2.CEL
>> Reading in : GSM839733_GF_28mm_PC-3.CEL
>> Reading in : GSM839734_GF_41mm_EC-1.CEL
>> Reading in : GSM839735_GF_41mm_EC-2.CEL
>> Reading in : GSM839736_GF_41mm_EC-3.CEL
>> Reading in : GSM839737_GF_41mm_PC-1.CEL
>> Reading in : GSM839738_GF_41mm_PC-2.CEL
>> Reading in : GSM839739_GF_41mm_PC-3.CEL
>> > pmSeq<-pmSequence(affyCit)
>> > pmSeq[1:10]
>> A DNAStringSet instance of length 10
>> width seq
>> [1] 25 GCGGAACGATGGCGATGGCTA
>> [2] 25 CGACGGGTTGCCTTCGGAGCTAAAT
>> [3] 25 TACTGCAGAAGACCATTACCCTACA
>> [4] 25 TCACATAGCTGTGCAAGGACCGTAT
>> [5] 25 TCGCCTAGCAAAGCTGCCAGCATGT
>> [6] 25 TTACGTCTACGTGGTGGTGCTAAGA
>> [7] 25 CCGAACGACCTGTTGGACCAAAGCA
>> [8] 25 AAGCTAGTCTAGCTCCACCGACGGC
>> [9] 25 CACCGGTGACGTGCCGGTCGC
>> [10] 25 GGTTAAGCCCGGCACTATCCGGGCA
>> > pmsLog2<-log2(pm(affyCit))
>> > plot(pmsLog2) #the plots looks good across arrays (object=affyCit)
>>
>> However, still get:
>> > coefs<-getAffinitySplineCoefficients(pmsLog2, pmSeq)
>> Error in model.frame.default(formula = intensities ~ design,
>> drop.unused.levels = TRUE) :
>> variable lengths differ (found for 'design')
>
>
>
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] oligo_1.22.0Biobase_2.18.0  oligoClasses_1.20.0
> [4] BiocInstaller_1.8.1 BiocGenerics_0.4.0
>
> loaded via a namespace (and not attached):
>  [1] affxparser_1.30.0 affyio_1.26.0 Biostrings_2.26.1
>  [4] bit_1.1-8 codetools_0.2-8   DBI_0.2-5
>  [7] ff_2.2-7  foreach_1.4.0 GenomicRanges_1.10.1
> [10] IRanges_1.16.2iterators_1.0.6   parallel_2.15.1
> [13] preprocessCore_1.20.0 splines_2.15.1stats4_2.15.1
> [16] tools_2.15.1  zlibbioc_1.4.0
>
> I have been working on the issue for two weeks already.
>
> For example, above I loaded the Citrus.pd, additionally, I tried working with 
> library(citruscdf), although this did not work either?
>
> Moreover, I used R 2.6 with the devel 'affyio' package version 1.27.1, but 
> cannot run 'oligo' with R 2.6 for some reason (i.e. error in list.celFiles 
> and read.celfiles commands), although R version for 'oligo' is 2.15 or 
> greater, so cannot use the list matrix generated in 'affyio' version 1.27 on 
> R 2.6 cause is does not seem co

Re: [R] Format of numbers in plotmath expressions.

2012-10-07 Thread William Dunlap
In-line comments below.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Rolf Turner
> Sent: Friday, October 05, 2012 5:02 PM
> To: Uwe Ligges
> Cc: r-help@r-project.org
> Subject: Re: [R] Format of numbers in plotmath expressions.
> 
> 
> 
> Thanks Uwe.  I think your recipe is substantially sexier than mine.
> 
> However I will, I believe, ***NEVER*** understand how to put together
> plotmath constructs.  They seem to require some subset of:
> 
>  * expression()
>  * bquote()
>  * substitute()
>  * parse()

Note that using parse was one source of your original problem.  You did
the equivalent of
   parse(text=paste("theta", "1.", sep="=="))
which gives the same result as
   parse(text=paste("theta", "1", sep="=="))
because "x==1." and "x==1" should be parsed to be the same expression.

If you wanted the string "1." to come out of parse then you would have
to quote it, as in
  legend("topleft",pch=1:5,legend=parse(text=paste0("theta == \"",TH,"\"")))
instead of your original
  legend("topleft",pch=1:5,legend=parse(text=paste0("theta == ", TH)))
This works because plotmath does not render the quotes in strings.

I would recommend taking parse(), paste(), substitute(), and even expression() 
off 
your list of things to try when using plotmath.  For single chunks of plotmath 
text,
isn't bquote() sufficient?  For multiple chunks (e.g., the strings given to 
legend or axis)
I think you can restrict  yourself to the idiom
as.expression(lapply(data, function(d)bquote(...))) 

mapply would be fine here also, but I would avoid sapply, as its simplification 
algorithm
can surprise you.  expression() is good when you have a fixed (parameterless)
expression you want to display, but bquote is just as good, so don't bother 
thinking
about using expression() in plotmath.

Here is an example of mapply used to make axis tick labels of the form
num * pi / den, leaving out unneeded 1's, and related legend labels:

curve(sin, from=0, to=6.5, axes=FALSE)
num  <- 0:8 ; den <- 4 # want labels num * pi / den, simplified when possible
labs <- as.expression(mapply(num, den, SIMPLIFY=FALSE, FUN=function(n, d)
{
gcd <- function(a,b) ifelse (b==0, a, gcd(b, a %% b))
div <- gcd(n, d)
if (div > 1) {
n <- n / div ; d <- d / div
}
if (n==0) {
bquote(0)
} else if (d==1) {
if (n==1) {
bquote(pi)
} else {
bquote(.(n)*pi)
}
} else {
if (n==1) {
bquote(pi/.(d))
} else {
bquote(.(n)*pi/.(d))
}
}
}
))
axis(side=1, at=num*pi/den, lab=labs)
# Now put theta= on the front of each label for the legend
legend("bottomleft", as.expression(lapply(labs, 
function(lab)bquote(theta==.(lab)

I am not an expert on plotmath, but my feeling from watching people use
it is that they tend to lose track of the boundary between standard R functions
and the functions by the same name used by plotmath for different purposes
By sticking to using bquote() for creating single plotmath exressions and
as.expression(lapply(..., function(x)bquote(.(x for collections of plotmath
expressions, you can concentrate on the learning the plotmath language itself.

Are there plotmath expressions that cannot be made with bquote instead of
parse(text=paste(...))?  Perhaps not, but some with a variable number of
components may be more easily done with parse.

>  * paste()
>  * as.expression()
>  * .(...)
> 
> (and quite possibly other things that I have forgotten) in a bewildering
> variety of combinations with no perceptible rationale as what combination
> is required in what circumstances.
> 
> It makes quantum mechanics look simple by comparison.
> 
>  cheers,
> 
>  Rolf
> 
> On 06/10/12 06:58, Uwe Ligges wrote:
> >
> >
> > On 05.10.2012 09:30, Rolf Turner wrote:
> >>
> >> I want to do something like:
> >>
> >> TH <- sprintf("%1.1f",c(0.3,0.5,0.7,0.9,1))
> >> plot(1:10)
> >> legend("bottomright",pch=1:5,legend=parse(text=paste("theta ==",TH)))
> >>
> >> Notice that the final "1" comes out in the legend as just plain "1"
> >> and NOT
> >> as "1.0" although TH is
> >>
> >> [1] "0.3" "0.5" "0.7" "0.9" "1.0"
> >>
> >> I can get plotmath to preserve "1.0" as "1.0" and NOT convert it to "1"
> >> if I use substitute, as in
> >>
> >> text(2,5,labels=substitute(list(theta == a),list(a=TH[5])))
> >>
> >> but substitute doesn't work appropriately with vectors.
> >>
> >> Can anyone tell me how to get a "1.0" rather than "1" in the legend?
> >>
> >> Ta.
> >>
> >>  cheers,
> >>
> >>  Rolf Turner
> >>
> >> P.S. Just figured out a way using sapply():
> >>
> >> leg <- sapply(TH,function(x){substitute(list(theta == a),list(a=x))})
> >> plot(1:10)
> >> legend("bottomrigh

[R] BioConductor package: 'oligo'

2012-10-07 Thread Johnson, Franklin Theodore
Dear Help,



After loading the pd.Citrus library and checking the DataFrame, I ran
> the R code for:
>
> 1) 'oligo'
>
>
>
> {> library(pd.citrus)
> Loading required package: RSQLite
> Loading required package: DBI
> > data(pmSequence)
>
> > show(pmSequence)
> DataFrame with 341730 rows and 2 columns
> fid sequence
>  
> 1 990 GCGGAACGATGGCGATGGCTA
> 2 991 CGACGGGTTGCCTTCGGAGCTAAAT
> 3 992 TACTGCAGAAGACCATTACCCTACA
> 4 993 TCACATAGCTGTGCAAGGACCGTAT
> 5 994 TCGCCTAGCAAAGCTGCCAGCATGT
> 6 995 TTACGTCTACGTGGTGGTGCTAAGA
> 7 996 CCGAACGACCTGTTGGACCAAAGCA
> 8 999 AAGCTAGTCTAGCTCCACCGACGGC
> 9 1000 CACCGGTGACGTGCCGGTCGC
> ... ... ...
> 341722 963599 AAATTCGACACTTTACTGAGA
> 341723 963790 GGATGCCCTCCGGTAATTGAATCAT
> 341724 963802 GTTCAGCTCAAACCCTACATAGAGA
> 341725 963818 GGATGTCTCAACCAGCTGGTT
> 341726 963841 GAGAAGATGTTCAGAGGGCCCTACA
> 341727 963859 GGTGCAGTTCGACTCTAAGTTTGCT
> 341728 963863 AAACACGGTTATTCATCTGCGAAAC
> 341729 963874 GATGCTCTTCATTGGGAGGCAGCGA
> 341730 963889 ATTGATACAGCCTTCTCTGCAGTAA
> > getwd()
> [1] "C:/Users/franklin.johnson.PW50-WEN/Desktop/GSE33964_citrus epi
> cells/exData"}
>
> {library(oligo)
> > celFiles<-list.celfiles("exData", full.names=TRUE)
> > affyCit<-read.celfiles("GSM839728_GF_28mm_EC-1.CEL",
> "GSM839729_GF_28mm_EC-2.CEL", "GSM839730_GF_28mm_EC-3.CEL",
> "GSM839731_GF_28mm_PC-1.CEL", "GSM839732_GF_28mm_PC-2.CEL",
> "GSM839733_GF_28mm_PC-3.CEL", "GSM839734_GF_41mm_EC-1.CEL",
> "GSM839735_GF_41mm_EC-2.CEL", "GSM839736_GF_41mm_EC-3.CEL",
> "GSM839737_GF_41mm_PC-1.CEL", "GSM839738_GF_41mm_PC-2.CEL",
> "GSM839739_GF_41mm_PC-3.CEL", pkgname="pd.citrus")
> Platform design info loaded.
> Reading in : GSM839728_GF_28mm_EC-1.CEL
> Reading in : GSM839729_GF_28mm_EC-2.CEL
> Reading in : GSM839730_GF_28mm_EC-3.CEL
> Reading in : GSM839731_GF_28mm_PC-1.CEL
> Reading in : GSM839732_GF_28mm_PC-2.CEL
> Reading in : GSM839733_GF_28mm_PC-3.CEL
> Reading in : GSM839734_GF_41mm_EC-1.CEL
> Reading in : GSM839735_GF_41mm_EC-2.CEL
> Reading in : GSM839736_GF_41mm_EC-3.CEL
> Reading in : GSM839737_GF_41mm_PC-1.CEL
> Reading in : GSM839738_GF_41mm_PC-2.CEL
> Reading in : GSM839739_GF_41mm_PC-3.CEL
> > pmSeq<-pmSequence(affyCit)
> > pmSeq[1:10]
> A DNAStringSet instance of length 10
> width seq
> [1] 25 GCGGAACGATGGCGATGGCTA
> [2] 25 CGACGGGTTGCCTTCGGAGCTAAAT
> [3] 25 TACTGCAGAAGACCATTACCCTACA
> [4] 25 TCACATAGCTGTGCAAGGACCGTAT
> [5] 25 TCGCCTAGCAAAGCTGCCAGCATGT
> [6] 25 TTACGTCTACGTGGTGGTGCTAAGA
> [7] 25 CCGAACGACCTGTTGGACCAAAGCA
> [8] 25 AAGCTAGTCTAGCTCCACCGACGGC
> [9] 25 CACCGGTGACGTGCCGGTCGC
> [10] 25 GGTTAAGCCCGGCACTATCCGGGCA
> > pmsLog2<-log2(pm(affyCit))
> > plot(pmsLog2) #the plots looks good across arrays (object=affyCit)
>
> However, still get:
> > coefs<-getAffinitySplineCoefficients(pmsLog2, pmSeq)
> Error in model.frame.default(formula = intensities ~ design,
> drop.unused.levels = TRUE) :
> variable lengths differ (found for 'design')



> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] oligo_1.22.0Biobase_2.18.0  oligoClasses_1.20.0
[4] BiocInstaller_1.8.1 BiocGenerics_0.4.0

loaded via a namespace (and not attached):
 [1] affxparser_1.30.0 affyio_1.26.0 Biostrings_2.26.1
 [4] bit_1.1-8 codetools_0.2-8   DBI_0.2-5
 [7] ff_2.2-7  foreach_1.4.0 GenomicRanges_1.10.1
[10] IRanges_1.16.2iterators_1.0.6   parallel_2.15.1
[13] preprocessCore_1.20.0 splines_2.15.1stats4_2.15.1
[16] tools_2.15.1  zlibbioc_1.4.0

I have been working on the issue for two weeks already.

For example, above I loaded the Citrus.pd, additionally, I tried working with 
library(citruscdf), although this did not work either?

Moreover, I used R 2.6 with the devel 'affyio' package version 1.27.1, but 
cannot run 'oligo' with R 2.6 for some reason (i.e. error in list.celFiles and 
read.celfiles commands), although R version for 'oligo' is 2.15 or greater, so 
cannot use the list matrix generated in 'affyio' version 1.27 on R 2.6 cause is 
does not seem compatible with 'oligo' version 1.22 on R 2.6. I am also using 
the recently updated BioC version 2.11.

In oligo using R v. 2.15, I am able to view the .CEL images, make boxplots, 
MAplots of the data, but cannot proceed beyond this point (as indicated above).



In summary, is this a bug in the 'oligo' package??



Any assistance is greatly appreciated.

If you have questions or need additional information, please feel free to 
contact me.



Best Regards,



Franklin



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/lis

[R] gam error message: matrix not +ve definite

2012-10-07 Thread garth
Hello, 

I'm running a multimodel analysis which involves fitting several GAM models
as implemented in package mgcv.  The issue I'm having is that when I try to
fit my model, gam gives me the following error message: 'Error in
initial.sp(w * X, S, off) : S[[2]] matrix is not +ve definite.' The strange
part of this is that the error message stops my model fitting function when
run on a linux platform, but not on my local windows machine. Ordinarily I
would just run the analysis on my local machine, but I need to run this from
the linux machine to take advantage of the much larger computing capacity.
The version of mgcv(1.7-21) and R (2.15.1) is the same on both machines. 

The data set to which the model if fitted is too large to post here but it
contains 2209 observations, and the model is of the form: gam(Response~Year
+ s(Dayofyear,k=5,bs='cc') + s(Longitude,Latitude,k=4) +
s(Coast_distance,k=4), family=Gamma('log'), data=dat, gamma=1.4)

I realize this is a very particular question, but any help would be really
appreciated.
Thanks,
Dan.



--
View this message in context: 
http://r.789695.n4.nabble.com/gam-error-message-matrix-not-ve-definite-tp4645329.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] Problem with national characters in main, xlab, ylab with pdf{grDevices} / postscript {grDevices}

2012-10-07 Thread Magdalena A. Tkacz
Hello.

Yes, you're right -Poland, Central/Eastern Europe.
My apologies - my fault  - not to state it directly in post.

Than you for your advice, especially concerning viewer (when OS is Win).

Under Windows (checked both on english and polish version of OS) works
fine with font family you proposed, previewed with Sumatra PDF or
TeXworks internal viewer (Adobe Reader does NOT display generated pdf
correctly ).

On my Linux workstation, cairo_pdf(fileName.pdf) works OK without any
additional parameters, both Okular and Document Viewer also works fine
as a viewers.

Thank You very much.
Problem solved.

Regards

Magdalena Tkacz


2012/10/7 Prof Brian Ripley :
> 'National': not my nation, and none is stated.  Somewhere in Eastern Europe
> ... Poland?
>
> Short answer: you need to use a family which contains those glyphs (try
> family='NimbusSan': the default 'Helvetica' does not) *and* a viewer that
> uses fonts that do.
>
> Longer answer: read ?pdf and ?postscript carefully, as they told you this
> and more.
>
> Your example works correctly with that family for me on Linux, but not with
> OS X viewers.  It does not with the default family.
>
> For people on Unix I would suggest the cairo_pdf() device as a possibly
> easier alternative since it usually embeds fonts.  On Windows and OS X you
> are at the mercy of what fonts cairo has access to.  That's all in the help,
> too.
>
>
> On Sun, 7 Oct 2012, Magdalena A. Tkacz wrote:
>
>> Hello.
>>
>> I'm trying to make some graphics with nationalized labels (pdf for use
>> in LaTeX document).
>>
>>
>> On console (displayed on screen) using  all looks ok:
>> \/
>> data<-rnorm(100)
>> hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
>> ylab='Częstość występowania')
>> ---/\
>>
>> But using:
>> ---\/
>> data<-rnorm(100)
>>
>> pdf('plik.pdf',encoding="CP1250.enc")
>> hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
>> ylab='Częstość występowania')
>> dev.off()
>> /\
>>
>> It does not look fine ...
>
>
> Actually it is just a binary file, and no viewer has been mentioned.
>
>>
>> Without specifying encoding:
>> ---\/
>> pdf('plik-wo-enc.pdf')
>> hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
>> ylab='Częstość występowania')
>> dev.off()
>> -/\
>> Almost does not have national characters. (Almost, because "ó" letter
>> appears)
>>
>> Exemplary pdf file are here:
>>
>> https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167942261/plik.pdf
>>
>> https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167945977/plik-wo-enc.pdf
>>
>>
>> I have read "Non-Standard Fonts in PostScript and PDF Graphics" by
>> Paul Murrell and Brian Ripley in Rnews.
>>
>> I have also tried option with
>> ---\/
>> Sys.setlocale(category="LC_CTYPE", locale="pl_PL.utf8")
>> ---/\
>> but even in admin (run R as admin) in Win7 I received warning:
>> ---\/
>> "In Sys.setlocale(category = "LC_CTYPE", locale = "pl_PL.utf8") :
>> Żądania raportów OS aby ustawić lokalizację na "pl_PL.utf8" nie mogą
>> zostać wykonane"
>> ---/\
>> (translated in short : OS report request to set locale to "pl_PL.utf8"
>> can not be done)
>>
>>
>> Does anyone knows how to obtain pdf documents with acceptable quality?
>>
>>
>>
>> Thanks in advance,
>>
>> Regards
>>
>> --
>> /|/| _ _ _/_ /_   _  /  / _ __
>> /   |(/(/(/(/((-/)(/ (  /((/( /_
>> _/
>> Magdalena Tkacz
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595



-- 
/|/| _ _ _/_ /_   _  /  / _ __
/   |(/(/(/(/((-/)(/ (  /((/( /_
 _/
Magdalena Tkacz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Presence/ absence data from matrix to single column

2012-10-07 Thread arun
Hi,
I guess you are not talking about the melt() method.
dat1<-read.table(text="
Year    Route    Point    Sp1    Sp2    Sp3
2004    123    123-1    0    1    0
2004    123    123-2    0    1    1
2004    123    123-10    1    1    0
",header=TRUE,sep="",stringsAsFactors=FALSE)


#If all the Sp columns are located next to another as shown in your example 
dataset, then you can also try this:
name1<-unlist(strsplit(paste(colnames(dat1)[4:6],collapse=" ")," "))
reshape(dat1,varying=4:6,v.name="Sp-value",times=name1,timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long")

A.K.






- Original Message -
From: Rui Barradas 
To: agoijman 
Cc: r-help@r-project.org
Sent: Sunday, October 7, 2012 2:32 PM
Subject: Re: [R] Presence/ absence data from matrix to single column

Hello,

I haven't been following this thread but apparently the answer to your 
worries is no.
You can use a combination of names() and grep() to sort it out. 
something like

#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)


Hope this helps,

Rui Barradas
Em 07-10-2012 15:35, agoijman escreveu:
> The problem with that, is that I just wrote an example of my database, but I
> have around 250 species and more than 500 sites. In the approach you show
> me, it looks like I have to enter every species name and sites individually,
> right?
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


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


Re: [R] Testing volatility cluster (heteroscedasticity) in stock return?

2012-10-07 Thread Eko andryanto Prakasa
Hi Michael,

I'm sorry for the mistake..
i don't know if it's not permitted to sent the same message to both (r-help and 
r-sig)
Thank's a lot for the information...

Eko



 
- Original Message -
From: R. Michael Weylandt 
To: Eko andryanto Prakasa 
Cc: "r-help@R-project.org" 
Sent: Monday, October 8, 2012 12:56 AM
Subject: Re: [R] Testing volatility cluster (heteroscedasticity) in stock 
return?

Hi Eko,

Please don't cross-post to both R-Help and R-SIG-Finance.

Michael

On Sun, Oct 7, 2012 at 6:49 PM, Eko andryanto Prakasa
 wrote:
> Dear All,
> i want to use garch model in return of stock. and the data should presence 
> volatility cluster (Heteroscedasticity).
> Do you know how to test volatility cluster (the presence of 
> heteroscedasticity) in series data of stock return in R?
> Is it using Langrange Multiplier (LM)  ARCH test? what package i should use?
> I really need the help. Thanks for the attention.
> Eko A P
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Presence/ absence data from matrix to single column

2012-10-07 Thread Rui Barradas

Hello,

I haven't been following this thread but apparently the answer to your 
worries is no.
You can use a combination of names() and grep() to sort it out. 
something like


#nms <- names(adat)
nms <- c("Year", "Route", "Point", paste0("Sp", 1:250))

pattern <- "^Sp[[:digit:]]+$"
whichCols <- grep(pattern, nms)
whichNames <- nms[whichCols]

reshape(..., varying = whichCols, times = whichNames, ...)


Hope this helps,

Rui Barradas
Em 07-10-2012 15:35, agoijman escreveu:

The problem with that, is that I just wrote an example of my database, but I
have around 250 species and more than 500 sites. In the approach you show
me, it looks like I have to enter every species name and sites individually,
right?



--
View this message in context: 
http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.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] a merge() problem

2012-10-07 Thread Peter Ehlers

On 2012-10-07 10:50, arun wrote:

Hi,

Though, this does give the result you wanted when the column names are the same.
  y1<-y
  colnames(y1)<-c("a","b")
merge(x,y1,by="a",all=TRUE,suffixes=c("",".y"))
#  a b  b.y
#1 1 4a
#2 2 5b
#3 3 6 
A.K.


Yes, because 'b' is _not_ a 'by'-name.

Peter Ehlers






- Original Message -
From: Sam Steingold 
To: r-help@r-project.org
Cc:
Sent: Sunday, October 7, 2012 11:34 AM
Subject: [R] a merge() problem

I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---

x <- data.frame(a=c(1,2,3),b=c(4,5,6))
y <- data.frame(b=c(1,2),a=c("a","b"))
merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))

   a ba
1 1 4a
2 2 5b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
   column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".
(when I omit suffixes, the result is the same).
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] Testing volatility cluster (heteroscedasticity) in stock return?

2012-10-07 Thread R. Michael Weylandt
Hi Eko,

Please don't cross-post to both R-Help and R-SIG-Finance.

Michael

On Sun, Oct 7, 2012 at 6:49 PM, Eko andryanto Prakasa
 wrote:
> Dear All,
> i want to use garch model in return of stock. and the data should presence 
> volatility cluster (Heteroscedasticity).
> Do you know how to test volatility cluster (the presence of 
> heteroscedasticity) in series data of stock return in R?
> Is it using Langrange Multiplier (LM)  ARCH test? what package i should use?
> I really need the help. Thanks for the attention.
> Eko A P
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] a merge() problem

2012-10-07 Thread arun
Hi,

Though, this does give the result you wanted when the column names are the same.
 y1<-y
 colnames(y1)<-c("a","b")
merge(x,y1,by="a",all=TRUE,suffixes=c("",".y"))
#  a b  b.y
#1 1 4    a
#2 2 5    b
#3 3 6 
A.K.




- Original Message -
From: Sam Steingold 
To: r-help@r-project.org
Cc: 
Sent: Sunday, October 7, 2012 11:34 AM
Subject: [R] a merge() problem

I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---
> x <- data.frame(a=c(1,2,3),b=c(4,5,6))
> y <- data.frame(b=c(1,2),a=c("a","b"))
> merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))
  a b    a
1 1 4    a
2 2 5    b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
  column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".
(when I omit suffixes, the result is the same).
Thanks.
-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://palestinefacts.org http://honestreporting.com
http://truepeace.org http://openvotingconsortium.org
My name is Deja Vu. Have we met before?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Testing volatility cluster (heteroscedasticity) in stock return?

2012-10-07 Thread Eko andryanto Prakasa
Dear All,
i want to use garch model in return of stock. and the data should presence 
volatility cluster (Heteroscedasticity).
Do you know how to test volatility cluster (the presence of heteroscedasticity) 
in series data of stock return in R?
Is it using Langrange Multiplier (LM)  ARCH test? what package i should use?
I really need the help. Thanks for the attention.
Eko A P

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


Re: [R] Problem with national characters in main, xlab, ylab with pdf{grDevices} / postscript {grDevices}

2012-10-07 Thread Prof Brian Ripley
'National': not my nation, and none is stated.  Somewhere in Eastern 
Europe ... Poland?


Short answer: you need to use a family which contains those glyphs 
(try family='NimbusSan': the default 'Helvetica' does not) *and* a 
viewer that uses fonts that do.


Longer answer: read ?pdf and ?postscript carefully, as they told you 
this and more.


Your example works correctly with that family for me on Linux, 
but not with OS X viewers.  It does not with the default family.


For people on Unix I would suggest the cairo_pdf() device as a 
possibly easier alternative since it usually embeds fonts.  On 
Windows and OS X you are at the mercy of what fonts cairo has access 
to.  That's all in the help, too.


On Sun, 7 Oct 2012, Magdalena A. Tkacz wrote:


Hello.

I'm trying to make some graphics with nationalized labels (pdf for use
in LaTeX document).


On console (displayed on screen) using  all looks ok:
\/
data<-rnorm(100)
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
---/\

But using:
---\/
data<-rnorm(100)

pdf('plik.pdf',encoding="CP1250.enc")
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
dev.off()
/\

It does not look fine ...


Actually it is just a binary file, and no viewer has been mentioned.



Without specifying encoding:
---\/
pdf('plik-wo-enc.pdf')
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
dev.off()
-/\
Almost does not have national characters. (Almost, because "ó" letter appears)

Exemplary pdf file are here:
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167942261/plik.pdf
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167945977/plik-wo-enc.pdf


I have read "Non-Standard Fonts in PostScript and PDF Graphics" by
Paul Murrell and Brian Ripley in Rnews.

I have also tried option with
---\/
Sys.setlocale(category="LC_CTYPE", locale="pl_PL.utf8")
---/\
but even in admin (run R as admin) in Win7 I received warning:
---\/
"In Sys.setlocale(category = "LC_CTYPE", locale = "pl_PL.utf8") :
Żądania raportów OS aby ustawić lokalizację na "pl_PL.utf8" nie mogą
zostać wykonane"
---/\
(translated in short : OS report request to set locale to "pl_PL.utf8"
can not be done)


Does anyone knows how to obtain pdf documents with acceptable quality?



Thanks in advance,

Regards

--
/|/| _ _ _/_ /_   _  /  / _ __
/   |(/(/(/(/((-/)(/ (  /((/( /_
_/
Magdalena Tkacz

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a merge() problem

2012-10-07 Thread Peter Ehlers

On 2012-10-07 08:34, Sam Steingold wrote:

I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---

x <- data.frame(a=c(1,2,3),b=c(4,5,6))
y <- data.frame(b=c(1,2),a=c("a","b"))
merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))

   a ba
1 1 4a
2 2 5b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
   column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".


The 'suffixes' argument refers to _non-by_ names only (as per ?merge).

Peter Ehlers


(when I omit suffixes, the result is the same).
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] Computing for Data Analysis ~ R

2012-10-07 Thread David Winsemius
This is not the mailing list for any course.

-- 

On Oct 7, 2012, at 12:27 AM, brigettebre...@aol.com wrote:

> Do to work schedules, I may have to  discontinue.
> 
> I really like this course and wish to finish. When is this course offered  
> again, and if so, can I take again?
> 
> Or, do we have to submit my even the hard deadlines? I can continue if we  
> do not have to submit even by the hard deadline.
> 
> I am the type of person, I have to "understand" what I am doing, but just  
> memorizing and then performing.
> 
> Thanks,
> 
> Dr. Brenda Nelson-Porter
>   [[alternative HTML version deleted]]
> 

--
David Winsemius, MD
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get: problem with environments

2012-10-07 Thread Martin Ivanov
 Thank You very much for Your replies.
Dear Michael,

"Does this persist after a new session (perhaps running as R --vanilla) and/or 
reinstall?"
Yes, it does. After running R --vanilla, still there are 4 contexts more on the 
call stack.
 
"You didn't show us how you tried to use parent.frame()"
I did it like this:
testfun1 <- function (x1) {
 a1 <- 1;
 sapply(X="a1", FUN=get, envir=parent.frame(x1));
}

testfun1(x1=1);

The above code never succeeds no matter what a number I give to x1.

" 3. Why does the number of contexts in the call stack differ in R and in 
rkward?
 It shouldn't. This is an issue that needs further sorting out."

Here is some more info on my setup:
sessionInfo()   
R version 2.15.1 (2012-06-22)
Platform: x86_64-slackware-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US   LC_NUMERIC=C LC_TIME=en_US   
 [4] LC_COLLATE=C LC_MONETARY=en_USLC_MESSAGES=en_US   
 [7] LC_PAPER=C   LC_NAME=CLC_ADDRESS=C
[10] LC_TELEPHONE=C   LC_MEASUREMENT=en_US LC_IDENTIFICATION=C 

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

loaded via a namespace (and not attached):
[1] tools_2.15.1


Best regards,

Martin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 national characters in main, xlab, ylab with pdf{grDevices} / postscript {grDevices}

2012-10-07 Thread Magdalena A. Tkacz
Hello.

I'm trying to make some graphics with nationalized labels (pdf for use
in LaTeX document).


On console (displayed on screen) using  all looks ok:
\/
data<-rnorm(100)
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
---/\

But using:
---\/
data<-rnorm(100)

pdf('plik.pdf',encoding="CP1250.enc")
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
dev.off()
/\

It does not look fine ...

Without specifying encoding:
---\/
pdf('plik-wo-enc.pdf')
hist(data,main='Rozkład gęstości punktów', xlab='Wartość na osi y',
ylab='Częstość występowania')
dev.off()
-/\
Almost does not have national characters. (Almost, because "ó" letter appears)

Exemplary pdf file are here:
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167942261/plik.pdf
https://www.drivehq.com/file/df.aspx/shareID10318887/fileID1167945977/plik-wo-enc.pdf


I have read "Non-Standard Fonts in PostScript and PDF Graphics" by
Paul Murrell and Brian Ripley in Rnews.

I have also tried option with
---\/
Sys.setlocale(category="LC_CTYPE", locale="pl_PL.utf8")
---/\
but even in admin (run R as admin) in Win7 I received warning:
---\/
"In Sys.setlocale(category = "LC_CTYPE", locale = "pl_PL.utf8") :
Żądania raportów OS aby ustawić lokalizację na "pl_PL.utf8" nie mogą
zostać wykonane"
---/\
(translated in short : OS report request to set locale to "pl_PL.utf8"
can not be done)


Does anyone knows how to obtain pdf documents with acceptable quality?



Thanks in advance,

Regards

-- 
/|/| _ _ _/_ /_   _  /  / _ __
/   |(/(/(/(/((-/)(/ (  /((/( /_
 _/
Magdalena Tkacz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a merge() problem

2012-10-07 Thread Sam Steingold
I know it does not look very good - using the same column names to mean
different things in different data frames, but here you go:
--8<---cut here---start->8---
> x <- data.frame(a=c(1,2,3),b=c(4,5,6))
> y <- data.frame(b=c(1,2),a=c("a","b"))
> merge(x,y,by.x="a",by.y="b",all.x=TRUE,suffixes=c("","y"))
  a ba
1 1 4a
2 2 5b
3 3 6 
Warning message:
In merge.data.frame(x, y, by.x = "a", by.y = "b", all.x = TRUE) :
  column name 'a' is duplicated in the result
--8<---cut here---end--->8---
why is the suffixes argument ignored?
I mean, I expected that the second "a" to be "a.y".
(when I omit suffixes, the result is the same).
Thanks.
-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://palestinefacts.org http://honestreporting.com
http://truepeace.org http://openvotingconsortium.org
My name is Deja Vu. Have we met before?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Presence/ absence data from matrix to single column

2012-10-07 Thread agoijman
The problem with that, is that I just wrote an example of my database, but I
have around 250 species and more than 500 sites. In the approach you show
me, it looks like I have to enter every species name and sites individually,
right?



--
View this message in context: 
http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645331.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] get: problem with environments

2012-10-07 Thread R. Michael Weylandt
On Sun, Oct 7, 2012 at 12:33 PM, Rui Barradas  wrote:
> Hello,
>
> No, I can't confirm the behavior the op sees.
> I've tried it in an R terminal on ubuntu 12.04, rkward on ubuntu, and RGui
> on Windows 7. R version 2.15.1.
>
> Here's the rkward sessionInfo.
>
> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-linux-gnu (64-bit)

On Sun, Oct 7, 2012 at 1:28 PM, arun  wrote:
> I am getting the same error message as Michael got (R terminal (R 2.15) on 
> Ubuntu 12.04).
>
>   testfun(x=5)
> #Error in sys.frame(which = x) : not that many frames on the stack
>  print(testfun(x=6))
> #Error in sys.frame(which = x) : not that many frames on the stack
>

From: R. Michael Weylandt 
> To: Martin Ivanov 
> Cc: r-help@r-project.org
> Sent: Sunday, October 7, 2012 5:34 AM
> Subject: Re: [R] get: problem with environments
>
> On Sun, Oct 7, 2012 at 10:16 AM, Martin Ivanov  wrote:
>>  Dear R users,
>>
>> I am running R-2.15.1 in Linux Slackware64-14.0. Here is my minimal working 
>> example:
>>
>> testfun <- function (x) {
>>  a <- 0;
>>  sapply(X="a", FUN=get, envir=sys.frame(which=x));
>> }
>>
>> Inside R, that is R called from within a Linux terminal, the following code 
>> works:
>> testfun(x=5)
>> print(testfun(x=6))
>> But within rkward the above code fails and the following works:
>> testfun(x=1)
>> print(testfun(x=2))
>>
>> As you can see, the number of contexts up the call stack that contain the 
>> variable "a"
>> varies depending on the implementation. If I call testfun() from within 
>> print(), I have to go
>> one context up the call stack than if I call testfun() alone by itself. This 
>> implies
>> some inherent instability of my code.
>
> Unlike you, I don't get testfun(x = 5) to work in a terminal emulator.
> As expected, I only get x =1 and print(... x = 2) to work and I just
> tried this with R 2.15.0 and R devel, both in Terminal and by way of
> ESS.  It could be a buglet introduced later into the 2.15 branch, but
> that seems unlikely. As expected,
>
>> testfun(5)
> Error in sys.frame(which = x) : not that many frames on the stack
>

So this all suggests something very strange has happened to your
setup, Martin. Does this persist after a new session (perhaps running
as R --vanilla) and/or reinstall?

To your original questions:

> 1. Do You have an idea how I could implement the code
> more stably, so that the variable "a" is always visible to get, regardless of 
> whether testfun
> is used alone by itself or called from within another function?

Well, you can do it without get() and just trust in the scoping rules
to make it work. Depending on your application, this might simplify
the code nicely.

If you really do need to compute something on the fly, tricks like
eval(parse(text = "")), as.name(), call() etc might work, but they're
occasionally difficult to get right.

a <- 54
eval(as.name("a")) + 2

testfun2 <- function(n, letter) eval(as.name(letter)) + n

testfun2(3, "a") # 57

>
> 2. Why does the implementation with parent.frame() not work?

You didn't show us how you tried to use parent.frame()

>
> 3. Why does the number of contexts in the call stack differ in R and in 
> rkward?

It shouldn't. This is an issue that needs further sorting out.

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Computing for Data Analysis ~ R

2012-10-07 Thread Brigettebrenda
Do to work schedules, I may have to  discontinue.
 
I really like this course and wish to finish. When is this course offered  
again, and if so, can I take again?
 
Or, do we have to submit my even the hard deadlines? I can continue if we  
do not have to submit even by the hard deadline.
 
I am the type of person, I have to "understand" what I am doing, but just  
memorizing and then performing.
 
Thanks,
 
Dr. Brenda Nelson-Porter
[[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] (no subject)

2012-10-07 Thread Rui Barradas

Hello,

You must install the appropriate package(s). Try, for instance,

install.packages('rugarch')  # do this only once


And then, every time you start an R session, if you want to use it,

library(rugarch)  # do this every R session


To know more, try

help('rugarch')
vignette(package = 'rugarch')
vignette('Introduction_to_the_rugarch_package', package = 'rugarch')


The first 'vignette' instruction gives you a list of available 
vignettes, the second one opens the vignette file in a new window.


Hope this helps,

Rui Barradas

Em 07-10-2012 11:05, mina izadi escreveu:

Dear r-helper
I am pleased to send you this email. I have the R 2.11.1 and R 2.15.1
versions but they dose't have GARCH models. May you please guide me in
which version can i find GARCH models.
Best.
M.Izadi

[[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] get: problem with environments

2012-10-07 Thread arun
Hi,

I am getting the same error message as Michael got (R terminal (R 2.15) on 
Ubuntu 12.04).


  testfun(x=5)
#Error in sys.frame(which = x) : not that many frames on the stack
 print(testfun(x=6))
#Error in sys.frame(which = x) : not that many frames on the stack

A.K.

- Original Message -
From: R. Michael Weylandt 
To: Martin Ivanov 
Cc: r-help@r-project.org
Sent: Sunday, October 7, 2012 5:34 AM
Subject: Re: [R] get: problem with environments

On Sun, Oct 7, 2012 at 10:16 AM, Martin Ivanov  wrote:
>  Dear R users,
>
> I am running R-2.15.1 in Linux Slackware64-14.0. Here is my minimal working 
> example:
>
> testfun <- function (x) {
>  a <- 0;
>  sapply(X="a", FUN=get, envir=sys.frame(which=x));
> }
>
> Inside R, that is R called from within a Linux terminal, the following code 
> works:
> testfun(x=5)
> print(testfun(x=6))
> But within rkward the above code fails and the following works:
> testfun(x=1)
> print(testfun(x=2))
>
> As you can see, the number of contexts up the call stack that contain the 
> variable "a"
> varies depending on the implementation. If I call testfun() from within 
> print(), I have to go
> one context up the call stack than if I call testfun() alone by itself. This 
> implies
> some inherent instability of my code.

Unlike you, I don't get testfun(x = 5) to work in a terminal emulator.
As expected, I only get x =1 and print(... x = 2) to work and I just
tried this with R 2.15.0 and R devel, both in Terminal and by way of
ESS.  It could be a buglet introduced later into the 2.15 branch, but
that seems unlikely. As expected,

> testfun(5)
Error in sys.frame(which = x) : not that many frames on the stack

Can someone else confirm the behavior you see?

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get: problem with environments

2012-10-07 Thread Rui Barradas

Hello,

No, I can't confirm the behavior the op sees.
I've tried it in an R terminal on ubuntu 12.04, rkward on ubuntu, and 
RGui on Windows 7. R version 2.15.1.


Here's the rkward sessionInfo.

sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=pt_PT.UTF-8  LC_NUMERIC=C
 [3] LC_TIME=pt_PT.UTF-8   LC_COLLATE=pt_PT.UTF-8
 [5] LC_MONETARY=pt_PT.UTF-8   LC_MESSAGES=pt_PT.UTF-8
 [7] LC_PAPER=pt_PT.UTF-8  LC_NAME=pt_PT.UTF-8
 [9] LC_ADDRESS=pt_PT.UTF-8LC_TELEPHONE=pt_PT.UTF-8
[11] LC_MEASUREMENT=pt_PT.UTF-8LC_IDENTIFICATION=pt_PT.UTF-8

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

other attached packages:
[1] rkward_0.5.6

loaded via a namespace (and not attached):
[1] tools_2.15.1

Rui Barradas

Em 07-10-2012 10:34, R. Michael Weylandt escreveu:

On Sun, Oct 7, 2012 at 10:16 AM, Martin Ivanov  wrote:

  Dear R users,

I am running R-2.15.1 in Linux Slackware64-14.0. Here is my minimal working 
example:

testfun <- function (x) {
  a <- 0;
  sapply(X="a", FUN=get, envir=sys.frame(which=x));
}

Inside R, that is R called from within a Linux terminal, the following code 
works:
testfun(x=5)
print(testfun(x=6))
But within rkward the above code fails and the following works:
testfun(x=1)
print(testfun(x=2))

As you can see, the number of contexts up the call stack that contain the variable 
"a"
varies depending on the implementation. If I call testfun() from within 
print(), I have to go
one context up the call stack than if I call testfun() alone by itself. This 
implies
some inherent instability of my code.

Unlike you, I don't get testfun(x = 5) to work in a terminal emulator.
As expected, I only get x =1 and print(... x = 2) to work and I just
tried this with R 2.15.0 and R devel, both in Terminal and by way of
ESS.  It could be a buglet introduced later into the 2.15 branch, but
that seems unlikely. As expected,


testfun(5)

  Error in sys.frame(which = x) : not that many frames on the stack

Can someone else confirm the behavior you see?

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get: problem with environments

2012-10-07 Thread R. Michael Weylandt
On Sun, Oct 7, 2012 at 10:16 AM, Martin Ivanov  wrote:
>  Dear R users,
>
> I am running R-2.15.1 in Linux Slackware64-14.0. Here is my minimal working 
> example:
>
> testfun <- function (x) {
>  a <- 0;
>  sapply(X="a", FUN=get, envir=sys.frame(which=x));
> }
>
> Inside R, that is R called from within a Linux terminal, the following code 
> works:
> testfun(x=5)
> print(testfun(x=6))
> But within rkward the above code fails and the following works:
> testfun(x=1)
> print(testfun(x=2))
>
> As you can see, the number of contexts up the call stack that contain the 
> variable "a"
> varies depending on the implementation. If I call testfun() from within 
> print(), I have to go
> one context up the call stack than if I call testfun() alone by itself. This 
> implies
> some inherent instability of my code.

Unlike you, I don't get testfun(x = 5) to work in a terminal emulator.
As expected, I only get x =1 and print(... x = 2) to work and I just
tried this with R 2.15.0 and R devel, both in Terminal and by way of
ESS.  It could be a buglet introduced later into the 2.15 branch, but
that seems unlikely. As expected,

> testfun(5)
 Error in sys.frame(which = x) : not that many frames on the stack

Can someone else confirm the behavior you see?

Cheers,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] get: problem with environments

2012-10-07 Thread Martin Ivanov
 Dear R users,

I am running R-2.15.1 in Linux Slackware64-14.0. Here is my minimal working 
example:

testfun <- function (x) {
 a <- 0;
 sapply(X="a", FUN=get, envir=sys.frame(which=x));
}

Inside R, that is R called from within a Linux terminal, the following code 
works:
testfun(x=5)
print(testfun(x=6))
But within rkward the above code fails and the following works:
testfun(x=1)
print(testfun(x=2))

As you can see, the number of contexts up the call stack that contain the 
variable "a"
varies depending on the implementation. If I call testfun() from within 
print(), I have to go 
one context up the call stack than if I call testfun() alone by itself. This 
implies 
some inherent instability of my code. 

Actually I need to provide get() access to the calling environment of sapply().
According to the documentation of parent.frame(), "The parent frame of a 
function evaluation is the environment in which the function was called". I 
tried to use parent.frame() instead of sys.frame() above,
but the variable "a" is never found, regardless of what value I give to the 
parameter "n" of 
parent.frame().

I have basically three questions:

1. Do You have an idea how I could implement the code 
more stably, so that the variable "a" is always visible to get, regardless of 
whether testfun
is used alone by itself or called from within another function?

2. Why does the implementation with parent.frame() not work?

3. Why does the number of contexts in the call stack differ in R and in rkward? 
It seems that when R is called from within the Linux terminal the call stack 
contains 4 contexts more that it does when is called from rkward. This also 
points to the instability of the code which I would like to solve.

Any suggestions on any on the above questions will be greatly appreciated.

Best regards,

Martin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 for Random Points on a Sphere

2012-10-07 Thread 周果
Hi Lorenzo,

Just a quick thought, the uniform probability density on a unit sphere is 1
/ (4pi),
what about binning those random points according to their directions and do
a chi-square test?

Regards,
Guo

On Sun, Oct 7, 2012 at 2:16 AM,  wrote:

> "Lorenzo Isella"  writes:
>
> > Dear All,
> > I implemented an algorithm for (uniform) random rotations.
> > In order to test it, I can apply it to a unit vector (0,0,1) in
> > Cartesian coordinates.
> > The result is supposed to be a set of random, uniformly distributed,
> > points on a sphere (not the point of the algorithm, but a way to test
> > it).
> > This is what the points look like when I plot them, but other then
> > eyeballing them, can anyone suggest a test to ensure that I am really
> > generating uniform random points on a sphere?
>
> There is a substantial literature on this topic and more than one
> (metaphorical?) direction you could follow.
>
> I suggest you Google 'directional statistics' and start reading.
>
> Visit http://www.rseek.org and enter 'directional statistics' in
> the search box and click on the search button to see if there is
> something in R to meet your needs.
>
> A post to r-sig-geo might get more helpful responses once you can focus
> the question a bit more.
>
>
> HTH,
>
> Chuck
>
> > Many thanks
> >
> > Lorenzo
> >
>
> --
> Charles C. BerryDept of Family/Preventive
> Medicine
> cberry at 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.
>

[[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] vector is not assigned correctly in for loop

2012-10-07 Thread 周果
Thank you all for helping me out.
As Michael points out, I abused the rounding and formatting of print()
while debugging.
The default number of digits to print is 7 according to ?print.default,
which makes floating point numbers to be somewhat plausible for index vector
subsetting at first glance:
--
> print(0.0001)
[1] 1e-12
> print(0.)
[1] 1
--
However, since ?[ mentioned that numerics are coerced to integers in fact, it
turns out to be an floating point issue.
As Berend and Rui noted, it can be revealed by:
--
> print(0.0001, digits = 17)
[1] 9.9998e-13
> print(formatC(0.0001, format="f", 17))
[1] "0.00010"
> print(0., digits = 17)
[1] 0.2
> print(formatC(0., format="f", 17))
[1] "0.2"
--
As we can see above, floating point number is a miracle, and there is still
some magic with print(). :)
BTW, I think this is a general issue, which should be carefully considered
regardless of R or other languages.
Have a nice day.

Cheers,
Guo

[[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] two indirect effects of path analysis

2012-10-07 Thread yrosseel

On 10/07/2012 02:17 AM, Elaine Kuo wrote:

Hello,

This is Elaine.

I am trying a path analysis using lavaan Package.

There are three explanatory variables: X, Z, and M.
The response variable is Y.
A, b, and c have direct effects on Y.

On the other hand, X and Z also have direct effects on M.
In other words, X and Z have indirect effects on Y.

I found the code example of lavaan package describes only one indirect
effect as below.
Please kindly advise how to modify it as two indirect effects.


You need to write down all the regressions that are involved in your 
model. For each 'dependent' variable, there is a regression formula:


model <- '
Y ~ X + Z + M
M ~ X + Z
'

Optionally, you can label the parameters, and define some indirect effects:

model <- '
Y ~ c1*X + c2*Z + b*M
M ~ a1*X + a2*Z

ab1 := a1*b
ab2 := a2*b

totalx := ab1 + c1
totalz := ab2 + c2
'

Hope this helps,

Yves.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] geoRglm with factor variable as covariable

2012-10-07 Thread Filoche
Thank you Ruben.

You were absolutly right. I'm using trend option now to specify my model. 

Thank for the help,
Phil



--
View this message in context: 
http://r.789695.n4.nabble.com/geoRglm-with-factor-variable-as-covariable-tp4645067p4645310.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.