Re: [R] concurvity

2017-02-27 Thread Bert Gunter
Eva:

Yours is a statistical question, which is generally off topic here.
While you may get a reply, I think you would do better to post on a
statistics list like stats.stackexchange.com. Even better, I think,
would be to consult a local statistical expert, as it sounds like you
are fairly confused about the "concurvity" issues and may need a 1-1
discussion about what is appropriate in your application context.

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Feb 27, 2017 at 1:27 PM, Eva Maria Leunissen
 wrote:
> Hi, I'm using the concurvity function to check for concurvity in my model.
> The output I get when comparing to the rest of the model (ie full=TRUE)
>  many of the variables have concurvity values higher than 0.9. However when
> comparing the terms pairwise most values are very small, less than 0.1
> (with the worst around 0.5). I am not sure where to go from here, should
> the full model output be cause for concern and should I refit the model
> eliminating some terms with high concurvity? or are the pairwise
> concurvities more informative?
> is there anything else I can do? The terms in the model are mostly
> interactions, with a few smooths and one parametric term.
>
> Thanks in advance
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] order.by requires an appropriate time-based object

2017-02-27 Thread Allan Tanaka
Jesus!! even a small mistake like that can make me a headache.Thanks, this 
works like charm :) :) 

On Tuesday, 28 February 2017, 4:12, Joshua Ulrich  
wrote:
 

 On Sun, Feb 26, 2017 at 11:37 PM, Allan Tanaka  wrote:
> Here is the screenshoot to show what's happening entirely
>
>
>
> On Monday, 27 February 2017, 12:23, Allan Tanaka 
> wrote:
>
>
> See attached for updated R script
>
>
> On Monday, 27 February 2017, 12:22, Allan Tanaka 
> wrote:
>
>
> I have converted the data into as.Date but then the dates itself (containing
> the data[,1]) have NA value. Even after removing NA values by this
> particular code:
> ag.direction.returns[1] <- 0

Your dates have NA values because you specified the format incorrectly
in your call to as.Date().  Despite the column names, the format is
"MM.DD.", not "DD.MM.".

R> head(data)
  DD.MM.      O      H      L      C
1  3/26/2009 132.63 133.90 132.33 133.70
2  3/27/2009 133.69 133.86 129.35 130.09
3  3/30/2009 129.75 130.55 126.40 128.65
4  3/31/2009 128.64 131.87 128.22 130.95
5  4/1/2009 130.94 131.89 129.86 130.54
6  4/2/2009 130.55 134.23 130.29 134.16

Additionally, 'src' and 'dateFormat' are not arguments to as.Date(),
so they're unnecessary.  Your as.Date() call should be:
dates <- as.Date(data[,1], format="%m/%d/%Y")


> it's still containing NA values, that won't be allowedwhen i try to merge
> xts in this particular code:
> both.curves <- cbind(ag.curve, buy.hold.curve)
>
>
>> both.curves <- cbind(ag.curve, buy.hold.curve)
> nan, nan
> Error in merge.xts(..., all = all, fill = fill, suffixes = suffixes) :
>  'NA' not allowed in 'index'
>
>
>
>
>
> On Monday, 27 February 2017, 12:05, Joshua Ulrich 
> wrote:
>
>
> Please provide a minimal, reproducible example.  It's really hard for
> someone to help you if you give them nearly 100 lines of code and no
> data.  My guess is that data[,1] is character (or factor) and you need
> to convert it to Date or POSIXct.
>
> On Sun, Feb 26, 2017 at 9:24 AM, Allan Tanaka 
> wrote:
>> HiNot sure why i get error like this: Error in xts(forecasts,
>> dates[(window.length):length(returns)]) :  order.by requires an appropriate
>> time-based object
>> I have researched for the answer that i need to convert returns into time
>> series. I did that but still it doesn't work?See attached for file.Thanks
>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Joshua Ulrich  |  about.me/joshuaulrich
> FOSS Trading  |  www.fosstrading.com
> R/Finance 2017 | www.rinfinance.com
>
>
>
>
>
>
>



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2017 | www.rinfinance.com


   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] concurvity

2017-02-27 Thread Eva Maria Leunissen
Hi, I'm using the concurvity function to check for concurvity in my model.
The output I get when comparing to the rest of the model (ie full=TRUE)
 many of the variables have concurvity values higher than 0.9. However when
comparing the terms pairwise most values are very small, less than 0.1
(with the worst around 0.5). I am not sure where to go from here, should
the full model output be cause for concern and should I refit the model
eliminating some terms with high concurvity? or are the pairwise
concurvities more informative?
is there anything else I can do? The terms in the model are mostly
interactions, with a few smooths and one parametric term.

Thanks in advance

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [FORGED] if and

2017-02-27 Thread Jeff Newmiller
Really? That seems unlikely, given that

* = is used for moving values, not comparing them,

* - is not a legal symbol for a variable name, it is subtraction, and 
year-month can hardly end up as a character string like "FEB2015"

* (possible problem) & and | compare vectors one at a time, so are not 
generally recommended for use in "if", but are more commonly used in the 
"ifelse" function. 

These points are all discussed in the Introduction to R document that comes 
with R.
-- 
Sent from my phone. Please excuse my brevity.

On February 27, 2017 7:02:29 PM PST, Val  wrote:
>Thank you  Rolf and Bert!
>
>I found the problem and this
>
>if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
>has be changed  to  this
>if(country="USA" & year-month == "FEB2015" | year-month == "FEB2012" ){
>
>On Mon, Feb 27, 2017 at 8:45 PM, Bert Gunter 
>wrote:
>
>> I note that you have "Year-month" (capital 'Y') and "year-month" in
>> your code; case matters in R.
>>
>> Otherwise, Rolf's advice applies.
>>
>> Cheers,
>> Bert
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming
>along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Mon, Feb 27, 2017 at 6:16 PM, Rolf Turner
>
>> wrote:
>> > On 28/02/17 14:47, Val wrote:
>> >>
>> >> Currently I have  about  six or more  scripts that do the same
>job.  I
>> >> thought it might be possible and more efficient to use one script
>by
>> using
>> >> IF ELSE statements. Here is an example but this will be expandable
>for
>> >> several countries ans year-months
>> >>
>> >>
>> >> Year-month = FEB2015, FEB2012,  Feb2010
>> >>  country  = USA, CAN.MEX
>> >> First I want to do if country = USA and year-month = FEB2015,
>FEB2012 do
>> >> the statements
>> >> second if country = CAN and year-month =Feb2010 do  the statements
>> >>
>> >>
>> >> if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
>> >> statemnt1
>> >> .
>> >> statemnt10
>> >>
>> >> } else if (country="USA" & year-month ="FEB2015") {
>> >> statemnt1
>> >> .
>> >> statemnt10
>> >> }
>> >>
>> >> else
>> >> {
>> >> statemnt1
>> >> .
>> >> statemnt10
>> >> }
>> >>
>> >> The above script did not work. is there a different ways of doing
>it?
>> >
>> >
>> > Uh, yes.  Get the syntax right.  Use R, when you are using R.
>> >
>> > Looking at ?Syntax and ?Logic might help you a bit.
>> >
>> > Other than that, there's not much that one can say without seeing a
>> > reproducible example.  And if you sat down and wrote out a
>*reproducible
>> > example*, using correct R syntax, you probably wouldn't need any
>> assistance
>> > from R-help.
>> >
>> > Have you read any of the readily available R tutorials?  If not do
>so. If
>> > so, read them again and actually take note of what they say!
>> >
>> > cheers,
>> >
>> > Rolf Turner
>> >
>> > --
>> > Technical Editor ANZJS
>> > Department of Statistics
>> > University of Auckland
>> > Phone: +64-9-373-7599 ext. 88276
>> >
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [FORGED] if and

2017-02-27 Thread Val
Thank you  Rolf and Bert!

I found the problem and this

if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
has be changed  to  this
if(country="USA" & year-month == "FEB2015" | year-month == "FEB2012" ){

On Mon, Feb 27, 2017 at 8:45 PM, Bert Gunter  wrote:

> I note that you have "Year-month" (capital 'Y') and "year-month" in
> your code; case matters in R.
>
> Otherwise, Rolf's advice applies.
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Mon, Feb 27, 2017 at 6:16 PM, Rolf Turner 
> wrote:
> > On 28/02/17 14:47, Val wrote:
> >>
> >> Currently I have  about  six or more  scripts that do the same job.  I
> >> thought it might be possible and more efficient to use one script by
> using
> >> IF ELSE statements. Here is an example but this will be expandable for
> >> several countries ans year-months
> >>
> >>
> >> Year-month = FEB2015, FEB2012,  Feb2010
> >>  country  = USA, CAN.MEX
> >> First I want to do if country = USA and year-month = FEB2015, FEB2012 do
> >> the statements
> >> second if country = CAN and year-month =Feb2010 do  the statements
> >>
> >>
> >> if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
> >> statemnt1
> >> .
> >> statemnt10
> >>
> >> } else if (country="USA" & year-month ="FEB2015") {
> >> statemnt1
> >> .
> >> statemnt10
> >> }
> >>
> >> else
> >> {
> >> statemnt1
> >> .
> >> statemnt10
> >> }
> >>
> >> The above script did not work. is there a different ways of doing it?
> >
> >
> > Uh, yes.  Get the syntax right.  Use R, when you are using R.
> >
> > Looking at ?Syntax and ?Logic might help you a bit.
> >
> > Other than that, there's not much that one can say without seeing a
> > reproducible example.  And if you sat down and wrote out a *reproducible
> > example*, using correct R syntax, you probably wouldn't need any
> assistance
> > from R-help.
> >
> > Have you read any of the readily available R tutorials?  If not do so. If
> > so, read them again and actually take note of what they say!
> >
> > cheers,
> >
> > Rolf Turner
> >
> > --
> > Technical Editor ANZJS
> > Department of Statistics
> > University of Auckland
> > Phone: +64-9-373-7599 ext. 88276
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [FORGED] if and

2017-02-27 Thread Bert Gunter
I note that you have "Year-month" (capital 'Y') and "year-month" in
your code; case matters in R.

Otherwise, Rolf's advice applies.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Feb 27, 2017 at 6:16 PM, Rolf Turner  wrote:
> On 28/02/17 14:47, Val wrote:
>>
>> Currently I have  about  six or more  scripts that do the same job.  I
>> thought it might be possible and more efficient to use one script by using
>> IF ELSE statements. Here is an example but this will be expandable for
>> several countries ans year-months
>>
>>
>> Year-month = FEB2015, FEB2012,  Feb2010
>>  country  = USA, CAN.MEX
>> First I want to do if country = USA and year-month = FEB2015, FEB2012 do
>> the statements
>> second if country = CAN and year-month =Feb2010 do  the statements
>>
>>
>> if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
>> statemnt1
>> .
>> statemnt10
>>
>> } else if (country="USA" & year-month ="FEB2015") {
>> statemnt1
>> .
>> statemnt10
>> }
>>
>> else
>> {
>> statemnt1
>> .
>> statemnt10
>> }
>>
>> The above script did not work. is there a different ways of doing it?
>
>
> Uh, yes.  Get the syntax right.  Use R, when you are using R.
>
> Looking at ?Syntax and ?Logic might help you a bit.
>
> Other than that, there's not much that one can say without seeing a
> reproducible example.  And if you sat down and wrote out a *reproducible
> example*, using correct R syntax, you probably wouldn't need any assistance
> from R-help.
>
> Have you read any of the readily available R tutorials?  If not do so. If
> so, read them again and actually take note of what they say!
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [FORGED] if and

2017-02-27 Thread Rolf Turner

On 28/02/17 14:47, Val wrote:

Currently I have  about  six or more  scripts that do the same job.  I
thought it might be possible and more efficient to use one script by using
IF ELSE statements. Here is an example but this will be expandable for
several countries ans year-months


Year-month = FEB2015, FEB2012,  Feb2010
 country  = USA, CAN.MEX
First I want to do if country = USA and year-month = FEB2015, FEB2012 do
the statements
second if country = CAN and year-month =Feb2010 do  the statements


if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
statemnt1
.
statemnt10

} else if (country="USA" & year-month ="FEB2015") {
statemnt1
.
statemnt10
}

else
{
statemnt1
.
statemnt10
}

The above script did not work. is there a different ways of doing it?


Uh, yes.  Get the syntax right.  Use R, when you are using R.

Looking at ?Syntax and ?Logic might help you a bit.

Other than that, there's not much that one can say without seeing a 
reproducible example.  And if you sat down and wrote out a *reproducible 
example*, using correct R syntax, you probably wouldn't need any 
assistance from R-help.


Have you read any of the readily available R tutorials?  If not do so. 
If so, read them again and actually take note of what they say!


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] if and

2017-02-27 Thread Val
Currently I have  about  six or more  scripts that do the same job.  I
thought it might be possible and more efficient to use one script by using
IF ELSE statements. Here is an example but this will be expandable for
several countries ans year-months


Year-month = FEB2015, FEB2012,  Feb2010
 country  = USA, CAN.MEX
First I want to do if country = USA and year-month = FEB2015, FEB2012 do
the statements
second if country = CAN and year-month =Feb2010 do  the statements


if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
statemnt1
.
statemnt10

} else if (country="USA" & year-month ="FEB2015") {
statemnt1
.
statemnt10
}

else
{
statemnt1
.
statemnt10
}

The above script did not work. is there a different ways of doing it?

Thank you in advance
.

[[alternative HTML version deleted]]

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


Re: [R] plotting dates in x axis

2017-02-27 Thread Jeff Newmiller
While humorous, the term "Mexican Wall" is unlikely to be clear to the OP. This 
is a reference to the mailing list anti-virus strategy of cutting out 
attachments that don't meet a very restrictive set of requirements outlined in 
the Posting Guide that all R-users are supposed to have read and memorized, but 
which few even seem to know exists. You can best avoid the "Mexican Wall" by 
setting your email program to send plain text instead of HTML, and to embed 
your R code example (believe it or not, this is not the Excel-To-R translation 
service, so show us your R code and text data, not your Excel file) in the 
email along with your description of your problem. For more help on getting 
help search the Internet for "R reproducible example".
-- 
Sent from my phone. Please excuse my brevity.

On February 27, 2017 1:11:05 PM PST, Jim Lemon  wrote:
>Hi Maria,
>First, Excel files don't make it through the Mexican Wall. A CSV with
>the extension changed to .txt might. You can get all of the years like
>this:
>
>aa<-data.frame(var1=runif(180),
> SDATE=paste(sample(1998:2012,180,TRUE),
> sample(1:12,180,TRUE),sample(1:28,180,TRUE),sep="-"))
>aa$sdate<-as.Date(aa$SDATE)
>plot(aa$sdate,aa$var1,xaxt="n")
>library(plotrix)
># set the tick marks at the middle of each year
>axis.dates<-as.Date(paste(1998:2012,6,30,sep="-"))
>staxlab(1,axis.dates,1998:2012,nlines=3)
>
>Obviously you don't want all of the months, so just add the months to
>the years:
>
>plot(aa$sdate,aa$var1,xaxt="n")
>staxlab(1,axis.dates,format(axis.dates,"%b/%Y"),nlines=3)
>
>Jim
>
>
>On Tue, Feb 28, 2017 at 2:26 AM, Maria Lathouri via R-help
> wrote:
>> Dear all,
>> I have an excel file of 180 observations with dates and one variable,
>from 1998 to 2012 by random months (there are some years that I might
>not have all the months or I might have two observations in one month).
>I am trying to plot the dates in x axis and the variable in y axis. I
>have already used as.Date for the dates so I can import them into R.
>> Here is my script:> aa<-read.csv("aa.csv")> attach(aa)>
>names(aa)#"SDATE" "var1"
>> I convert the dates into R: > sdate<-as.Date(SDATE,
>format="%Y-%m-%d")
>>
>> I am plotting the dates with my var1:> plot(sdate, var1, type="l")
>> Up to now, everything seems ok. However, in the x-axis I only get
>three years, 2000, 2005 and 2010. As I want to show all the years or at
>least as many as it could be, I am using the following:
>>> plot(sdate, var1, type="l", xaxt="n")
>>
>>> d1<-c((sdate[1]), (sdate[183]))> d2<-as.Date((d1[1])+365*(0:15))
>>> axis(side=1, at=0:15, labels=strftime(d2, format="%Y"),
>cex.axis=0.8,las=2);  I tried also to plot the dates in a month-Year
>form:
>>
>>> d2<-as.Date((d1[1])+150*(0:20))
>>> plot(sdate, var1, type="l", xaxt="n")> axis(side=1, at=0:15,
>labels=strftime(d2, format="%m-%Y"), cex.axis=0.8,las=2)
>>
>> But nothing happened. I cannot understand why it doesn't show
>anything.
>> I have attached the file as well in case you want to have a more
>clear picture.
>> I really appreciate it if you can help me on this.
>> Thank you very much in advance.
>> Kind regards,Maria
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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: [ESS] Ess in emacs on mac

2017-02-27 Thread Lionel Henry
It is implicit when you use an IDE that it will change the environment.
Just like we are not giving any warning that the search path is altered
by ESS or that we are pre-processing any input the user supplies.

The number of users who care about these options is probably very small.
I myself have no idea what they are for. At the minimum, we should have
an `inferior-ess-silent-init` option set to `t` by default.

Lionel


> On 27 févr. 2017, at 22:23, Martin Maechler  
> wrote:
> 
> On Mon, Feb 27, 2017 at 7:04 PM, Vitalie Spinu  > wrote:
>> 
>> I would agree with that. I think it's pretty safe to make that silent.
> 
> I don't think that safety is the issue here.  Rather "transparency".
> If ESS changes relatively important  options()  in R, as an R user I'd
> rather like to notice.   So this was visibly quite on purpose.
> 
> Martin
> 
>> 
 On Mon, Feb 27 2017 13:54, Lionel Henry wrote:
>> 
>>> Hi Luping,
>> 
>>> This is normal and part of ESS initialisation, but it has always
>>> bugged me as well. I think we should make this output silent.
>> 
>>> Lionel
>> 
 On 27 févr. 2017, at 10:10, Luping Zhang  wrote:
 
 To whom may concern
 Sorry for bothering you. But I have a question about ESS.
 When typing the command “M-x R RET” in mini buffer, I can
 go in R, as the following picture shows. However, there is always
 an information: “if (identical (getOption)…” pops up. I am not sure
 this is normal when using ESS in emacs. Could you explain for me
 why this information always shows, and how can I avoid this. By the way,
 My configuration in emacs initial file is
 ( use-package ess-site
 :ensure ess
 :init
 (setq inferior-R-program-name “/usr/local/bin/R)
 (setq ess-ask-for-ess-directory nil))
 
 Thanks again, long for hear from you
 
 Greetings from Nanjing China
 
 Luping
 __
 ESS-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/ess-help
>> 
>>> __
>>> ESS-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/ess-help
>> 
>> __
>> ESS-help@r-project.org  mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help 
>> 

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: [ESS] Ess in emacs on mac

2017-02-27 Thread Martin Maechler
On Mon, Feb 27, 2017 at 7:04 PM, Vitalie Spinu  wrote:
>
> I would agree with that. I think it's pretty safe to make that silent.

I don't think that safety is the issue here.  Rather "transparency".
If ESS changes relatively important  options()  in R, as an R user I'd
rather like to notice.   So this was visibly quite on purpose.

Martin

>
>>> On Mon, Feb 27 2017 13:54, Lionel Henry wrote:
>
>> Hi Luping,
>
>> This is normal and part of ESS initialisation, but it has always
>> bugged me as well. I think we should make this output silent.
>
>> Lionel
>
>>> On 27 févr. 2017, at 10:10, Luping Zhang  wrote:
>>>
>>> To whom may concern
>>> Sorry for bothering you. But I have a question about ESS.
>>> When typing the command “M-x R RET” in mini buffer, I can
>>> go in R, as the following picture shows. However, there is always
>>> an information: “if (identical (getOption)…” pops up. I am not sure
>>> this is normal when using ESS in emacs. Could you explain for me
>>> why this information always shows, and how can I avoid this. By the way,
>>> My configuration in emacs initial file is
>>> ( use-package ess-site
>>>  :ensure ess
>>>  :init
>>>  (setq inferior-R-program-name “/usr/local/bin/R)
>>>  (setq ess-ask-for-ess-directory nil))
>>>
>>> Thanks again, long for hear from you
>>>
>>> Greetings from Nanjing China
>>>
>>> Luping
>>> __
>>> ESS-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/ess-help
>
>> __
>> ESS-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: [R] order.by requires an appropriate time-based object

2017-02-27 Thread Joshua Ulrich
On Sun, Feb 26, 2017 at 11:37 PM, Allan Tanaka  wrote:
> Here is the screenshoot to show what's happening entirely
>
>
>
> On Monday, 27 February 2017, 12:23, Allan Tanaka 
> wrote:
>
>
> See attached for updated R script
>
>
> On Monday, 27 February 2017, 12:22, Allan Tanaka 
> wrote:
>
>
> I have converted the data into as.Date but then the dates itself (containing
> the data[,1]) have NA value. Even after removing NA values by this
> particular code:
> ag.direction.returns[1] <- 0

Your dates have NA values because you specified the format incorrectly
in your call to as.Date().  Despite the column names, the format is
"MM.DD.", not "DD.MM.".

R> head(data)
  DD.MM.  O  H  L  C
1  3/26/2009 132.63 133.90 132.33 133.70
2  3/27/2009 133.69 133.86 129.35 130.09
3  3/30/2009 129.75 130.55 126.40 128.65
4  3/31/2009 128.64 131.87 128.22 130.95
5   4/1/2009 130.94 131.89 129.86 130.54
6   4/2/2009 130.55 134.23 130.29 134.16

Additionally, 'src' and 'dateFormat' are not arguments to as.Date(),
so they're unnecessary.  Your as.Date() call should be:
dates <- as.Date(data[,1], format="%m/%d/%Y")


> it's still containing NA values, that won't be allowedwhen i try to merge
> xts in this particular code:
> both.curves <- cbind(ag.curve, buy.hold.curve)
>
>
>> both.curves <- cbind(ag.curve, buy.hold.curve)
> nan, nan
> Error in merge.xts(..., all = all, fill = fill, suffixes = suffixes) :
>   'NA' not allowed in 'index'
>
>
>
>
>
> On Monday, 27 February 2017, 12:05, Joshua Ulrich 
> wrote:
>
>
> Please provide a minimal, reproducible example.  It's really hard for
> someone to help you if you give them nearly 100 lines of code and no
> data.  My guess is that data[,1] is character (or factor) and you need
> to convert it to Date or POSIXct.
>
> On Sun, Feb 26, 2017 at 9:24 AM, Allan Tanaka 
> wrote:
>> HiNot sure why i get error like this: Error in xts(forecasts,
>> dates[(window.length):length(returns)]) :  order.by requires an appropriate
>> time-based object
>> I have researched for the answer that i need to convert returns into time
>> series. I did that but still it doesn't work?See attached for file.Thanks
>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Joshua Ulrich  |  about.me/joshuaulrich
> FOSS Trading  |  www.fosstrading.com
> R/Finance 2017 | www.rinfinance.com
>
>
>
>
>
>
>



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2017 | www.rinfinance.com

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


Re: [R] plotting dates in x axis

2017-02-27 Thread Jim Lemon
Hi Maria,
First, Excel files don't make it through the Mexican Wall. A CSV with
the extension changed to .txt might. You can get all of the years like
this:

aa<-data.frame(var1=runif(180),
 SDATE=paste(sample(1998:2012,180,TRUE),
 sample(1:12,180,TRUE),sample(1:28,180,TRUE),sep="-"))
aa$sdate<-as.Date(aa$SDATE)
plot(aa$sdate,aa$var1,xaxt="n")
library(plotrix)
# set the tick marks at the middle of each year
axis.dates<-as.Date(paste(1998:2012,6,30,sep="-"))
staxlab(1,axis.dates,1998:2012,nlines=3)

Obviously you don't want all of the months, so just add the months to the years:

plot(aa$sdate,aa$var1,xaxt="n")
staxlab(1,axis.dates,format(axis.dates,"%b/%Y"),nlines=3)

Jim


On Tue, Feb 28, 2017 at 2:26 AM, Maria Lathouri via R-help
 wrote:
> Dear all,
> I have an excel file of 180 observations with dates and one variable, from 
> 1998 to 2012 by random months (there are some years that I might not have all 
> the months or I might have two observations in one month). I am trying to 
> plot the dates in x axis and the variable in y axis. I have already used 
> as.Date for the dates so I can import them into R.
> Here is my script:> aa<-read.csv("aa.csv")> attach(aa)> names(aa)#"SDATE" 
> "var1"
> I convert the dates into R: > sdate<-as.Date(SDATE, format="%Y-%m-%d")
>
> I am plotting the dates with my var1:> plot(sdate, var1, type="l")
> Up to now, everything seems ok. However, in the x-axis I only get three 
> years, 2000, 2005 and 2010. As I want to show all the years or at least as 
> many as it could be, I am using the following:
>> plot(sdate, var1, type="l", xaxt="n")
>
>> d1<-c((sdate[1]), (sdate[183]))> d2<-as.Date((d1[1])+365*(0:15))
>> axis(side=1, at=0:15, labels=strftime(d2, format="%Y"), cex.axis=0.8,las=2); 
>>  I tried also to plot the dates in a month-Year form:
>
>> d2<-as.Date((d1[1])+150*(0:20))
>> plot(sdate, var1, type="l", xaxt="n")> axis(side=1, at=0:15, 
>> labels=strftime(d2, format="%m-%Y"), cex.axis=0.8,las=2)
>
> But nothing happened. I cannot understand why it doesn't show anything.
> I have attached the file as well in case you want to have a more clear 
> picture.
> I really appreciate it if you can help me on this.
> Thank you very much in advance.
> Kind regards,Maria
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Metafor multilevel metaregression: total variance increases when moderator added?

2017-02-27 Thread Duncan, Laura
Hi there,

I am running a two level multilevel meta-regression of 170 estimates nested 
within 3 informants nested within 26 studies. I run the null model to get a 
pooled estimate with random effects at the informant level and study level.

Then I test a series of potential moderators (one at a time, given small number 
of studies and adjust p-values for multiple testing). I use:
(sum(Model1$sigma2) - sum(Model2$sigma2)) / sum(Model1$sigma2)
to compute the proportional reduction in the total variance from here:
http://stackoverflow.com/questions/22356450/getting-r-squared-from-a-mixed-effects-multilevel-model-in-metafor

For one moderator, I get a negative value for reduced total variance and an 
unexpected negative coefficient. Based on Wolfgang's response in the link above 
this is possible "depending on the size of your dataset, those variance 
components may not be estimated very precisely and that can lead to such 
counter-intuitive results".

I am trying to diagnose why this model is not being estimated properly and why 
I am getting an unexpected negative result. When I remove the second level from 
the model and run a single-level random effects models of 170 estimates nested 
within 26 studies, the coefficient is positive and as we would expect.

Does anyone have any suggestions for what might be going on or how I might 
diagnose the problem with this model?

Thanks,
Laura

Laura Duncan, M.A.
Research Coordinator
Offord Centre for Child Studies
McMaster University

Tel: 905 525 9140 x21504
Fax: 905 574 6665
dunca...@mcmaster.ca
ontariochildhealthstudy.ca
offordcentre.com

Mailing Address   Courier Address
1280 Main St. W. MIP 201A   175 Longwood Rd. S. MIP 201A
Hamilton, Ontario L8S 4K1 Hamilton, Ontario L8P 0A1


[[alternative HTML version deleted]]

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


[R] Help with GENETICS package

2017-02-27 Thread Giulia Valvassori
Dear all,

I am writing you this email because i need your help and I will really
appreciate if you can dedicate some minutes of your time in helping me.

I'm trying to use the R genetics package for a Linkage Disequilibrium
analysis of data matrix obtained from a RADseq protocol (Stacks software).
After several filtration steps, i'm currently working on a matrix of
approximately 3000 SNPs (100 samples). I'm having some issues in
understanding which type of input file should i run. I have found something
related to the genlight format but i really don't understand how can i
convert my genepop file into this new format.

Can anyone please tell me if i'm working on the right direction and how can
i convert my file?

Thank you very much for your time!
Best regards,
Giulia

[[alternative HTML version deleted]]

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


[R] [R-pkgs] usmap v 0.1.0 released

2017-02-27 Thread Paolo Di Lorenzo
Hello useRs,
I am announcing the release of my first package, usmap 
(http://cran.r-project.org/package=usmap).
"usmap" is a package to aid in the creation of US choropleths that include 
Alaska and Hawaii. It is still in its early stages (v 0.1.0) but I hope to 
improve it with added functionality over time.
Features can be seen in the vignettes 
here:https://cran.r-project.org/web/packages/usmap/vignettes/introduction.html
https://cran.r-project.org/web/packages/usmap/vignettes/mapping.html

Feel free to contribute ideas and code: http://github.com/pdil/usmap
If you have any questions please email me at pa...@dilorenzo.pl or message me 
on Twitter @dilorenzopl.
Thank you,
Paolo Di Lorenzohttp://dilorenzo.plpa...@dilorenzo.pl // dilorenz...@gmail.com


[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Baddperiods and other functions

2017-02-27 Thread Piyush Roy
Is there a way to use baddperiods and other Bloomberg API functions in R
through package Rblpapi or any other packages ?

Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] RStudio

2017-02-27 Thread Manuel Máquez
Guido:
Mucho te (les) agradezco las atenciones que han tenido todos ustedes, para
resolver el problema que tengo.
*MANOLO MÁRQUEZ P.*

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] R: How to prune using holdout data

2017-02-27 Thread Alfredo
Thank you, Terry, for your answer. 

I'll try to explain better my question. When you create a classification or
regression tree you first grow a tree based on a splitting criteria: this
usually results in a large tree that provides a good fit to the training
data. The problem with this tree is its potential for overfitting the data:
the tree can be tailored too specifically to the training data and not
generalize well to new data. The solution (apart cross-validation) is to
find a smaller subtree that results in a low error rate on holdout or
validation data.

Hope it helps to clarity my question.

Best,

Alfredo

 

 

-Messaggio originale-
Da: Therneau, Terry M., Ph.D. [mailto:thern...@mayo.edu] 

You will need to give more detail of exactly what you mean by "prune using a
validation set".  THe prune.rpart function will prune at any value you want,
what I suspect you are looking for is to compute the error of each possible
tree, using a validation data set, then find the best one, and then prune
there.

How do you define "best"?


[[alternative HTML version deleted]]

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


Re: [R] Reading S-plus data in R

2017-02-27 Thread Martin Maechler
> Richard M Heiberger 
> on Sun, 26 Feb 2017 15:46:07 -0500 writes:

> Bill,
> this looks good.  Can you add it to the splus2R  package?

Well, the natural place would rather be the foreign package,
and some of use R core members would be happy with maintaining a
function  with   \author{Bill Dunlap}

Martin

> Rich


> On Sun, Feb 26, 2017 at 11:57 AM, William Dunlap via R-help
>  wrote:
>> You should be looking for foreign::data.restore, not data.dump nor 
read.S.
>> 
>> In any case, I think that foreign::data.restore does not recognize 
S-version4
>> data.dump files, ones whose first line is
>> ## Dump S Version 4 Dump ##
>> Here is a quickly written and barely tested function that should read
>> data.frames
>> and other simple S+ objects in SV4 data.dump files.  It stores the
>> objects it reads
>> from the file 'file' in the environment 'env'.
>> 
>> data.restore4 <- function(file, print = FALSE, verbose = FALSE, env =
>> .GlobalEnv)
>> {
>> if (!inherits(file, "connection")) {
>> file <- file(file, "r")
>> on.exit(close(file))
>> }
>> lineNo <- 0
>> nextLine <- function(n = 1) {
>> lineNo <<- lineNo + n
>> readLines(file, n = n)
>> }
>> Message <- function(...) {
>> if (verbose) {
>> message(simpleMessage(paste("(line ", lineNo, ") ",
>> paste(..., collapse = " "), sep = ""), sys.call(-1)))
>> }
>> }
>> Stop <- function(...) {
>> stop(simpleError(paste(paste(..., collapse = " "), sep = "",
>> " (file ", deparse(summary(file)$description), ", line ",
>> lineNo, ")"), sys.call(-1)))
>> }
>> txt <- nextLine()
>> stopifnot(txt == "## Dump S Version 4 Dump ##")
>> .data.restore4 <- function()
>> {
>> class <- nextLine()
>> mode <- nextLine()
>> length <- as.numeric(tmp <- nextLine())
>> if (is.na(length) || length%%1 != 0 || length < 0) {
>> Stop("Expected nonnegative integer 'length' at line ",
>> lineNo, " but got ", deparse(tmp))
>> }
>> if (mode == "character") {
>> nextLine(length)
>> } else if (mode == "logical") {
>> txt <- nextLine(length)
>> lglVector <- rep(NA, length)
>> lglVector[txt != "N"] <- as.logical(as.integer(txt[txt != "N"]))
>> lglVector
>> } else if (mode %in% c("integer", "single", "numeric")) {
>> txt <- nextLine(length)
>> txt[txt == "M"] <- "NaN"
>> txt[txt == "I"] <- "Inf"
>> txt[txt == "J"] <- "-Inf"
>> atomicVector <- rep(as(NA, mode), length)
>> atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
>> atomicVector
>> } else if (mode == "complex") {
>> txt <- nextLine(length)
>> txt <- gsub("M", "NaN", txt)
>> txt <- gsub("\\", "Inf", txt)
>> txt <- gsub("\\", "-Inf", txt)
>> atomicVector <- rep(as(NA, mode), length)
>> atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
>> atomicVector
>> } else if (mode == "list") {
>> vectors <- lapply(seq_len(length), function(i).data.restore4())
>> vectors
>> } else if (mode == "NULL") {
>> NULL
>> } else if (mode == "structure") {
>> vectors <- lapply(seq_len(length), function(i).data.restore4())
>> if (class == ".named_I" || class == "named") {
>> if (length != 2) {
>> Stop("expected length of '.named_I' component is
>> 2, but got ", length)
>> } else if (length(vectors[[1]]) != length(vectors[[2]])) {
>> Stop("expected lengths of '.named_I' components to
>> be the same, but got ", length(vectors[[1]]), " and ",
>> length(vectors[[2]]))
>> } else if (!is.character(vectors[[2]])) {
>> Stop("expected second component of '.named_I' to
>> be character, but got ", deparse(mode(vectors[[2]])))
>> }
>> names(vectors[[1]]) <- vectors[[2]]
>> if (identical(vectors[[2]][1], ".Data")) { # a hack -
>> really want to know if vectors[[1] had mode "structure" or not
>> do.call(structure, vectors[[1]], quote = TRUE)
>> } else {
>> vectors[[1]]
>> }
>> } else {
>> vectors # TODO: is this ok?  It assumes that is within
>> a .Named_I/structure
>> }
>> } else if (mode == "name") {
>> if (length != 1) {
>> Stop("expected length of 'name' objects is 1, but got", length)
>> }
>> as.name(nextLine())
>> } else if (mode == "call") {
>> callList <- lapply(seq_len(length), function(i).data.restore4())
>> as.call(callList)
>> } else {
>> Stop("Unimplemented mode: ", deparse(mode))
>> }
>> }
>> while (length(objName <- nextLine()) == 1) {
>> Message(objName, ": ")
>> obj <- .data.restore4()
>> Message("class ", deparse(class(obj)), ", size=",
>> object.size(obj), "\n")
>> assign(objName, obj, envir=env)
>> }
>> }
>> 
>> 
>> 
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>> 
>> 

[R] plotting dates in x axis

2017-02-27 Thread Maria Lathouri via R-help
Dear all, 
I have an excel file of 180 observations with dates and one variable, from 1998 
to 2012 by random months (there are some years that I might not have all the 
months or I might have two observations in one month). I am trying to plot the 
dates in x axis and the variable in y axis. I have already used as.Date for the 
dates so I can import them into R. 
Here is my script:> aa<-read.csv("aa.csv")> attach(aa)> names(aa)#"SDATE" "var1"
I convert the dates into R: > sdate<-as.Date(SDATE, format="%Y-%m-%d")

I am plotting the dates with my var1:> plot(sdate, var1, type="l")
Up to now, everything seems ok. However, in the x-axis I only get three years, 
2000, 2005 and 2010. As I want to show all the years or at least as many as it 
could be, I am using the following:
> plot(sdate, var1, type="l", xaxt="n")

> d1<-c((sdate[1]), (sdate[183]))> d2<-as.Date((d1[1])+365*(0:15))
> axis(side=1, at=0:15, labels=strftime(d2, format="%Y"), cex.axis=0.8,las=2);  
> I tried also to plot the dates in a month-Year form: 

> d2<-as.Date((d1[1])+150*(0:20))
> plot(sdate, var1, type="l", xaxt="n")> axis(side=1, at=0:15, 
> labels=strftime(d2, format="%m-%Y"), cex.axis=0.8,las=2)

But nothing happened. I cannot understand why it doesn't show anything. 
I have attached the file as well in case you want to have a more clear picture. 
I really appreciate it if you can help me on this.  
Thank you very much in advance. 
Kind regards,Maria
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread PIKAL Petr
Hi

Above what was said

data(data[,4] == 1, c(1 2 4))
Error: unexpected numeric constant in "data(data[,4] == 1, c(1 2"

is not valid syntax as it assume that data is a function and c(1 2 4) is also 
not correct syntax (I wonder if commands in MATLAB are such free form).

And I am a little puzzled what means to bring 3 columns together. Calculate 
sum? Paste respective values in mentioned 3 columns.

Anyway, if you want to select only first n rows you should use something like

data[1:20,][data[1:20,4]==1,c(1,2,4)]
or
data[which(data[1:20,4]==1), c(1,2,4)]

You should also be careful with "==" if you compare numbers, especially 
fractions and to select without "with" if your data contain NA values in 
respective columns.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erich
> Subscriptions
> Sent: Monday, February 27, 2017 1:30 PM
> To: Tunga Kantarcı 
> Cc: R-help 
> Subject: Re: [R] Selecting rows and columns of a data frame using relational
> operators
>
> The answer is simple
>
> data[,4] == 1 produces a logical vector of length nrow(data) and the
> subsetting mechanism for data frames in R needs a vector of the same length
> as the data frame has rows.
>
> data[1:20,4] == 1
> produces a data frame of length 20, and if this is not the length of data.
> So R applies its standard procedure, it repeats this vector as often as needed
> to get a vector of length == nrow(data)
>
>
> Th following code illustrates what is happening
>
> data <-
> data.frame(x=rnorm(100),y=rnorm(100),z=rnorm(100),a=rep(c(1,2,1,2),c(2,4
> 8,2,48)))
>
> vec1 <- data[,4]==1
> vec2 <- data[1:20,4]==1
>
>
> > On 27 Feb 2017, at 13:07, Tunga Kantarcı 
> wrote:
> >
> > Consider a data frame named data. data contains 4 columns and 1000
> > rows. Say the aim is to bring together columns 1, 2, and 4, if the
> > values in column 4 is equal to 1. We could use the syntax
> >
> > data(data[,4] == 1, c(1 2 4))
> >
> > for this purpose. Suppose now that the aim is to bring together
> > columns 1, 2, and 4, if the values in column 4 is equal to 1, for the
> > first 20 rows of column 4. We could use the syntax
> >
> > data(data[1:20,4] == 1, c(1 2 4))
> >
> > for this purpose. However, this does not produce the desired result.
> > This is surprising at least for someone coming from MATLAB because
> > MATLAB produces what is desired.
> >
> > Question 1: The code makes sense but why does it not produce what we
> > expect it to produce?
> >
> > Question 2: What code is instead suitable?
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you 

Re: [R] Reading S-plus data in R

2017-02-27 Thread roslinazairimah zakaria
Hi William,

I read again your message. Yes, finally, it works beautifully!  Thank you
so much.


## Import Data from S-Plus to R
library(foreign)
data.restore4("C:/Users/FTSI/Desktop/2 ICGPA/1ACTIVITY.sdd", verbose=TRUE,
print=TRUE, env = SplusDataEnv <- new.env())
objects(SplusDataEnv)
dt <- SplusDataEnv[["ACTIVITY"]]
head(dt); tail(dt)

Output:
> head(dt); tail(dt)
  ESTEEM CTPS   CS SSTWRES LLL MGMT.ENTRE VALUE.ETHICS LEADERSHIP
17600 18201190 910  0 6260   2360
2   16400 2220 870 870  0 7020   5080
36000  940 750 470  0 3460   1880
4   12000  480 400 160  0 1920   3440
51600  240   0  40  0  120240
6  00  400  80  80  0  560 80
 ESTEEM CTPSCS SSTWRES  LLL MGMT.ENTRE VALUE.ETHICS LEADERSHIP
6989   2880 2280  79604000 2270   196011790   5760
6990   4280 4720 11060 2330   2240 8230   7240
6991   5540 2620  65202400 1490   1140 9310  14180
6992   4520 3940 102805130 2450   3180 8340   5560
6993   7640 2260  46401000  770   1020 9730  22440
6994   4860 3940  86005140 2690   238014690  11700




##
data.restore4 <- function(file, print = FALSE, verbose = FALSE, env =
.GlobalEnv)
{
if (!inherits(file, "connection")) {
file <- file(file, "r")
on.exit(close(file))
}
lineNo <- 0
nextLine <- function(n = 1) {
lineNo <<- lineNo + n
readLines(file, n = n)
}
Message <- function(...) {
if (verbose) {
message(simpleMessage(paste("(line ", lineNo, ") ", paste(...,
collapse = " "), sep = ""), sys.call(-1)))
}
}
Stop <- function(...) {
stop(simpleError(paste(paste(..., collapse = " "), sep = "",
" (file ", deparse(summary(file)$description), ", line ",
lineNo, ")"), sys.call(-1)))
}
txt <- nextLine()
stopifnot(txt == "## Dump S Version 4 Dump ##")
.data.restore4 <- function()
{
class <- nextLine()
mode <- nextLine()
length <- as.numeric(tmp <- nextLine())
if (is.na(length) || length%%1 != 0 || length < 0) {
Stop("Expected nonnegative integer 'length' at line ", lineNo,
" but got ", deparse(tmp))
}
if (mode == "character") {
nextLine(length)
} else if (mode == "logical") {
txt <- nextLine(length)
lglVector <- rep(NA, length)
lglVector[txt != "N"] <- as.logical(as.integer(txt[txt != "N"]))
lglVector
} else if (mode %in% c("integer", "single", "numeric")) {
txt <- nextLine(length)
txt[txt == "M"] <- "NaN"
txt[txt == "I"] <- "Inf"
txt[txt == "J"] <- "-Inf"
atomicVector <- rep(as(NA, mode), length)
atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
atomicVector
} else if (mode == "complex") {
txt <- nextLine(length)
txt <- gsub("M", "NaN", txt)
txt <- gsub("\\", "Inf", txt)
txt <- gsub("\\", "-Inf", txt)
atomicVector <- rep(as(NA, mode), length)
atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
atomicVector
} else if (mode == "list") {
vectors <- lapply(seq_len(length), function(i).data.restore4())
vectors
} else if (mode == "NULL") {
NULL
} else if (mode == "structure") {
vectors <- lapply(seq_len(length), function(i).data.restore4())
if (class == ".named_I" || class == "named") {
if (length != 2) {
Stop("expected length of '.named_I' component is 2, but
got ", length)
} else if (length(vectors[[1]]) != length(vectors[[2]])) {
Stop("expected lengths of '.named_I' components to be
the same, but got ", length(vectors[[1]]), " and ", length(vectors[[2]]))
} else if (!is.character(vectors[[2]])) {
Stop("expected second component of '.named_I' to be
character, but got ", deparse(mode(vectors[[2]])))
}
names(vectors[[1]]) <- vectors[[2]]
if (identical(vectors[[2]][1], ".Data")) { # a hack -
really want to know if vectors[[1] had mode "structure" or not
do.call(structure, vectors[[1]], quote = TRUE)
} else {
vectors[[1]]
}
} else {
vectors # TODO: is this ok?  It assumes that is within a
.Named_I/structure
}
} else if (mode == "name") {
if (length != 1) {
Stop("expected length of 'name' objects is 1, but got",
length)
   

Re: [R] Reading S-plus data in R

2017-02-27 Thread roslinazairimah zakaria
Hi Willianm,

Thank you. However, still null:

> library(foreign)
> dt <- data.restore4("C:/Users/FTSI/Desktop/2 ICGPA/1ACTIVITY.sdd",
verbose=TRUE, print=TRUE, env = SplusDataEnv <- new.env())
> SplusDataEnv[["dt"]]
NULL




On Mon, Feb 27, 2017 at 10:41 AM, William Dunlap  wrote:

> > It stores the objects it reads from the file 'file' in the environment
> 'env'.
> >
> > data.restore4 <- function(file, print = FALSE, verbose = FALSE, env =
> .GlobalEnv)
>
> It returns NULL.  foreign::data.restore() returns the 'file' argument
> and I should have copied that behavior (even though it is not very
> useful).  You can use verbose=TRUE to have it print the names of what
> it found in the file.
>
> Use it as
>data.restore4("yourFile.sdd", verbose=TRUE, env = SplusDataEnv <-
> new.env())
> Then objects(SplusDataEnv) will list what in the file and
> SplusDataEnv[["name"]] with get the dataset "name" from the file.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Sun, Feb 26, 2017 at 3:47 PM, roslinazairimah zakaria
>  wrote:
> > Hi all,
> >
> > Something is working but the data is NULL.
> >
> > I tried this:
> >
> > library(foreign)
> >> dt <- data.restore4("C:/Users/FTSI/Desktop/2 ICGPA/1ACTIVITY.sdd")
> >> head(dt); tail(dt)
> > NULL
> > NULL
> >
> >
> > On Mon, Feb 27, 2017 at 12:57 AM, William Dunlap 
> wrote:
> >>
> >> You should be looking for foreign::data.restore, not data.dump nor
> read.S.
> >>
> >> In any case, I think that foreign::data.restore does not recognize
> >> S-version4
> >> data.dump files, ones whose first line is
> >>   ## Dump S Version 4 Dump ##
> >> Here is a quickly written and barely tested function that should read
> >> data.frames
> >> and other simple S+ objects in SV4 data.dump files.  It stores the
> >> objects it reads
> >> from the file 'file' in the environment 'env'.
> >>
> >> data.restore4 <- function(file, print = FALSE, verbose = FALSE, env =
> >> .GlobalEnv)
> >> {
> >> if (!inherits(file, "connection")) {
> >> file <- file(file, "r")
> >> on.exit(close(file))
> >> }
> >> lineNo <- 0
> >> nextLine <- function(n = 1) {
> >> lineNo <<- lineNo + n
> >> readLines(file, n = n)
> >> }
> >> Message <- function(...) {
> >> if (verbose) {
> >> message(simpleMessage(paste("(line ", lineNo, ") ",
> >> paste(..., collapse = " "), sep = ""), sys.call(-1)))
> >> }
> >> }
> >> Stop <- function(...) {
> >> stop(simpleError(paste(paste(..., collapse = " "), sep = "",
> >> " (file ", deparse(summary(file)$description), ", line ",
> >> lineNo, ")"), sys.call(-1)))
> >> }
> >> txt <- nextLine()
> >> stopifnot(txt == "## Dump S Version 4 Dump ##")
> >> .data.restore4 <- function()
> >> {
> >> class <- nextLine()
> >> mode <- nextLine()
> >> length <- as.numeric(tmp <- nextLine())
> >> if (is.na(length) || length%%1 != 0 || length < 0) {
> >> Stop("Expected nonnegative integer 'length' at line ",
> >> lineNo, " but got ", deparse(tmp))
> >> }
> >> if (mode == "character") {
> >> nextLine(length)
> >> } else if (mode == "logical") {
> >> txt <- nextLine(length)
> >> lglVector <- rep(NA, length)
> >> lglVector[txt != "N"] <- as.logical(as.integer(txt[txt !=
> >> "N"]))
> >> lglVector
> >> } else if (mode %in% c("integer", "single", "numeric")) {
> >> txt <- nextLine(length)
> >> txt[txt == "M"] <- "NaN"
> >> txt[txt == "I"] <- "Inf"
> >> txt[txt == "J"] <- "-Inf"
> >> atomicVector <- rep(as(NA, mode), length)
> >> atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
> >> atomicVector
> >> } else if (mode == "complex") {
> >> txt <- nextLine(length)
> >> txt <- gsub("M", "NaN", txt)
> >> txt <- gsub("\\", "Inf", txt)
> >> txt <- gsub("\\", "-Inf", txt)
> >> atomicVector <- rep(as(NA, mode), length)
> >> atomicVector[txt != "N"] <- as(txt[txt != "N"], mode)
> >> atomicVector
> >> } else if (mode == "list") {
> >> vectors <- lapply(seq_len(length),
> >> function(i).data.restore4())
> >> vectors
> >> } else if (mode == "NULL") {
> >> NULL
> >> } else if (mode == "structure") {
> >> vectors <- lapply(seq_len(length),
> >> function(i).data.restore4())
> >> if (class == ".named_I" || class == "named") {
> >> if (length != 2) {
> >> Stop("expected length of '.named_I' component is
> >> 2, but got ", length)
> >> } else if (length(vectors[[1]]) !=
> length(vectors[[2]])) {
> >> Stop("expected lengths of '.named_I' components to

Re: [R] How to prune using a validation set

2017-02-27 Thread Therneau, Terry M., Ph.D.
You will need to give more detail of exactly what you mean by "prune using a validation 
set".  THe prune.rpart function will prune at any value you want, what I suspect you are 
looking for is to compute the error of each possible tree, using a validation data set, 
then find the best one, and then prune there.


How do you define "best"?

Terry Therneau


On 02/26/2017 05:00 AM, r-help-requ...@r-project.org wrote:

I'd like to use a different data ( validation) set for pruning my
classification tree. Unfortunately there aren't arguments to get this in
prune.rpart().

Any suggestions?

Thanks!

Alfredo



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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: [ESS] Ess in emacs on mac

2017-02-27 Thread Lionel Henry
Hi Luping,

This is normal and part of ESS initialisation, but it has always
bugged me as well. I think we should make this output silent.

Lionel


> On 27 févr. 2017, at 10:10, Luping Zhang  wrote:
> 
> To whom may concern
> Sorry for bothering you. But I have a question about ESS.
> When typing the command “M-x R RET” in mini buffer, I can 
> go in R, as the following picture shows. However, there is always
> an information: “if (identical (getOption)…” pops up. I am not sure 
> this is normal when using ESS in emacs. Could you explain for me 
> why this information always shows, and how can I avoid this. By the way,
> My configuration in emacs initial file is
> ( use-package ess-site
>   :ensure ess
>   :init
>   (setq inferior-R-program-name “/usr/local/bin/R)
>   (setq ess-ask-for-ess-directory nil))
> 
> Thanks again, long for hear from you
> 
> Greetings from Nanjing China
> 
> Luping
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Erich Subscriptions
The answer is simple

data[,4] == 1 produces a logical vector of length nrow(data)
and the subsetting mechanism for data frames in R needs a vector of the same 
length 
as the data frame has rows.

data[1:20,4] == 1
produces a data frame of length 20, and if this is not the length of data.
So R applies its standard procedure, it repeats this vector as often as needed 
to get
a vector of length == nrow(data)


Th following code illustrates what is happening

data <- 
data.frame(x=rnorm(100),y=rnorm(100),z=rnorm(100),a=rep(c(1,2,1,2),c(2,48,2,48)))

vec1 <- data[,4]==1
vec2 <- data[1:20,4]==1


> On 27 Feb 2017, at 13:07, Tunga Kantarcı  wrote:
> 
> Consider a data frame named data. data contains 4 columns and 1000
> rows. Say the aim is to bring together columns 1, 2, and 4, if the
> values in column 4 is equal to 1. We could use the syntax
> 
> data(data[,4] == 1, c(1 2 4))
> 
> for this purpose. Suppose now that the aim is to bring together
> columns 1, 2, and 4, if the values in column 4 is equal to 1, for the
> first 20 rows of column 4. We could use the syntax
> 
> data(data[1:20,4] == 1, c(1 2 4))
> 
> for this purpose. However, this does not produce the desired result.
> This is surprising at least for someone coming from MATLAB because
> MATLAB produces what is desired.
> 
> Question 1: The code makes sense but why does it not produce what we
> expect it to produce?
> 
> Question 2: What code is instead suitable?
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Ulrik Stervbo
Hi Tunga,

The function subset() is probably what you are looking for. You might also
want to look at a tutorial to understand the R syntax.

In addition, calling your data data is not a good idea because of the name
clash with the function data().

Hope this helps,
Ulrik

On Mon, 27 Feb 2017 at 13:10 Tunga Kantarcı  wrote:

> Consider a data frame named data. data contains 4 columns and 1000
> rows. Say the aim is to bring together columns 1, 2, and 4, if the
> values in column 4 is equal to 1. We could use the syntax
>
> data(data[,4] == 1, c(1 2 4))
>
> for this purpose. Suppose now that the aim is to bring together
> columns 1, 2, and 4, if the values in column 4 is equal to 1, for the
> first 20 rows of column 4. We could use the syntax
>
> data(data[1:20,4] == 1, c(1 2 4))
>
> for this purpose. However, this does not produce the desired result.
> This is surprising at least for someone coming from MATLAB because
> MATLAB produces what is desired.
>
> Question 1: The code makes sense but why does it not produce what we
> expect it to produce?
>
> Question 2: What code is instead suitable?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Tunga Kantarcı
Consider a data frame named data. data contains 4 columns and 1000
rows. Say the aim is to bring together columns 1, 2, and 4, if the
values in column 4 is equal to 1. We could use the syntax

data(data[,4] == 1, c(1 2 4))

for this purpose. Suppose now that the aim is to bring together
columns 1, 2, and 4, if the values in column 4 is equal to 1, for the
first 20 rows of column 4. We could use the syntax

data(data[1:20,4] == 1, c(1 2 4))

for this purpose. However, this does not produce the desired result.
This is surprising at least for someone coming from MATLAB because
MATLAB produces what is desired.

Question 1: The code makes sense but why does it not produce what we
expect it to produce?

Question 2: What code is instead suitable?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Rstudio

2017-02-27 Thread Guido Corradi
Prueba ejecutando esto en la terminal:



sudo apt-get install libxml2-dev

sudo apt-get install libcurl4-openssl-dev libssl-dev

El 25 de febrero de 2017, 20:27, Manuel David Jiménez Patiño <
manueldavi...@gmail.com> escribió:

> Hola Manuel Máquez,
>
> Recientemente yo instalé RStudio en Ubuntu 14.04, para ello seguí esta
> receta y me fue bien:
>
> https://softwarecodesite.wordpress.com/2017/02/20/
> instalar-r-studio-en-ubuntu-14-04/
>
> Si las llegas a seguir cuéntanos por favor qué tal te fue.
>
> Saludos y suerte.
>
> 2017-02-25 2:57 GMT+01:00 :
>
> > Estimado Manuel Máquez
> >
> > Ese es un problema de Linux, cuando se les ocurre tocar siempre hay algo
> > que te deja a pata, y con R ese problema yo lo tuve en varias
> oportunidades.
> >
> > Ahora ya no uso Linux, pero siguiendo la recomendación de Carlos Ortega,
> > hay una parte en esos artículos que no citan pero que pueden facilitarle
> > las cosas, me refiero a “ubuntu synaptic”, desconozco si todavía existe,
> > pero si está en los repositorios desde este programa puede buscar las
> > dependencias que le falta e instalarlas con solo uno o dos click.
> >
> > Javier Rubén Marcuzzi
> >
> > De: Carlos Ortega
> > Enviado: viernes, 24 de febrero de 2017 22:20
> > Para: Manuel Máquez
> > CC: r-help-es
> > Asunto: Re: [R-es] Rstudio
> >
> > Hola,
> >
> > Aunque no uso Ubuntu, buscando por el problema que tienes, aparece esta
> > entrada dentro del soporte de RStudio:
> > https://support.rstudio.com/hc/en-us/community/posts/
> > 221967507-Not-installing-in-Ubuntu-16-10
> >
> > Y ahí recomiendan seguir el proceso de instalación que describen aquí:
> > https://mikewilliamson.wordpress.com/2016/11/14/
> > installing-r-studio-on-ubuntu-16-10/
> >
> > Saludos,
> > Carlos.
> >
> >
> > El 24 de febrero de 2017, 21:42, Manuel Máquez 
> > escribió:
> >
> > > Estimados colegas:
> > > Tuve que instalar en mi PC Ubuntu 16.10 y quiero instalar nuevamente
> > > RStudio, sin embargo no sucede así, porque en la terminal se indica que
> > hay
> > > dependencias incumplidas. He encontrado que se ha cambiado una
> > > librería libgstreamer y no se como hacer para que se pueda instalar
> > > adecuadamente el paquete RStudio.
> > > ¿Alguno de ustedes me puede decir el procedimiento completo para lograr
> > > dicha instalación?
> > > Adelanto las gracias más cumplidas.
> > >
> > > *MANOLO MÁRQUEZ P.*
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ___
> > > R-help-es mailing list
> > > R-help-es@r-project.org
> > > https://stat.ethz.ch/mailman/listinfo/r-help-es
> > >
> >
> >
> >
> > --
> > Saludos,
> > Carlos Ortega
> > www.qualityexcellence.es
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Guido B. Corradi
Doctorando en EvoCog  y coeditor en Rasgo Latente

@GuidoBCor

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] [R-pkgs] New package: hrbrthemes

2017-02-27 Thread Bob Rudis
Hey folks,

I'm pleased to announce the inaugural release of my hrbrthemes (0.1.0)
on CRAN: https://CRAN.R-project.org/package=hrbrthemes

The primary goal of said package is to provide opinionated
typographical and other aesthetic defaults for ggplot2 charts.

Two core themes are included:

- theme_ipsum() – an Arial Narrow-based theme
- theme_ipsum_rc() – a Roboto Condensed-based theme.

The Roboto Condensed Google Font comes with the package along with an
installer for said font.

Other niceties include:

- scale_[xy]_comma() — shortcut for expand=c(0,0), labels=scales::comma
- scale_[xy]_percent() — shortcut for expand=c(0,0), labels=scales::percent
- scale_[color|fill]_ipsum() — discrete scale with 9 colors
- gg_check() — pass-through spell checker for ggplot2 label elements

Source version is tracked on GitHub: https://github.com/hrbrmstr/hrbrthemes

Critiques, bug reports and enhancement requests are most welcome as
GitHub issues.

-Bob

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Theta in Negative binomial GAM

2017-02-27 Thread Simon Wood
nb() will default to "REML" smoothing parameter estimation, while 
negbin() will default to "UBRE" unless you use the 'method="REML"' 
option to 'gam'. Using UBRE in place of REML may lead to differences in 
model fit, and will also mean that the AIC is not corrected for 
smoothing parameter uncertainty (this correction increases the AIC). You 
also expect AIC to drop by 2 or so, because negbin is treating theta as 
fixed.


So...

m <- gam(...,family=nb())

should give similar AIC values about 2 higher than

th1 <- m$family$getTheta(TRUE)
m1 <- gam(...,family=negbin(th1),method="REML")

If you don't know theta it is better to estimate it.

best,
Simon

ps. Tedious details of AIC smoothing uncertainty correction are in 
sections 4 and 5 of this:

http://amstat.tandfonline.com/doi/pdf/10.1080/01621459.2016.1180986

On 26/02/17 22:26, Eva Maria Leunissen wrote:

Hi, I'm fitting a negative binomial GAM (using mgcv) to my data using
family=nb() so theta is estimated during the fitting process. When I then
extract this theta from the model and refit the same model with
family=negbin(theta) it gives a much lower AIC. I know using AIC to compare
negative binomial models should be done with caution (
http://r.789695.n4.nabble.com/How-to-compare-GLM-and-GAM-models-tt827923.html#a827926)
but approximately it is ok. My questions are:

Is it better to do model selection with nb() or with negbin and a known
theta. if the latter how do you know what theta is?

can you compare models using AIC if the theta is different for each model?

Thanks in advance, any help is much appreciated

Kind regards,

Eva Leunissen

[[alternative HTML version deleted]]

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



--
Simon Wood, School of Mathematics, University of Bristol BS8 1TW UK
+44 (0)117 33 18273 http://www.maths.bris.ac.uk/~sw15190

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Impose Structure for Exogenous in vars Package

2017-02-27 Thread Pfaff, Bernhard Dr.
Hi Andrew,

if I understand your question correctly, then you would like to place 
constraints for your exogenous variables in some VAR equations.
If so, please have a look at ?restrict.

As a toy example:

library(vars)
?restrict
data(Canada)
N <- nrow(Canada)
ExoVar <- matrix(runif(N))
colnames(ExoVar) <- "Exogenous"
mod <- VAR(Canada, exogen = ExoVar)
summary(mod)
summary(restrict(mod))

here, ExoVar will be removed given that the plain vanilla call to restrict() 
removes all variables with insignificant coeffiecients (|t-stat| < 2.0)   in a 
VAR equation. 
You can also provide a 'constraint' matrix for entering zero-constraints.

HTH,
Bernhard



-Ursprüngliche Nachricht-
Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von Castro, Andrew 
William Keahi
Gesendet: Donnerstag, 23. Februar 2017 15:42
An: r-help@R-project.org
Betreff: [EXT] [R] Impose Structure for Exogenous in vars Package

Hello everyone,

I see there are structural VAR options in the vars package for the endogenous 
variables, but is there any easy way to impose structure on the exogenous 
variable matrix (notated as the matrix C on page 45 of 
https://cran.r-project.org/web/packages/vars/vars.pdf). Thanks!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] ASReml-R lack of documentation

2017-02-27 Thread Patrick Connolly
Has anyone had any success contacting VSNi, distributors of the
non-free R package ASReml-R?  I tried posting a question on their
forum page but the forum software seems to have a bug too.

So I tried emailing their support address but with no success.  If
anyone has had recent success with either, please let me know what you
did to achieve it.

Better still. if you have experience with predictions from
asreml.binomial models, I have a question about a possible bug if
you'd bee so kind.

TIA

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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