[R] Decomposing tests of interaction terms in mixed-effects models

2008-08-04 Thread Andrew Robinson
Dear R colleagues,

a friend and I are trying to develop a modest workflow for the problem
of decomposing tests of higher-order terms into interpretable sets of
tests of lower order terms with conditioning.

For example, if the interaction between A (3 levels) and C (2 levels)
is significant, it may be of interest to ask whether or not A is
significant at level 1 of C and level 2 of C.

The textbook response seems to be to subset the data and perform the
tests on the two subsets, but using the RSS and DF from the original
fit.  

We're trying to answer the question using new explanatory variables.
This approach (seems to) work just fine in aov, but not lme.  

For example,

##

# Build the example dataset

set.seed(101)

Block - gl(6, 6, 36, lab = paste(B, 1:6, sep = ))
A - gl(3, 2, 36, lab = paste(A, 1:3, sep = ))
C - gl(2, 1, 36, lab = paste(C, 1:2, sep = ))
example - data.frame(Block, A, C) 
example$Y - rnorm(36)*2 + as.numeric(example$A)*as.numeric(example$C)^2 + 
3 * rep(rnorm(6), each=6)

with(example, interaction.plot(A, C, Y)) 

# lme 

require(nlme) 
anova(lme(Y~A*C, random = ~1|Block, data = example)) 

summary(aov(Y ~ Error(Block) + A*C, data = example))

# Significant 2-way interaction.  Now we would like to test the effect
# of A at C1 and the effect of A at C2.  Construct two new variables
# that decompose the interaction, so an LRT is possible.

example$AC - example$AC1 - example$AC2 - interaction(example$A, example$C) 

example$AC1[example$C == C1] - A1.C1  # A is constant at C1
example$AC2[example$C == C2] - A1.C2  # A is constant at C2

# lme fails (as does lmer)

lme(Y ~ AC1 + AC, random = ~ 1 | Block, data = example)

# but aov seems just fine.

summary(aov(Y ~ Error(Block) + AC1 + AC, data = example)) 

## AC was not significant, so A is not significant at C1

summary(aov(Y ~ Error(Block) + AC2 + AC, data = example)) 

## AC was significant, so A is significant at C2

## Some experimentation suggests that lme doesn't like the 'partial
## confounding' approach that we are using, rather than the variables
## that we have constructed.

lme(Y ~ AC, random = ~ 1 | Block, data = example)
lme(Y ~ A + AC, random = ~ 1 | Block, data = example)

##

Are we doing anything obviously wrong?   Is there another approach to
the goal that we are trying to achieve?

Many thanks,

Andrew

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

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


[R] about the 95%CI around the median...

2008-08-04 Thread Fernando Marmolejo Ramos
Dear people

I've learnt that by using the boxplot.stats command in the grDevices library
I can get the 5-number summaries of a boxplot, plus other important information,
like the confidence interval around the median.

I'm interested in knowing the actual formula to used in that package to
calculate that confidence interval.

Can someone help me with this?

Cheers,

Fernando

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] about the 95%CI around the median...

2008-08-04 Thread Simon Blomberg
See ?fivenum in the stats package. If you just type 

stats::fivenum

you will get the code. The crucial calculations are in the last few
lines.

Simon.

On Mon, 2008-08-04 at 16:19 +0930, Fernando Marmolejo Ramos wrote:
 Dear people
 
 I've learnt that by using the boxplot.stats command in the grDevices 
 library
 I can get the 5-number summaries of a boxplot, plus other important 
 information,
 like the confidence interval around the median.
 
 I'm interested in knowing the actual formula to used in that package to
 calculate that confidence interval.
 
 Can someone help me with this?
 
 Cheers,
 
 Fernando
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

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

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

2008-08-04 Thread MORNEAU François
Hello,

Is ?segments what you are looking for ?

François

-Message d'origine-
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de elyakhlifi 
mustapha
Envoyé : vendredi 1 août 2008 17:15
À : r-help@r-project.org
Objet : [R] graph

Hello.
 
I don't know how to do to ouput segments between points like the chart attached.
Can you help me please?
Thanks.


  

.yahoo.fr

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Major difference in multivariate analyses SPSS and R

2008-08-04 Thread Draga, R.
Dear colleagues,

 

I know SPSS can not compute linear mixed models. I used 'R' before for
computing multivariate analyses. But, I never encountered such a major
difference in outcome between SPSS and 'R':

 

In SPSS the Pearson correlation between variable 1 and variable 2 is 31%
p0.001.

 

In SPSS binary logistic regression gives us an Odds Ratio (OR)=4.9 (95%
CI 2.7-9.0), p0.001, n=338.

OR  lower   upper

gender  1,120   0,565   2,221

age   0,985   0,956   1,015

variable 2 4,937   2,698   9,032

 

In R multilevel logistic regression using statistical package 'lmer'
gives us an Odds Ratio=10.2 (95% CI 6.3-14), p=0.24, n=338, groups:
group 1, 98; group 2 84.

   OR   lower   upper

gender 2,295-2,840 7,430

age  0,003-70,047   70,054

variable 2 10,176 6,295   14,056

 

The crosstabs gives us:

 variable A

Var B  0   1

0 156 108

1  17  57

 

Would somebody know how it is possible that in SPSS we get p0.001 and
in R we get p=0.24?

And, in 'R' the 95% CI of the Odds Ratio is 6.2-14.1. Why is the
p-value=0.24?

 

Thanks, 

 

Ronald


[[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] Sweave and ggplot2

2008-08-04 Thread ONKELINX, Thierry
Dear Sorn, 

It's hard to guess what your problem is, as you don't provide any sample
code. My guess is that the graphics are empty. Did you use
print(qplot(...)) or just qplot(). The latter won't work. You need
print(qplot(...))

HTH,

Thierry



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

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: maandag 4 augustus 2008 6:55
Aan: r-help@r-project.org
Onderwerp: [R] Sweave and ggplot2

Hi all,

I've been trying to run Sweave with R code embedded - using the ggplot2 
package and in particular the qplot command. There appears to be a
problem 
in Sweave not picking up that qplot is a function. Has anybody else
tried 
to use qplot in Sweave and have you been successful? Any help would be 
very much appreciated.

Kind Regards,

Sorn


Notice:
This email and any attachments may contain information\ ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decomposing tests of interaction terms in mixed-effects models

2008-08-04 Thread Peter Dalgaard

Andrew Robinson wrote:

Dear R colleagues,

a friend and I are trying to develop a modest workflow for the problem
of decomposing tests of higher-order terms into interpretable sets of
tests of lower order terms with conditioning.

For example, if the interaction between A (3 levels) and C (2 levels)
is significant, it may be of interest to ask whether or not A is
significant at level 1 of C and level 2 of C.

The textbook response seems to be to subset the data and perform the
tests on the two subsets, but using the RSS and DF from the original
fit.  


We're trying to answer the question using new explanatory variables.
This approach (seems to) work just fine in aov, but not lme.  


For example,

##

# Build the example dataset

set.seed(101)

Block - gl(6, 6, 36, lab = paste(B, 1:6, sep = ))
A - gl(3, 2, 36, lab = paste(A, 1:3, sep = ))
C - gl(2, 1, 36, lab = paste(C, 1:2, sep = ))
example - data.frame(Block, A, C) 
example$Y - rnorm(36)*2 + as.numeric(example$A)*as.numeric(example$C)^2 + 
3 * rep(rnorm(6), each=6)


with(example, interaction.plot(A, C, Y)) 

# lme 

require(nlme) 
anova(lme(Y~A*C, random = ~1|Block, data = example)) 


summary(aov(Y ~ Error(Block) + A*C, data = example))

# Significant 2-way interaction.  Now we would like to test the effect
# of A at C1 and the effect of A at C2.  Construct two new variables
# that decompose the interaction, so an LRT is possible.

example$AC - example$AC1 - example$AC2 - interaction(example$A, example$C) 


example$AC1[example$C == C1] - A1.C1  # A is constant at C1
example$AC2[example$C == C2] - A1.C2  # A is constant at C2

# lme fails (as does lmer)

lme(Y ~ AC1 + AC, random = ~ 1 | Block, data = example)

# but aov seems just fine.

summary(aov(Y ~ Error(Block) + AC1 + AC, data = example)) 


## AC was not significant, so A is not significant at C1

summary(aov(Y ~ Error(Block) + AC2 + AC, data = example)) 


## AC was significant, so A is significant at C2

## Some experimentation suggests that lme doesn't like the 'partial
## confounding' approach that we are using, rather than the variables
## that we have constructed.

lme(Y ~ AC, random = ~ 1 | Block, data = example)
lme(Y ~ A + AC, random = ~ 1 | Block, data = example)

##

Are we doing anything obviously wrong?   Is there another approach to
the goal that we are trying to achieve?
  
This looks like a generic issue with lme/lmer, in that they are not 
happy with rank deficiencies in the design matrix.


Here's a dirty trick which you are not really supposed to know about 
because it is hidden inside the stats namespace:


M - model.matrix(~AC1+AC, data=example)
M2 - stats:::Thin.col(M)
summary(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example)

(Thin.col(), Thin.row(), and Rank() are support functions for 
anova.mlm() et al., but maybe we should document them and put them out 
in the open.)


--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] about the 95%CI around the median...

2008-08-04 Thread Gavin Simpson
On Mon, 2008-08-04 at 17:00 +1000, Simon Blomberg wrote:
 See ?fivenum in the stats package. If you just type 
 
 stats::fivenum
 
 you will get the code. The crucial calculations are in the last few
 lines.

That will only give the code to calculate the five number summary, but
Fernando wants to know how the confidence interval is calculated in
boxplot.stats.

To see the code just type boxplot.stats followed by return at the
command line in R.

The relevant line is:

conf - if (do.conf) 
stats[3] + c(-1.58, 1.58) * iqr/sqrt(n)

Which is working on the median (stats[3]). Details of this computation
are in ?boxplot.stats which should have been Fernando's first port of
call. Two works are cited in support of the calculation with full
references in the References section of that help page.

HTH

G

 
 Simon.
 
 On Mon, 2008-08-04 at 16:19 +0930, Fernando Marmolejo Ramos wrote:
  Dear people
  
  I've learnt that by using the boxplot.stats command in the grDevices 
  library
  I can get the 5-number summaries of a boxplot, plus other important 
  information,
  like the confidence interval around the median.
  
  I'm interested in knowing the actual formula to used in that package to
  calculate that confidence interval.
  
  Can someone help me with this?
  
  Cheers,
  
  Fernando
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Unexpected nls behaviour: Solved

2008-08-04 Thread Keith Jewell
Hi Everyone,

I'd omitted the non-optional 'parameters' argument to selfStart. Making this 
change to SSbatch gives the same (successful) result from the two calls to 
nls.

SSbatch-selfStart(
model=function(Batch, Coeffs)
{
Coeffs[Batch]
}
,initial=function(mCall, data, LHS)
{
 # Estimate coefficients as mean of each batch
xy - sortedXyData(mCall[[Batch]], LHS, data)
 Batch - data[[as.character(mCall[[Batch]])]]
 # check Batch is successive integers starting at 1
 if ((min(xy$x) !=1) | (any(diff(xy$x)!=1))) stop(
   Batch is not a successive integers sequence)
 Lval - list(xy$y)
 names(Lval) - mCall[Coeffs]
 Lval
}
, parameters = c(Coeffs)
)

Sorry for wasting anyones time.

Keith Jewell
-
Keith Jewell [EMAIL PROTECTED] wrote in message news:...
 Hi everyone,

 I thought that for a selfStart function, these two should be exactly 
 equivalent
 nls(Aform, DF)
 nls(Aform, DF, start=getInitial(Aform, DF))
 but in this example that is not the case in R (although it is in S-plus 
 V6.2)
 --
 SSbatch-selfStart(
 model=function(Batch, Coeffs)
 {
 Coeffs[Batch]

 }
 ,initial=function(mCall, data, LHS)
 {
 # Estimate coefficients as mean of each batch
xy - sortedXyData(mCall[[Batch]], LHS, data)
 Batch - data[[as.character(mCall[[Batch]])]]
 # check Batch is successive integers starting at 1
 if ((min(xy$x) !=1) | (any(diff(xy$x)!=1))) stop(
   Batch is not a successive integers sequence)
 Lval - list(xy$y)
 names(Lval) - mCall[Coeffs]
 Lval
 }
 )
 DF - data.frame(A=c(0.9, 1.1, 1.9, 2.0, 2.1, 2.9, 3.0), 
 Batch=c(1,1,2,2,2,3,3))
 Aform - formula(A~SSbatch(Batch,cA))
 nls(Aform, DF, start=getInitial(Aform, DF))
 nls(Aform, DF)
 
 Don't ask why I'd want such a silly selfStart, that's a long story.
 I guess wherever I would have used nls(Aform, DF)
 I could use nls(Aform, DF, start=getInitial(Aform, DF))
 but that seems clumsy.

 Can anyone point out my mistake? Or is this a limitation of nls in R (I 
 hesitate to use the b*g word).

 Thanks in advance,

 Keith Jewell
 --

 I don't think it's relevant but, for completeness:

 sessionInfo()

 version 2.7.0 (2008-04-22)
 i386-pc-mingw32

 locale:
 LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
 Kingdom.1252;LC_MONETARY=English_United 
 Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

 other attached packages:
 [1] xlsReadWrite_1.3.2 svSocket_0.9-5 svIO_0.9-5 R2HTML_1.58 
 svMisc_0.9-5   svIDE_0.9-5

 loaded via a namespace (and not attached):
 [1] tools_2.7.0 VGAM_0.7-7
  



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


Re: [R] How to format the output file just the way I want ?

2008-08-04 Thread Pierre8rou

I think I have found the answer myself.
If you have something better, please write it.

Pierre8r

My R code :
---


library(quantmod)
library(xts)

Lines -
2008.07.01,02:00,1.5761,1.5766,1.5760,1.5763,65
2008.07.01,02:15,1.5762,1.5765,1.5757,1.5761,95
2008.07.01,02:30,1.5762,1.5765,1.5758,1.5759,58
2008.07.01,02:45,1.5758,1.5758,1.5745,1.5746,91
2008.07.01,03:00,1.5745,1.5751,1.5744,1.5744,117
2008.07.01,03:15,1.5742,1.5742,1.5727,1.5729,100
2008.07.01,03:30,1.5730,1.5736,1.5730,1.5736,61
2008.07.01,03:45,1.5735,1.5740,1.5735,1.5739,55

quotes - read.csv(textConnection(Lines), header=FALSE)
x - as.xts(quotes[,-(1:2)],
as.POSIXct(paste(quotes[,1],quotes[,2]),format='%Y.%m.%d %H:%M'))
colnames(x) - c('Open','High','Low','Close','Volume')

x$Open - sprintf(%5.04f, x$Open)
x$High - sprintf(%5.04f, x$High)
x$Low - sprintf(%5.04f, x$Low)
x$Close - sprintf(%5.04f, x$Close)

x$Volume - sprintf(%.0f, x$Volume)

write.table(x,file = K:\\OutputFile.csv, quote=FALSE,  col.names=FALSE,
row.names=format(index(x),%Y.%m.%d,%H:%M),  sep=,)


-- 
View this message in context: 
http://www.nabble.com/How-to-format-the-output-file-just-the-way-I-want---tp18790926p18808276.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] source a script file straight from a subversion repository

2008-08-04 Thread Martin Maechler
 SM == Steven McKinney [EMAIL PROTECTED]
 on Fri, 1 Aug 2008 18:38:54 -0700 writes:

SM Thanks to Duncan Murdoch and Marc Schwartz for their
SM excellent help.

SM As we don't yet have the apache http: interface to svn
SM running yet, 'svn export' is the access mechanism.

yes.
Note that svn.r-project.org for the R sources (and some
recommended packages' ones) *only* runs the apache secure http
interface  'https:/.'  for security reasons.

It has the big advantage that there exist no (!) user logins on
that machine at all, and hence no compromised user ssh
information can be misused to break in.

*and* you can use source(...)!

Martin Maechler, ETH Zurich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] xyplot strip=function for two conditioning variables

2008-08-04 Thread Gabor Grothendieck
Checkout this one:

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

On Mon, Aug 4, 2008 at 6:24 AM, Henning Wildhagen [EMAIL PROTECTED] wrote:
 Dear list,

 for a data structure like in df:

 set.seed(100)
 Treatment-rep(c(Nitrogen,Carbon, Sulfur),each=9)
 week-rep(c(1,5,9),3,each=3)
 genes-rep(c(18s, EF1b, NR),9)
 copies-rnorm(27, 100,40)
 df-data.frame(Treatment,week,genes,copies)

 i wrote this code for a xyplot:

 library(lattice)
 PLOT-xyplot(data=df, copies~week|Treatment+genes,type=c(b,g))

 I would like to change PLOT in a way, that the strips for Treatment are
 displayed only once at the top of each of the three columns. Additionally i
 would like to strips for genes at the top of each panel.

 I tried to adopt some code i found in the helplist using strip=function...
 but i did not manage to get what i would like.

 Can anyone give me advice?

 Thanks,

 Henning


 --



[[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] R and emacs

2008-08-04 Thread pir2.jv

I wrote a program  truc.r with emacs
In emacs, I start the buffer R, then I eval the buffer truc.r (C-c C-b)
All is correct and I have my results.

But, when I return to Console R, and make:
 source (truc.r), I obtain an error:
Erreur dans source(truc.r) :
  invalid multibyte character in parser at line 1

If I copy, line by line the instructions of the emacs buffer and put  
them in R console, all is correct.

 

Thanks




Jacques Vernin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] xyplot strip=function for two conditioning variables

2008-08-04 Thread Henning Wildhagen
Dear list,

for a data structure like in df:

set.seed(100)
Treatment-rep(c(Nitrogen,Carbon, Sulfur),each=9)
week-rep(c(1,5,9),3,each=3)
genes-rep(c(18s, EF1b, NR),9)
copies-rnorm(27, 100,40)
df-data.frame(Treatment,week,genes,copies)

i wrote this code for a xyplot:

library(lattice)
PLOT-xyplot(data=df, copies~week|Treatment+genes,type=c(b,g))

I would like to change PLOT in a way, that the strips for Treatment are 
displayed only once at the top of each of the three columns. Additionally i 
would like to strips for genes at the top of each panel.

I tried to adopt some code i found in the helplist using strip=function... 
but i did not manage to get what i would like.

Can anyone give me advice?

Thanks,

Henning


-- 



[[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] R and emacs

2008-08-04 Thread Peter Dalgaard

pir2.jv wrote:

I wrote a program  truc.r with emacs
In emacs, I start the buffer R, then I eval the buffer truc.r (C-c C-b)
All is correct and I have my results.

But, when I return to Console R, and make:
 source (truc.r), I obtain an error:
Erreur dans source(truc.r) :
  invalid multibyte character in parser at line 1

If I copy, line by line the instructions of the emacs buffer and put 
them in R console, all is correct.

 

Sounds like encoding/locale confusion. Presumably, you have an accented 
character in the file somewhere, but in a different encoding to what 
source() expects. What is your platform?


Notice also that emacs sometimes switches encodings on the fly.

(Remember to follow up to the R-help, not to me. On some platforms, 
there are things I Just Don't Know, and it is good practice anyway to 
keep things on the list.)



Thanks




Jacques Vernin

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

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



--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Exporting data to a text file

2008-08-04 Thread pacomet
Hi John

I don't get an error message but a warning

 write.table(myclara$clustering,cluster.dat,append=TRUE)
Warning message:
In write.table(myclara$clustering, cluster.dat, append = TRUE) :
  appending column names to file


Here it is the output of str(myclara), it looks strange to me. I think
clustering are integers and data are real numbers

str(myclara)
List of 10
 $ sample: chr [1:56] 32356 33277 43230 52386 ...
 $ medoids   : num [1:8, 1:14]  7.888 12.019  5.427  0.725 17.688 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:8] 109056 98194 56959 109806 ...
  .. ..$ : chr [1:14] lon lat sst01 sst02 ...
 $ i.med : int [1:8] 20482 16158 5137 20722 48599 56033 68028 64308
 $ clustering: Named int [1:75459] 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, names)= chr [1:75459] 12296 12297 12298 12299 ...
 $ objective : num 3.22
 $ clusinfo  : num [1:8, 1:4] 15055  9474  5164 13702 11340 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:4] size max_diss av_diss isolation
 $ diss  :Classes 'dissimilarity', 'dist'  atomic [1:1540] 1.11 6.54
4.62 3.30 4.32 ...
  .. ..- attr(*, Size)= int 56
  .. ..- attr(*, Metric)= chr euclidean
  .. ..- attr(*, Labels)= chr [1:56] 32356 33277 43230 52386 ...
 $ call  : language clara(x = mydata, k = 8)
 $ silinfo   :List of 3
  ..$ widths : num [1:56, 1:3] 1 1 1 1 1 1 1 1 2 2 ...
  .. ..- attr(*, dimnames)=List of 2
  .. .. ..$ : chr [1:56] 96250 109056 130058 116317 ...
  .. .. ..$ : chr [1:3] cluster neighbor sil_width
  ..$ clus.avg.widths: num [1:8] 0.343 0.355 0.533 0.265 0.308 ...
  ..$ avg.width  : num 0.362
 $ data  : num [1:75459, 1:14] 8.68 8.72 8.77 8.81 8.86 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:75459] 12296 12297 12298 12299 ...
  .. ..$ : chr [1:14] lon lat sst01 sst02 ...
 - attr(*, class)= chr [1:2] clara partition



I can't output the two variables in two different files without any problem.

Thanks


2008/8/1 John Kane [EMAIL PROTECTED]

 try
 str(myclara)
 to see what you have - a data frame , matrix etc

 Are you getting any error messages?

 I tried your write.table commands and they work okay.


 --- On Fri, 8/1/08, pacomet [EMAIL PROTECTED] wrote:

  From: pacomet [EMAIL PROTECTED]
  Subject: [R] Exporting data to a text file
  To: r-help@r-project.org
  Received: Friday, August 1, 2008, 12:49 PM
  HI R users
 
  With clara function I get a data frame (maybe this is not
  the exact word,
  I'm new to R) with the following variables:
 
   names(myclara)
   [1] sample medoids
  i.med  clustering
  objective
   [6] clusinfo   diss
  call   silinfo
  data
 
  I want to export clustering and
  data to a new text file so I try
 
   write.table(myclara$data,cluster.dat)
  
  write.table(myclara$clustering,cluster.dat,append=TRUE)
 
  Variable data is properly exported but clustering is not
  appended to the
  output file.
 
  Please, where is the mistake? is it possible to export the
  two variables in
  just a sentence?
 
  thanks in advance
 
  Paco
 
  --
  _
  El ponent la mou, el llevant la plou
  Usuari Linux registrat: 363952
  ---
  Fotos: http://picasaweb.google.es/pacomet
 
[[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.


  __
 Connect with friends from any web browser - no download required. Try the
 new Yahoo! Canada Messenger for the Web BETA at
 http://ca.messenger.yahoo.com/webmessengerpromo.php




-- 
_
El ponent la mou, el llevant la plou
Usuari Linux registrat: 363952
---
Fotos: http://picasaweb.google.es/pacomet

[[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] greek letters in italic font

2008-08-04 Thread Luis Tercero

Dear HelpeRs,

I am trying to write axis labels with some letters in cursive for later 
inclusion in a LaTeX document. The following code does what I want with 
latin letters (c cursive and the rest not cursive):


plot(1:10, 1:10, ylab = expression(italic(c)*(MB)))
or
plot(1:10, 1:10, ylab = expression(paste(italic(c)*(MB),   /  , 
mu*g~L^{-1}))


but it does not work for greek letters:
plot(1:10, 1:10, ylab = expression(italic(rho)*(MB)))

Using text() or mtext() with the option font = 3 does not work either.

I found a way around this by writing rho and then having rho be 
changed to the corresponding greek letter in LaTeX by using the PSfrag 
package... but it only works for text(), not for mtext() nor xlab/ylab 
within the plot() command.


I would be grateful for some ideas.

Many thanks and best regards,

Luis

--

Luis Tercero, M.Sc.

Engler-Bunte-Institut der Universität Karlsruhe (TH)
Bereich Wasserchemie
Engler-Bunte-Ring 1
D-76131 Karlsruhe
Tel. +49 721 608 6381
Fax: +49 721 608 7051

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

2008-08-04 Thread Sandy Small

   Many thanks
   I was sure it was simple. That was exactly what I wanted.
   I should have clarified that I was looking for a box-plot.
   Thanks to all who responed.
   Sandy
   S Ellison wrote:

Sandy,

You can re-order a factor with

df$Eyeball-factor(df$Eyeball, levels=c(Normal, Mild, Moderate,
Severe), ordered=T)

(assuming df is your data frame and that you want an _ordered_ factor;
the latter is not essential to your plots)

Incidentally, NULL isn't a particularly friendly item to find in a
data frame. NULL often implies I'm not here at all while NA says I
exist but I'm a missing value. For an example of when it might matter,
try

length(c(1,2,NULL,3))

#versus
length(c(1,2,NA,3))


Steve E

  

Sandy Small [1][EMAIL PROTECTED] 01/08/2008 16:21:29 


Hi
I'm sure this question has been asked before but I can't find it in the

archives.


I want to plot them in the order Normal, Mild,


Moderate, Severe so that the trend (or not) is obvious.



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

References

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


Re: [R] greek letters in italic font

2008-08-04 Thread Gabor Grothendieck
You could piece it together using the Hershey fonts for the italic rho:

op - par(xpd = NA)
plot(1, type = n, ylab = )
u - par(usr)
text(u[1] - .1 * diff(u[1:2]), 1, \\*r, vfont = c(serif, italic))
par(op)

Now add the rest.
?Hershey
?par
?strwidth

On Mon, Aug 4, 2008 at 7:12 AM, Luis Tercero
[EMAIL PROTECTED] wrote:
 Dear HelpeRs,

 I am trying to write axis labels with some letters in cursive for later
 inclusion in a LaTeX document. The following code does what I want with
 latin letters (c cursive and the rest not cursive):

 plot(1:10, 1:10, ylab = expression(italic(c)*(MB)))
 or
 plot(1:10, 1:10, ylab = expression(paste(italic(c)*(MB),   /  ,
 mu*g~L^{-1}))

 but it does not work for greek letters:
 plot(1:10, 1:10, ylab = expression(italic(rho)*(MB)))

 Using text() or mtext() with the option font = 3 does not work either.

 I found a way around this by writing rho and then having rho be changed
 to the corresponding greek letter in LaTeX by using the PSfrag package...
 but it only works for text(), not for mtext() nor xlab/ylab within the
 plot() command.

 I would be grateful for some ideas.

 Many thanks and best regards,

 Luis

 --

 Luis Tercero, M.Sc.

 Engler-Bunte-Institut der Universität Karlsruhe (TH)
 Bereich Wasserchemie
 Engler-Bunte-Ring 1
 D-76131 Karlsruhe
 Tel. +49 721 608 6381
 Fax: +49 721 608 7051

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Decomposing tests of interaction terms in mixed-effects models

2008-08-04 Thread Andrew Robinson
On Mon, Aug 04, 2008 at 10:17:38AM +0200, Peter Dalgaard wrote:
 Andrew Robinson wrote:
 Dear R colleagues,
 
 a friend and I are trying to develop a modest workflow for the problem
 of decomposing tests of higher-order terms into interpretable sets of
 tests of lower order terms with conditioning.
 
 For example, if the interaction between A (3 levels) and C (2 levels)
 is significant, it may be of interest to ask whether or not A is
 significant at level 1 of C and level 2 of C.
 
 The textbook response seems to be to subset the data and perform the
 tests on the two subsets, but using the RSS and DF from the original
 fit.  
 
 We're trying to answer the question using new explanatory variables.
 This approach (seems to) work just fine in aov, but not lme.  
 
 For example,
 
 ##
 
 # Build the example dataset
 
 set.seed(101)
 
 Block - gl(6, 6, 36, lab = paste(B, 1:6, sep = ))
 A - gl(3, 2, 36, lab = paste(A, 1:3, sep = ))
 C - gl(2, 1, 36, lab = paste(C, 1:2, sep = ))
 example - data.frame(Block, A, C) 
 example$Y - rnorm(36)*2 + as.numeric(example$A)*as.numeric(example$C)^2 + 
 3 * rep(rnorm(6), each=6)
 
 with(example, interaction.plot(A, C, Y)) 
 
 # lme 
 
 require(nlme) 
 anova(lme(Y~A*C, random = ~1|Block, data = example)) 
 
 summary(aov(Y ~ Error(Block) + A*C, data = example))
 
 # Significant 2-way interaction.  Now we would like to test the effect
 # of A at C1 and the effect of A at C2.  Construct two new variables
 # that decompose the interaction, so an LRT is possible.
 
 example$AC - example$AC1 - example$AC2 - interaction(example$A, 
 example$C) 
 example$AC1[example$C == C1] - A1.C1  # A is constant at C1
 example$AC2[example$C == C2] - A1.C2  # A is constant at C2
 
 # lme fails (as does lmer)
 
 lme(Y ~ AC1 + AC, random = ~ 1 | Block, data = example)
 
 # but aov seems just fine.
 
 summary(aov(Y ~ Error(Block) + AC1 + AC, data = example)) 
 
 ## AC was not significant, so A is not significant at C1
 
 summary(aov(Y ~ Error(Block) + AC2 + AC, data = example)) 
 
 ## AC was significant, so A is significant at C2
 
 ## Some experimentation suggests that lme doesn't like the 'partial
 ## confounding' approach that we are using, rather than the variables
 ## that we have constructed.
 
 lme(Y ~ AC, random = ~ 1 | Block, data = example)
 lme(Y ~ A + AC, random = ~ 1 | Block, data = example)
 
 ##
 
 Are we doing anything obviously wrong?   Is there another approach to
 the goal that we are trying to achieve?
   
 This looks like a generic issue with lme/lmer, in that they are not 
 happy with rank deficiencies in the design matrix.
 
 Here's a dirty trick which you are not really supposed to know about 
 because it is hidden inside the stats namespace:
 
 M - model.matrix(~AC1+AC, data=example)
 M2 - stats:::Thin.col(M)
 summary(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example)
 
 (Thin.col(), Thin.row(), and Rank() are support functions for 
 anova.mlm() et al., but maybe we should document them and put them out 
 in the open.)

That is a neat idea, thanks, Peter, but it doesn't quite fit the bill.
The summary provides t-tests but I am hoping to find F-tests,
otherwise I'm not sure how to efficiently test A (3 levels) at the two
levels of C.  

The anova.lme function doesn't help, sadly:

 anova(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example))
   numDF denDF F-value p-value
M2 625 23.0198  .0001

so I'm still flummoxed!

Andrew
-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] memory problem - failing to load rgl in R 2.7.1 patched

2008-08-04 Thread Monica Pisica

 Hi,

 yesterday i had the surprise not to be able to load the package ca on R 
 2.7.0 saying that cannot find required package rgl although it was there. So 
 today i've upgraded to 7.2.1. patched and i got the following error:

 local({pkg - select.list(sort(.packages(all.available = TRUE)))
 + if(nchar(pkg)) library(pkg, character.only=TRUE)})
 Loading required package: rgl
 Error : cannot allocate vector of size 2.0 Gb
 Error: package 'rgl' could not be loaded

 I've up-ed the memory to max which is 4 Gb for my computer and tried again 
 ... same result. I know how to install packages and load them  or at 
 least i thought so. Do you know what is wrong??


 sysname release
 Windows XP
 version nodename
 build 2600, Service Pack 2
 machine
 x86

 sessionInfo()
 R version 2.7.1 Patched (2008-07-31 r46185)
 i386-pc-mingw32

 locale:
 LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
 States.1252;LC_MONETARY=English_United 
 States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

 other attached packages:
 [1] e1071_1.5-18 class_7.2-42

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

 Thanks for any advice,

 Monica


 _
 Time for vacation? WIN what you need- enter now!
 http://www.gowindowslive.com/summergiveaway/?ocid=tag_jlyhm

_


LM_WLYIA_whichathlete_us
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SOLVED - memory problem - failing to load rgl in R 2.7.1 patched

2008-08-04 Thread Monica Pisica


Hi,

Sorry for that . Today R did load both ca and rgl packages with no problems 
... the single thing i've done since Friday was to put defrag on drive C, i 
even didn't re-start the computer ...actually it was re-started several time 
with same weird problem ... so i suppose something was segmented badly on the 
hard drive.

Monica


 From: [EMAIL PROTECTED]
 To: r-help@r-project.org
 Subject: [R] memory problem - failing to load rgl in R 2.7.1 patched
 Date: Mon, 4 Aug 2008 12:27:31 +


 Hi,

 yesterday i had the surprise not to be able to load the package ca on R 
 2.7.0 saying that cannot find required package rgl although it was there. So 
 today i've upgraded to 7.2.1. patched and i got the following error:

 local({pkg - select.list(sort(.packages(all.available = TRUE)))
 + if(nchar(pkg)) library(pkg, character.only=TRUE)})
 Loading required package: rgl
 Error : cannot allocate vector of size 2.0 Gb
 Error: package 'rgl' could not be loaded

 I've up-ed the memory to max which is 4 Gb for my computer and tried again 
 ... same result. I know how to install packages and load them  or at 
 least i thought so. Do you know what is wrong??


 sysname release
 Windows XP
 version nodename
 build 2600, Service Pack 2
 machine
 x86

 sessionInfo()
 R version 2.7.1 Patched (2008-07-31 r46185)
 i386-pc-mingw32

 locale:
 LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
 States.1252;LC_MONETARY=English_United 
 States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

 other attached packages:
 [1] e1071_1.5-18 class_7.2-42

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

 Thanks for any advice,

 Monica


 _
 Time for vacation? WIN what you need- enter now!
 http://www.gowindowslive.com/summergiveaway/?ocid=tag_jlyhm

 _
 Reveal your inner athlete and share it with friends on Windows Live.
 http://revealyourinnerathlete.windowslive.com?locale=en-usocid=TXT_TAGLM_WLYIA_whichathlete_us

_
Get more from your digital life.  Find out how.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decomposing tests of interaction terms in mixed-effects models

2008-08-04 Thread Peter Dalgaard

Andrew Robinson wrote:

On Mon, Aug 04, 2008 at 10:17:38AM +0200, Peter Dalgaard wrote:
  

Andrew Robinson wrote:


Dear R colleagues,

a friend and I are trying to develop a modest workflow for the problem
of decomposing tests of higher-order terms into interpretable sets of
tests of lower order terms with conditioning.

For example, if the interaction between A (3 levels) and C (2 levels)
is significant, it may be of interest to ask whether or not A is
significant at level 1 of C and level 2 of C.

The textbook response seems to be to subset the data and perform the
tests on the two subsets, but using the RSS and DF from the original
fit.  


We're trying to answer the question using new explanatory variables.
This approach (seems to) work just fine in aov, but not lme.  


For example,

##

# Build the example dataset

set.seed(101)

Block - gl(6, 6, 36, lab = paste(B, 1:6, sep = ))
A - gl(3, 2, 36, lab = paste(A, 1:3, sep = ))
C - gl(2, 1, 36, lab = paste(C, 1:2, sep = ))
example - data.frame(Block, A, C) 
example$Y - rnorm(36)*2 + as.numeric(example$A)*as.numeric(example$C)^2 + 
   3 * rep(rnorm(6), each=6)


with(example, interaction.plot(A, C, Y)) 

# lme 

require(nlme) 
anova(lme(Y~A*C, random = ~1|Block, data = example)) 


summary(aov(Y ~ Error(Block) + A*C, data = example))

# Significant 2-way interaction.  Now we would like to test the effect
# of A at C1 and the effect of A at C2.  Construct two new variables
# that decompose the interaction, so an LRT is possible.

example$AC - example$AC1 - example$AC2 - interaction(example$A, 
example$C) 
example$AC1[example$C == C1] - A1.C1  # A is constant at C1

example$AC2[example$C == C2] - A1.C2  # A is constant at C2

# lme fails (as does lmer)

lme(Y ~ AC1 + AC, random = ~ 1 | Block, data = example)

# but aov seems just fine.

summary(aov(Y ~ Error(Block) + AC1 + AC, data = example)) 


## AC was not significant, so A is not significant at C1

summary(aov(Y ~ Error(Block) + AC2 + AC, data = example)) 


## AC was significant, so A is significant at C2

## Some experimentation suggests that lme doesn't like the 'partial
## confounding' approach that we are using, rather than the variables
## that we have constructed.

lme(Y ~ AC, random = ~ 1 | Block, data = example)
lme(Y ~ A + AC, random = ~ 1 | Block, data = example)

##

Are we doing anything obviously wrong?   Is there another approach to
the goal that we are trying to achieve?
 
  
This looks like a generic issue with lme/lmer, in that they are not 
happy with rank deficiencies in the design matrix.


Here's a dirty trick which you are not really supposed to know about 
because it is hidden inside the stats namespace:


M - model.matrix(~AC1+AC, data=example)
M2 - stats:::Thin.col(M)
summary(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example)

(Thin.col(), Thin.row(), and Rank() are support functions for 
anova.mlm() et al., but maybe we should document them and put them out 
in the open.)



That is a neat idea, thanks, Peter, but it doesn't quite fit the bill.
The summary provides t-tests but I am hoping to find F-tests,
otherwise I'm not sure how to efficiently test A (3 levels) at the two
levels of C.  


The anova.lme function doesn't help, sadly:

  

anova(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example))


   numDF denDF F-value p-value
M2 625 23.0198  .0001

so I'm still flummoxed!

Andrew
  
You do have to peek into M2 to know that the test is for whether the 
last two coefs are zero, but how about


 M3 - M2[,2:4]
 M4 - M2[,5:6]
 anova(lme(Y ~ M3+M4, random = ~ 1 | Block, data = example))
   numDF denDF  F-value p-value
(Intercept) 125 10.66186  0.0032
M3  325 55.31464  .0001
M4  225  1.27591  0.2967

Also, check out estimable() in the gmodels package.

--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decomposing tests of interaction terms in mixed-effects models

2008-08-04 Thread Andrew Robinson
On Mon, Aug 04, 2008 at 02:51:48PM +0200, Peter Dalgaard wrote:
 Andrew Robinson wrote:
 On Mon, Aug 04, 2008 at 10:17:38AM +0200, Peter Dalgaard wrote:
   
 Andrew Robinson wrote:
 
 
 That is a neat idea, thanks, Peter, but it doesn't quite fit the bill.
 The summary provides t-tests but I am hoping to find F-tests,
 otherwise I'm not sure how to efficiently test A (3 levels) at the two
 levels of C.  
 
 The anova.lme function doesn't help, sadly:
 
   
 anova(lme(Y ~ M2 - 1, random = ~ 1 | Block, data = example))
 
numDF denDF F-value p-value
 M2 625 23.0198  .0001
 
 so I'm still flummoxed!
 
 Andrew
   
 You do have to peek into M2 to know that the test is for whether the 
 last two coefs are zero, but how about
 
  M3 - M2[,2:4]
  M4 - M2[,5:6]
  anova(lme(Y ~ M3+M4, random = ~ 1 | Block, data = example))
numDF denDF  F-value p-value
 (Intercept) 125 10.66186  0.0032
 M3  325 55.31464  .0001
 M4  225  1.27591  0.2967

Marvelous, many thanks, Peter.

 Also, check out estimable() in the gmodels package.

Will do.  Actually had done, but will do again.

Cheers

Andrew

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] about the 95%CI around the median...

2008-08-04 Thread Frank E Harrell Jr

Gavin Simpson wrote:

On Mon, 2008-08-04 at 17:00 +1000, Simon Blomberg wrote:
See ?fivenum in the stats package. If you just type 


stats::fivenum

you will get the code. The crucial calculations are in the last few
lines.


That will only give the code to calculate the five number summary, but
Fernando wants to know how the confidence interval is calculated in
boxplot.stats.

To see the code just type boxplot.stats followed by return at the
command line in R.

The relevant line is:

conf - if (do.conf) 
stats[3] + c(-1.58, 1.58) * iqr/sqrt(n)


Which is working on the median (stats[3]). Details of this computation
are in ?boxplot.stats which should have been Fernando's first port of
call. Two works are cited in support of the calculation with full
references in the References section of that help page.

HTH

G


I wonder why we don't just use the exact nonparametric confidence 
interval for the median, which is just as easy to compute.  Also, it 
will be asymmetric if the data are skewed, as it should be.


Frank




Simon.

On Mon, 2008-08-04 at 16:19 +0930, Fernando Marmolejo Ramos wrote:

Dear people

I've learnt that by using the boxplot.stats command in the grDevices library
I can get the 5-number summaries of a boxplot, plus other important information,
like the confidence interval around the median.

I'm interested in knowing the actual formula to used in that package to
calculate that confidence interval.

Can someone help me with this?

Cheers,

Fernando



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

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


[R] Trouble when I call a function within another

2008-08-04 Thread bbouling

Greetings,

I recently discovered R and how to tackle my own functions.
I'm blocked on a simple barrier I guess. I call a function that recognizes a
string and return the adequate formula in a main function. This is done
through a script.

When I type the formula in the main function, it works fine. When I
attempted to use a second function (with conditional choice) it doesn't work
any more. May you guide me?

http://www.nabble.com/file/p18811385/annexe.R annexe.R 

-
B. Boulinguiez
[EMAIL PROTECTED]
Ph.D. in Chemistry
Ecole Nationale Supérieure de Chimie de Rennes
35700 Rennes (FRANCE) 
-- 
View this message in context: 
http://www.nabble.com/Trouble-when-I-call-a-function-within-another-tp18811385p18811385.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] Howto Smooth a Curve Created with the Point Function

2008-08-04 Thread Gundala Viswanath
Hi all,

I have this figure:

 http://docs.google.com/Doc?id=df5zfsj4_103rjt2v4d5

created with the following steps:

 x
  [1]  90.4  57.8  77.0 103.7  55.4 217.5  68.1  85.3 152.0 113.0  97.1  89.9
 [13]  68.1  83.7  77.4  34.5 104.9 170.3  88.6  88.1 108.8  77.4  85.6  82.7
 [25]  81.3 108.0  49.5  71.0  85.7  99.3 203.5 275.9  51.1  84.8  16.5  72.6
 [37] 160.5 158.3 136.7 140.0  98.4 116.1 177.0 168.7 208.0 219.3  90.5 119.7
 [49]  72.9 138.4  98.6  56.0 151.6 230.0  82.0  65.6  83.0 106.9 141.3 103.9
 [61]  76.0  90.6  72.9  85.5  70.5 134.3 129.5 130.9 187.1 131.4  57.7 179.7
 [73]  89.7 126.1 124.4 103.2 111.8 143.1  59.4  85.3 122.8 100.0 158.4 188.2
 [85]  91.9  90.0  74.5  70.2 105.8  90.0  96.6 109.5 176.8 145.1 126.2 215.9
 [97] 103.4 154.3  84.8 112.8 119.8 111.9 107.6 114.3 198.7  98.2 187.6 196.7
[109] 138.5 146.1  75.0  80.0 147.7 171.3  90.1  58.1 109.3 136.6  91.5  93.8
[121]  79.4  71.8

 xhist - hist(x,col=blue, xlab=Exp Level,freq=FALSE)
 alpha - 6.352082
 beta   - 17.84647
 g.pdf - dgamma(x,shape=alpha,scale=beta)
 points(x,g.pdf,col=red,type='l')  ## problem here

My question is:

Why the command points DOES NOT create smooth red curve
as we expected? How can I resolve this problem?

I specifically want to use the dgamma
function with the learned parameter (alpha,beta).

That's why I don't use this command:
 lines(density(x),add=T, col=red)


- Gundala Viswanath
Jakarta - Indonesia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trouble when I call a function within another

2008-08-04 Thread Duncan Murdoch

bbouling wrote:

Greetings,

I recently discovered R and how to tackle my own functions.
I'm blocked on a simple barrier I guess. I call a function that recognizes a
string and return the adequate formula in a main function. This is done
through a script.

When I type the formula in the main function, it works fine. When I
attempted to use a second function (with conditional choice) it doesn't work
any more. May you guide me?

http://www.nabble.com/file/p18811385/annexe.R annexe.R 


You need to show us the output you get, and tell us the output you want, 
in a reproducible way.  Just showing us a function is not enough:  we 
don't know what inputs to give to the function, etc.


Duncan Murdoch

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


Re: [R] Howto Smooth a Curve Created with the Point Function

2008-08-04 Thread Ling, Gary (Electronic Trading)
Hi Gundala,
You have to reorder the points, like below:

#(your code ...)
g - cbind(x,g.pdf)[order(x),]
points(x=[,1],y=g[,2],type='l',col=red)

Cheers,
gary

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Gundala Viswanath
Sent: Monday, August 04, 2008 9:50 AM
To: [EMAIL PROTECTED]
Subject: [R] Howto Smooth a Curve Created with the Point Function


Hi all,

I have this figure:

 http://docs.google.com/Doc?id=df5zfsj4_103rjt2v4d5

created with the following steps:

 x
  [1]  90.4  57.8  77.0 103.7  55.4 217.5  68.1  85.3 152.0 113.0  97.1
89.9
 [13]  68.1  83.7  77.4  34.5 104.9 170.3  88.6  88.1 108.8  77.4  85.6
82.7
 [25]  81.3 108.0  49.5  71.0  85.7  99.3 203.5 275.9  51.1  84.8  16.5
72.6
 [37] 160.5 158.3 136.7 140.0  98.4 116.1 177.0 168.7 208.0 219.3  90.5
119.7
 [49]  72.9 138.4  98.6  56.0 151.6 230.0  82.0  65.6  83.0 106.9 141.3
103.9
 [61]  76.0  90.6  72.9  85.5  70.5 134.3 129.5 130.9 187.1 131.4  57.7
179.7
 [73]  89.7 126.1 124.4 103.2 111.8 143.1  59.4  85.3 122.8 100.0 158.4
188.2
 [85]  91.9  90.0  74.5  70.2 105.8  90.0  96.6 109.5 176.8 145.1 126.2
215.9
 [97] 103.4 154.3  84.8 112.8 119.8 111.9 107.6 114.3 198.7  98.2 187.6
196.7
[109] 138.5 146.1  75.0  80.0 147.7 171.3  90.1  58.1 109.3 136.6  91.5
93.8
[121]  79.4  71.8

 xhist - hist(x,col=blue, xlab=Exp Level,freq=FALSE)
 alpha - 6.352082
 beta   - 17.84647
 g.pdf - dgamma(x,shape=alpha,scale=beta)
 points(x,g.pdf,col=red,type='l')  ## problem here

My question is:

Why the command points DOES NOT create smooth red curve
as we expected? How can I resolve this problem?

I specifically want to use the dgamma
function with the learned parameter (alpha,beta).

That's why I don't use this command:
 lines(density(x),add=T, col=red)


- Gundala Viswanath
Jakarta - Indonesia

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


This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.

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


[R] subset inside a lattice plot using panel.lines

2008-08-04 Thread Michael Hopkins


Hi R people

Pulling my hair out here trying to get something very simple to work.   
Have a data frame of 774 rows and want to plot first and second half  
on same axes with different colours.  A variable is present call 'row'  
created like this and checked to be OK:

row - seq( len=length( variable1 ) )

...so I just want to plot the two subsets where row = 387 and where  
row  387.  None of these work properly:

plots both over each other in correct colours
opt_plot2 - function( var_string, c, units ) {
print( xyplot( get(var_string) ~ variable1 | variable2, panel =
function( x, y, ... ) {
panel.xyplot( x, y, type =n, ... )
panel.grid( h=-1, v=-1, lty=3, lwd=1, col=grey )
panel.lines( x, y, col = red, subset = row = 387 )
panel.lines( x, y, col = dark green, subset = row  387 )
},
}

plots both just in red
... panel.lines( x[row = 387], y[row = 387], col = red )
panel.lines( x[row  387], y[row  387], col = dark green )

first - (row = 387)
second - (row  387)

plots both over each other in correct colours
... panel.lines( x, y, col = red, subset = first )
panel.lines( x, y, col = dark green, subset = second )

plots both just in red
... panel.lines( x[first], y[first], col = red )
panel.lines( x[second], y[second], col = dark green )


I'm feeling frustrated and a bit stupid but should this be so  
difficult?  Any help or tips on what I am doing wrong greatly  
appreciated.

TIA

Michael

__

 Hopkins Research  Touch the Future
__


[[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] subset inside a lattice plot using panel.lines

2008-08-04 Thread Michael Hopkins



Hi R people [duplicate - sorry, just posted HTML by mistake]

Pulling my hair out here trying to get something very simple to work.   
Have a data frame of 774 rows and want to plot first and second half  
on same axes with different colours.  A variable is present call 'row'  
created like this and checked to be OK:


row - seq( len=length( variable1 ) )

...so I just want to plot the two subsets where row = 387 and where  
row  387.  None of these work properly:


plots both over each other in correct colours
opt_plot2 - function( var_string, c, units ) {
print( xyplot( get(var_string) ~ variable1 | variable2, panel =
function( x, y, ... ) {
panel.xyplot( x, y, type =n, ... )
panel.grid( h=-1, v=-1, lty=3, lwd=1, col=grey )
panel.lines( x, y, col = red, subset = row = 387 )
panel.lines( x, y, col = dark green, subset = row  387 )
},
}

plots both just in red
... panel.lines( x[row = 387], y[row = 387], col = red )
panel.lines( x[row  387], y[row  387], col = dark 
green )

first - (row = 387)
second - (row  387)

plots both over each other in correct colours
... panel.lines( x, y, col = red, subset = first )
panel.lines( x, y, col = dark green, subset = second )
plots both just in red
... panel.lines( x[first], y[first], col = red )
panel.lines( x[second], y[second], col = dark green )


I'm feeling frustrated and a bit stupid but should this be so  
difficult?  Any help or tips on what I am doing wrong greatly  
appreciated.


TIA

Michael

__

Hopkins Research  Touch the Future

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


Re: [R] subset inside a lattice plot using panel.lines

2008-08-04 Thread Mark Difford

Hi Michael,

 Pulling my hair out here trying to get something very simple to work. ...

I can't quite see what you are trying to do [and I am not sure that you
clearly state it], but you could make things easier and simpler by (1)
creating a factor to identify your groups of rows more cleanly and (2) by
using the groups= argument in lattice.

## Something along these lines
copyDat - originalDat
copyDat$newFac - gl(2, 387, 774, labels=c(A,B))

xyplot(response ~ predictor|maybe.condition, data=copyDat, groups=newFac)

I hope this gives you some ideas.

Mark.


Michael Hopkins wrote:
 
 
 
 Hi R people [duplicate - sorry, just posted HTML by mistake]
 
 Pulling my hair out here trying to get something very simple to work.   
 Have a data frame of 774 rows and want to plot first and second half  
 on same axes with different colours.  A variable is present call 'row'  
 created like this and checked to be OK:
 
   row - seq( len=length( variable1 ) )
 
 ...so I just want to plot the two subsets where row = 387 and where  
 row  387.  None of these work properly:
 
 plots both over each other in correct colours
   opt_plot2 - function( var_string, c, units ) {
   print( xyplot( get(var_string) ~ variable1 | variable2, panel =
   function( x, y, ... ) {
   panel.xyplot( x, y, type =n, ... )
   panel.grid( h=-1, v=-1, lty=3, lwd=1, col=grey )
   panel.lines( x, y, col = red, subset = row = 387 )
   panel.lines( x, y, col = dark green, subset = row  387 )
   },
   }
 
 plots both just in red
   ... panel.lines( x[row = 387], y[row = 387], col = red )
   panel.lines( x[row  387], y[row  387], col = dark 
 green )
 
 first - (row = 387)
 second - (row  387)
 
 plots both over each other in correct colours
   ... panel.lines( x, y, col = red, subset = first )
   panel.lines( x, y, col = dark green, subset = second )
 plots both just in red
   ... panel.lines( x[first], y[first], col = red )
   panel.lines( x[second], y[second], col = dark green )
 
 
 I'm feeling frustrated and a bit stupid but should this be so  
 difficult?  Any help or tips on what I am doing wrong greatly  
 appreciated.
 
 TIA
 
 Michael
 
 __
 
  Hopkins Research  Touch the Future
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/subset-inside-a-lattice-plot-using-panel.lines-tp18813236p18813818.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] plot() change unit length

2008-08-04 Thread Qian R








I am try to plot a data frame, and encounter some difficulties. 
 
my x axis range is from -60 to 80 and unit length is 10 
so x axis looks like
 
-60, -40, -20, .., 40,60,80
 
But I want chang unit length from 10 to 5
 
-60, -50, -40, .., 60,70,80
 
Does anyone know how to do it?
 
Thanks



  
[[alternative HTML version deleted]]

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


[R] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Arthur Roberts

Hi, all,

	I would like to know if there is any gui interface out there  
(academic or commercial) that allows one to edit R-language generated  
graphs (e.g positioning x axis labels.)  It would be nice to have  
something like the user interface of Igor or Origin.  I have already  
used JGR and R-gui.  These are good, but they don't allow one to  
easily edit graphs.  I have also tried locator() and the package  
iplots.  Your input is greatly appreciated.


Best wishes,
Art Roberts
University of Washington

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


Re: [R] plot() change unit length

2008-08-04 Thread jim holtman
You can always create the axis yourself:

x - seq(-60,80)
plot(x, seq_along(x), xaxt='n')
axis(1, at=pretty(x,10))



On Mon, Aug 4, 2008 at 12:47 PM, Qian R [EMAIL PROTECTED] wrote:








 I am try to plot a data frame, and encounter some difficulties.

 my x axis range is from -60 to 80 and unit length is 10
 so x axis looks like

 -60, -40, -20, .., 40,60,80

 But I want chang unit length from 10 to 5

 -60, -50, -40, .., 60,70,80

 Does anyone know how to do it?

 Thanks




[[alternative HTML version deleted]]


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





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

What is the problem that you are trying to solve?

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


Re: [R] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Bert Gunter
No. Can't be. Editable graphs require that the graph be produced via code
that produces changeable components. All R graphs are essentially static.

That said, caveats: graphs drawn via the grid package functionality -- for
example lattice graphs -- **are** produced via changeable code. If you read
the lattice docs carefully, you'll see that there are a few features there
that allow some graph editing. There may be other packages that also have
some editing capabilties. R's base graphics also allow a little interaction
via identify() and locator(), which can be useful (e.g. for positioning
legends).

One can also simulate interactivity by recording various components of
graph construction and then modifying and redrawing them. But this is just
manually doing what you're looking for, so probably a dumb suggestion.

While graph editing certainly can be a nice feature, it is very difficult to
implement without severely constraining graphing flexibility (IMO, of
course). Graphs are very complex beasties, so it's hard to write clean code
that allows flexibile editing capabilities. Look at S-Plus's graph editing,
which I always found harder to use (and more buggy) than just issuing the
commands. (To be fair, it's been some years since I tried).

Again, just my 2 bits. Others may well disagree (and perhaps point you to
what you seek).

Cheers,
Bert

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Arthur Roberts
Sent: Monday, August 04, 2008 9:51 AM
To: [EMAIL PROTECTED]
Subject: [R] Are there any guis out there,which will allow editing of the
graph?

Hi, all,

I would like to know if there is any gui interface out there  
(academic or commercial) that allows one to edit R-language generated  
graphs (e.g positioning x axis labels.)  It would be nice to have  
something like the user interface of Igor or Origin.  I have already  
used JGR and R-gui.  These are good, but they don't allow one to  
easily edit graphs.  I have also tried locator() and the package  
iplots.  Your input is greatly appreciated.

Best wishes,
Art Roberts
University of Washington

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

2008-08-04 Thread John P. Burkett
My goal is to prepare a thematic map of the US, with states shaded 
according to their values for a variable of interest.  I would like to 
include an inset for Alaska in the upper left and an inset for Hawaii in 
the lower left. If possible, I'd like to use Albers conic projection, or 
something similar.  Thus far I have tried using the maps package with 
its state database (which omits Alaska and Hawaii) and the gmaps package 
(which places an inset for Alaska in the lower left and uses a 
projection [Miller cylindrical?] that distorts states along the northern 
and southern fringe). I would be very grateful for suggestions about 
alternative approaches.

John


--
John P. Burkett
Department of Environmental and Natural Resource Economics
and Department of Economics
University of Rhode Island
Kingston, RI 02881-0808
USA

phone (401) 874-9195

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Duncan Murdoch

On 04/08/2008 12:50 PM, Arthur Roberts wrote:

Hi, all,

	I would like to know if there is any gui interface out there  
(academic or commercial) that allows one to edit R-language generated  
graphs (e.g positioning x axis labels.)  It would be nice to have  
something like the user interface of Igor or Origin.  I have already  
used JGR and R-gui.  These are good, but they don't allow one to  
easily edit graphs.  I have also tried locator() and the package  
iplots.  Your input is greatly appreciated.


I imagine there are a number of commercial packages available that would 
allow you to edit PDF or PS files, but I haven't used any of them, so I 
can't recommend one.


Duncan Murdoch

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


Re: [R] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Bryan Hanson
A colleague of mine, quite by accident, discovered that Adobe Illustrator
can manipulate plots made by base graphics, and when you do, many pieces of
the plot are separate items that can be manipulated with Illustrator.  He
cuts and pastes from a Quartz window on his Mac, into Illustrator.
Apparently Illustrator has two kinds of selection arrows, one of which
selects groups of things, the other selects individual things.  He confirms
that text from R may be changed, colors in polygonal areas may be changed,
objects may be moved etc once they are selected.

Apparently he saw a notation that this was possible on some R code that went
with a Wikipedia entry, and he tried it, and it works.

YMMV. Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA



On 8/4/08 1:09 PM, Bert Gunter [EMAIL PROTECTED] wrote:

 No. Can't be. Editable graphs require that the graph be produced via code
 that produces changeable components. All R graphs are essentially static.
 
 That said, caveats: graphs drawn via the grid package functionality -- for
 example lattice graphs -- **are** produced via changeable code. If you read
 the lattice docs carefully, you'll see that there are a few features there
 that allow some graph editing. There may be other packages that also have
 some editing capabilties. R's base graphics also allow a little interaction
 via identify() and locator(), which can be useful (e.g. for positioning
 legends).
 
 One can also simulate interactivity by recording various components of
 graph construction and then modifying and redrawing them. But this is just
 manually doing what you're looking for, so probably a dumb suggestion.
 
 While graph editing certainly can be a nice feature, it is very difficult to
 implement without severely constraining graphing flexibility (IMO, of
 course). Graphs are very complex beasties, so it's hard to write clean code
 that allows flexibile editing capabilities. Look at S-Plus's graph editing,
 which I always found harder to use (and more buggy) than just issuing the
 commands. (To be fair, it's been some years since I tried).
 
 Again, just my 2 bits. Others may well disagree (and perhaps point you to
 what you seek).
 
 Cheers,
 Bert
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of Arthur Roberts
 Sent: Monday, August 04, 2008 9:51 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Are there any guis out there,which will allow editing of the
 graph?
 
 Hi, all,
 
 I would like to know if there is any gui interface out there
 (academic or commercial) that allows one to edit R-language generated
 graphs (e.g positioning x axis labels.)  It would be nice to have
 something like the user interface of Igor or Origin.  I have already
 used JGR and R-gui.  These are good, but they don't allow one to
 easily edit graphs.  I have also tried locator() and the package
 iplots.  Your input is greatly appreciated.
 
 Best wishes,
 Art Roberts
 University of Washington
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Peter Dalgaard

Bert Gunter wrote:

No. Can't be. Editable graphs require that the graph be produced via code
that produces changeable components. All R graphs are essentially static.
  
Well, there's the xfig() device whose output can be edited with xfig 
This was originally written (by me, for S-PLUS, back in the dark ages, 
later modified extensively for R by Brian) with the purpose of being 
able to do things like moving unfortunately placed labels around. In 
practice, I hardly ever used it because of the writing in sand aspect 
that affects all such interactive tools.  However, xfig is still around 
and even installable on Windows with a little extra effort.



--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Gabor Grothendieck
Microsoft Word's graphics editor can edit R graphics saved in
metafile format, wmf.  That includes x axis labels, etc.

On Mon, Aug 4, 2008 at 12:50 PM, Arthur Roberts [EMAIL PROTECTED] wrote:
 Hi, all,

I would like to know if there is any gui interface out there
 (academic or commercial) that allows one to edit R-language generated graphs
 (e.g positioning x axis labels.)  It would be nice to have something like
 the user interface of Igor or Origin.  I have already used JGR and R-gui.
  These are good, but they don't allow one to easily edit graphs.  I have
 also tried locator() and the package iplots.  Your input is greatly
 appreciated.

 Best wishes,
 Art Roberts
 University of Washington

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

2008-08-04 Thread Duncan Murdoch

On 04/08/2008 1:14 PM, John P. Burkett wrote:
My goal is to prepare a thematic map of the US, with states shaded 
according to their values for a variable of interest.  I would like to 
include an inset for Alaska in the upper left and an inset for Hawaii in 
the lower left. If possible, I'd like to use Albers conic projection, or 
something similar.  Thus far I have tried using the maps package with 
its state database (which omits Alaska and Hawaii) and the gmaps package 
(which places an inset for Alaska in the lower left and uses a 
projection [Miller cylindrical?] that distorts states along the northern 
and southern fringe). I would be very grateful for suggestions about 
alternative approaches.


Alaska and Hawaii are in the world map, coded as regions USA:Alaska and 
Hawaii:Hawaii.


I believe you can plot the states data, then add Alaska and Hawaii at 
locations of your choice afterwards.  I don't know how to do multiple 
regions on the same plot, but here's how to do the components:


map(state, projection=albers, parameters=c(25,40))

map(world2Hires, USA:Alaska, projection=albers, parameters=c(55, 70))

map(world2Hires, Hawaii, projection=albers, parameters=c(15, 25))

This needs the mapdata package for world2Hires, and (I think) the 
mapproj package for the Albers projections.


Duncan Murdoch

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


Re: [R] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Peter Dalgaard

Peter Dalgaard wrote:

Bert Gunter wrote:
No. Can't be. Editable graphs require that the graph be produced via 
code
that produces changeable components. All R graphs are essentially 
static.
  
Well, there's the xfig() device whose output can be edited with 
xfig This was originally written (by me, for S-PLUS, back in the 
dark ages, later modified extensively for R by Brian) 
Actually, rewritten is more like it. R and S device drivers are rather 
different beasts, so Brian started from scratch, modifying the 
postscript device using the fig file specification.


with the purpose of being able to do things like moving unfortunately 
placed labels around. In practice, I hardly ever used it because of 
the writing in sand aspect that affects all such interactive tools.  
However, xfig is still around and even installable on Windows with a 
little extra effort.






--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sorting a matrix by a column

2008-08-04 Thread John Sorkin
R 2.6
Windows XP

I have a 100x4 matirx

data-matrix(nrow=100,ncol=4)

I would like to sort the entire matrix by column two, i.e. data[,2]
I looked at the help page for sort() but can not determine how I can use it to 
sort a matrix on one of the matrix's columns.

Thanks,
John 

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sorting a matrix by a column

2008-08-04 Thread Prof Brian Ripley

On Mon, 4 Aug 2008, John Sorkin wrote:


R 2.6
Windows XP

I have a 100x4 matirx

data-matrix(nrow=100,ncol=4)

I would like to sort the entire matrix by column two, i.e. data[,2]
I looked at the help page for sort() but can not determine how I can use it to 
sort a matrix on one of the matrix's columns.


Rather, use sort.list, e.g.  data[sort.list(data[,2]), ]

There's an example for data frames on ?order.



Thanks,
John

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Sorting a matrix by a column

2008-08-04 Thread Dimitris Rizopoulos

probably you need order(), e.g.,

data[order(data[, 2]), ]


I hope it helps.

Best,
Dimitris


John Sorkin wrote:

R 2.6
Windows XP

I have a 100x4 matirx

data-matrix(nrow=100,ncol=4)

I would like to sort the entire matrix by column two, i.e. data[,2]
I looked at the help page for sort() but can not determine how I can use it to 
sort a matrix on one of the matrix's columns.

Thanks,
John 


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for ...{{dropped:25}}


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Long Range Dependence: Hurst exponent estimation

2008-08-04 Thread tolga . i . uzuner
Dear R Users,

Can anyone point me to a package for R vrsion 2.7.1 which implements some 
Hurst exponent estimation methods ?

Thanks in advance,
Tolga

Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase  Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase 
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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] FW: Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Bert Gunter

Well, just goes to show you how much I know! Glad you were able to get some
help.

-- Bert 

-Original Message-
From: Arthur Roberts [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 04, 2008 12:05 PM
To: Bert Gunter
Subject: Re: [R] Are there any guis out there,which will allow editing of
the graph?

Dear Bert,

I heard from several commentators that you can actually edit Figures  
by a variety of means.  I tried Inkscape and it seems to work pretty  
well.

Best wishes,
Art

On Aug 4, 2008, at 10:09 AM, Bert Gunter wrote:

 No. Can't be. Editable graphs require that the graph be produced via  
 code
 that produces changeable components. All R graphs are essentially  
 static.

 That said, caveats: graphs drawn via the grid package functionality  
 -- for
 example lattice graphs -- **are** produced via changeable code. If  
 you read
 the lattice docs carefully, you'll see that there are a few features  
 there
 that allow some graph editing. There may be other packages that also  
 have
 some editing capabilties. R's base graphics also allow a little  
 interaction
 via identify() and locator(), which can be useful (e.g. for  
 positioning
 legends).

 One can also simulate interactivity by recording various  
 components of
 graph construction and then modifying and redrawing them. But this  
 is just
 manually doing what you're looking for, so probably a dumb suggestion.

 While graph editing certainly can be a nice feature, it is very  
 difficult to
 implement without severely constraining graphing flexibility (IMO, of
 course). Graphs are very complex beasties, so it's hard to write  
 clean code
 that allows flexibile editing capabilities. Look at S-Plus's graph  
 editing,
 which I always found harder to use (and more buggy) than just  
 issuing the
 commands. (To be fair, it's been some years since I tried).

 Again, just my 2 bits. Others may well disagree (and perhaps point  
 you to
 what you seek).

 Cheers,
 Bert

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 ] On
 Behalf Of Arthur Roberts
 Sent: Monday, August 04, 2008 9:51 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Are there any guis out there,which will allow editing  
 of the
 graph?

 Hi, all,

   I would like to know if there is any gui interface out there
 (academic or commercial) that allows one to edit R-language generated
 graphs (e.g positioning x axis labels.)  It would be nice to have
 something like the user interface of Igor or Origin.  I have already
 used JGR and R-gui.  These are good, but they don't allow one to
 easily edit graphs.  I have also tried locator() and the package
 iplots.  Your input is greatly appreciated.

 Best wishes,
 Art Roberts
 University of Washington

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] xyplot strip=function for two conditioning variables

2008-08-04 Thread Deepayan Sarkar
On Mon, Aug 4, 2008 at 3:36 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Checkout this one:

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

And there's a wrapper for this in the latticeExtra package:

library(latticeExtra)
useOuterStrips(xyplot(data=df, copies~week|Treatment+genes,type=c(b,g)))

-Deepayan

 On Mon, Aug 4, 2008 at 6:24 AM, Henning Wildhagen [EMAIL PROTECTED] wrote:
 Dear list,

 for a data structure like in df:

 set.seed(100)
 Treatment-rep(c(Nitrogen,Carbon, Sulfur),each=9)
 week-rep(c(1,5,9),3,each=3)
 genes-rep(c(18s, EF1b, NR),9)
 copies-rnorm(27, 100,40)
 df-data.frame(Treatment,week,genes,copies)

 i wrote this code for a xyplot:

 library(lattice)
 PLOT-xyplot(data=df, copies~week|Treatment+genes,type=c(b,g))

 I would like to change PLOT in a way, that the strips for Treatment are
 displayed only once at the top of each of the three columns. Additionally i
 would like to strips for genes at the top of each panel.

 I tried to adopt some code i found in the helplist using strip=function...
 but i did not manage to get what i would like.

 Can anyone give me advice?

 Thanks,

 Henning


 --



[[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there any way to make pretty tables in R to pdf?

2008-08-04 Thread Arthur Roberts

Hi, all,

All your comments have been very useful.  I was wondering if there was  
a package that can make pretty R tables to pdf.  I guess I could use  
xtable, but I would like something a little more elegant.  Your input  
is greatly appreciated.


Best wishes,
Art

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


Re: [R] subset inside a lattice plot using panel.lines

2008-08-04 Thread Deepayan Sarkar
On Mon, Aug 4, 2008 at 8:44 AM, Mark Difford [EMAIL PROTECTED] wrote:

 Hi Michael,

 Pulling my hair out here trying to get something very simple to work. ...

 I can't quite see what you are trying to do [and I am not sure that you
 clearly state it], but you could make things easier and simpler by (1)
 creating a factor to identify your groups of rows more cleanly and (2) by
 using the groups= argument in lattice.

 ## Something along these lines
 copyDat - originalDat
 copyDat$newFac - gl(2, 387, 774, labels=c(A,B))

 xyplot(response ~ predictor|maybe.condition, data=copyDat, groups=newFac)

Right, and using 'row' directly should also work (although not with as
good possibilities for annotation):

xyplot(response ~ predictor|maybe.condition, data=copyDat,
   groups=(row = 387), type = c(l, g))

If you need a custom panel function, try using panel.groups:

xyplot(response ~ predictor|maybe.condition, data=copyDat,
   groups=(row = 387),
   panel = panel.superpose,
   panel.groups = function(...) {
  panel.grid(h = -1, v = -1, lty = 3)
  panel.lines(...)
   })

-Deepayan

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


[R] backslash in character string?

2008-08-04 Thread zack holden

Dear list,
 
After searching many old posts, I can't find the solution to a simple problem. 
 
can someone tell me how to create a character string with multiple backslashes, 
as in: 
 
file_dir - c(C:\files\data\) 
 
I need to create this string and then paste it to many files names for batch 
processing in another software program. R won't accept the backslash and 
removes it.
 
Thanks for any suggestions,
 
zack
 
 
[[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] an interesting finding on Hurst exponent estimation from fSeries

2008-08-04 Thread tolga . i . uzuner
Dear R Users,

I am using code from the following links to do Hurst exponent estimation.
link:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php?rev=1root=rmetricsview=rev
file: LongRangeDependence.R

Take a look at the following run:

 x-(cos((1:200)/10))
 rsFit(diff(x,15))@hurst$H
[1] 1.027420
 aggvarFit(diff(x,15))@hurst$H
[1] 0.02301331

First of all, can anyone cast a light on the drastically different results 
(obviously, the R/S fit is just wrong) ?

Further, can anyone recommend something which is more stable ? This code 
appears to be part of fSeries tho it doesnt appear if one installs and 
loads that package. Instead, one has to source the R code directly from 
the .R file.

Thanks in advance,
Tolga

Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase  Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase 
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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] backslash in character string?

2008-08-04 Thread Henrique Dallazuanna
Try:

file_dir - C:\\files\\data\\

On Mon, Aug 4, 2008 at 5:02 PM, zack holden [EMAIL PROTECTED] wrote:

 Dear list,

 After searching many old posts, I can't find the solution to a simple problem.

 can someone tell me how to create a character string with multiple 
 backslashes, as in:

 file_dir - c(C:\files\data\)

 I need to create this string and then paste it to many files names for batch 
 processing in another software program. R won't accept the backslash and 
 removes it.

 Thanks for any suggestions,

 zack


[[alternative HTML version deleted]]

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




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there any way to make pretty tables in R to pdf?

2008-08-04 Thread Mark Difford

Hi Arthur,

 I was wondering if there was a package that can make pretty R tables to
 pdf.

You got through TeX/LateX, but PDF could be your terminus. Package Hmisc:

? summary.formula

and its various arguments and options. You can't get much better.

http://cran.za.r-project.org/doc/contrib/Harrell-statcomp-notes.pdf

HTH, Mark.


Arthur Roberts wrote:
 
 Hi, all,
 
 All your comments have been very useful.  I was wondering if there was  
 a package that can make pretty R tables to pdf.  I guess I could use  
 xtable, but I would like something a little more elegant.  Your input  
 is greatly appreciated.
 
 Best wishes,
 Art
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Is-there-any-way-to-make-pretty-tables-in-R-to-pdf--tp18818187p18818675.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] Long Range Dependence: Hurst exponent estimation

2008-08-04 Thread tolga . i . uzuner
Thanks Gary. 

That package is a bit weird. When one installs and loads it up, you don't 
actually get any of those functions. One has to go to the following link:

http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php?rev=1root=rmetricsview=rev

and then download and source the file LongRangeDependence.R to get the 
aggvar and rsFit functions to do Hurst exponent estimation.

 It appears to be the case that the fSeries package currently does not 
really have that functionality. Perhaps they meant to put it in there but 
decided to exclude it in the current release for some reason.

I have also cc'd the RMetrics group here to see if they can cast a light 
on this issue.

Thanks,
Tolga






Ling, Gary \(Electronic Trading\) [EMAIL PROTECTED] 
04/08/2008 20:51

To
[EMAIL PROTECTED]
cc

Subject
RE: [R] Long Range Dependence: Hurst exponent estimation






Hi, you can try the fSeries package.
See this doc:
http://phase.hpcc.jp/mirrors/stat/R/CRAN/doc/packages/fSeries.pdf
-gary

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Monday, August 04, 2008 3:04 PM
To: r-help@r-project.org
Subject: [R] Long Range Dependence: Hurst exponent estimation


Dear R Users,

Can anyone point me to a package for R vrsion 2.7.1 which implements
some 
Hurst exponent estimation methods ?

Thanks in advance,
Tolga

Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase  Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase 
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
 [[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.


This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically 
indicated, this message is not an offer to sell or a solicitation of any 
investment products or other financial product or service, an official 
confirmation of any transaction, or an official statement of Merrill 
Lynch. Subject to applicable law, Merrill Lynch may monitor, review and 
retain e-communications (EC) traveling through its networks/systems. The 
laws of the country of each sender/recipient may impact the handling of 
EC, and EC may be archived, supervised and produced in countries other 
than the country in which you are located. This message cannot be 
guaranteed to be secure or error-free. This message is subject to terms 
available at the following link: http://www.ml.com/e-communications_terms/
. By messaging with Merrill Lynch you consent to the foregoing.




Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or

Re: [R] Is there any way to make pretty tables in R to pdf?

2008-08-04 Thread Mark Difford

Hi Arthur,

Sorry, sent you down the wrong track: this will help you to get there:

http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/summary.pdf

Regards, Mark.


Arthur Roberts wrote:
 
 Hi, all,
 
 All your comments have been very useful.  I was wondering if there was  
 a package that can make pretty R tables to pdf.  I guess I could use  
 xtable, but I would like something a little more elegant.  Your input  
 is greatly appreciated.
 
 Best wishes,
 Art
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Is-there-any-way-to-make-pretty-tables-in-R-to-pdf--tp18818187p18818837.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] backslash in character string?

2008-08-04 Thread Christoph Heibl

You have to escape every backslash by a second backslash - try this:

f - C:\\files\\data\\ # create character string
write(f, ) # write to file
system(open -t ) # see what happen to the character string

 file_dir - c(C:\files\data\)




Christoph Heibl

Systematic Botany
Ludwig-Maximilians-Universität München
Menzinger Str. 67
D-80638 München
GERMANY

phone: +49-(0)89-17861-251
e-mail:[EMAIL PROTECTED]

http://www.christophheibl.de/ch-home.html

SAVE PAPER - THINK BEFORE YOU PRINT








[[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] History pruning

2008-08-04 Thread Ken Williams



On 8/1/08 1:13 PM, Richard M. Heiberger [EMAIL PROTECTED] wrote:

 I meant 5a 5b 5c.  Multiple-line commands are handled correctly.
 What is is doing is looking for   and  + prompts.  Anything else
 is removed.

When I said 5c) prune any lines that don't have assignment operators I
meant to take a sequence like this (to pick a semi-random chunk from my
history log):

---
df - data.frame(x=2:9, y=(1:8)^2)
cor(df)
?cor
mad(c(1:9))
?reshape
a - matrix(1:12, nrow=3)
b - matrix(2:13, nrow=3)
b - matrix(4:15, nrow=3)
b - matrix(2:13, nrow=3)
c - matrix(4:15, nrow=3)
a
b
c
---

And turn it into this:

---
df - data.frame(x=2:9, y=(1:8)^2)
a - matrix(1:12, nrow=3)
b - matrix(2:13, nrow=3)
b - matrix(4:15, nrow=3)
b - matrix(2:13, nrow=3)
c - matrix(4:15, nrow=3)
---

Obviously I wouldn't *always* want this performed, but selectively it would
be quite nice.

Further, if the dependency graph among variable definitions were computable,
the sequence could be reduced to this:

---
df - data.frame(x=2:9, y=(1:8)^2)
a - matrix(1:12, nrow=3)
b - matrix(2:13, nrow=3)
c - matrix(4:15, nrow=3)
---

Note that the starting point of all of this is a sequence of commands (the
output of savehistory(), so separating commands from output isn't necessary.

I've made a bit of progress on this, hopefully I can get clearance to show
my work soon.  It would be nice if this could be hooked into ESS for
selective pruning or something.

 -Ken


-- 
Ken Williams
Research Scientist
The Thomson Reuters Corporation
Eagan, MN

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] simulate data based on partial correlation matrix

2008-08-04 Thread Benjamin Michael Kelcey


Given four known and fixed vectors, x1,x2,x3,x4, I am trying to  
generate a fifth vector,z, with specified known and fixed partial  
correlations.

How can I do this?

In the past I have used the following (thanks to Greg Snow) to  
generate a fifth vector based on zero order correlations---however I'd  
like to modify it so that it can generate a fifth vector with specific  
partial correlations rather than zero order correlations:


# create x1-x4
x1 - rnorm(100, 50, 3)
x2 - rnorm(100) + x1/5
x3 - rnorm(100) + x2/5
x4 - rnorm(100) + x3/5

# find current correlations
cor1 - cor( cbind(x1,x2,x3,x4) )
cor1

# create 1st version of z
z - rnorm(100)
# combine in a matrix
m1 - cbind( x1, x2, x3, x4, z )

# center and scale
m2 - scale(m1)

# find cholesky decomp
c1 - chol(var(m2))

# force to be independent
m3 - m2 %*% solve(c1)

# create new correlation matrix:
cor2 - cbind( rbind( cor1, z=c(.5,.3,.1,.05) ), z=c(.5,.3,.1,.05,1) )

# create new matrix
m4 - m3 %*% chol(cor2)

# uncenter and unscale
m5 - sweep( m4, 2, attr(m2, 'scaled:scale'), '*')
m5 - sweep( m5, 2, attr(m2, 'scaled:center'), '+')

##Check they are equal
zapsmall(cor(m5))==zapsmall(cor2)

Thanks, ben

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

2008-08-04 Thread rcoder

Hi,

I guess my question is really more about the nested for loop construct and
whether it is doing what I intend it to do in my code in the previous post.
I would be grateful if anyone who has used nested loops could let me know if
I am doing something wrong.

Thanks,

rcoder



rcoder wrote:
 
 Hi everyone,
 
 I'm experiencing difficulty getting the results I want when I use a nested
 for loop. I have a data set to which I perform some calculations, and then
 try to apply a regression over a rolling window. The code runs, but the
 regression results I am getting (intercept and slope) are simply the same,
 repeated again and again in the results matrix. The regression does not
 seem to be obeying the instructions of the nested loop, which intend it to
 calculate regression coefficients over a data one row at a time. I have
 been struggling with the code for many days now, testing various parts,
 and I cannot seem to get the nested loop to work as I want it to. I would
 be very grateful for any suggestions. Below is a brief version of my code:
 
 #Code start
 library(zoo)
 seed.set(1)
 Pmat-matrix(rnorm(1000), nrow=100, ncol=100)
 maxcol-ncol(Pmat)
 maxrow-nrow(Pmat)
 startrow-10  
 period-10
 wind-2   #roll window
 subdiv-period/wind
 rollstart-11 #start roll at period+1
 #converting Pmat into ts for rollapply() to work...
 PmatTS-ts(Pmat)
 Preg-matrix(NA,ncol=maxcol,nrow=2*maxrow)
 PmatWt-matrix(NA, nrow=subdiv,ncol=maxcol)
 mult_col-matrix(1:5, nrow=5, ncol=1)
 #rolling calculations...
 for (i in (rollstart):maxrow)   
   {
 #extract the relevant timeframe...
 dslice-PmatTS[(i-period):i,] 
 dslicets-ts(dslice)
 #operating on sliced data...
 Pmin-rollapply(dslicets, wind, by=wind, min, na.rm=F)  
 Pmax-rollapply(dslicets, wind, by=wind, max, na.rm=F) 
 Pmult-Pmin*Pmax#calculating product
 tt-time(Pmult)
 for (j in 1:5)#1st nested loop
   {
 PmatWt[j,]-Pmult[j,]*mult_col[j,]
   }
 #rolling regression analysis...
 for (k in 1:maxcol)   #2nd nested loop
 {
   sel_col-PmatWt[,k] 
   if(!all(is.na(sel_col))) {Preg[,k]-coef(lm(tt~sel_col))}
 }
   }
 #Code End
 
 Thanks,
 
 rcoder
 

-- 
View this message in context: 
http://www.nabble.com/problem-with-nested-loop-for-regression-tp18792841p18815273.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] Turning Cross-tab into new data frame

2008-08-04 Thread Spencer

Dear R Experts,

I am wondering if anyone has a solution to the following:

I am creating some cross-tabulation tables and want to input the results 
from these tables into a new set of functions. Is there a way to turn 
the cross-tab table into a new dataset? I haven't yet been able to 
accomplish this by placing the cross tab function inside a as.matrix 
or data.frame yet.


Any help would be great!

Spencer

--
Spencer Cohen
PhD Student
Department of Geography
University of Washington
Email: [EMAIL PROTECTED]
Website: staff.washington.edu/zhuge99

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Lattice: How to draw curves from given formulae

2008-08-04 Thread John Smith
I have another questions. How can I type specific names into strips of the
resulting plot?

For instance, in the resulting figure from the attached code, instead of
'umbrella(d)', I want have 'UMBRELLA' in the strip.

library(lattice)

flat - function(d) 0 * d
linear   - function(d) -(1.65/8) * d
logistic - function(d) 0.015 - 1.73 / (1 + exp(1.2 * (4-d)))
umbrella - function(d) -(1.65/3) * d + (1.65 / 36) * d^2
emax - function(d) -1.81 * d / (0.79 + d)
sigmoid  - function(d) -1.70 * d^5 / (4^5 + d^5)

xyplot(flat(d) + linear(d) + logistic(d) + umbrella(d) + emax(d) +
sigmoid(d) ~ d,
   data = list(d = seq(0, 8, length = 101)),
   ylab='Expected change from baseline in VAS at Week 6', xlab='Dose',
   type = l, outer = TRUE, )

Many thanks




On Tue, Jul 22, 2008 at 4:31 PM, Deepayan Sarkar
[EMAIL PROTECTED]wrote:

 On 7/22/08, John Smith [EMAIL PROTECTED] wrote:
  Thanks, Deepayan,
 
   I actually want to have a picture like the Figure 5.9 in Mixed-Effects
   Models in S and S-PLUS, which have a separate panel for each function
 and
   has the function name been printed in strip.

 xyplot(linear(d) + logistic(d) + umbrella(d) ~ d,
  data = list(d = seq(-5, 5, length = 101)),
   type = l, outer = TRUE)

 There are several ways to make the strip labels just the names; the
 simplest is to create a data frame with all the necessary columns
 beforehand.

 -Deepayan

 
   Thanks
 
 
 
   On Tue, Jul 22, 2008 at 1:08 PM, Deepayan Sarkar 
 [EMAIL PROTECTED]
   wrote:
 
 
On 7/21/08, John Smith [EMAIL PROTECTED] wrote:
 Dear R Users:

  I have a list function as:
  Flat:  y = 0
  Linear: y = -(1.65/8)d
  Logistic: y = 0.015 - 1.73/{1+exp[1.2(4-d)]}
  Umbrella: y= -(1.65/3)d + (1.65/36)d^2
  Emax: y = -1.81d/(0.79+d)
  Sigmoid Emax: y = -1.70d^5/(4^5+d^5)

  And want draw the figure as attached (those material are extracted
 from
a
  paper). Could anyone give me a sample code to do this?
   
The attachment didn't come through, but here's one approach (with
three of your functions):
   
linear - function(d) -(1.65/8) * d
logistic - function(d) 0.015 - 1.73 / (1 + exp(1.2 * (4-d)))
umbrella - function(d) -(1.65/3) * d + (1.65 / 36) * d^2
   
xyplot(linear(d) + logistic(d) + umbrella(d) ~ d,
  data = list(d = seq(-5, 5, length = 101)),
  type = l,
  auto.key = list(lines = TRUE, points = FALSE))
   
-Deepayan


[[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] simulate data based on partial correlation matrix

2008-08-04 Thread Benjamin Michael Kelcey


Given four known and fixed vectors, x1,x2,x3,x4, I am trying to  
generate a fifth vector,z, with specified known and fixed partial  
correlations.

How can I do this?

In the past I have used the following (thanks to Greg Snow) to  
generate a fifth vector based on zero order correlations---however I'd  
like to modify it so that it can generate a fifth vector with specific  
partial correlations rather than zero order correlations:


# create x1-x4
x1 - rnorm(100, 50, 3)
x2 - rnorm(100) + x1/5
x3 - rnorm(100) + x2/5
x4 - rnorm(100) + x3/5

# find current correlations
cor1 - cor( cbind(x1,x2,x3,x4) )
cor1

# create 1st version of z
z - rnorm(100)
# combine in a matrix
m1 - cbind( x1, x2, x3, x4, z )

# center and scale
m2 - scale(m1)

# find cholesky decomp
c1 - chol(var(m2))

# force to be independent
m3 - m2 %*% solve(c1)

# create new correlation matrix:
cor2 - cbind( rbind( cor1, z=c(.5,.3,.1,.05) ), z=c(.5,.3,.1,.05,1) )

# create new matrix
m4 - m3 %*% chol(cor2)

# uncenter and unscale
m5 - sweep( m4, 2, attr(m2, 'scaled:scale'), '*')
m5 - sweep( m5, 2, attr(m2, 'scaled:center'), '+')

##Check they are equal
zapsmall(cor(m5))==zapsmall(cor2)

Thanks, ben

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Long Range Dependence: Hurst exponent estimation

2008-08-04 Thread Hans W. Borchers
 

There is the 'fdim' package that computes the fractal dimension D.
Between D and the Hurst exponent H there should be a relation

D = 2 - H

I wonder if this is true when computing D and H with different
approaches

Regards,

Hans Werner Borchers
ABB Corporate Research

tolga.i.uzuner at jpmorgan.com writes:
 Thanks Gary. 
 
 That package is a bit weird. When one installs and loads it up, you don't 
 actually get any of those functions. [...]
  
  It appears to be the case that the fSeries package currently does not 
 really have that functionality. Perhaps they meant to put it in there but 
 decided to exclude it in the current release for some reason.
 
 I have also cc'd the RMetrics group here to see if they can cast a light 
 on this issue.
 
 Thanks,
 Tolga


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

2008-08-04 Thread Zhang Yanwei - Princeton-MRAm
Hi all,
  I'd like to fit a multivariate regression with the variance of the error term 
porportional to the predictors, like the WLS in the univariate case.
  y_1~x_1+x_2
  y_2~x_1+x_2
  var(y_1)=x_1*sigma_1^2
  var(y_2)=x_2*sigma_2^2
  cov(y_1,y_2)=sqrt(x_1*x_2)*sigma_12^2

 How can I specify this in R? Is there a corresponding function to the 
univariate specification lm(y~x,weights=x)?? Thanks.

Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel: 609-275-2176
Email: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]


[[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] about the 95%CI around the median...

2008-08-04 Thread Rolf Turner


On 5/08/2008, at 1:31 AM, Frank E Harrell Jr wrote:

snip

I wonder why we don't just use the exact nonparametric confidence  
interval for the median, which is just as easy to compute.  Also,  
it will be asymmetric if the data are skewed, as it should be.


snip

The boxplot.stats() function gives the same ``confidence interval''  
for the median as the

boxplot() function. This isn't however *really*  a confidence interval.

The help on boxplot() (see the ``notch'' argument) indicates that  
this ``confidence interval''
actually provides a rough *hypothesis test* of the equality of *two*  
medians. The null hypothesis

is rejected if the notches (confidence intervals) don't overlap.

cheers,

Rolf

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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


Re: [R] Multivariate Regression with Weights

2008-08-04 Thread Zhang Yanwei - Princeton-MRAm
 Thanks.


Sincerely,
Yanwei Zhang
Department of Actuarial Research and Modeling
Munich Re America
Tel: 609-275-2176
Email: [EMAIL PROTECTED]

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, August 04, 2008 5:15 PM
To: Zhang Yanwei - Princeton-MRAm
Subject: RE: [R] Multivariate Regression with Weights

  the systemfit package can do that and the documentation is quite nice also.


On Mon, Aug 4, 2008 at  4:39 PM, Zhang Yanwei - Princeton-MRAm wrote:

 Hi all,
   I'd like to fit a multivariate regression with the variance of the
 error term porportional to the predictors, like the WLS in the
 univariate case.
   y_1~x_1+x_2
   y_2~x_1+x_2
   var(y_1)=x_1*sigma_1^2
   var(y_2)=x_2*sigma_2^2
   cov(y_1,y_2)=sqrt(x_1*x_2)*sigma_12^2

  How can I specify this in R? Is there a corresponding function to the
 univariate specification lm(y~x,weights=x)?? Thanks.

 Sincerely,
 Yanwei Zhang
 Department of Actuarial Research and Modeling Munich Re America
 Tel: 609-275-2176
 Email: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]


   [[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] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Hans W. Borchers
Duncan Murdoch murdoch at stats.uwo.ca writes:
 
 On 04/08/2008 12:50 PM, Arthur Roberts wrote:
  Hi, all,
  
  I would like to know if there is any gui interface out there  
  (academic or commercial) that allows one to edit R-language generated  
  graphs (e.g positioning x axis labels.)  It would be nice to have  
  something like the user interface of Igor or Origin.  I have already  
  used JGR and R-gui.  These are good, but they don't allow one to  
  easily edit graphs.  I have also tried locator() and the package  
  iplots.  Your input is greatly appreciated.
 
 I imagine there are a number of commercial packages available that would 
 allow you to edit PDF or PS files, but I haven't used any of them, so I 
 can't recommend one.

There is this fantastic open source editor for vector graphics, *Inkscape*
(http://www.inkscape.org/). Inkscape can read PDF files generated by R as
PDFs. By 'ungrouping' graphs, Inkscape is able to modify any single piece
of the diagram. Inkscape will save modified diagrams in PDF, EPS, SVG or
any other reasonable graphics format.

Regards,

Hans Werner Borchers
ABB Corporate Research

 
 Duncan Murdoch


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


[R] log and Log Histogram

2008-08-04 Thread Alessandro
Hi All,

 

I have a X,Y and Z text file. I wish modify the X value in a logarithmic
value and to plot  all log(Z) with Histogram. I try different code but I
have a problem to find the solution.

 

Thank you very much

 

Ale 


[[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] log and Log Histogram

2008-08-04 Thread David Scott

On Mon, 4 Aug 2008, Alessandro wrote:


Hi All,



I have a X,Y and Z text file. I wish modify the X value in a logarithmic
value and to plot  all log(Z) with Histogram. I try different code but I
have a problem to find the solution.



My package HyperbolicDist has a log histogram function.

David Scott

_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

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


[R] R init file and source()

2008-08-04 Thread Allin Cottrell
In the context of calling R from another program (namely gretl, 
http://gretl.sourceforge.net ) I'm trying to understand the 
interactions of the R init file (corresponding to the environment 
variable RPROFILE) and the source() function.

I'll illustrate my problem with the following simplified contrast
implemented in the bash shell (with R 2.7.1).

1. Works fine:

[EMAIL PROTECTED]:~/Rfoo$ cat fooProfile1
# nothing here
[EMAIL PROTECTED]:~/Rfoo$ cat doit.1
export RPROFILE=fooProfile1
R --no-save --no-init-file --no-restore-data --slave fooSrc
[EMAIL PROTECTED]:~/Rfoo$ cat fooSrc 
library(graphics)
postscript(myfile.ps)
[EMAIL PROTECTED]:~/Rfoo$ sh doit.1

(silently produces a well-formed but empty myfile.ps)

2. Doesn't work:

[EMAIL PROTECTED]:~/Rfoo$ cat fooProfile2
source(fooSrc, verbose=TRUE, echo=TRUE)
[EMAIL PROTECTED]:~/Rfoo$ cat doit.2
export RPROFILE=fooProfile2
R --no-save --no-init-file --no-restore-data --slave
[EMAIL PROTECTED]:~/Rfoo$ cat fooSrc 
library(graphics)
postscript(myfile.ps)
[EMAIL PROTECTED]:~/Rfoo$ sh doit.2
'envir' chosen:environment: R_GlobalEnv
encoding = native.enc chosen
-- parsed 2 expressions; now eval(.)ing them:

 eval(expression_nr. 1 )
 =

 library(graphics)
curr.fun: symbol library
 .. after `expression(library(graphics))'

 eval(expression_nr. 2 )
 =

 postscript(myfile.ps)
Error in eval.with.vis(expr, envir, enclos) : 
  could not find function postscript

== end of output ==

I'd like to understand why, after loading the graphics library, 
the function postscript() is not available in the second case 
while it is in the first.  (The file fooSrc has the same content 
in the two cases: in the first case it's loaded via the shell, 
while in the second it's loaded using R's source() function.)

Thanks for any help.

-- 
Allin Cottrell
Department of Economics
Wake Forest University, NC

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

2008-08-04 Thread alan . ng
Hello,

I am trying to run a constrained optimization in R. constrOptim is really 
useful and has helped me a lot, but unfortunately, it doesn't provide the 
hessian.  Is there a solution to this problem?

I've tried optim with penalty-functions and L-BFGS-B, but it doesn't help.

Alan.
-- 

http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196

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


[R] R: log and Log Histogram

2008-08-04 Thread Alessandro
Hi david,

I tried HyperbolicDist but I have this problem (I wish transform Z value)

Library (HyperbolicDist)
Data (testground) # X,Y and Z value in txt file
changetestground - testground[-length(testground)]/testground[-1]
hist(change)
Error in hist.default(change) : 'x' deve essere numeric
logHist(change)
Error in hist.default(x, plot = FALSE) : 'x' must be numeric

THANK

Ale

-Messaggio originale-
Da: David Scott [mailto:[EMAIL PROTECTED] 
Inviato: lunedì 4 agosto 2008 16.30
A: Alessandro
Cc: r-help@r-project.org
Oggetto: Re: [R] log and Log Histogram

On Mon, 4 Aug 2008, Alessandro wrote:

 Hi All,



 I have a X,Y and Z text file. I wish modify the X value in a logarithmic
 value and to plot  all log(Z) with Histogram. I try different code but I
 have a problem to find the solution.


My package HyperbolicDist has a log histogram function.

David Scott

_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

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


Re: [R] Lattice: How to draw curves from given formulae

2008-08-04 Thread Deepayan Sarkar
On Mon, Aug 4, 2008 at 1:39 PM, John Smith [EMAIL PROTECTED] wrote:
 I have another questions. How can I type specific names into strips of the
 resulting plot?

 For instance, in the resulting figure from the attached code, instead of
 'umbrella(d)', I want have 'UMBRELLA' in the strip.

 library(lattice)

 flat - function(d) 0 * d
 linear   - function(d) -(1.65/8) * d
 logistic - function(d) 0.015 - 1.73 / (1 + exp(1.2 * (4-d)))
 umbrella - function(d) -(1.65/3) * d + (1.65 / 36) * d^2
 emax - function(d) -1.81 * d / (0.79 + d)
 sigmoid  - function(d) -1.70 * d^5 / (4^5 + d^5)

 xyplot(flat(d) + linear(d) + logistic(d) + umbrella(d) + emax(d) +
 sigmoid(d) ~ d,
   data = list(d = seq(0, 8, length = 101)),
   ylab='Expected change from baseline in VAS at Week 6', xlab='Dose',
   type = l, outer = TRUE, )

Here's one solution.

xyplot(flat(d) + linear(d) + logistic(d) +
   umbrella(d) + emax(d) + sigmoid(d) ~ d,
   data = list(d = seq(0, 8, length = 101)),
   ylab='Expected change from baseline in VAS at Week 6', xlab='Dose',
   type = l, outer = TRUE,
   strip = strip.custom(factor.levels =
  c(FLAT, LINEAR, LOGISTIC, UMBRELLA, EMAX, SIGMOID)))

-Deepayan

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


Re: [R] problem with nested loop for regression

2008-08-04 Thread jim holtman
Exactly what problem are you having?  There is nothing wrong with
nested for loops, so what is leading you to believe you have a
problem?  I ran your program and it seems to terminate.  Most of the
time seems to have been spent in the following statement:

  if(!all(is.na(sel_col))) {Preg[,k]-coef(lm(tt~sel_col))}

Given that you appear to be executing this statement about 9000 times,
it is not surprising.  So can you provide more details?

  0  51.2 root
  1.   44.5 coef
  2. .   44.1 lm
  3. . .   15.7 eval
  4. . . .   15.6 eval
  5. . . . |   15.6 model.frame
  6. . . . | .   15.3 model.frame.default
  7. . . . | . .6.0 sapply
  8. . . . | . . .3.8 lapply
  9. . . . | . . . .3.0 FUN
 10. . . . | . . . . |1.1 %in%
 11. . . . | . . . . | .1.0 match
 12. . . . | . . . . | . .0.8 is.factor
 13. . . . | . . . . | . . .0.7 inherits
 10. . . . | . . . . |1.0 .deparseOpts
 11. . . . | . . . . | .0.3 pmatch
  9. . . . | . . . .0.5 as.list
  8. . . . | . . .1.7 unique
  9. . . . | . . . .0.7 unique.default
  9. . . . | . . . .0.6 unlist
 10. . . . | . . . . |0.4 lapply
  8. . . . | . . .0.3 unlist
  7. . . . | . .4.0 na.omit
  8. . . . | . . .3.8 na.omit.data.frame
  9. . . . | . . . .3.0 [
 10. . . . | . . . . |2.9 [.data.frame
 11. . . . | . . . . | .0.6 duplicated
 12. . . . | . . . . | . .0.3 duplicated.default
 11. . . . | . . . . | .0.3 [
 12. . . . | . . . . | . .0.2 [.ts
 11. . . . | . . . . | .0.3 [[

On Mon, Aug 4, 2008 at 12:58 PM, rcoder [EMAIL PROTECTED] wrote:

 Hi,

 I guess my question is really more about the nested for loop construct and
 whether it is doing what I intend it to do in my code in the previous post.
 I would be grateful if anyone who has used nested loops could let me know if
 I am doing something wrong.

 Thanks,

 rcoder



 rcoder wrote:

 Hi everyone,

 I'm experiencing difficulty getting the results I want when I use a nested
 for loop. I have a data set to which I perform some calculations, and then
 try to apply a regression over a rolling window. The code runs, but the
 regression results I am getting (intercept and slope) are simply the same,
 repeated again and again in the results matrix. The regression does not
 seem to be obeying the instructions of the nested loop, which intend it to
 calculate regression coefficients over a data one row at a time. I have
 been struggling with the code for many days now, testing various parts,
 and I cannot seem to get the nested loop to work as I want it to. I would
 be very grateful for any suggestions. Below is a brief version of my code:

 #Code start
 library(zoo)
 seed.set(1)
 Pmat-matrix(rnorm(1000), nrow=100, ncol=100)
 maxcol-ncol(Pmat)
 maxrow-nrow(Pmat)
 startrow-10
 period-10
 wind-2   #roll window
 subdiv-period/wind
 rollstart-11 #start roll at period+1
 #converting Pmat into ts for rollapply() to work...
 PmatTS-ts(Pmat)
 Preg-matrix(NA,ncol=maxcol,nrow=2*maxrow)
 PmatWt-matrix(NA, nrow=subdiv,ncol=maxcol)
 mult_col-matrix(1:5, nrow=5, ncol=1)
 #rolling calculations...
 for (i in (rollstart):maxrow)
   {
 #extract the relevant timeframe...
 dslice-PmatTS[(i-period):i,]
 dslicets-ts(dslice)
 #operating on sliced data...
 Pmin-rollapply(dslicets, wind, by=wind, min, na.rm=F)
 Pmax-rollapply(dslicets, wind, by=wind, max, na.rm=F)
 Pmult-Pmin*Pmax#calculating product
 tt-time(Pmult)
 for (j in 1:5)#1st nested loop
   {
 PmatWt[j,]-Pmult[j,]*mult_col[j,]
   }
 #rolling regression analysis...
 for (k in 1:maxcol)   #2nd nested loop
 {
   sel_col-PmatWt[,k]
   if(!all(is.na(sel_col))) {Preg[,k]-coef(lm(tt~sel_col))}
 }
   }
 #Code End

 Thanks,

 rcoder


 --
 View this message in context: 
 http://www.nabble.com/problem-with-nested-loop-for-regression-tp18792841p18815273.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


[R] Create data frame from header only

2008-08-04 Thread Etienne Bellemare Racine
Hi all,

Given a string list,
 paste(A,1:5,sep=)
[1] A1 A2 A3 A4 A5

I would like to create an empty data frame using that list as the 
header, so I can access my data frame column using,
 df [ list [ i ] ]

Anyone ?

Thanks,
Etienne



[[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] Sweave and ggplot2

2008-08-04 Thread Sorn . Norng
Dear Thierry,

Your guess was correct. I was not aware that I needed print( ). It was not 
needed with plot( ). I have yet to try xyplot( ) but I suspect that the 
print( ) might be needed here as well. Thank you very much for your help.

Cheers,

Sorn




ONKELINX, Thierry [EMAIL PROTECTED] 
04/08/2008 06:02 PM

To
[EMAIL PROTECTED], r-help@r-project.org
cc

Subject
RE: [R] Sweave and ggplot2






Dear Sorn, 

It's hard to guess what your problem is, as you don't provide any sample
code. My guess is that the graphics are empty. Did you use
print(qplot(...)) or just qplot(). The latter won't work. You need
print(qplot(...))

HTH,

Thierry



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

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

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: maandag 4 augustus 2008 6:55
Aan: r-help@r-project.org
Onderwerp: [R] Sweave and ggplot2

Hi all,

I've been trying to run Sweave with R code embedded - using the ggplot2 
package and in particular the qplot command. There appears to be a
problem 
in Sweave not picking up that qplot is a function. Has anybody else
tried 
to use qplot in Sweave and have you been successful? Any help would be 
very much appreciated.

Kind Regards,

Sorn


Notice:
This email and any attachments may contain information\ ...{{dropped:26}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Create data frame from header only

2008-08-04 Thread milton ruser
Hi Etienne

It is not so elegant, bu I think that work.


colname.list-paste(A,1:5,sep=)

df-data.frame(matrix(matrix(rep(1,length(colname.list)),1),1))
df
colnames(df)-colname.list
df

df-df[-1,]
df

Cheers,


Miltinho Astronauta
Brazil

On 8/4/08, Etienne Bellemare Racine [EMAIL PROTECTED] wrote:

 Hi all,

 Given a string list,
 paste(A,1:5,sep=)
[1] A1 A2 A3 A4 A5

 I would like to create an empty data frame using that list as the
 header, so I can access my data frame column using,
 df [ list [ i ] ]

 Anyone ?

 Thanks,
 Etienne



[[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] problem with nested loop for regression

2008-08-04 Thread jim holtman
Actually now that I read it closer, I see what your problem is.  what
did you think the statement:

Preg[,k]-coef(lm(tt~sel_col))

was going to do?  Preg is a 200x100 matrix and you are only storing
two values (the coefficients) so they will be repeated 100 times in
the column.  So there is nothing wrong with your nested for loops;
it is in the algorithm that you are using.  You might want to use the
browser and you would see something like this:

Browse[1] str(sel_col)
 num [1:5] -0.115 -2.666 -0.811  1.440 -0.879
Browse[1] str(tt)
 Time-Series [1:5] from 2 to 10: 2 4 6 8 10
Browse[1] n
debug: if (!all(is.na(sel_col))) {
Preg[, k] - coef(lm(tt ~ sel_col))
}
Browse[1] n
debug: Preg[, k] - coef(lm(tt ~ sel_col))
Browse[1] k
[1] 1
Browse[1] n
debug: k
Browse[1] n
debug: sel_col - PmatWt[, k]
Browse[1] k
[1] 2
Browse[1] str(sel_col)
 num [1:5] -0.115 -2.666 -0.811  1.440 -0.879
Browse[1] str(Preg)
 num [1:200, 1:100] 6.356 0.587 6.356 0.587 6.356 ...
Browse[1] str(PmatWt)
 num [1:5, 1:100] -0.115 -2.666 -0.811  1.440 -0.879 ...
Browse[1] coef(lm(tt~sel_col))
(Intercept) sel_col
   6.3557600.586699
Browse[1] str(Preg)
 num [1:200, 1:100] 6.356 0.587 6.356 0.587 6.356 ...
Browse[1]

This would help you to understand what is happening.

On Mon, Aug 4, 2008 at 8:35 PM, jim holtman [EMAIL PROTECTED] wrote:
 Exactly what problem are you having?  There is nothing wrong with
 nested for loops, so what is leading you to believe you have a
 problem?  I ran your program and it seems to terminate.  Most of the
 time seems to have been spent in the following statement:

  if(!all(is.na(sel_col))) {Preg[,k]-coef(lm(tt~sel_col))}

 Given that you appear to be executing this statement about 9000 times,
 it is not surprising.  So can you provide more details?

  0  51.2 root
  1.   44.5 coef
  2. .   44.1 lm
  3. . .   15.7 eval
  4. . . .   15.6 eval
  5. . . . |   15.6 model.frame
  6. . . . | .   15.3 model.frame.default
  7. . . . | . .6.0 sapply
  8. . . . | . . .3.8 lapply
  9. . . . | . . . .3.0 FUN
  10. . . . | . . . . |1.1 %in%
  11. . . . | . . . . | .1.0 match
  12. . . . | . . . . | . .0.8 is.factor
  13. . . . | . . . . | . . .0.7 inherits
  10. . . . | . . . . |1.0 .deparseOpts
  11. . . . | . . . . | .0.3 pmatch
  9. . . . | . . . .0.5 as.list
  8. . . . | . . .1.7 unique
  9. . . . | . . . .0.7 unique.default
  9. . . . | . . . .0.6 unlist
  10. . . . | . . . . |0.4 lapply
  8. . . . | . . .0.3 unlist
  7. . . . | . .4.0 na.omit
  8. . . . | . . .3.8 na.omit.data.frame
  9. . . . | . . . .3.0 [
  10. . . . | . . . . |2.9 [.data.frame
  11. . . . | . . . . | .0.6 duplicated
  12. . . . | . . . . | . .0.3 duplicated.default
  11. . . . | . . . . | .0.3 [
  12. . . . | . . . . | . .0.2 [.ts
  11. . . . | . . . . | .0.3 [[

 On Mon, Aug 4, 2008 at 12:58 PM, rcoder [EMAIL PROTECTED] wrote:

 Hi,

 I guess my question is really more about the nested for loop construct and
 whether it is doing what I intend it to do in my code in the previous post.
 I would be grateful if anyone who has used nested loops could let me know if
 I am doing something wrong.

 Thanks,

 rcoder



 rcoder wrote:

 Hi everyone,

 I'm experiencing difficulty getting the results I want when I use a nested
 for loop. I have a data set to which I perform some calculations, and then
 try to apply a regression over a rolling window. The code runs, but the
 regression results I am getting (intercept and slope) are simply the same,
 repeated again and again in the results matrix. The regression does not
 seem to be obeying the instructions of the nested loop, which intend it to
 calculate regression coefficients over a data one row at a time. I have
 been struggling with the code for many days now, testing various parts,
 and I cannot seem to get the nested loop to work as I want it to. I would
 be very grateful for any suggestions. Below is a brief version of my code:

 #Code start
 library(zoo)
 seed.set(1)
 Pmat-matrix(rnorm(1000), nrow=100, ncol=100)
 maxcol-ncol(Pmat)
 maxrow-nrow(Pmat)
 startrow-10
 period-10
 wind-2   #roll window
 subdiv-period/wind
 rollstart-11 #start roll at period+1
 #converting Pmat into ts for rollapply() to work...
 PmatTS-ts(Pmat)
 Preg-matrix(NA,ncol=maxcol,nrow=2*maxrow)
 PmatWt-matrix(NA, nrow=subdiv,ncol=maxcol)
 mult_col-matrix(1:5, nrow=5, ncol=1)
 #rolling calculations...
 for (i in (rollstart):maxrow)
   {
 #extract the relevant timeframe...
 dslice-PmatTS[(i-period):i,]
 dslicets-ts(dslice)
 #operating on sliced data...
 Pmin-rollapply(dslicets, wind, by=wind, min, na.rm=F)
 Pmax-rollapply(dslicets, wind, by=wind, max, na.rm=F)
 Pmult-Pmin*Pmax#calculating product
 tt-time(Pmult)
 for (j in 1:5)#1st nested loop
   {
 PmatWt[j,]-Pmult[j,]*mult_col[j,]
   }
 

Re: [R] Create data frame from header only

2008-08-04 Thread Marc Schwartz

on 08/04/2008 07:40 PM Etienne Bellemare Racine wrote:

Hi all,

Given a string list,
 paste(A,1:5,sep=)
[1] A1 A2 A3 A4 A5

I would like to create an empty data frame using that list as the 
header, so I can access my data frame column using,

 df [ list [ i ] ]

Anyone ?

Thanks,
Etienne


You don't indicate how you might want the column classes to be defined, but:

Cols - paste(A, 1:5, sep=)

 Cols
[1] A1 A2 A3 A4 A5


DF - read.table(textConnection(), col.names = Cols)

 DF
[1] A1 A2 A3 A4 A5
0 rows (or 0-length row.names)

 str(DF)
'data.frame':   0 obs. of  5 variables:
 $ A1: logi
 $ A2: logi
 $ A3: logi
 $ A4: logi
 $ A5: logi


Or, as an example of using 'colClasses':

DF - read.table(textConnection(), col.names = Cols,
 colClasses = character)

 str(DF)
'data.frame':   0 obs. of  5 variables:
 $ A1: chr
 $ A2: chr
 $ A3: chr
 $ A4: chr
 $ A5: chr



Note from the Value section of ?read.table:

Empty input is an error unless col.names is specified, when a 0-row data 
frame is returned: similarly giving just a header line if header = TRUE 
results in a 0-row data frame. Note that in either case tthe columns 
will logical unless colClasses was supplied.



In this case, I am supplying an empty value using textConnection() in 
place of the typical source file name.


HTH,

Marc Schwartz

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


Re: [R] Create data frame from header only

2008-08-04 Thread Etienne B. Racine

Even if it's not so elegant, I will bind it in a function, so I don't have to
bother with that anymore. I think there should be a simple function in R to
initialize an empty data frame. From what I've read, it is a recurrent
question on that list.

#Create an empty data frame from a header list
empty.df- function(header){
df-data.frame(matrix(matrix(rep(1,length(header)),1),1))
colnames(df)-header
return(df[NULL,])
}

# Usage
new.df - empty.df(paste(A,1:5,sep=))
 new.df
[1] A1 A2 A3 A4 A5
0 rows (or 0-length row.names)

Thanks again,
Etienne


milton ruser wrote:
 
 Hi Etienne
 
 It is not so elegant, bu I think that work.
 
 
 colname.list-paste(A,1:5,sep=)
 
 df-data.frame(matrix(matrix(rep(1,length(colname.list)),1),1))
 df
 colnames(df)-colname.list
 df
 
 df-df[-1,]
 df
 
 Cheers,
 
 
 Miltinho Astronauta
 Brazil
 

-- 
View this message in context: 
http://www.nabble.com/Create-data-frame-from-header-only-tp18822575p18823082.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] Create data frame from header only

2008-08-04 Thread Henrik Bengtsson
See dataFrame() in R.utils.  It was design for the purpose of
allocating empty data frames in an efficient way.

Example:

 library(R.utils);
 df - dataFrame(colClasses=c(a=integer, b=double), nrow=10);
 str(df)
'data.frame':   10 obs. of  2 variables:
 $ a: int  0 0 0 0 0 0 0 0 0 0
 $ b: num  0 0 0 0 0 0 0 0 0 0

/Henrik


On Mon, Aug 4, 2008 at 6:42 PM, Etienne B. Racine [EMAIL PROTECTED] wrote:

 Even if it's not so elegant, I will bind it in a function, so I don't have to
 bother with that anymore. I think there should be a simple function in R to
 initialize an empty data frame. From what I've read, it is a recurrent
 question on that list.

 #Create an empty data frame from a header list
 empty.df- function(header){
df-data.frame(matrix(matrix(rep(1,length(header)),1),1))
colnames(df)-header
return(df[NULL,])
 }

 # Usage
 new.df - empty.df(paste(A,1:5,sep=))
 new.df
 [1] A1 A2 A3 A4 A5
 0 rows (or 0-length row.names)

 Thanks again,
 Etienne


 milton ruser wrote:

 Hi Etienne

 It is not so elegant, bu I think that work.


 colname.list-paste(A,1:5,sep=)

 df-data.frame(matrix(matrix(rep(1,length(colname.list)),1),1))
 df
 colnames(df)-colname.list
 df

 df-df[-1,]
 df

 Cheers,


 Miltinho Astronauta
 Brazil


 --
 View this message in context: 
 http://www.nabble.com/Create-data-frame-from-header-only-tp18822575p18823082.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] normalize a data-set

2008-08-04 Thread Alessandro
Dear All,

 

I have a dataset (X,Y and Z) with no-normalize distribution (I saw with
qqnorm) but with Gaussian shape. I am a not good statistic and I wish to
know  a method to normalize Z values.

 

Thanks for help. It's very useful for my PhD

 

ALe


[[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] optimize simultaneously two binomials inequalities using nlm( ) or optim( )

2008-08-04 Thread emir.toktar
Dear R users,

I´m trying to optimize simultaneously two binomials inequalities (used in
acceptance sampling) which are nonlinear solution, so there is no simple
direct solution. Please, let me explain shortly the the problem and the
question as following.

The objective is to obtain the smallest value of 'n' (sample size)
satisfying both inequalities: 

(1-alpha) = pbinom(c, n, p1)  pbinom(c, n, p2) = beta

Where p1 (AQL) and p2 (LTPD) are probabilities parameters (Consumer and
Producer), the alpha and beta are conumer and producer risks, and finally,
the 'n' represents the sample size and the 'c' an acceptance number or
maximum number of defects (nonconforming) in sample size.

Considering that the 'n' and 'c' values are integer variables, it is
commonly not possible to derive an OC curve including the both (p1,1-alpha)
and (p2,beta) points. Some adjacency compromise is commonly required,
achieved by searching a more precise OC curve with respect to one of the
points. 

I´m using Mathematica 6 but it is a Trial, so I would like use R intead (or
better, I need it)!

To exemplify,  In Mathematica I call the function using NMinimize passing
the restriction and parameters:

/* function name findOpt and parameters... */

restriction = (1 - alpha) = CDF[BinomialDistribution[sample_n, p1], c] 
  betha = CDF[BinomialDistribution[sample_n, p2], c] 
   0  alpha  alphamax  0  betha  bethamax   
   1  sample_n = lot_Size  0 = c  lot_size
  p1  p2  p2max ;

fcost = sample_n/lot_Size; 

result = NMinimize[{fcost, restriction}, {sample_n, c, alpha, betha, p2max},
Method - NelderMead, AccuracyGoal - 10];

/* Calling the function findOpt */
findOpt[p1=0.005, lot_size=1000, alphamax=0.05, bethamax =0.05, p2max =
0.04]

/* and I got the return of values of; minimal n, c, alpha, betha and
the p2 or (LTPD) were computed */ {0.514573, {alpha$74 - 0.0218683,
sample_n$74 - 155.231, betha$74 - 0.05,
c$74 - 2, p2$74 - 0.04}}

Now, using R, I would define the pbinom(c, n, prob) given only the minimum
and maximum values to n and c and limits to p1 and p2 probabilities
(Consumer and Producer), similar on the example above.  

I found some examples to optimize equations in R and some tips, but I not be
able to define the sintaxe to use with that functions. Among the functions
that could be used to resolve the problem presented, I found the function
optim() that it is used for unconstrained optimization and the nlm() which
is used for solving nonlinear unconstrained minimization problems. 
May I wrong, but the nlm() function would be appropriate to solve this
problem, is it right?

Can I get a pointer to solve this problem using the nlm() function or where
could I get some tips/example to help me, please?

// (1-alpha) = pbinom(c, n, p1)  pbinom(c, n, p2) = beta
It was used betha parameter name to avoid the 'beta' function used in
Mathematica...


findS - function(p1='numeric', lot_size='numeric', alphamax='numeric',
bethamax ='numeric', p2max ='numeric')
{
(1 - alpha) = pbinom(c, sample_n, p1)   betha = pbinom(c,
sample_n, p2)
   0  alpha  alphamax  0  betha  bethamax   
   1  sample_n = lot_Size  0 = c  lot_size
  p1  p2  p2max ;
}

Parameters:
p1=0.005, 
lot_size=1000, 
alphamax=0.05, 
bethamax =0.05, 
p2max = 0.04


Minimize results should return/printing the following values:
sample_n,   (minimal sample size)
c , (critical level of defectives)
alpha , (producer's risk)
betha , (consumer's risk)
p2max   (consumer's probability p2)


Could one help me understand how can desing the optimize nonlinear function
using R for two binomials or point me some tips?


Thanks in advance.

EToktar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] I have an array of plots and I would like to put a title on the whole array.

2008-08-04 Thread Arthur Roberts

Hi, all,

Does anyone know of a way to get a title on an array of plots?  I have  
tried to use title, mtext, and text to get the title on the array, but  
to no avail.  I would like something like the following.



title(Big Array)
par(mfrow=c(2,4))
plot(x1,y1)
plot(x2,y2)
..
..
..

Much appreciated,
Art

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Create data frame from header only

2008-08-04 Thread Prof Brian Ripley

On Mon, 4 Aug 2008, Etienne B. Racine wrote:



Even if it's not so elegant, I will bind it in a function, so I don't have to
bother with that anymore. I think there should be a simple function in R to
initialize an empty data frame. From what I've read, it is a recurrent
question on that list.


Not from what I have seen.  But it is easy with data.frame

colname.list - paste(A,1:5,sep=) # note this is not a list.
cols - lapply(colname.list, function(x) numeric(0))
names(cols) - colname.list
do.call(data.frame, cols)



#Create an empty data frame from a header list
empty.df- function(header){
df-data.frame(matrix(matrix(rep(1,length(header)),1),1))
colnames(df)-header
return(df[NULL,])
}

# Usage
new.df - empty.df(paste(A,1:5,sep=))

new.df

[1] A1 A2 A3 A4 A5
0 rows (or 0-length row.names)

Thanks again,
Etienne


milton ruser wrote:


Hi Etienne

It is not so elegant, bu I think that work.


colname.list-paste(A,1:5,sep=)

df-data.frame(matrix(matrix(rep(1,length(colname.list)),1),1))
df
colnames(df)-colname.list
df

df-df[-1,]
df

Cheers,


Miltinho Astronauta
Brazil



--
View this message in context: 
http://www.nabble.com/Create-data-frame-from-header-only-tp18822575p18823082.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.



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

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


Re: [R] I have an array of plots and I would like to put a title on the whole array.

2008-08-04 Thread Prof Brian Ripley

par(mfrow=c(2,4), oma=c(0,0,1,0))
plots ...
title(Big Array, outer=TRUE)

You need to set up an outer margin.  See 'An Introduction to R' for that 
topic.


You probably want to reset the margins (mar=) for such a large array of 
plots.


On Mon, 4 Aug 2008, Arthur Roberts wrote:


Hi, all,

Does anyone know of a way to get a title on an array of plots?  I have tried 
to use title, mtext, and text to get the title on the array, but to no avail. 
I would like something like the following.



title(Big Array)
par(mfrow=c(2,4))
plot(x1,y1)
plot(x2,y2)
..
..
..

Much appreciated,
Art

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


[R] 95% CI bands on a Lowess smoother

2008-08-04 Thread Gareth Campbell
Hi there,

I'm plotting some glass RI values just by plotting

plot(x)

then I put on my lowess smoother

lines(lowess(x))

now I want to put on some 95% Confidence Interval bands of the lowess
smoother, but don't know how??


Thanks

-- 
Gareth Campbell
PhD Candidate
The University of Auckland

P +649 815 3670
M +6421 256 3511
E [EMAIL PROTECTED]
[EMAIL PROTECTED]

[[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] Constrained Optimization

2008-08-04 Thread Hans W. Borchers
 alan.ng at gmx.net writes:

 
 Hello,
 
 I am trying to run a constrained optimization in R. constrOptim is really 
 useful and has helped me a lot, but unfortunately, it doesn't provide the 
 hessian.  Is there a solution to this problem?

You didn't provide an example to understand why 'optim' doesn't solve your
problem. Perhaps you can find an optimal point with 'constrOptim' and then
compute the hessian at that point with some other R function, for instance
'numDeriv::hessian'.

//  Hans Werner Borchers
 
 I've tried optim with penalty-functions and L-BFGS-B, but it doesn't help.
 
 Alan.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 95% CI bands on a Lowess smoother

2008-08-04 Thread Prof Brian Ripley

On Tue, 5 Aug 2008, Gareth Campbell wrote:


Hi there,

I'm plotting some glass RI values just by plotting

plot(x)

then I put on my lowess smoother

lines(lowess(x))

now I want to put on some 95% Confidence Interval bands of the lowess
smoother, but don't know how??


You can have pointwise confidence intervals or a simultaneous confidence 
band, so which did you mean?


I don't know of any theory for the latter, whereas for the former lowess 
is a locally linear fit and hence there will be asymptotic results not 
very relevant for local fits.


Looks like a case for simulation-based inference, e.g. via a bootstrap.




Thanks

--
Gareth Campbell
PhD Candidate
The University of Auckland

P +649 815 3670
M +6421 256 3511
E [EMAIL PROTECTED]
[EMAIL PROTECTED]

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

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


[R] Including exogenous X-variables in ARFIMA models

2008-08-04 Thread Scotty Nelson

Does anybody know if there is a way to include exogenous X-variables in an 
ARFIMA model?
It appears the ARFIMA function in fracdiff does not support this.

Supposing there is nothing already written, and I wanted to modify the existing 
arfima function, how would I go about this?
Would I need to modify the fracdiff() binaries and compile them on my machine?  
I'm running WindowsI think I'm screwed = (

-- Scotty

_
Get more from your digital life.  Find out how.

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