Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Yihui Xie
All your questions are answered by the knitr book in my first reply,
which introduces knitr in a systematic manner. For the web pages, I
have tried my best, and nobody can make everybody happy. I do not
understand why you do not understand Rnw and markdown, and I do not
quite believe a person who understands R cannot understand markdown. I
understand you do not have control over your lab machines, but you
still have other options like your own laptop (if you do not like
RStudio, feel free to remove it and use your favorite editors after
you have got the idea).

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Thu, Jul 18, 2013 at 5:50 PM, C W  wrote:
> Hi,
> @Yihui
> When I am using a public computer, say university computer lab or
> financial company.  I do not have control what to install.
>
> I'm also very happy with R editor on OS X, it integrates with Mac
> well.  As for my Mac Air, I am keeping installation to the minimal.
>
> There are a lot links on your page, I don't understand what I am
> reading.  What is Rnw, what is markdown?  As a newbie, it's above my
> level.  I googled Rnw, it's refers to Sweave package, now I am
> tracking back to Sweave.
>
> As a user, I want to spend more time using the package, not installing.
>
> @Simon: thanks, I will definitely rename the extension.  I really hope
> there will be a more thorough description somewhere soon.
>
> Mike

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

2013-07-18 Thread Roslina Zakaria
Dear r-users,
 
I would like to construct tem and leaf plot using iris data.  It should be 
easy, but I don't understand why the plot is not right.
 
Thank you so much for your help.
 
dat <- iris[,1] > stem(dat)  The decimal point is 1 digit(s) to the left of the 
| 42 | 0 44 |  46 | 00 48 | 000 50 | 000 52 | 
0 54 | 0 56 | 00 58 | 00 60 |  
62 | 0 64 |  66 | 00 68 | 000 70 | 00 72 | 
 74 | 0 76 | 0 78 | 0
[[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] Paternity data analysis

2013-07-18 Thread Moshiur Rahman
Dear R-experts!

I did an experiment with Guppy where I had two dietary groups ("High" and
"Low"). I completed all my data analysis, but stacked in "paternity
analysis". I ran the attached model to analyse them, but as a novice in R,
it's very hard for me to confirm whether this gives me the correct output
or not. I would like to examine the effect of the predictor traits (VAP,
Viability, Body FAs) on paternity success (Proportion). Here, I fitted
generalized linear models (GLMs) using a logit-link function as my data has
some zeroes and ones. I also lie to use quasi-GLMs to correct for
overdispersion. Now, I need some help from you guys to estimate the
paternity success of my high group or both groups? **

 With kind regards,


Moshi

-- 
MD. MOSHIUR RAHMAN
PhD Candidate
School of Animal Biology/Zoology (M092)
University of Western Australia
35 Stirling Hwy, Crawley, WA, 6009
Australia.
Mob.: 061-425205507
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Yixuan Qiu
Hi Mike,
As long as you have access to some user folder, you can download a
non-install version of RStudio.
Go to the page http://www.rstudio.com/ide/download/desktop and select "Show
zip/tarball downloads", download, extract, and run.
Do believe Yihui that running an example using RStudio saves you a lot of
time.


Best,
Yixuan



2013/7/18 C W 

> Hi,
> @Yihui
> When I am using a public computer, say university computer lab or
> financial company.  I do not have control what to install.
>
> I'm also very happy with R editor on OS X, it integrates with Mac
> well.  As for my Mac Air, I am keeping installation to the minimal.
>
> There are a lot links on your page, I don't understand what I am
> reading.  What is Rnw, what is markdown?  As a newbie, it's above my
> level.  I googled Rnw, it's refers to Sweave package, now I am
> tracking back to Sweave.
>
> As a user, I want to spend more time using the package, not installing.
>
> @Simon: thanks, I will definitely rename the extension.  I really hope
> there will be a more thorough description somewhere soon.
>
> Mike
>
> On Thu, Jul 18, 2013 at 4:50 PM, Simon Zehnder 
> wrote:
> > Hi Mike,
> >
> > if you browse the folders, you find always the Rscript binary (the
> executable) under
> /Library/Frameworks/R.framework/Versions/.../Resources/Rscript.
> >
> > Do not forget to give your tex file the extension .Rnw! Then surround
> each Rcode with < one; results = 'asis')>>= Here your r code as you do it in the R shell 
> at the end a @. Always inside the \begin{document} \end{document} tags.
> >
> >
> >
> > Best
> >
> > Simon
> >
> > On Jul 18, 2013, at 10:22 PM, C W  wrote:
> >
> >> Thanks, Simon.  I would never figured it out!
> >>
> >> I apologize if I sound frustrated, because I am.
> >>
> >> @package author: you have a great package, but I think a lot of the
> >> directions are hand waving.  For the newbies, this leads to more
> >> confusion.
> >>
> >> @Berend: I am using OS X.
> >>
> >> Mike
> >>
> >>
> >> On Thu, Jul 18, 2013 at 4:19 PM, Berend Hasselman 
> wrote:
> >>>
> >>> On 18-07-2013, at 22:09, C W  wrote:
> >>>
> 
> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165
> 
>  In step 3: "add the executable file (step 3)".
> 
>  What is the executable file?  Locate package knitr directory path in
> R?
> 
> >>>
> >>> From the window:  Executable ==> Program. So the executable is
> Rscript.exe.
> >>>
> >>>
> >>> Berend
> >>>
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Yixuan Qiu 
Department of Statistics,
Purdue University

[[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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Hi,
@Yihui
When I am using a public computer, say university computer lab or
financial company.  I do not have control what to install.

I'm also very happy with R editor on OS X, it integrates with Mac
well.  As for my Mac Air, I am keeping installation to the minimal.

There are a lot links on your page, I don't understand what I am
reading.  What is Rnw, what is markdown?  As a newbie, it's above my
level.  I googled Rnw, it's refers to Sweave package, now I am
tracking back to Sweave.

As a user, I want to spend more time using the package, not installing.

@Simon: thanks, I will definitely rename the extension.  I really hope
there will be a more thorough description somewhere soon.

Mike

On Thu, Jul 18, 2013 at 4:50 PM, Simon Zehnder  wrote:
> Hi Mike,
>
> if you browse the folders, you find always the Rscript binary (the 
> executable) under 
> /Library/Frameworks/R.framework/Versions/.../Resources/Rscript.
>
> Do not forget to give your tex file the extension .Rnw! Then surround each 
> Rcode with < results = 'asis')>>= Here your r code as you do it in the R shell  at the 
> end a @. Always inside the \begin{document} \end{document} tags.
>
>
>
> Best
>
> Simon
>
> On Jul 18, 2013, at 10:22 PM, C W  wrote:
>
>> Thanks, Simon.  I would never figured it out!
>>
>> I apologize if I sound frustrated, because I am.
>>
>> @package author: you have a great package, but I think a lot of the
>> directions are hand waving.  For the newbies, this leads to more
>> confusion.
>>
>> @Berend: I am using OS X.
>>
>> Mike
>>
>>
>> On Thu, Jul 18, 2013 at 4:19 PM, Berend Hasselman  wrote:
>>>
>>> On 18-07-2013, at 22:09, C W  wrote:
>>>
 http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165

 In step 3: "add the executable file (step 3)".

 What is the executable file?  Locate package knitr directory path in R?

>>>
>>> From the window:  Executable ==> Program. So the executable is Rscript.exe.
>>>
>>>
>>> Berend
>>>
>

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


Re: [R] Test if 2 samples differ if they have autocorrelation

2013-07-18 Thread Rolf Turner



I imagine that most readers of this list will put your question in the 
too hard basket.

That being so, here is my inexpert take on the question.

The issue is to estimate the uncertainty in the estimated difference of 
the means.
This uncertainty depends on the nature of the serial dependence of the 
series.

Therefore in order to get anywhere you need to *model* this dependence.

Different models could yield very different values for the variance of 
the estimated

difference of the means.

If the series are observed at the same times I would suggest taking the 
pointwise

difference of the two series: D_t = X_t - Y_t, say.

Fit the best arima model that you can to D_t. Then the standard error of 
what
is incorrectly labelled "intercept" (it is actually the estimate of the 
series *mean*)
is the appropriate estimate of the uncertainty. The ratio of the 
"intercept" value

to its standard error is the test statistic you are looking for.

If the series are *not* observed at the same times but can be assumed to be
independent then model *each* series as well as you can (different 
models for
each series) and obtain the standard error of the "intercept" for each 
series.
Your test statistic is then the difference of the "intercept estimates 
divided by

sqrt(se_X^2 + se_Y^2) in what I hope is an "obvious" notation.

If the series are not observed at the same times and cannot be assumed to be
independent then you probably haven't got sufficient information to answer
the question that you wish to answer.

I hope that there is some value in the forgoing.

cheers,

Rolf Turner

On 18/07/13 21:50, Eric Jaeger wrote:

Dear all

I have one question that I struggle to find an answer:

Let`s assume I have 2 timeseries of daily PnL data over 2 years coming from 2 
different trading strategies. I want to find out if strategy A is better than 
strategy B. The problem is that the two series have serial correlations, hence 
I cannot just do a simple t-test.

I tried something like this:

1.create cumulative timeseries of PnL_A = C_A and of PnL_B = C_B

2.take the difference of both: C_A – C_B = DiffPnL (to see how the difference 
evolves over time)

3.do a regression: DiffPnL = beta * time + error (I thought if beta is 
significantly different from 0 than the two time series are different)

4.estimate beta not with OLS, but with the Newey-West method (HAC estimator) -> 
this corrects statistical tests, standard errors for beta heteroskedasticity and 
autocorrelation

BUT: I read something that the tests are biased when the timeseries are unit 
root non-stationary (which is due to the fact that I take cumulative time 
series)

  


I am lost! This should be fairly simple: test if two samples differ if they 
have autocorrelation? Probably my approach above is completely wrong…


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


Re: [R] How code for an exponential function

2013-07-18 Thread Rui Barradas

Hello,

First of all, you need to read the posting guide.
Where is a data example? And code?

As for the question, at an R prompt, type ?log.

Hope this helps,

Rui Barradas

Em 18-07-2013 20:18, Munroe, Ryan escreveu:

Hi,

I ran a linear regression on a data set and got an Rsq of about .27. The plot 
looks as though an exponential curve would be a better fit. What codes do I use 
to do this?
Thank you,
Ryan Munroe


[[alternative HTML version deleted]]

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



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


[R] How code for an exponential function

2013-07-18 Thread Munroe, Ryan
Hi,

I ran a linear regression on a data set and got an Rsq of about .27. The plot 
looks as though an exponential curve would be a better fit. What codes do I use 
to do this?
Thank you,
Ryan Munroe


[[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] combine select data from 2 dataframes sharing same variables

2013-07-18 Thread bcrombie
Wow.  That is exactly what I wanted (thread viewers see output below).  I 
think/hope this script will be more user friendly for my needs (RTF final 
output) than the loop I currently have for LaTex output.  Thanks very much A.K. 
 I’ll need to send you a Bundt cake at some point I suppose…  BNC

> lst1
$MWtotaleesDue
  zeroNOzeroYES
Mean8.428571  0.9076923
StdError2.496256  0.4117990
Median  7.00  0.000
StdDev  6.604472  3.3200295
Min 1.00  0.000
Max17.00 17.000
NinetyPct   3.593998  0.5332467
NinetyPctLower  4.834573  0.3744456
NinetyPctUpper 12.022570  1.4409390

$OTtotaleesDue
  zeroNOzeroYES
Mean6.60  1.0153846
StdError2.242023  0.4442433
Median  3.00  0.000
StdDev  7.089899  3.5816036
Min 1.00  0.000
Max23.00 23.000
NinetyPct   3.100782  0.5752594
NinetyPctLower  3.499218  0.4401252
NinetyPctUpper  9.700782  1.5906440

$OTtotalBWsDue
  zeroNOzeroYES
Mean559.9440   86.14523
StdError305.7341   51.57520
Median  257.55000.0
StdDev  966.8160  415.81256
Min  15.19000.0
Max3232.9700 3232.97000
NinetyPct   422.8390   66.78575
NinetyPctLower  137.1050   19.35948
NinetyPctUpper  982.7830  152.93098

$TotalBWsFD
  zeroNOzeroYES
Mean693.2973  159.99169
StdError265.0846   69.86036
Median  267.58000.0
StdDev 1026.6682  563.23225
Min  15.19000.0
Max3232.9700 3232.97000
NinetyPct   356.5468   90.46357
NinetyPctLower  336.7505   69.52812
NinetyPctUpper 1049.8442  250.45526


From: arun kirshna [via R] [mailto:ml-node+s789695n4671818...@n4.nabble.com]
Sent: Thursday, July 18, 2013 12:24 AM
To: Crombie, Burnette N
Subject: Re: combine select data from 2 dataframes sharing same variables

Hi,
Not sure if this is what you wanted:
#If columns are arranged in the same order in both data.frames.

lst1<-lapply(seq_len(ncol(StatsUTAH)),function(i) 
{x1<-cbind(StatsUTAH[,i],sStatsUTAH[,i]);row.names(x1)<-row.names(StatsUTAH);colnames(x1)<-c("zeroNO","zeroYES");x1})
 names(lst1)<- colnames(StatsUTAH)

A.K.





--
View this message in context: 
http://r.789695.n4.nabble.com/combine-select-data-from-2-dataframes-sharing-same-variables-tp4671790p4671887.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Simon Zehnder
Hi Mike,

if you browse the folders, you find always the Rscript binary (the executable) 
under /Library/Frameworks/R.framework/Versions/.../Resources/Rscript. 

Do not forget to give your tex file the extension .Rnw! Then surround each 
Rcode with <>= Here your r code as you do it in the R shell  at the 
end a @. Always inside the \begin{document} \end{document} tags.



Best

Simon

On Jul 18, 2013, at 10:22 PM, C W  wrote:

> Thanks, Simon.  I would never figured it out!
> 
> I apologize if I sound frustrated, because I am.
> 
> @package author: you have a great package, but I think a lot of the
> directions are hand waving.  For the newbies, this leads to more
> confusion.
> 
> @Berend: I am using OS X.
> 
> Mike
> 
> 
> On Thu, Jul 18, 2013 at 4:19 PM, Berend Hasselman  wrote:
>> 
>> On 18-07-2013, at 22:09, C W  wrote:
>> 
>>> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165
>>> 
>>> In step 3: "add the executable file (step 3)".
>>> 
>>> What is the executable file?  Locate package knitr directory path in R?
>>> 
>> 
>> From the window:  Executable ==> Program. So the executable is Rscript.exe.
>> 
>> 
>> Berend
>> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Yihui Xie
I recommend RStudio not because I want to promote it in any sense, but
because of the fact that it has the best support for Rnw/knitr at the
moment, and it will save you a lot of headache to get started. It
seems you just do not believe me, and insist on going through all the
low-level configurations as a newbie. That will lead to confusion by
definition. I do not know why you do not have _access_ to it; it is
free and open source, so everybody has access to it unless one does
not have the Internet connection.

I'm not the developer of TeXworks, so I have no control over what
TeXworks can support.

knitr and its website are open source; please feel free to improve
them if you find anything unclear:
http://yihui.name/en/2013/06/fix-typo-in-documentation/

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Thu, Jul 18, 2013 at 1:22 PM, C W  wrote:
> Thanks, Simon.  I would never figured it out!
>
> I apologize if I sound frustrated, because I am.
>
> @package author: you have a great package, but I think a lot of the
> directions are hand waving.  For the newbies, this leads to more
> confusion.
>
> @Berend: I am using OS X.
>
> Mike

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 'save' method for S4 class

2013-07-18 Thread Uwe Ligges



On 18.07.2013 20:23, Christofer Bogaso wrote:

Hi Simon,

Thanks for your pointer.

However could you please explain what 'function(x, file_Path)
standardGeneric("save")' means here?


It is the definition of the generic function for save()?

The underlying help files look quite

rocket science for me!


So start reading about S4 seems to be essential, if you ask for S4 
methods. Otherwise we cannot help, given you do not even understand the 
code to define the generic function.


Uwe Ligges




Thanks for your time.

Thanks and regards,


On Thu, Jul 18, 2013 at 4:32 PM, Simon Zehnder  wrote:


Hi Christopher,

I think, that "save" is no generic function like "plot", "show", etc. So
at first you have to determine a generic.

setGeneric("save", function(x, file_Path) standardGeneric("save"))

Now your definition via setMethod.


Best

Simon



On Jul 18, 2013, at 12:09 PM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:


Hello again,

I am trying to define the 'save' method for my S4 class as below:

setClass("MyClass", representation(
   Slot1 = "data.frame"
   ))

setMethod("save", "MyClass", definition = function(x, file_Path) {

   write.table(x@Slot1, file = file_Path, append = FALSE,

quote = TRUE,

sep = ",",
   eol = "\n", na = "NA", dec

= ".", row.names = FALSE,

   col.names = TRUE, qmethod

= c("escape", "double"),

   fileEncoding = "")
   })

However while doing this I am getting following error:

Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
  in method for ‘save’ with signature ‘list="MyClass"’: formal
arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
version = "MyClass", envir = "MyClass", compress = "MyClass",
compression_level = "MyClass", eval.promises = "MyClass", precheck =
"MyClass") omitted in the method definition cannot be in the signature


Can somebody point me what will be the correct approach to define
'save' method for S4 class?

Thanks and regards,

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

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

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





[[alternative HTML version deleted]]



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



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


Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Berend Hasselman

On 18-07-2013, at 22:22, C W  wrote:

> Thanks, Simon.  I would never figured it out!
> 
> I apologize if I sound frustrated, because I am.
> 
> @package author: you have a great package, but I think a lot of the
> directions are hand waving.  For the newbies, this leads to more
> confusion.
> 
> @Berend: I am using OS X.
> 

Then leave out the .exe.
And you could always try something!

Berend

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Thanks, Simon.  I would never figured it out!

I apologize if I sound frustrated, because I am.

@package author: you have a great package, but I think a lot of the
directions are hand waving.  For the newbies, this leads to more
confusion.

@Berend: I am using OS X.

Mike


On Thu, Jul 18, 2013 at 4:19 PM, Berend Hasselman  wrote:
>
> On 18-07-2013, at 22:09, C W  wrote:
>
>> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165
>>
>> In step 3: "add the executable file (step 3)".
>>
>> What is the executable file?  Locate package knitr directory path in R?
>>
>
> From the window:  Executable ==> Program. So the executable is Rscript.exe.
>
>
> Berend
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Berend Hasselman

On 18-07-2013, at 22:09, C W  wrote:

> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165
> 
> In step 3: "add the executable file (step 3)".
> 
> What is the executable file?  Locate package knitr directory path in R?
> 

>From the window:  Executable ==> Program. So the executable is Rscript.exe.


Berend

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Simon Zehnder
The executable is in case of knitr always Rscript. 
On a mac it is simply Rscript on windows it is Rscript.exe. This should be on 
your PATH. If you are not sure, open the Mac Terminal and type Rscript 
--version. If it does not say "Command not found" all is fine. 

Best

Simon
On Jul 18, 2013, at 10:09 PM, C W  wrote:

> http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165
> 
> In step 3: "add the executable file (step 3)".
> 
> What is the executable file?  Locate package knitr directory path in R?
> 
> Mike
> 
> On Thu, Jul 18, 2013 at 3:56 PM, C W  wrote:
>> Actually, I see it at the bottom.  Sorry!
>> 
>> On Thu, Jul 18, 2013 at 3:44 PM, C W  wrote:
>>> Hi Simon,
>>> I am on OS X Lion, I have TeXworks, I don't have knitr as an option.
>>> 
>>> How do I install that into TeXworks?  Seems like I have to something
>>> in terminal?
>>> 
>>> Mike
>>> 
>>> On Thu, Jul 18, 2013 at 3:31 PM, Simon Zehnder  wrote:
 Hi Mike,
 
 I found my way with this little blog: http://yihui.name/knitr/demo/editors/
 
 The .Rnw files are created very well in a Latex editor. Everything else 
 can be easily googled. The command via knitr::knit2pdf works very fine if 
 you use the chunks. If you are trying to compile an Rtex file, this I do 
 not know either (I like the symbols though in for example 
 https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex). But 
 the .Rnw files are compiled pretty nice in e.g. texmaker, as described in 
 the blog. Use for example this source file: 
 https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw
 
 
 Hope this helps
 
 
 Best
 
 Simon
 
 
 
 
 
 On Jul 18, 2013, at 8:52 PM, C W  wrote:
 
> How do you create a .Rnw file, in R or LaTex?  I don't think any
> tutorial mentions it.
> 
> btw, I am very new to the terms like markdown, so I don't understand
> "markdown to HTML".
> 
> I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
> that you need to compile at terminal.  I do not know terminal, is
> there other ways?
> 
> Could you do a video on just "simple" R?  I have seen 3 videos on R
> Studio including yours.
> 
> Mike
> 
> On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
>> I'm not sure what your question really is. You do not have to use
>> RStudio, but it will be much easier to get started with RStudio,
>> because it does a lot of automatic conversion behind the scenes (e.g.
>> tex to PDF, markdown to HTML, ...). If you want a "pure" solution
>> without any text editor support, the answer is
>> 
>> library(knitr)
>> knit('your_input_file')
>> 
>> For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
>> with LaTeX, you can mess with this foo.tex now (outside of R).
>> 
>> Minimal examples for different document formats are at
>> http://yihui.name/knitr/demo/minimal/ (you must have read this page),
>> and more examples at https://github.com/yihui/knitr-examples
>> 
>> If you are asking about the internals of knitr, "Luke, use the
>> source": https://github.com/yihui/knitr Or for a more comprehensive
>> introduction, see http://www.crcpress.com/product/isbn/9781482203530
>> 
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: 206-667-4385 Web: http://yihui.name
>> Fred Hutchinson Cancer Research Center, Seattle
>> 
>> 
>> On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
>>> Hi everyone,
>>> 
>>> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>>> 
>>> Read through Yihui's page, didn't find it helpful.  Stuck on terms
>>> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
>>> reference is not helping.
>>> 
>>> Is there a simple step-by-step example WITHOUT RStudio?
>>> 
>>> My question:
>>> What is the procedure?  The documentation explains the functions, but
>>> does not say how to operate between R and LaTex.
>>> 
>>> Mike
>>> 
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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:/

Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
http://tex.stackexchange.com/questions/85154/knitr-with-texworks/85165#85165

In step 3: "add the executable file (step 3)".

What is the executable file?  Locate package knitr directory path in R?

Mike

On Thu, Jul 18, 2013 at 3:56 PM, C W  wrote:
> Actually, I see it at the bottom.  Sorry!
>
> On Thu, Jul 18, 2013 at 3:44 PM, C W  wrote:
>> Hi Simon,
>> I am on OS X Lion, I have TeXworks, I don't have knitr as an option.
>>
>> How do I install that into TeXworks?  Seems like I have to something
>> in terminal?
>>
>> Mike
>>
>> On Thu, Jul 18, 2013 at 3:31 PM, Simon Zehnder  wrote:
>>> Hi Mike,
>>>
>>> I found my way with this little blog: http://yihui.name/knitr/demo/editors/
>>>
>>> The .Rnw files are created very well in a Latex editor. Everything else can 
>>> be easily googled. The command via knitr::knit2pdf works very fine if you 
>>> use the chunks. If you are trying to compile an Rtex file, this I do not 
>>> know either (I like the symbols though in for example 
>>> https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex). But 
>>> the .Rnw files are compiled pretty nice in e.g. texmaker, as described in 
>>> the blog. Use for example this source file: 
>>> https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw
>>>
>>>
>>> Hope this helps
>>>
>>>
>>> Best
>>>
>>> Simon
>>>
>>>
>>>
>>>
>>>
>>> On Jul 18, 2013, at 8:52 PM, C W  wrote:
>>>
 How do you create a .Rnw file, in R or LaTex?  I don't think any
 tutorial mentions it.

 btw, I am very new to the terms like markdown, so I don't understand
 "markdown to HTML".

 I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
 that you need to compile at terminal.  I do not know terminal, is
 there other ways?

 Could you do a video on just "simple" R?  I have seen 3 videos on R
 Studio including yours.

 Mike

 On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
> I'm not sure what your question really is. You do not have to use
> RStudio, but it will be much easier to get started with RStudio,
> because it does a lot of automatic conversion behind the scenes (e.g.
> tex to PDF, markdown to HTML, ...). If you want a "pure" solution
> without any text editor support, the answer is
>
> library(knitr)
> knit('your_input_file')
>
> For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
> with LaTeX, you can mess with this foo.tex now (outside of R).
>
> Minimal examples for different document formats are at
> http://yihui.name/knitr/demo/minimal/ (you must have read this page),
> and more examples at https://github.com/yihui/knitr-examples
>
> If you are asking about the internals of knitr, "Luke, use the
> source": https://github.com/yihui/knitr Or for a more comprehensive
> introduction, see http://www.crcpress.com/product/isbn/9781482203530
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 206-667-4385 Web: http://yihui.name
> Fred Hutchinson Cancer Research Center, Seattle
>
>
> On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
>> Hi everyone,
>>
>> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>>
>> Read through Yihui's page, didn't find it helpful.  Stuck on terms
>> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
>> reference is not helping.
>>
>> Is there a simple step-by-step example WITHOUT RStudio?
>>
>> My question:
>> What is the procedure?  The documentation explains the functions, but
>> does not say how to operate between R and LaTex.
>>
>> Mike
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Actually, I see it at the bottom.  Sorry!

On Thu, Jul 18, 2013 at 3:44 PM, C W  wrote:
> Hi Simon,
> I am on OS X Lion, I have TeXworks, I don't have knitr as an option.
>
> How do I install that into TeXworks?  Seems like I have to something
> in terminal?
>
> Mike
>
> On Thu, Jul 18, 2013 at 3:31 PM, Simon Zehnder  wrote:
>> Hi Mike,
>>
>> I found my way with this little blog: http://yihui.name/knitr/demo/editors/
>>
>> The .Rnw files are created very well in a Latex editor. Everything else can 
>> be easily googled. The command via knitr::knit2pdf works very fine if you 
>> use the chunks. If you are trying to compile an Rtex file, this I do not 
>> know either (I like the symbols though in for example 
>> https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex). But the 
>> .Rnw files are compiled pretty nice in e.g. texmaker, as described in the 
>> blog. Use for example this source file: 
>> https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw
>>
>>
>> Hope this helps
>>
>>
>> Best
>>
>> Simon
>>
>>
>>
>>
>>
>> On Jul 18, 2013, at 8:52 PM, C W  wrote:
>>
>>> How do you create a .Rnw file, in R or LaTex?  I don't think any
>>> tutorial mentions it.
>>>
>>> btw, I am very new to the terms like markdown, so I don't understand
>>> "markdown to HTML".
>>>
>>> I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
>>> that you need to compile at terminal.  I do not know terminal, is
>>> there other ways?
>>>
>>> Could you do a video on just "simple" R?  I have seen 3 videos on R
>>> Studio including yours.
>>>
>>> Mike
>>>
>>> On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
 I'm not sure what your question really is. You do not have to use
 RStudio, but it will be much easier to get started with RStudio,
 because it does a lot of automatic conversion behind the scenes (e.g.
 tex to PDF, markdown to HTML, ...). If you want a "pure" solution
 without any text editor support, the answer is

 library(knitr)
 knit('your_input_file')

 For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
 with LaTeX, you can mess with this foo.tex now (outside of R).

 Minimal examples for different document formats are at
 http://yihui.name/knitr/demo/minimal/ (you must have read this page),
 and more examples at https://github.com/yihui/knitr-examples

 If you are asking about the internals of knitr, "Luke, use the
 source": https://github.com/yihui/knitr Or for a more comprehensive
 introduction, see http://www.crcpress.com/product/isbn/9781482203530

 Regards,
 Yihui
 --
 Yihui Xie 
 Phone: 206-667-4385 Web: http://yihui.name
 Fred Hutchinson Cancer Research Center, Seattle


 On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
> Hi everyone,
>
> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>
> Read through Yihui's page, didn't find it helpful.  Stuck on terms
> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
> reference is not helping.
>
> Is there a simple step-by-step example WITHOUT RStudio?
>
> My question:
> What is the procedure?  The documentation explains the functions, but
> does not say how to operate between R and LaTex.
>
> Mike
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Hi Simon,
I am on OS X Lion, I have TeXworks, I don't have knitr as an option.

How do I install that into TeXworks?  Seems like I have to something
in terminal?

Mike

On Thu, Jul 18, 2013 at 3:31 PM, Simon Zehnder  wrote:
> Hi Mike,
>
> I found my way with this little blog: http://yihui.name/knitr/demo/editors/
>
> The .Rnw files are created very well in a Latex editor. Everything else can 
> be easily googled. The command via knitr::knit2pdf works very fine if you use 
> the chunks. If you are trying to compile an Rtex file, this I do not know 
> either (I like the symbols though in for example 
> https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex). But the 
> .Rnw files are compiled pretty nice in e.g. texmaker, as described in the 
> blog. Use for example this source file: 
> https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw
>
>
> Hope this helps
>
>
> Best
>
> Simon
>
>
>
>
>
> On Jul 18, 2013, at 8:52 PM, C W  wrote:
>
>> How do you create a .Rnw file, in R or LaTex?  I don't think any
>> tutorial mentions it.
>>
>> btw, I am very new to the terms like markdown, so I don't understand
>> "markdown to HTML".
>>
>> I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
>> that you need to compile at terminal.  I do not know terminal, is
>> there other ways?
>>
>> Could you do a video on just "simple" R?  I have seen 3 videos on R
>> Studio including yours.
>>
>> Mike
>>
>> On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
>>> I'm not sure what your question really is. You do not have to use
>>> RStudio, but it will be much easier to get started with RStudio,
>>> because it does a lot of automatic conversion behind the scenes (e.g.
>>> tex to PDF, markdown to HTML, ...). If you want a "pure" solution
>>> without any text editor support, the answer is
>>>
>>> library(knitr)
>>> knit('your_input_file')
>>>
>>> For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
>>> with LaTeX, you can mess with this foo.tex now (outside of R).
>>>
>>> Minimal examples for different document formats are at
>>> http://yihui.name/knitr/demo/minimal/ (you must have read this page),
>>> and more examples at https://github.com/yihui/knitr-examples
>>>
>>> If you are asking about the internals of knitr, "Luke, use the
>>> source": https://github.com/yihui/knitr Or for a more comprehensive
>>> introduction, see http://www.crcpress.com/product/isbn/9781482203530
>>>
>>> Regards,
>>> Yihui
>>> --
>>> Yihui Xie 
>>> Phone: 206-667-4385 Web: http://yihui.name
>>> Fred Hutchinson Cancer Research Center, Seattle
>>>
>>>
>>> On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
 Hi everyone,

 I am using package knitr, FIRST TIME.  I don't have access to RStudio.

 Read through Yihui's page, didn't find it helpful.  Stuck on terms
 Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
 reference is not helping.

 Is there a simple step-by-step example WITHOUT RStudio?

 My question:
 What is the procedure?  The documentation explains the functions, but
 does not say how to operate between R and LaTex.

 Mike

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Simon Zehnder
Hi Mike,

I found my way with this little blog: http://yihui.name/knitr/demo/editors/

The .Rnw files are created very well in a Latex editor. Everything else can be 
easily googled. The command via knitr::knit2pdf works very fine if you use the 
chunks. If you are trying to compile an Rtex file, this I do not know either (I 
like the symbols though in for example 
https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex). But the 
.Rnw files are compiled pretty nice in e.g. texmaker, as described in the blog. 
Use for example this source file: 
https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw


Hope this helps


Best

Simon





On Jul 18, 2013, at 8:52 PM, C W  wrote:

> How do you create a .Rnw file, in R or LaTex?  I don't think any
> tutorial mentions it.
> 
> btw, I am very new to the terms like markdown, so I don't understand
> "markdown to HTML".
> 
> I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
> that you need to compile at terminal.  I do not know terminal, is
> there other ways?
> 
> Could you do a video on just "simple" R?  I have seen 3 videos on R
> Studio including yours.
> 
> Mike
> 
> On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
>> I'm not sure what your question really is. You do not have to use
>> RStudio, but it will be much easier to get started with RStudio,
>> because it does a lot of automatic conversion behind the scenes (e.g.
>> tex to PDF, markdown to HTML, ...). If you want a "pure" solution
>> without any text editor support, the answer is
>> 
>> library(knitr)
>> knit('your_input_file')
>> 
>> For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
>> with LaTeX, you can mess with this foo.tex now (outside of R).
>> 
>> Minimal examples for different document formats are at
>> http://yihui.name/knitr/demo/minimal/ (you must have read this page),
>> and more examples at https://github.com/yihui/knitr-examples
>> 
>> If you are asking about the internals of knitr, "Luke, use the
>> source": https://github.com/yihui/knitr Or for a more comprehensive
>> introduction, see http://www.crcpress.com/product/isbn/9781482203530
>> 
>> Regards,
>> Yihui
>> --
>> Yihui Xie 
>> Phone: 206-667-4385 Web: http://yihui.name
>> Fred Hutchinson Cancer Research Center, Seattle
>> 
>> 
>> On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
>>> Hi everyone,
>>> 
>>> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>>> 
>>> Read through Yihui's page, didn't find it helpful.  Stuck on terms
>>> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
>>> reference is not helping.
>>> 
>>> Is there a simple step-by-step example WITHOUT RStudio?
>>> 
>>> My question:
>>> What is the procedure?  The documentation explains the functions, but
>>> does not say how to operate between R and LaTex.
>>> 
>>> Mike
>>> 
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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] 'save' method for S4 class

2013-07-18 Thread Simon Zehnder
Hi Christofer,

R's S4 class system builds on generics, that is one class defines the raw frame 
of a function and maybe an own distinct implementation and other classes, that 
(usually) inherit from this class, set their special implementations of it. 
Consider a generic function in R as being an abstract function, just telling 
inheriting classes how to build such a function, i.e. what to put in. 
Furthermore it enables the dispatches like callNextMethod, which calls the 
method from the parent (be aware if you have more than one direct parent!). 
Under the hood, R must know from the input arguments what function should be 
called. If you put in an B class that inherits from an A class it must know, 
what to do with a user-defined "save" function when the input argument is for 
example an object of class "B". If you put in an "A" class object, it should 
know how to proceed this object and so on. So the generic method gives a kind 
of internal map for R how to call this function in which contexts.

The standardGeneric() function: We must provide a name and a definition of the 
generic function. In most cases you just want to tell, what arguments the 
function should expect. With the function standardGeneric("name") R creates a 
generic which can then be dispatched in form of distinct methods. So if you 
call "save" R sees, that it is a generic function and checks which of the 
distinct functions to call, evaluating the arguments. If it finds no specific 
function for the arguments at hand, it calls a default function. If, as in your 
case, the function name is already taken, R sets, when you use setGeneric, the 
usual "save" function as the default method, getting called when nothing else 
fits ... resulting in either an error because of mismatching function arguments 
or in saving in a way you do not want to. Solution is here to define inside the 
setGeneric also the default function via the argument useAsDefault = function() 
{}. 

So generic function (setGeneric): What should be done?
Distinct function (setMethod): How should it be done?


You find a very good introduction to the S4 class system here: 
http://cran.r-project.org/doc/contrib/Genolini-S4tutorialV0-5en.pdf

Deep down information can be found for example in the books: "Programming with 
Data" and "Software for Data Analysis and Computing with R", both from John 
Chambers. 


Best

Simon



On Jul 18, 2013, at 8:23 PM, Christofer Bogaso  
wrote:

> Hi Simon,
> 
> Thanks for your pointer.
> 
> However could you please explain what 'function(x, file_Path) 
> standardGeneric("save")' means here? The underlying help files look quite 
> rocket science for me!
> 
> Thanks for your time.
> 
> Thanks and regards,
> 
> 
> On Thu, Jul 18, 2013 at 4:32 PM, Simon Zehnder  wrote:
> Hi Christopher,
> 
> I think, that "save" is no generic function like "plot", "show", etc. So at 
> first you have to determine a generic.
> 
> setGeneric("save", function(x, file_Path) standardGeneric("save"))
> 
> Now your definition via setMethod.
> 
> 
> Best
> 
> Simon
> 
> 
> 
> On Jul 18, 2013, at 12:09 PM, Christofer Bogaso  
> wrote:
> 
> > Hello again,
> >
> > I am trying to define the 'save' method for my S4 class as below:
> >
> > setClass("MyClass", representation(
> >   Slot1 = "data.frame"
> >   ))
> >
> > setMethod("save", "MyClass", definition = function(x, file_Path) {
> >
> >   write.table(x@Slot1, file = file_Path, append = FALSE, quote 
> > = TRUE,
> > sep = ",",
> >   eol = "\n", na = "NA", dec = 
> > ".", row.names = FALSE,
> >   col.names = TRUE, qmethod = 
> > c("escape", "double"),
> >   fileEncoding = "")
> >   })
> >
> > However while doing this I am getting following error:
> >
> > Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
> >  in method for ‘save’ with signature ‘list="MyClass"’: formal
> > arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
> > version = "MyClass", envir = "MyClass", compress = "MyClass",
> > compression_level = "MyClass", eval.promises = "MyClass", precheck =
> > "MyClass") omitted in the method definition cannot be in the signature
> >
> >
> > Can somebody point me what will be the correct approach to define
> > 'save' method for S4 class?
> >
> > Thanks and regards,
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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 co

Re: [R] Difference between arima(1, 1, 1) of y and arima(1, 0, 1) of diff(y)

2013-07-18 Thread George Milunovich
Hi Mark,
This is very helpful!!
Much appreciated

Sent from my iPad

On Jul 19, 2013, at 3:51 AM, Mark Leeds  wrote:

> Hi George: Assuming it's still relevant, the link below will explain why. 
> 
> http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm
> 
> 
> 
> On Thu, Jul 18, 2013 at 2:14 PM, George Milunovich 
>  wrote:
>> Dear all,
>> When I run an arima(1,1,1) on an I(1) variable, y, I get different estimates 
>> to when I first difference the variable myself, e.g y2<-diff(y), and then 
>> run arima(1,0,1) on y2. Shouldn't these two approaches give the same output?
>> Any help will be much appreciated.
>> george
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 

[[alternative HTML version deleted]]

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


[R] extracting variance and covariance

2013-07-18 Thread G Girija
Hi,

I am not able to ‘extract variance and covariance’

As mentioned, there are 5 stocks and changed the code [
http://www.forecastingfinancialrisk.com/3.html] as follows:

> S<-cov(returns)

> S

 V1   V2   V3   V4   V5

V1 0.0004951526 0.0001256519 0.0001651016 0.0003024310 0.0003516796

V2 0.0001256519 0.0008076471 0.0001251208 0.0002005305 0.0002347568

V3 0.0001651016 0.0001251208 0.001707 0.0003158028 0.0003682633

V4 0.0003024310 0.0002005305 0.0003158028 0.0011405561 0.0008442661

V5 0.0003516796 0.0002347568 0.0003682633 0.0008442661 0.0018536153



> EWMA[1,]<-c(S)[c(1,10,5)]

> a=t(as.numeric(returns$i)) %*% as.numeric(returns$i) ---*Here we need


 to change dataframe to numeric, that too only columns.*

> str(a)

 num [1, 1] 0

> dim(a)

[1] 1 1

> dim(lambda*S)

[1] 5 5   -*As the dimensions are not same we can not do
‘%*%’*

> dim((1-lambda)*a)

[1] 1 1

 for(i in 2:T)

{

  S<- lambda*S+ (1-lambda)*t(returns$i) %*% returns$i

  EWMA[i,]=c(S)[c(1,4,2)]

}



*Original code as per* http://www.forecastingfinancialrisk.com/3.html is

EWMA = *matrix*(*nrow*=T,*ncol*=3)   *# create a matrix to hold the
covariance matrix for each t*

lambda = 0.94

S = *cov*(y) *# initial (t=1) covariance matrix*

EWMA[1,] = *c*(S)[*c*(1,4,2)]  *# extract the variances and covariance*

*for* (i *in* 2:T){*# loop though the sample*

 S = lambda * S  + (1-lambda) * *t*(y[i]) %*% y[i]

[[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] Principal component / EOF analysis of data dominated by a couple frequencies

2013-07-18 Thread Ateljevich, Eli@DWR
Hi R folk,
I have a time series of scalar downstream velocity data measured across a tidal 
channel. The variables are the locations in bins across the channel, the 
samples are over time.

The fluctuation over the tide cycle is an enormous fraction of the time 
variation in the data ... 96%. The spectral energy of the tide is concentrated 
in a couple bands that make up the major constituents of the tide. Over short 
periods, we could pretend there are just two frequencies, though they are 
really clusters of nearby frequencies that start to diverge as the record gets 
long. Tidal frequencies also beat which causes monthly/14-day "spring-neap" 
cycles with greatly accentuated or attenuated inequalities between high tide 
and low tide.

Despite the dominance of the tide, there is variation across the channel that 
is of interest. A good physical interpretation of what is happening is not just 
that amplitude varies across the channel but that the phase on the edge of the 
channel gets in and out of shape. So a data description that could characterize 
short-medium duration anomalies in relative phase would be really useful and 
hints at some sort of complex analysis. These may be excited by the spring-neap 
cycle, and my concern with spectral PC analysis that isolates a single band 
would be that it might miss that.

Here are the questions:
1. Is there a variant of PC (or other) analysis in R can characterize this type 
of variation well?
2. Should I sweat the way a simple time fluctuation dominates the series? I 
don't object to having a big PC1, but it doesn't fit the textbook examples very 
well. Are there techniques (rotation, normalization) that are designed for this 
situation? I seem to run into it in all sorts of applications.

Thanks,

Eli

[[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] cut into groups of equal nr of elements...

2013-07-18 Thread Wet Bell Diver


Here's one way:

Vec <- rnorm(30)
Vec.cut <- cut(Vec, breaks=c(quantile(Vec, probs = seq(0, 1, by = 0.20))),
labels=c("0-20","20-40","40-60","60-80","80-100"), include.lowest=TRUE)
table(Vec.cut)


or determine the breaks automatically:

cut.size <- function(x, size) {
  cut.prob <- size/length(x)
  if (length(x)%%size != 0) warning("Equal sized groups only possible 
by dropping some elements from x")
  Vec.cut <- cut(x, breaks=c(quantile(x, probs = seq(0, 1, by = 
size/length(x, include.lowest=TRUE)

}
CUT <- cut.size(Vec, 6)
table(CUT)

When asking for
cut.size(Vec, 7)
this will yield 4 equal-sized groups of 7, because there is no way to 
perfectly split 30 observations in groups of 7 each.


HTH,
Peter


Op 18-7-2013 18:09, Marc Schwartz schreef:

Greg,

Good catch. My recollection was that the vector would be broken up into 
'breaks' groups of equal size, however it is range(x) that is split into 
'breaks' intervals, each of which is equal width.

Thanks,

Marc


On Jul 18, 2013, at 10:55 AM, Greg Snow <538...@gmail.com> wrote:


Marc,

Your method works fine when the data is perfectly uniform, but try it with "Vec <- 
rnorm(30)" and you will see that there are more observations in the middle groups and 
fewer in the tail groups.  Something like quantile needs to be used to find the unequally 
spaced breaks that will give equal counts within groups.


On Wed, Jul 17, 2013 at 5:04 PM, Marc Schwartz  wrote:
On Jul 17, 2013, at 4:43 PM, Witold E Wolski  wrote:


I would like to "cut" a vector into groups of equal nr of elements.
looking for a function on the lines of cut but where I can specify
the size of the groups instead of the nr of groups.



In addition to the other options, if the 'breaks' argument to cut() is a single 
number, rather than a vector of cut points, it defines the number of intervals 
to break the 'x' vector into, which of course you can derive from length(x) / 
size.

Thus:

set.seed(1)
Vec <- sample(30)


Vec

  [1]  8 11 17 25  6 23 27 16 14  2  5  4 13  7 18 30 29 24 20  9 10 21
[23] 26  1 22 15 28 12  3 19


# Split into 5 groups of 6 each


split(Vec, cut(Vec, 5))

$`(0.971,6.78]`
[1] 6 2 5 4 1 3

$`(6.78,12.6]`
[1]  8 11  7  9 10 12

$`(12.6,18.4]`
[1] 17 16 14 13 18 15

$`(18.4,24.2]`
[1] 23 24 20 21 22 19

$`(24.2,30]`
[1] 25 27 30 29 26 28


Regards,

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.



--
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com


[[alternative HTML version deleted]]

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


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


Re: [R] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
How do you create a .Rnw file, in R or LaTex?  I don't think any
tutorial mentions it.

btw, I am very new to the terms like markdown, so I don't understand
"markdown to HTML".

I am reading here http://biostat.mc.vanderbilt.edu/wiki/Main/KnitrHowto
that you need to compile at terminal.  I do not know terminal, is
there other ways?

Could you do a video on just "simple" R?  I have seen 3 videos on R
Studio including yours.

Mike

On Thu, Jul 18, 2013 at 2:43 PM, Yihui Xie  wrote:
> I'm not sure what your question really is. You do not have to use
> RStudio, but it will be much easier to get started with RStudio,
> because it does a lot of automatic conversion behind the scenes (e.g.
> tex to PDF, markdown to HTML, ...). If you want a "pure" solution
> without any text editor support, the answer is
>
> library(knitr)
> knit('your_input_file')
>
> For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
> with LaTeX, you can mess with this foo.tex now (outside of R).
>
> Minimal examples for different document formats are at
> http://yihui.name/knitr/demo/minimal/ (you must have read this page),
> and more examples at https://github.com/yihui/knitr-examples
>
> If you are asking about the internals of knitr, "Luke, use the
> source": https://github.com/yihui/knitr Or for a more comprehensive
> introduction, see http://www.crcpress.com/product/isbn/9781482203530
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 206-667-4385 Web: http://yihui.name
> Fred Hutchinson Cancer Research Center, Seattle
>
>
> On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
>> Hi everyone,
>>
>> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>>
>> Read through Yihui's page, didn't find it helpful.  Stuck on terms
>> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
>> reference is not helping.
>>
>> Is there a simple step-by-step example WITHOUT RStudio?
>>
>> My question:
>> What is the procedure?  The documentation explains the functions, but
>> does not say how to operate between R and LaTex.
>>
>> Mike
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Difference between arima(1, 1, 1) of y and arima(1, 0, 1) of diff(y)

2013-07-18 Thread Mark Leeds
Hi George: Assuming it's still relevant, the link below will explain why.

http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm



On Thu, Jul 18, 2013 at 2:14 PM, George Milunovich <
george.milunov...@mq.edu.au> wrote:

> Dear all,
> When I run an arima(1,1,1) on an I(1) variable, y, I get different
> estimates to when I first difference the variable myself, e.g y2<-diff(y),
> and then run arima(1,0,1) on y2. Shouldn't these two approaches give the
> same output?
> Any help will be much appreciated.
> george
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Difference between arima(1, 1, 1) for y and arima(1, 0, 1) for diff(y)

2013-07-18 Thread george
Dear all,
When I run an arima(1,1,1) on an I(1) variable, e.g. y, I get different
estimates to when I first difference the variable myself, e.g y2<-diff(y),
and then run arima(1,0,1) on y2. Shouldn't these two approaches give the
same output?
Any help will be much appreciated.
george



--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-arima-1-1-1-for-y-and-arima-1-0-1-for-diff-y-tp4671873.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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread Yihui Xie
I'm not sure what your question really is. You do not have to use
RStudio, but it will be much easier to get started with RStudio,
because it does a lot of automatic conversion behind the scenes (e.g.
tex to PDF, markdown to HTML, ...). If you want a "pure" solution
without any text editor support, the answer is

library(knitr)
knit('your_input_file')

For example, knit('foo.Rnw') gives you foo.tex; if you are familiar
with LaTeX, you can mess with this foo.tex now (outside of R).

Minimal examples for different document formats are at
http://yihui.name/knitr/demo/minimal/ (you must have read this page),
and more examples at https://github.com/yihui/knitr-examples

If you are asking about the internals of knitr, "Luke, use the
source": https://github.com/yihui/knitr Or for a more comprehensive
introduction, see http://www.crcpress.com/product/isbn/9781482203530

Regards,
Yihui
--
Yihui Xie 
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle


On Thu, Jul 18, 2013 at 11:13 AM, C W  wrote:
> Hi everyone,
>
> I am using package knitr, FIRST TIME.  I don't have access to RStudio.
>
> Read through Yihui's page, didn't find it helpful.  Stuck on terms
> Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
> reference is not helping.
>
> Is there a simple step-by-step example WITHOUT RStudio?
>
> My question:
> What is the procedure?  The documentation explains the functions, but
> does not say how to operate between R and LaTex.
>
> Mike
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] 'save' method for S4 class

2013-07-18 Thread Christofer Bogaso
Hi Simon,

Thanks for your pointer.

However could you please explain what 'function(x, file_Path)
standardGeneric("save")' means here? The underlying help files look quite
rocket science for me!

Thanks for your time.

Thanks and regards,


On Thu, Jul 18, 2013 at 4:32 PM, Simon Zehnder  wrote:

> Hi Christopher,
>
> I think, that "save" is no generic function like "plot", "show", etc. So
> at first you have to determine a generic.
>
> setGeneric("save", function(x, file_Path) standardGeneric("save"))
>
> Now your definition via setMethod.
>
>
> Best
>
> Simon
>
>
>
> On Jul 18, 2013, at 12:09 PM, Christofer Bogaso <
> bogaso.christo...@gmail.com> wrote:
>
> > Hello again,
> >
> > I am trying to define the 'save' method for my S4 class as below:
> >
> > setClass("MyClass", representation(
> >   Slot1 = "data.frame"
> >   ))
> >
> > setMethod("save", "MyClass", definition = function(x, file_Path) {
> >
> >   write.table(x@Slot1, file = file_Path, append = FALSE,
> quote = TRUE,
> > sep = ",",
> >   eol = "\n", na = "NA", dec
> = ".", row.names = FALSE,
> >   col.names = TRUE, qmethod
> = c("escape", "double"),
> >   fileEncoding = "")
> >   })
> >
> > However while doing this I am getting following error:
> >
> > Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
> >  in method for ‘save’ with signature ‘list="MyClass"’: formal
> > arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
> > version = "MyClass", envir = "MyClass", compress = "MyClass",
> > compression_level = "MyClass", eval.promises = "MyClass", precheck =
> > "MyClass") omitted in the method definition cannot be in the signature
> >
> >
> > Can somebody point me what will be the correct approach to define
> > 'save' method for S4 class?
> >
> > Thanks and regards,
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] restrected arima models

2013-07-18 Thread george
Thanks

Sent from my iPhone

On 19/07/2013, at 1:43 AM, "Prof Brian Ripley [via R]" 
 wrote:

> On 18/07/2013 16:14, george wrote: 
> > Dear all, 
> > Does anyone know if it is possible to estimate restricted arima models 
> > using 
> > the arima command in R? For instance lets say I want arima(6,0,0) but where 
> > the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3) 
> > = 0, and only the last three are actually estimated. 
> 
> Yes. 
> 
> > Any help will be much appreciated. 
> 
> Have you read the help page?  Someone helped you by writing it (and  
> indeed, by providing the facility, which few ARIMA-fitting programs have). 
> 
> fixed: optional numeric vector of the same length as the total 
>number of parameters.  If supplied, only ‘NA’ entries in 
>‘fixed’ will be varied.  ‘transform.pars = TRUE’ will be 
>overridden (with a warning) if any AR parameters are fixed. 
> 
> E.g. 
> 
> x <- rnorm(100) 
> arima(x, order=c(6,0,0), fixed = c(0,0,0,NA,NA,NA,NA)) 
> 
> Coefficients: 
>ar1  ar2  ar3 ar4 ar5 ar6  intercept 
>  000  0.0423  0.0977  0.1299-0.1462 
> s.e.000  0.1065  0.1075  0.1059 0.1323 
> 
> 
> > george 
> 
> 
> 
> -- 
> Brian D. Ripley,  [hidden email] 
> 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 
> 
> __ 
> [hidden email] mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847p4671862.html
> To unsubscribe from restrected arima models, click here.
> NAML




--
View this message in context: 
http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847p4671867.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] Difference between arima(1, 1, 1) of y and arima(1, 0, 1) of diff(y)

2013-07-18 Thread George Milunovich
Dear all,
When I run an arima(1,1,1) on an I(1) variable, y, I get different estimates to 
when I first difference the variable myself, e.g y2<-diff(y), and then run 
arima(1,0,1) on y2. Shouldn't these two approaches give the same output?
Any help will be much appreciated.
george

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Looking for knitr example for beginner (NO RStudio)

2013-07-18 Thread C W
Hi everyone,

I am using package knitr, FIRST TIME.  I don't have access to RStudio.

Read through Yihui's page, didn't find it helpful.  Stuck on terms
Rnw, GFM (GitHub Flavored Markdown).  Never used Sweave, so the
reference is not helping.

Is there a simple step-by-step example WITHOUT RStudio?

My question:
What is the procedure?  The documentation explains the functions, but
does not say how to operate between R and LaTex.

Mike

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

2013-07-18 Thread David Winsemius

On Jul 18, 2013, at 9:02 AM, Jason wrote:

> How do I change my email settings? I would like to limit the emails that I 
> receive to only those of interest.
> 

You can use various search engines. I like the MarkMail option. It allows me to 
search in various r-related groups. If you wnat to run it daily with a 
particular set of filters, that should be possible to automate.

http://markmail.org/search/?q=list%3Aorg.r-project

-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] restrected arima models

2013-07-18 Thread Prof Brian Ripley

On 18/07/2013 16:14, george wrote:

Dear all,
Does anyone know if it is possible to estimate restricted arima models using
the arima command in R? For instance lets say I want arima(6,0,0) but where
the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3)
= 0, and only the last three are actually estimated.


Yes.


Any help will be much appreciated.


Have you read the help page?  Someone helped you by writing it (and 
indeed, by providing the facility, which few ARIMA-fitting programs have).


   fixed: optional numeric vector of the same length as the total
  number of parameters.  If supplied, only ‘NA’ entries in
  ‘fixed’ will be varied.  ‘transform.pars = TRUE’ will be
  overridden (with a warning) if any AR parameters are fixed.

E.g.

x <- rnorm(100)
arima(x, order=c(6,0,0), fixed = c(0,0,0,NA,NA,NA,NA))

Coefficients:
  ar1  ar2  ar3 ar4 ar5 ar6  intercept
000  0.0423  0.0977  0.1299-0.1462
s.e.000  0.1065  0.1075  0.1059 0.1323



george




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

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


Re: [R] restrected arima models

2013-07-18 Thread Rui Barradas

Hello,

Take a look at parameter 'fixed' of function arima. From the help page 
for arima():


"fixed 

optional numeric vector of the same length as the total number of 
parameters. If supplied, only NA entries in fixed will be varied."



Example use ('fixed' has length 7 because we must count the intercept term):

x <- ts(cumsum(rnorm(100)))

fit <- arima(x, order = c(6,0,0), fixed = c(0, 0, 0, NA, NA, NA, NA), 
transform.pars = FALSE)

fit

Hope this helps,

Rui Barradas

Em 18-07-2013 16:14, george escreveu:

Dear all,
Does anyone know if it is possible to estimate restricted arima models using
the arima command in R? For instance lets say I want arima(6,0,0) but where
the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3)
= 0, and only the last three are actually estimated.
Any help will be much appreciated.
george



--
View this message in context: 
http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Changing settings

2013-07-18 Thread David Carlson
Go to Settings  | Filters in Gmail and set filters to delete
the r-help messages you don't want or move them to a folder
for review. R-help messages are not tagged so you cannot
restrict them before they are sent. 

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

-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Jason
Sent: Thursday, July 18, 2013 11:03 AM
To: R-help@r-project.org
Subject: [R] Changing settings

How do I change my email settings? I would like to limit the
emails that 
I receive to only those of interest.

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

2013-07-18 Thread Greg Snow
I am guessing that you are trying to use the densityplot function from the
lattice package (if you had followed the posting guidelines and told us
which package you were using, then we would not need to guess).

If that is the case then you are trying to mix base graphics (mfrow) and
grid graphics (densityplot) and the 2 do not play nicely together (without
extra effort).

One option would be to use only base graphics and plot the pairs of
densities yourself using plot, lines, density, and maybe other functions.

Probably a little bit better is to use only lattice tools, see the help
page ?print.trellis and specifically the split and more arguments for how
to put multiple trellis plots onto a single page.

You could mix the 2 using the gridBase package, but that is probably way
more work than needed for this.

You could also investigate the ggplot2 package which may make this easier
using grid graphics.


On Thu, Jul 18, 2013 at 1:04 AM, meng  wrote:

> Hi all:
> My data:
>   f1  f2  f3   f4 y
> 1  -4.45   3  6.44 3.721
> 2  25.66 121 39.03 3.55 0
> 3  -9.75  12 11.77 3.40   1
> 4 -12.09  17 13.75 3.33   0
> 5  -3.53   4  6.47 3.24  0
> 6  13.18  69 26.55 3.201
> ... ...
> I want to plot f1 for y=0 and 1; f2 for y=0 and 1...and the same as f3,f4.
> And I want to get 4 plots at once(2*2)
>
> My code:
> par(mfrow=c(2,2))
> densityplot(~f1,data=dat,group=y,auto.key=T)
> densityplot(~f2,data=dat,group=y,auto.key=T)
> densityplot(~f3,data=dat,group=y,auto.key=T)
> densityplot(~f4,data=dat,group=y,auto.key=T)
>
> The result is not what I want,since it produce 1 plot a time,but not 4
> plots together(2*2).
> Maybe something wrong with par(mfrow=c(2,2))?
> Any suggestion? Many thanks!
>
> Best.
> [[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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


[R] Changing settings

2013-07-18 Thread Jason
How do I change my email settings? I would like to limit the emails that 
I receive to only those of interest.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] cut into groups of equal nr of elements...

2013-07-18 Thread Marc Schwartz
Greg,

Good catch. My recollection was that the vector would be broken up into 
'breaks' groups of equal size, however it is range(x) that is split into 
'breaks' intervals, each of which is equal width.

Thanks,

Marc


On Jul 18, 2013, at 10:55 AM, Greg Snow <538...@gmail.com> wrote:

> Marc,
> 
> Your method works fine when the data is perfectly uniform, but try it with 
> "Vec <- rnorm(30)" and you will see that there are more observations in the 
> middle groups and fewer in the tail groups.  Something like quantile needs to 
> be used to find the unequally spaced breaks that will give equal counts 
> within groups.
> 
> 
> On Wed, Jul 17, 2013 at 5:04 PM, Marc Schwartz  wrote:
> On Jul 17, 2013, at 4:43 PM, Witold E Wolski  wrote:
> 
> > I would like to "cut" a vector into groups of equal nr of elements.
> > looking for a function on the lines of cut but where I can specify
> > the size of the groups instead of the nr of groups.
> 
> 
> 
> In addition to the other options, if the 'breaks' argument to cut() is a 
> single number, rather than a vector of cut points, it defines the number of 
> intervals to break the 'x' vector into, which of course you can derive from 
> length(x) / size.
> 
> Thus:
> 
> set.seed(1)
> Vec <- sample(30)
> 
> > Vec
>  [1]  8 11 17 25  6 23 27 16 14  2  5  4 13  7 18 30 29 24 20  9 10 21
> [23] 26  1 22 15 28 12  3 19
> 
> 
> # Split into 5 groups of 6 each
> 
> > split(Vec, cut(Vec, 5))
> $`(0.971,6.78]`
> [1] 6 2 5 4 1 3
> 
> $`(6.78,12.6]`
> [1]  8 11  7  9 10 12
> 
> $`(12.6,18.4]`
> [1] 17 16 14 13 18 15
> 
> $`(18.4,24.2]`
> [1] 23 24 20 21 22 19
> 
> $`(24.2,30]`
> [1] 25 27 30 29 26 28
> 
> 
> Regards,
> 
> 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.
> 
> 
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com


[[alternative HTML version deleted]]

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


Re: [R] Orders of levels affecting wilcox.test() output

2013-07-18 Thread Greg Snow
The p-value and inference is the same, the only difference that I see is
the value of the W statistic.  The definition of the W statistic (as
discussed in the Note section on the help page) is based on the sum of the
ranks in the **First** group, so if you change which group is first then
you should expect the W statistic to change.  As long as the inference does
not change, why worry about it?


On Thu, Jul 18, 2013 at 3:18 AM, Alastair Potts  wrote:

> Good day all,
>
> My first posting to this list. It looked like the best place to post this
> question.
>
> When running the wilcox.test(), I noticed that the output values change if
> you change the ordering of the levels (example below which includes a
> t.test for comparison). I think this has something to do with the change in
> ranking order, but this doesn't make much sense as I would expect the
> ranking in this case to remain constant as there are no ties. So my
> questions are: a) is this correct (i.e. not a bug)?, and b) if it is, then
> which values should I report?
>
>
> x <- cbind(data.frame((c(rep("A",50),rep("B",50,runif(100))
> colnames(x) <- c("a","b")
> wilcox.test(b~a,data=x)
> t.test(b~a,data=x)
> x$a <- relevel(x$a,ref="B")
> wilcox.test(b~a,data=x)
> t.test(b~a,data=x)
>
> Thank you in advance for your time,
> Regards,
> Alastair
>
> [[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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Wensui Liu
my fault. qcut() is a python function in pandas ;-)

what i meant is cut2() in hmisc.

sorry for messing up.
On Jul 18, 2013 11:51 AM, "Greg Snow" <538...@gmail.com> wrote:

> Wensui,
>
> ?qcut on  my machine gives an error and ??qcut does not find anything in
> the installed packages.  Which package is qcut in?
>
>
> On Wed, Jul 17, 2013 at 4:43 PM, Wensui Liu  wrote:
>
>> ?qcut
>> On Jul 17, 2013 5:45 PM, "Witold E Wolski"  wrote:
>>
>> > I would like to "cut" a vector into groups of equal nr of elements.
>> > looking for a function on the lines of cut but where I can specify
>> > the size of the groups instead of the nr of groups.
>> >
>> >
>> >
>> >
>> > --
>> > Witold Eryk Wolski
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/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.
>>
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com
>

[[alternative HTML version deleted]]

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


Re: [R] Orders of levels affecting wilcox.test() output

2013-07-18 Thread David Carlson
The short answer is whichever version you want since they are
the same. Look at the t-test results, they are also different.
In one t is positive and in the other it is negative. That is
just a result of whether the smaller mean is subtracted from
the larger mean or vice versa. The same is happening with
Wilcoxon (see
http://en.wikipedia.org/wiki/Mann-Whitney-Wilcoxon_test ) for
the specific equations. 

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


-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Alastair
Potts
Sent: Thursday, July 18, 2013 4:18 AM
To: r-help@r-project.org
Subject: [R] Orders of levels affecting wilcox.test() output

Good day all,

My first posting to this list. It looked like the best place
to post this
question.

When running the wilcox.test(), I noticed that the output
values change if
you change the ordering of the levels (example below which
includes a
t.test for comparison). I think this has something to do with
the change in
ranking order, but this doesn't make much sense as I would
expect the
ranking in this case to remain constant as there are no ties.
So my
questions are: a) is this correct (i.e. not a bug)?, and b) if
it is, then
which values should I report?


x <-
cbind(data.frame((c(rep("A",50),rep("B",50,runif(100))
colnames(x) <- c("a","b")
wilcox.test(b~a,data=x)
t.test(b~a,data=x)
x$a <- relevel(x$a,ref="B")
wilcox.test(b~a,data=x)
t.test(b~a,data=x)

Thank you in advance for your time,
Regards,
Alastair

[[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] cut into groups of equal nr of elements...

2013-07-18 Thread Greg Snow
Marc,

Your method works fine when the data is perfectly uniform, but try it with
"Vec <- rnorm(30)" and you will see that there are more observations in the
middle groups and fewer in the tail groups.  Something like quantile needs
to be used to find the unequally spaced breaks that will give equal counts
within groups.


On Wed, Jul 17, 2013 at 5:04 PM, Marc Schwartz  wrote:

> On Jul 17, 2013, at 4:43 PM, Witold E Wolski  wrote:
>
> > I would like to "cut" a vector into groups of equal nr of elements.
> > looking for a function on the lines of cut but where I can specify
> > the size of the groups instead of the nr of groups.
>
>
>
> In addition to the other options, if the 'breaks' argument to cut() is a
> single number, rather than a vector of cut points, it defines the number of
> intervals to break the 'x' vector into, which of course you can derive from
> length(x) / size.
>
> Thus:
>
> set.seed(1)
> Vec <- sample(30)
>
> > Vec
>  [1]  8 11 17 25  6 23 27 16 14  2  5  4 13  7 18 30 29 24 20  9 10 21
> [23] 26  1 22 15 28 12  3 19
>
>
> # Split into 5 groups of 6 each
>
> > split(Vec, cut(Vec, 5))
> $`(0.971,6.78]`
> [1] 6 2 5 4 1 3
>
> $`(6.78,12.6]`
> [1]  8 11  7  9 10 12
>
> $`(12.6,18.4]`
> [1] 17 16 14 13 18 15
>
> $`(18.4,24.2]`
> [1] 23 24 20 21 22 19
>
> $`(24.2,30]`
> [1] 25 27 30 29 26 28
>
>
> Regards,
>
> 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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] cut into groups of equal nr of elements...

2013-07-18 Thread Greg Snow
Wensui,

?qcut on  my machine gives an error and ??qcut does not find anything in
the installed packages.  Which package is qcut in?


On Wed, Jul 17, 2013 at 4:43 PM, Wensui Liu  wrote:

> ?qcut
> On Jul 17, 2013 5:45 PM, "Witold E Wolski"  wrote:
>
> > I would like to "cut" a vector into groups of equal nr of elements.
> > looking for a function on the lines of cut but where I can specify
> > the size of the groups instead of the nr of groups.
> >
> >
> >
> >
> > --
> > Witold Eryk Wolski
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


[R] restrected arima models

2013-07-18 Thread george
Dear all,
Does anyone know if it is possible to estimate restricted arima models using
the arima command in R? For instance lets say I want arima(6,0,0) but where
the first three ar parameters are restricted to zero, ie. ar(1)=ar(2)=ar(3)
= 0, and only the last three are actually estimated. 
Any help will be much appreciated.
george 



--
View this message in context: 
http://r.789695.n4.nabble.com/restrected-arima-models-tp4671847.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] Moran's I

2013-07-18 Thread Owen Yancey
Dear list,

I’m an undergraduate research assistant trying to create a single function
that can calculate Moran’s I using the “ape” package.  The example that I
will use comes from online data about ozone levels. Here are the commands
that I have been using:

> library(ape)

> ozone<-read.table("http://www.ats.ucla.edu/stat/r/faq/ozone.csv";,
sep=",", header=T)

> head(ozone, n=10)

   Station Av8top  Lat  Lon  county

1   60  7.225806   34.13583  -117.9236  1

2   69  5.899194   34.17611  -118.3153  1

3   72  4.052885   33.82361  -118.1875  1

4   74  7.181452   34.19944  -118.5347  1

5   75  6.076613   34.06694  -117.7514  2

6   84  3.157258   33.92917  -118.2097  2

7   85  5.201613   34.01500  -118.0597  2

8   87  4.717742   34.06722  -118.2264  2

9   88  6.532258   34.08333  -118.1069  2

10  89 7.540323   34.38750  -118.5347  2



   >attach(ozone)

> Moran<- function(x)

+ {

+ distmatrix<- as.matrix(dist(cbind(Lon, Lat)))

+ invdistmatrix<- 1/distmatrix

+ diag(invdistmatrix)<-0

+ Moran.I(Av8top, invdistmatrix)

+ print(Moran.I)

+ }

> Moran.I(ozone)

I either receive an error saying that the matrix is not weighted, or I
receive a significant amount of output that does not include a calculation
for Moran’s I.  Do you have any suggestions on how to correctly create a
single function that calculates Moran’s I?

My ultimate goal is to run this function as a loop. I want to create a loop
that produces Moran’s I values for subsets of a very large database.
Specifically, I have points (block centroids) with population
characteristics. These points are nested within approximately 35,000 zip
codes. I want to create Moran’s I across blocks for each of the ~35,000 and
have the output stored in a new file that contains the zip code number and
Moran’s I values.  In the example of the ozone data I show above,  I would
create a loop that produces Moran’s I values for county 1 and county 2 and
then have the output stored in a new file with two records (one for each
county) and values for each county and the corresponding Moran’s I values.
Do you have any advice on creating this loop? Any help would be greatly
appreciated!

[[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] binary distance measure of the "dist" function in the "stats" package

2013-07-18 Thread David Carlson
If you read ?dist, it says that:

binary:
(aka asymmetric binary): The vectors are regarded as
binary bits, so non-zero elements are ‘on’ and zero elements
are ‘off’. The distance is the proportion of bits in which
only one is on amongst those in which at least one is on.

The short answer is that this is the Jaccard Distance measure.
If we label the cells of a 2x2 presence absence matrix as a,
b, c, d:

  Present  Absent
Present  ab
Absent   cd

Then the Jaccard Similarity index is a/(a+b+c)
And the Jaccard Distance index is (1 - a/(a+b+c)) or
(b+c)/(a+b+c)

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




-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of ??
Sent: Thursday, July 18, 2013 9:56 AM
To: r-help@r-project.org
Subject: [R] binary distance measure of the "dist" function in
the "stats" package

Dear all:
I want to ask question about "binary" distance measure. As
far as I
know, there are many binary distance measures,eg, binary
Jarcad distance,
binary euclidean distance, and binary Bray-Curtis
distance,etc. It is even
more confusing because many have more than one name. So , I
wan to know
what the definite name of  the binary distance measure of the
"dist"
function in the "stats" package is and further want to know
the equation of
the binary distance. Thank you very much!
With  my  best  regards.

[[alternative HTML version deleted]]

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] binary distance measure of the "dist" function in the "stats" package

2013-07-18 Thread 朱林
Dear all:
I want to ask question about "binary" distance measure. As far as I
know, there are many binary distance measures,eg, binary Jarcad distance,
binary euclidean distance, and binary Bray-Curtis distance,etc. It is even
more confusing because many have more than one name. So , I wan to know
what the definite name of  the binary distance measure of the "dist"
function in the "stats" package is and further want to know the equation of
the binary distance. Thank you very much!
With  my  best  regards.

[[alternative HTML version deleted]]

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


[R] Bland Altman summary stats for all column combinations

2013-07-18 Thread moadeep
Hello,

I have the following data.frame

structure(list(Study = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
19L), .Label = c("WCBP12236", "WCBP12241", "WCBP12242", "WCBP12243", 
"WCBP12245", "WCBP13001", "WCBP13002", "WCBP13003", "WCBP13004", 
"WCBP13005", "WCBP13006", "WCBP13007", "WCBP13008", "WCBP13009", 
"WCBP13010", "WCBP13011", "WCBP13012", "WCBP13013", "WCBP13014"
), class = "factor"), G1 = c(68, 68.6, 66.6, 73.1, 51.6, 50.1, 
64.1, 73, 63.7, 43.2, 62.3, 59.2, 67.5, 68.2, 54.6, 67.9, 56.5, 
54.2, 67.3, 68, 68.4, 67.9, 73.3, 51.7, 50.3, 63.9, 73.9, 64, 
42.9, 62.5, 59.3, 66.7, 68.4, 54, 68.2, 56.8, 54.5, 67, 53.2, 
41.4, 53, 52.3, 41, 37.4, 56.9, 65.3, 36.2, 35.3, 36.1, 32.5, 
56.5, 47.7, 39.4, 59.6, 38.1, 24.2, 30.2, 68.5, 68.9, 70.7, 74.9, 
53.4, 51.6, 65.9, 75.7, 64.7, 42.8, 61.4, 60.8, 69.5, 68.7, 55.9, 
70.7, 59.5, 51.1, 69.5), G2 = c(79.8, 72.2, 73.5, 74.4, 50.4, 
54.8, 63.1, 70.4, 63.6, 45.1, 65.3, 49.4, 65.3, 76.2, 51, 63.9, 
58.7, 57.8, 67, 79.6, 72.1, 73.9, 74.7, 50.5, 55.1, 62.8, 70.5, 
63.3, 44.6, 65.5, 48.9, 64.9, 76.3, 50.6, 64.8, 58.6, 58.3, 67.4, 
51.2, 37.7, 49.1, 53.7, 44.6, 37.3, 54.9, 64.1, 33.8, 31.9, 34.2, 
30.3, 56.2, 44.6, 38.2, 63.2, 35.8, 26.5, 27.6, 80.6, 71.6, 75.4, 
77.1, 52.4, 56.3, 66, 72.3, 64.5, 38.2, 64.3, 49.2, 66.9, 77.1, 
52.4, 67.5, 59.6, 55.6, 69.9), S1 = c(75.1, 65.9, 72.7, 68.8, 
49, 57.5, 66.5, 74.1, 60.9, 51.8, 58, 64.3, 71.1, 71.4, 58.9, 
62.2, 58, 57.7, 58.6, 75.2, 66, 73.2, 69.7, 48.9, 57.7, 66.5, 
74.7, 60.8, 51.4, 58.9, 65.5, 70.5, 71.4, 58.9, 65.1, 60.8, 57.7, 
58.4, 54.3, 40.2, 52.6, 60.5, 42.6, 34.1, 55, 64.7, 36.3, 32.5, 
39, 38.8, 58.1, 48, 40.5, 61, 40, 26.4, 28.8, 76.4, 66.5, 73.9, 
72, 50.7, 59.2, 69.9, 76.3, 62.4, 50, 58.5, 66.6, 73.7, 72.3, 
62.6, 69.6, 62.7, 57.9, 61.1), S2 = c(76.6, 71.6, 71.2, 72.7, 
51.6, 56.7, 65.9, 73.5, 63.6, 55.2, 62.6, 62.2, 69.1, 71.1, 56.8, 
61, 61.7, 60, 55.7, 76.9, 71.6, 72.3, 73.2, 51.7, 56.8, 64.5, 
74.9, 63.6, 51.3, 63, 62.8, 68.7, 71.3, 56.8, 64.2, 62.8, 60.4, 
55.8, 53.6, 42.5, 50, 54.4, 42.2, 36.4, 57.7, 64.1, 35.1, 30.8, 
39.1, 37.4, 58.7, 47.8, 42, 58.8, 39.4, 24.2, 28.2, 78.2, 73.3, 
72.3, 75.6, 53.4, 57.8, 68.3, 76.6, 63.7, 51.7, 63.4, 63.3, 71.5, 
72.3, 60.2, 67.1, 65.5, 58.2, 59.1), Method = structure(c(4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Simple_2_ROI", 
"Single_ROI", "WIG_drawn_bg", "WIG_Method"), class = "factor")), .Names =
c("Study", 
"G1", "G2", "S1", "S2", "Method"), row.names = c(NA, -76L), class =
"data.frame")

This shows the measurement results of 2 operators using 4 slightly different
analysis methods. The operators analyse each data file WCBPX twice -
(G1,G2,S1,S2) and there are 4 methods (Single_ROI,Simple_2_ROI etc)

What I would like to do is get the summary statistics from a Bland Altman
(Mean vs Difference) plot for all 16 combinations.

For example for G1 and G2, I can do the following

ddply(df,.(Method),summarise,mean=mean(G1-G2, na.rm = TRUE),
 sd=sd(G1-G2, na.rm = TRUE))

Eventually I want a data.frame with the format
Var1 Var2 Mean  Sd Method
G1   G2   -.67  5.2 Simple_2_ROI
G1   G2   1.12  2.3 Single_ROI
G1   G2   -1.08 4.8 WIG_drawn_bg
G1   G2   -1.17 4.9 WIG_Method
G1 G1 0 0 Simple_2_ROI

Is there a simple way to achieve this structure?

>From that things get more tricky. What I would like to do is to create a
heatmap using ggplot2 (geom_tile) to provide a visual summary of the data
similar to the correlation heatmap I have produced from the same data set
 
Instead of filling each tile based on R^2 I would like to fill based on
standard deviation. Also I would like to add geom_text to each tile
highlighting the bias (mean difference) and the standard deviation.

Any pointers how I can achieve this. I am completely stuck.

Here is my code for the correlation heatmap
plots <- dlply(df, .(Method), function (x1) {
ggplot(subset(melt(cor(x1[sapply(x1,is.numeric)]))[lower.tri(c),],Var1
!= Var2),
   aes(x=Var1,y=Var2,fill=value)) + geom_tile(aes(fill =
value),colour = "white") +
geom_text(aes(label = sprintf("%1.2f",value)), vjust = 1) + 
theme_bw() +
scale_fill_gradient2(name="R^2",midpoint=0.7,low = "white", high =
"red") + xlab(NULL)+ylab(NULL) +
theme(axis.text.x=element_blank(),axis.text.y=element_blank(),
axis.ticks=element_blank(),panel.border=element_blank()) +
ggtitle(x1$Me

Re: [R] combine select data from 2 dataframes sharing same variables

2013-07-18 Thread bcrombie
Hi, Peter.  Thanks for the suggestion.  I will investigate ?merge.  BNC

From: Peter Alspach-2 [via R] [mailto:ml-node+s789695n4671809...@n4.nabble.com]
Sent: Wednesday, July 17, 2013 8:08 PM
To: Crombie, Burnette N
Subject: Re: combine select data from 2 dataframes sharing same variables

Tena koe

Without reading your request in detail, I will suggest you look at ?merge.  It 
is often the answer when 'combine' is in the question.

Peter Alspach




--
View this message in context: 
http://r.789695.n4.nabble.com/combine-select-data-from-2-dataframes-sharing-same-variables-tp4671790p4671837.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] panel setting

2013-07-18 Thread meng
Hi all:
My data:
  f1  f2  f3   f4 y
1  -4.45   3  6.44 3.721
2  25.66 121 39.03 3.55 0
3  -9.75  12 11.77 3.40   1
4 -12.09  17 13.75 3.33   0
5  -3.53   4  6.47 3.24  0
6  13.18  69 26.55 3.201
... ...
I want to plot f1 for y=0 and 1; f2 for y=0 and 1...and the same as f3,f4.
And I want to get 4 plots at once(2*2)
 
My code:
par(mfrow=c(2,2))
densityplot(~f1,data=dat,group=y,auto.key=T)
densityplot(~f2,data=dat,group=y,auto.key=T)
densityplot(~f3,data=dat,group=y,auto.key=T)
densityplot(~f4,data=dat,group=y,auto.key=T)
 
The result is not what I want,since it produce 1 plot a time,but not 4 plots 
together(2*2).
Maybe something wrong with par(mfrow=c(2,2))?
Any suggestion? Many thanks!

Best.
[[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-squared and GLM

2013-07-18 Thread Chris89
Haha, true true! ;)

It was to be used as a measure on how good the models I use are, but I found
out that the AIC would be much easier to implement, and as I understand, a
better measure of how good the model fit.

Thanks,
Chris



--
View this message in context: 
http://r.789695.n4.nabble.com/R-squared-and-GLM-tp4671754p4671820.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] Orders of levels affecting wilcox.test() output

2013-07-18 Thread Alastair Potts
Good day all,

My first posting to this list. It looked like the best place to post this
question.

When running the wilcox.test(), I noticed that the output values change if
you change the ordering of the levels (example below which includes a
t.test for comparison). I think this has something to do with the change in
ranking order, but this doesn't make much sense as I would expect the
ranking in this case to remain constant as there are no ties. So my
questions are: a) is this correct (i.e. not a bug)?, and b) if it is, then
which values should I report?


x <- cbind(data.frame((c(rep("A",50),rep("B",50,runif(100))
colnames(x) <- c("a","b")
wilcox.test(b~a,data=x)
t.test(b~a,data=x)
x$a <- relevel(x$a,ref="B")
wilcox.test(b~a,data=x)
t.test(b~a,data=x)

Thank you in advance for your time,
Regards,
Alastair

[[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] Test if 2 samples differ if they have autocorrelation

2013-07-18 Thread Eric Jaeger
> Dear all
> 
> I have one question that I struggle to find an answer:
> 
> Let`s assume I have 2 timeseries of daily PnL data over 2 years coming from 2 
> different trading strategies. I want to find out if strategy A is better than 
> strategy B. The problem is that the two series have serial correlations, 
> hence I cannot just do a simple t-test.
> 
> I tried something like this:
> 
> 1.create cumulative timeseries of PnL_A = C_A and of PnL_B = C_B
> 
> 2.take the difference of both: C_A – C_B = DiffPnL (to see how the 
> difference evolves over time)
> 
> 3.do a regression: DiffPnL = beta * time + error (I thought if beta is 
> significantly different from 0 than the two time series are different)
> 
> 4.estimate beta not with OLS, but with the Newey-West method (HAC estimator) 
> -> this corrects statistical tests, standard errors for beta 
> heteroskedasticity and autocorrelation
> 
> BUT: I read something that the tests are biased when the timeseries are unit 
> root non-stationary (which is due to the fact that I take cumulative time 
> series)
> 
>  
> 
> I am lost! This should be fairly simple: test if two samples differ if they 
> have autocorrelation? Probably my approach above is completely wrong…
> 
>  
> 
> Thanks for your help
> 
> Best regards
> 
> Eric
> 
> 
> 
> The information in this e-mail is intended only for th...{{dropped:23}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bland Altman summary stats for all column combinations

2013-07-18 Thread arun
HI,
#dat1: data
Combn1<-combn(colnames(dat1)[2:5],2)
#For the first part, may be this helps:
library(plyr)
 res<-lapply(split(Combn1,col(Combn1)),function(x) 
{x1<-cbind(Var1=colnames(dat1[,x])[1],Var2=colnames(dat1[,x])[2],dat1[,x],Method=dat1[,6]);colnames(x1)[3:4]<-
 c("V1","V2"); ddply(x1,.(Method,Var1,Var2),summarize, 
mean1=mean(V1-V2,na.rm=TRUE),sd1=sd(V1-V2,na.rm=TRUE))})
 res[[1]]
#    Method Var1 Var2  mean1  sd1
#1 Simple_2_ROI   G1   G2 -0.6684211 5.223882
#2   Single_ROI   G1   G2  1.1263158 2.313929
#3 WIG_drawn_bg   G1   G2 -1.0894737 4.876576
#4   WIG_Method   G1   G2 -1.1684211 4.894447


Also,
G1 G1 0 0 Simple_2_ROI 
#part is not clear bcz ur ddply() code didn't do that.

A.K.




Hello, 

I have the following data.frame 

structure(list(Study = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 
19L), .Label = c("WCBP12236", "WCBP12241", "WCBP12242", "WCBP12243", 
"WCBP12245", "WCBP13001", "WCBP13002", "WCBP13003", "WCBP13004", 
"WCBP13005", "WCBP13006", "WCBP13007", "WCBP13008", "WCBP13009", 
"WCBP13010", "WCBP13011", "WCBP13012", "WCBP13013", "WCBP13014" 
), class = "factor"), G1 = c(68, 68.6, 66.6, 73.1, 51.6, 50.1, 
64.1, 73, 63.7, 43.2, 62.3, 59.2, 67.5, 68.2, 54.6, 67.9, 56.5, 
54.2, 67.3, 68, 68.4, 67.9, 73.3, 51.7, 50.3, 63.9, 73.9, 64, 
42.9, 62.5, 59.3, 66.7, 68.4, 54, 68.2, 56.8, 54.5, 67, 53.2, 
41.4, 53, 52.3, 41, 37.4, 56.9, 65.3, 36.2, 35.3, 36.1, 32.5, 
56.5, 47.7, 39.4, 59.6, 38.1, 24.2, 30.2, 68.5, 68.9, 70.7, 74.9, 
53.4, 51.6, 65.9, 75.7, 64.7, 42.8, 61.4, 60.8, 69.5, 68.7, 55.9, 
70.7, 59.5, 51.1, 69.5), G2 = c(79.8, 72.2, 73.5, 74.4, 50.4, 
54.8, 63.1, 70.4, 63.6, 45.1, 65.3, 49.4, 65.3, 76.2, 51, 63.9, 
58.7, 57.8, 67, 79.6, 72.1, 73.9, 74.7, 50.5, 55.1, 62.8, 70.5, 
63.3, 44.6, 65.5, 48.9, 64.9, 76.3, 50.6, 64.8, 58.6, 58.3, 67.4, 
51.2, 37.7, 49.1, 53.7, 44.6, 37.3, 54.9, 64.1, 33.8, 31.9, 34.2, 
30.3, 56.2, 44.6, 38.2, 63.2, 35.8, 26.5, 27.6, 80.6, 71.6, 75.4, 
77.1, 52.4, 56.3, 66, 72.3, 64.5, 38.2, 64.3, 49.2, 66.9, 77.1, 
52.4, 67.5, 59.6, 55.6, 69.9), S1 = c(75.1, 65.9, 72.7, 68.8, 
49, 57.5, 66.5, 74.1, 60.9, 51.8, 58, 64.3, 71.1, 71.4, 58.9, 
62.2, 58, 57.7, 58.6, 75.2, 66, 73.2, 69.7, 48.9, 57.7, 66.5, 
74.7, 60.8, 51.4, 58.9, 65.5, 70.5, 71.4, 58.9, 65.1, 60.8, 57.7, 
58.4, 54.3, 40.2, 52.6, 60.5, 42.6, 34.1, 55, 64.7, 36.3, 32.5, 
39, 38.8, 58.1, 48, 40.5, 61, 40, 26.4, 28.8, 76.4, 66.5, 73.9, 
72, 50.7, 59.2, 69.9, 76.3, 62.4, 50, 58.5, 66.6, 73.7, 72.3, 
62.6, 69.6, 62.7, 57.9, 61.1), S2 = c(76.6, 71.6, 71.2, 72.7, 
51.6, 56.7, 65.9, 73.5, 63.6, 55.2, 62.6, 62.2, 69.1, 71.1, 56.8, 
61, 61.7, 60, 55.7, 76.9, 71.6, 72.3, 73.2, 51.7, 56.8, 64.5, 
74.9, 63.6, 51.3, 63, 62.8, 68.7, 71.3, 56.8, 64.2, 62.8, 60.4, 
55.8, 53.6, 42.5, 50, 54.4, 42.2, 36.4, 57.7, 64.1, 35.1, 30.8, 
39.1, 37.4, 58.7, 47.8, 42, 58.8, 39.4, 24.2, 28.2, 78.2, 73.3, 
72.3, 75.6, 53.4, 57.8, 68.3, 76.6, 63.7, 51.7, 63.4, 63.3, 71.5, 
72.3, 60.2, 67.1, 65.5, 58.2, 59.1), Method = structure(c(4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Simple_2_ROI", 
"Single_ROI", "WIG_drawn_bg", "WIG_Method"), class = "factor")), .Names = 
c("Study", 
"G1", "G2", "S1", "S2", "Method"), row.names = c(NA, -76L), class = 
"data.frame") 

This shows the measurement results of 2 operators using 4 
slightly different analysis methods. The operators analyse each data 
file WCBPX twice - (G1,G2,S1,S2) and there are 4 methods 
(Single_ROI,Simple_2_ROI etc) 

What I would like to do is get the summary statistics from a Bland Altman (Mean 
vs Difference) plot for all 16 combinations. 

For example for G1 and G2, I can do the following 

ddply(df,.(Method),summarise,mean=mean(G1-G2, na.rm = TRUE), 
             sd=sd(G1-G2, na.rm = TRUE)) 

Eventually I want a data.frame with the format 
Var1 Var2 Mean  Sd Method 
G1   G2   -.67  5.2 Simple_2_ROI 
G1   G2   1.12  2.3 Single_ROI 
G1   G2   -1.08 4.8 WIG_drawn_bg 
G1   G2   -1.17 4.9 WIG_Method 
G1 G1 0 0 Simple_2_ROI 

Is there a simple way to achieve this structure? 


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


Re: [R] Merge with transposed matrix.

2013-07-18 Thread arun
Hi,

m1<- matrix(NA,5,5)
m1[upper.tri(m1)]<-c(2,3,8,4,9,14,5,10,15,20)
One way would be:
m1[lower.tri(m1)]<-t(m1)[lower.tri(t(m1))]
 m1
# [,1] [,2] [,3] [,4] [,5]
#[1,]   NA    2    3    4    5
#[2,]    2   NA    8    9   10
#[3,]    3    8   NA   14   15
#[4,]    4    9   14   NA   20
#[5,]    5   10   15   20   NA
A.K. 



Hello ! 

I would like to have some simple sintax in order to fill my matrix with its 
transposed. 
That is, as an example I have a correlation matrix like this, and the 
transposed one: 

> matrix 
          [,1]            [,2]         [,3]         [,4]         [,5]         
[1,]   NA             2               3              4           5         
[2,]   NA          NA              8              9          10         
[3,]   NA          NA           NA            14         15 
[4,]   NA          NA           NA           NA         20 
[5,]   NA          NA           NA           NA         NA 

> transposed.matrix<-t(matrix) 

          [,1]            [,2]         [,3]         [,4]         [,5] 
[1,]      NA         NA          NA          NA        NA 
[2,]       2            NA         NA          NA         NA 
[3,]       3             8            NA         NA          NA 
[4,]       4             9            14          NA          NA 
[5,]       5           10           15           20           NA 


And I would like to have 

          [,1]            [,2]         [,3]         [,4]          [,5] 
[1,]      NA           2               3              4             5   
[2,]       2            NA             8              9           10     
[3,]       3             8            NA            14          15 
[4,]       4             9            14            NA           20 
[5,]       5           10           15             20           NA 


Thank you very much for your help !!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] stopping functions with long execution times

2013-07-18 Thread Prof Brian Ripley

On 18/07/2013 10:37, ONKELINX, Thierry wrote:

Dear all,

I am running the same model on several datasets, each dataset is a different 
species. The problem is that for some datasets the model is not converging. 
Currently I have an INLA model running for 35 days and still no results. The 
process still uses near 100% of the CPU and less than 1 GB RAM on virtual 
Ubuntu box with 8 GB RAM on a blade server.

I can kill the process manual and make the script skip this model. However it 
would be more elegant if it was possible to automate this. E.g. let the model 
run but kill it automatically once it runs for more than 7 days. Once killed 
the model should throw an error so we can catch that in the error-handling.

Any suggestions on how to do this?


Learn how to use the R documentation.  ??limit gave me some useful hits, 
including to how I would do this.


However, as ?setTimeLimit points out, if this is running in C code, it 
cannot be interrupted from the R interpreter.  In that case, use 
separate processes and your OS facilities (man ulimit, for example).




Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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


And

'Asking on R-help is no substitute for doing your own homework'



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

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




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

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


Re: [R] 'save' method for S4 class

2013-07-18 Thread Martin Morgan

On 07/18/2013 03:47 AM, Simon Zehnder wrote:

Hi Christopher,

I think, that "save" is no generic function like "plot", "show", etc. So at 
first you have to determine a generic.

setGeneric("save", function(x, file_Path) standardGeneric("save"))


The implementation offered by Christofer shows write.table, and the end result 
is a text file rather than a binary file expected from base::save. This makes it 
seem inappropriate to use 'save' in this context.


Instead, it seems that what Cristofer wants to implement is functionality to 
support write.table. ?write.table says


 'write.table' prints its required argument 'x' (after converting
 it to a data frame if it is not one nor a matrix)

So implementing an S3 method

  as.data.frame.MyClass <-
  function(x, row.names=NULL, optional=FALSE, ...)
  {
  x@x
  }

is all that is needed, gaining lots of flexibility by re-using the code of 
write.table.


  myClass = new("MyClass", x=data.frame(x=1:3, y=3:1))
  write.table(myClass, stdout())

In the case of a 'save' method producing binary output (but this is what save 
does already...), I think it's better practice to promote the non-generic 'save' 
to an S4 generic using it's existing arguments; in this case it makes sense to 
restrict dispatch to '...', so


  setGeneric("save", signature="...")

The resulting generic is

> getGeneric("save")
standardGeneric for "save" defined from package ".GlobalEnv"

function (..., list = character(), file = stop("'file' must be specified"),
ascii = FALSE, version = NULL, envir = parent.frame(), compress = !ascii,
compression_level, eval.promises = TRUE, precheck = TRUE)
standardGeneric("save")

Methods may be defined for arguments: ...
Use  showMethods("save")  for currently available ones.

This means that a method might be defined as

  setMethod("save", "MyClass", function(..., list = character(),
  file = stop("'file' must be specified"), ascii = FALSE, version = NULL,
  envir = parent.frame(), compress = !ascii, compression_level,
  eval.promises = TRUE, precheck = TRUE)
  {
  ## check non-sensical or unsupported user input for 'MyClass'
  if (!is.null(version))
  stop("non-NULL 'version' not supported for 'MyClass'")
  ## ...
  ## implement save on MyClass
  })

It might be that Christofer wants to implement a 'write.table-like' (text 
output) or a 'save-like' (binary output) function that really does not conform 
to the behavior of write.table (e.g., producing output that could not be input 
by read.table) or save. Then I think the better approach is to implement 
writeMyClass (for text output) or saveMyClass (for binary output).


Martin



Now your definition via setMethod.


Best

Simon



On Jul 18, 2013, at 12:09 PM, Christofer Bogaso  
wrote:


Hello again,

I am trying to define the 'save' method for my S4 class as below:

setClass("MyClass", representation(
Slot1 = "data.frame"
))  

setMethod("save", "MyClass", definition = function(x, file_Path) {

write.table(x@Slot1, file = file_Path, append = FALSE, quote = 
TRUE,
sep = ",",
eol = "\n", na = "NA", dec = 
".", row.names = FALSE,
col.names = TRUE, qmethod = c("escape", 
"double"),
fileEncoding = "")
})

However while doing this I am getting following error:

Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
  in method for ‘save’ with signature ‘list="MyClass"’: formal
arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
version = "MyClass", envir = "MyClass", compress = "MyClass",
compression_level = "MyClass", eval.promises = "MyClass", precheck =
"MyClass") omitted in the method definition cannot be in the signature


Can somebody point me what will be the correct approach to define
'save' method for S4 class?

Thanks and regards,

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




--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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

Re: [R] stopping functions with long execution times

2013-07-18 Thread ONKELINX, Thierry
Hi Henrik,

That is exactly what I was looking for.

Thanks a lot.

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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


-Oorspronkelijk bericht-
Van: henrik.bengts...@gmail.com [mailto:henrik.bengts...@gmail.com] Namens 
Henrik Bengtsson
Verzonden: donderdag 18 juli 2013 12:43
Aan: ONKELINX, Thierry
CC: r-help@r-project.org
Onderwerp: Re: [R] stopping functions with long execution times

See evalWithTimeout() of R.utils, e.g.

tryCatch({
  evalWithTimeout({
slowFunction();
  }, timeout=7*24*3600);
}, TimeoutException=function(ex) {
  cat("Timeout. Skipping.\n");
})

help("evalWithTimeout") have more information and cross links.

/Henrik

On Thu, Jul 18, 2013 at 11:37 AM, ONKELINX, Thierry  
wrote:
> Dear all,
>
> I am running the same model on several datasets, each dataset is a different 
> species. The problem is that for some datasets the model is not converging. 
> Currently I have an INLA model running for 35 days and still no results. The 
> process still uses near 100% of the CPU and less than 1 GB RAM on virtual 
> Ubuntu box with 8 GB RAM on a blade server.
>
> I can kill the process manual and make the script skip this model. However it 
> would be more elegant if it was possible to automate this. E.g. let the model 
> run but kill it automatically once it runs for more than 7 days. Once killed 
> the model should throw an error so we can catch that in the error-handling.
>
> Any suggestions on how to do this?
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality
> Assurance Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> thierry.onkel...@inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than 
> asking him to perform a post-mortem examination: he may be able to say what 
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not 
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
>
> * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * *
> * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver 
> weer en binden het INBO onder geen enkel beding, zolang dit bericht niet 
> bevestigd is door een geldig ondertekend document.
> The views expressed in this message and any annex are purely those of the 
> writer and may not be regarded as stating an official position of INBO, as 
> long as the message is not confirmed by a duly signed document.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

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


Re: [R] 'save' method for S4 class

2013-07-18 Thread Simon Zehnder
Hi Christopher,

I think, that "save" is no generic function like "plot", "show", etc. So at 
first you have to determine a generic.

setGeneric("save", function(x, file_Path) standardGeneric("save"))

Now your definition via setMethod. 


Best

Simon



On Jul 18, 2013, at 12:09 PM, Christofer Bogaso  
wrote:

> Hello again,
> 
> I am trying to define the 'save' method for my S4 class as below:
> 
> setClass("MyClass", representation(
>   Slot1 = "data.frame"
>   ))  
>   
> setMethod("save", "MyClass", definition = function(x, file_Path) {
>   
>   write.table(x@Slot1, file = file_Path, append = FALSE, quote = 
> TRUE,
> sep = ",",
>   eol = "\n", na = "NA", dec = 
> ".", row.names = FALSE,
>   col.names = TRUE, qmethod = 
> c("escape", "double"),
>   fileEncoding = "")
>   })
> 
> However while doing this I am getting following error:
> 
> Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
>  in method for ‘save’ with signature ‘list="MyClass"’: formal
> arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
> version = "MyClass", envir = "MyClass", compress = "MyClass",
> compression_level = "MyClass", eval.promises = "MyClass", precheck =
> "MyClass") omitted in the method definition cannot be in the signature
> 
> 
> Can somebody point me what will be the correct approach to define
> 'save' method for S4 class?
> 
> Thanks and regards,
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] stopping functions with long execution times

2013-07-18 Thread Henrik Bengtsson
See evalWithTimeout() of R.utils, e.g.

tryCatch({
  evalWithTimeout({
slowFunction();
  }, timeout=7*24*3600);
}, TimeoutException=function(ex) {
  cat("Timeout. Skipping.\n");
})

help("evalWithTimeout") have more information and cross links.

/Henrik

On Thu, Jul 18, 2013 at 11:37 AM, ONKELINX, Thierry
 wrote:
> Dear all,
>
> I am running the same model on several datasets, each dataset is a different 
> species. The problem is that for some datasets the model is not converging. 
> Currently I have an INLA model running for 35 days and still no results. The 
> process still uses near 100% of the CPU and less than 1 GB RAM on virtual 
> Ubuntu box with 8 GB RAM on a blade server.
>
> I can kill the process manual and make the script skip this model. However it 
> would be more elegant if it was possible to automate this. E.g. let the model 
> run but kill it automatically once it runs for more than 7 days. Once killed 
> the model should throw an error so we can catch that in the error-handling.
>
> Any suggestions on how to do this?
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> thierry.onkel...@inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than 
> asking him to perform a post-mortem examination: he may be able to say what 
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not 
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
>
> * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
> en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd 
> is door een geldig ondertekend document.
> The views expressed in this message and any annex are purely those of the 
> writer and may not be regarded as stating an official position of INBO, as 
> long as the message is not confirmed by a duly signed document.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 'save' method for S4 class

2013-07-18 Thread Christofer Bogaso
Hello again,

I am trying to define the 'save' method for my S4 class as below:

setClass("MyClass", representation(
Slot1 = "data.frame"
))  

setMethod("save", "MyClass", definition = function(x, file_Path) {

write.table(x@Slot1, file = file_Path, append = FALSE, quote = 
TRUE,
sep = ",",
eol = "\n", na = "NA", dec = 
".", row.names = FALSE,
col.names = TRUE, qmethod = 
c("escape", "double"),
fileEncoding = "")
})

However while doing this I am getting following error:

Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
  in method for ‘save’ with signature ‘list="MyClass"’: formal
arguments (list = "MyClass", file = "MyClass", ascii = "MyClass",
version = "MyClass", envir = "MyClass", compress = "MyClass",
compression_level = "MyClass", eval.promises = "MyClass", precheck =
"MyClass") omitted in the method definition cannot be in the signature


Can somebody point me what will be the correct approach to define
'save' method for S4 class?

Thanks and regards,

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

2013-07-18 Thread alfonso . carfora

Maybe you can use "round" and "trunc" functions

For example if you have a vector like this:


x<- c(3.000 3.125 3.250 3.375 3.500 3.625 3.750 3.875 4.000)

and you want to round the numbers to 2 decimals you can use:


round(x,2)

[1] 3.00 3.12 3.25 3.38 3.50 3.62 3.75 3.88 4.00


if you want a numeric vector containing the integers formed by  
truncating the values in x



trunc(x)

[1] 3 3 3 3 3 3 3 3 4

I'hope it'is useful to you
A.C.




Def. Quota Rui Barradas :


Hello,

As for truncation, you can write a one line function:

dec_trunc <- function(x, digits = 0) trunc(x * 10^digits)/10^digits


As for approximation, maybe you're looking for ?signif.

Hope this helps,

Rui Barradas

Em 17-07-2013 18:41, Francesco Miranda escreveu:
What is the function to do the truncation to a certain decimal  
digit of a number. And the function approximation?

Thanks.
Francesco M
[[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.





**  
IL MERITO DEGLI STUDENTI VIENE RICONOSCIUTO

Il 5 per mille all'Universita' degli Studi di Napoli "Parthenope" incrementa le 
borse di studio agli studenti - codice fiscale 80018240632
http://www.uniparthenope.it/index.php/5xmille 


http://www.uniparthenope.it/index.php/it/avvisi-sito-di-ateneo/2943-la-parthenope-premia-il-tuo-voto-di-diploma-ed-il-tuo-imegno-con-i-proventi-del-5-per-mille

Questa informativa e' inserita in automatico dal sistema al fine esclusivo 
della realizzazione dei fini istituzionali dell'ente.

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

2013-07-18 Thread Pascal Oettli
Please reply to the list. You will have more chance to get an answer.

Pascal


2013/7/18 G Girija 

> Hi,
>
> Many thanks for your hint. Yes I made a mistake there.
>
> Also could you *please* help me in rectifying the following also?
>
> I am not able to ‘extract variance and covariance’
>
> As mentioned, there are 5 stocks and changed the code [
> http://www.forecastingfinancialrisk.com/3.html] as follows:
>
> > S<-cov(returns)
>
> > S
>
>  V1   V2   V3   V4   V5
>
> V1 0.0004951526 0.0001256519 0.0001651016 0.0003024310 0.0003516796
>
> V2 0.0001256519 0.0008076471 0.0001251208 0.0002005305 0.0002347568
>
> V3 0.0001651016 0.0001251208 0.001707 0.0003158028 0.0003682633
>
> V4 0.0003024310 0.0002005305 0.0003158028 0.0011405561 0.0008442661
>
> V5 0.0003516796 0.0002347568 0.0003682633 0.0008442661 0.0018536153
>
>
>
> > EWMA[1,]<-c(S)[c(1,10,5)]
>
> > a=t(as.numeric(returns$i)) %*% as.numeric(returns$i) ---*Here we need
>   
>  
> to change dataframe to numeric, that too only columns.*
>
> > str(a)
>
>  num [1, 1] 0
>
> > dim(a)
>
> [1] 1 1
>
> > dim(lambda*S)
>
>  [1] 5 5   -*As the dimensions are not same we can not do
> ‘%*%’*
>
> > dim((1-lambda)*a)
>
> [1] 1 1
>
>  for(i in 2:T)
>
> {
>
>   S<- lambda*S+ (1-lambda)*t(returns$i) %*% returns$i
>
>   EWMA[i,]=c(S)[c(1,4,2)]
>
> }
>
>
>
> *Original code as per* http://www.forecastingfinancialrisk.com/3.html is
>
> EWMA = *matrix*(*nrow*=T,*ncol*=3)   *# create a matrix to hold the 
> covariance matrix for each t*
>
> lambda = 0.94
>
> S = *cov*(y) *# initial (t=1) covariance matrix*
>
> EWMA[1,] = *c*(S)[*c*(1,4,2)]  *# extract the variances and covariance*
>
> *for* (i *in* 2:T){*# loop though the sample*
>
>  S = lambda * S  + (1-lambda) * *t*(y[i]) %*% y[i]
>
>  EWMA[i,] = *c*(S)[*c*(1,4,2)]  *# convert matrix to vector *
>
> }
>
>
>
> On Thu, Jul 18, 2013 at 5:54 AM, Pascal Oettli  wrote:
>
>> Hello,
>>
>> 1) In the provided example, you have 2 stock returns and
>>
>> > EWMA = matrix(nrow=T, ncol=3)
>>
>> See the number of columns (2+1)
>> Please modify the number of columns according to the number of stock
>> returns.
>>
>> 2) As you have 5 stock returns, the following cannot work
>>
>> > EWMA[1,] = c(S)[c(1,4,2)]
>>
>> You have to modify this part too.
>>
>>
>> 3) Do the same modification within the loop.
>>
>> Regards,
>> Pascal
>>
>>
>>
>> 2013/7/18 G Girija 
>>
>>> hi,
>>>
>>> Could anyone help me in solving the following error:
>>> I have 5 stocks returns data (returns)
>>>
>>> EWMA = matrix(nrow=T,ncol=5)  # create a matrix to hold
>>> the
>>> covariance matrix for each t
>>>
>>> lambda = 0.94
>>> S<-cov(returns) # initial (t=1)
>>> covariance matrix
>>> EWMA[1,] = c(S)[c(1,4,2)]  ---ERROR# extract the
>>> variances and covariancefor (i in 2:T)
>>>
>>>
>>>{# loop though the sample
>>> S<- lambda*S+(1-lambda)*t(returns[i])%*%returns[i]
>>> EWMA[i,] = c(S)[c(1,4,2)]   # convert matrix to vector
>>>}
>>>
>>> *ERROR as follows:*
>>>
>>> *> EWMA[1,]<-c(S)[c(1,4,2)]*
>>> *Error in EWMA[1, ] <- c(S)[c(1, 4, 2)] : *
>>> *  number of items to replace is not a multiple of replacement length*
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>

[[alternative HTML version deleted]]

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


[R] stopping functions with long execution times

2013-07-18 Thread ONKELINX, Thierry
Dear all,

I am running the same model on several datasets, each dataset is a different 
species. The problem is that for some datasets the model is not converging. 
Currently I have an INLA model running for 35 days and still no results. The 
process still uses near 100% of the CPU and less than 1 GB RAM on virtual 
Ubuntu box with 8 GB RAM on a blade server.

I can kill the process manual and make the script skip this model. However it 
would be more elegant if it was possible to automate this. E.g. let the model 
run but kill it automatically once it runs for more than 7 days. Once killed 
the model should throw an error so we can catch that in the error-handling.

Any suggestions on how to do this?

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

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

The plural of anecdote is not data.
~ Roger Brinner

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


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

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


[R] Finding All paths in a graph

2013-07-18 Thread Azam Peyvand
Hi,
Do you know any function/package in R which returns all possible paths in a
graph.

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.