Re: [R] [FORGED] Re: Fwd: Rpart help

2017-05-23 Thread Rolf Turner


On 24/05/17 14:38, Bert Gunter wrote:


Forget Excel. Erase it from your memory. banish its paradigms from
your practices. Faiing to do so will only bring misery as you explore
R. R is a rational programming language primarily for data analysis,
statistics, and graphics. Excel is, ummm, not.


Gotta be a fortune!!!

cheers,

Rolf

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


Re: [R] Fwd: Rpart help

2017-05-23 Thread Bert Gunter
1. Forget Excel. Erase it from your memory. banish its paradigms from
your practices. Faiing to do so will only bring misery as you explore
R. R is a rational programming language primarily for data analysis,
statistics, and graphics. Excel is, ummm, not.

2. Have you read the rpart documents and vignettes? That should be
your first port of call for questions about how it works.


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 Tue, May 23, 2017 at 6:45 PM, kristen wissmar
 wrote:
> Hi R users!
>
> I'm new to R, so I'm starting with a basic exercise in rpart.
>
> I'm predicting if a user will churn based on past order history.  I've
> calculated the probabilities in excel, and if user is a single order
> customer (1), then their probability of churn is 90%, if there are multiple
> orders(0) then the probability of churning is 70%. In the R model, the
> probability looks like it's 100% and 53%. In excel I used the count of
> shopper_key to calculate probabilities. So I'm wondering if R has needs a
> shopper_key to count?
>
> It would be helpful if someone could suggest where I'm going wrong.
>
> Thank you!
>
>
> Code -
> m1 <- rpart( churn ~ single_order , data = data2, method="anova" )
>
> Output-
> n= 22041
>
> node), split, n, deviance, yval
>   * denotes terminal node
>
> 1) root 22041 3229.265 0.8216959
>   2) single_order< 0.5 8407 2092.852 0.5325324 *
>   3) single_order>=0.5 136340.000 1.000 *
>
>
> shopper_key churn single_order
> 1 1 0
> 2 1 1
> 3 0 0
> 4 1 0
> 5 1 1
> 6 1 1
> 7 1 0
> 8 1 1
> 9 0 1
> 10 1 1
>
> [[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] Apriori Results- Same number to support an confidence

2017-05-23 Thread Bert Gunter
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 Tue, May 23, 2017 at 3:52 PM, Raquel D.  wrote:
> Hi!
>
>
> Does anybody knows why it can be happening? Lift = 1

Doubt it. Pretty incoherent, to me anyway.

But this is probaby the wrong place to post. This list is about R
programming; statistics is generally OT. Try posting on
stats.stackexchange.com for statistics issues. Being more coherent
might help, too

-- Bert


>
>
>
>
> rule length distribution (lhs + rhs):sizes
>  1
> 68
>
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
>   1   1   1   1   1   1
>
> summary of quality measures:
> support   confidencelift
>  Min.   :0.002050   Min.   :0.002050   Min.   :1
>  1st Qu.:0.002899   1st Qu.:0.002899   1st Qu.:1
>  Median :0.004465   Median :0.004465   Median :1
>  Mean   :0.008703   Mean   :0.008703   Mean   :1
>  3rd Qu.:0.007605   3rd Qu.:0.007605   3rd Qu.:1
>  Max.   :0.059593   Max.   :0.059593   Max.   :1
>
> mining info:
>  data ntransactions support confidence
>   txn438612   0.001  0.002
>
>
>
> [[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.


[R] Fwd: Rpart help

2017-05-23 Thread kristen wissmar
Hi R users!

I'm new to R, so I'm starting with a basic exercise in rpart.

I'm predicting if a user will churn based on past order history.  I've
calculated the probabilities in excel, and if user is a single order
customer (1), then their probability of churn is 90%, if there are multiple
orders(0) then the probability of churning is 70%. In the R model, the
probability looks like it's 100% and 53%. In excel I used the count of
shopper_key to calculate probabilities. So I'm wondering if R has needs a
shopper_key to count?

It would be helpful if someone could suggest where I'm going wrong.

Thank you!


Code -
m1 <- rpart( churn ~ single_order , data = data2, method="anova" )

Output-
n= 22041

node), split, n, deviance, yval
  * denotes terminal node

1) root 22041 3229.265 0.8216959
  2) single_order< 0.5 8407 2092.852 0.5325324 *
  3) single_order>=0.5 136340.000 1.000 *


shopper_key churn single_order
1 1 0
2 1 1
3 0 0
4 1 0
5 1 1
6 1 1
7 1 0
8 1 1
9 0 1
10 1 1

[[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] ggplot problem

2017-05-23 Thread greg holly
Hi all;

When I run the following program substantially I have "Warning message:
position_dodge requires non-overlapping x intervals"

How I can overcome this problem.

Regards,

Greg

p <- ggplot() + geom_point(data=a, aes(x=Betas, y=Traits, color=
Super.Pathway), shape=15, size=4)

p <- p + guides(color=guide_legend(title=NULL))

p <- p + theme(legend.key = element_blank())

p <- p  + geom_boxplot(data=a,aes(x=Betas,fill=factor(Super.Pathway),y=Traits))
+ guides(fill=FALSE) +scale_x_continuous(breaks = seq(-50, 60, 5))

p

[[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] Forecast using VAR model

2017-05-23 Thread John C Frain
Dhivya

You have two variables speed and vibration. It strikes me that speed causes
vibration and vibration does not cause speed. Forgive me if I have
misunderstood. In such a case you would be better off using an ARMAX model
with vibration as dependent variable and speed as an explanatory variable.
The fact that you have autocorrelation problems is an indication that your
var model is not a correct specification.  I note that there are many zeros
in your data set. Are these missed measurements or actual zeros. If they
are missing observations your analysis becomes much more complicated.

John C Frain
3 Aranleigh Park
Rathfarnham
Dublin 14
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@gmail.com

On 22 May 2017 at 06:16, Dhivya Narayanasamy  wrote:

> Hi Jon,
>
> sorry for the inconvenience. I have done it in plain text now.
>
> I am building a VAR model to forecast of bivariate time series. But it
> shows flat forecast and i am in need of correcting  it. Is there any way
> to correct this flat forecast?  or Do i have to go with other models?
>
> Code:
>
> > datax.zoo <- read.zoo(datax)
> > datax.ts <- ts(datax.zoo)
> > v1b <- VARselect(datax.ts, lag.max = 10, type = "const")
> > v1b$selection
> AIC(n)  HQ(n)  SC(n) FPE(n)
> 10  7  3 10
> > var7 = VAR(datax.ts, p=7)
> > serial.test(var7, lags.pt=10, type = "PT.asymptotic")
>
> Portmanteau Test (asymptotic)
>
> data:  Residuals of VAR object var7
> Chi-squared = 31.991, df = 12, p-value = 0.001388
>
> > gf1 <- forecast(var7, h = 600)
> > plot(gf1, main = "var7")
> > grangertest(datax.ts[,1] ~ datax.ts[,2], order = 7)
> Granger causality test
>
> Model 1: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7) + Lags(datax.ts[, 2],
> 1:7)
> Model 2: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7)
>   Res.Df Df  FPr(>F)
> 1   9968
> 2   9975 -7 20.852 < 2.2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> > grangertest(datax.ts[,2] ~  datax.ts[,1], order = 7)
> Granger causality test
>
> Model 1: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7) + Lags(datax.ts[, 1],
> 1:7)
> Model 2: datax.ts[, 2] ~ Lags(datax.ts[, 2], 1:7)
>   Res.Df Df  F   Pr(>F)
> 1   9968
> 2   9975 -7 3.0918 0.002948 **
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
>
> The P value from "Portmanteau Test" is very much less than << 0.05 for
> lagged value 7. Is this correct?
> I have added my plot and raw data in the attachment for your further
> reference. Thank you.
>
>
>
> Regards| Mit freundlichen Grüßen,
>> Dhivya Narayanasamy
>
>
> Regards| Mit freundlichen Grüßen,
>
> Dhivya Narayanasamy
>
> Contact No: +91-8438505020 <+91%2084385%2005020>
>
> On Sun, May 21, 2017 at 5:40 PM, John C Frain  wrote:
>
>> It would be much easier to see what you are doing if you reposted in
>> plain text.
>>
>> John C Frain
>> 3 Aranleigh Park
>> Rathfarnham
>> Dublin 14
>> Ireland
>> www.tcd.ie/Economics/staff/frainj/home.html
>> mailto:fra...@tcd.ie
>> mailto:fra...@gmail.com
>>
>> On 21 May 2017 at 06:05, Dhivya Narayanasamy 
>> wrote:
>>
>>> I am building a VAR model to forecast of bivariate timeseries. But it
>>> shows
>>> flat forecast.
>>>
>>> So I would like to use recursive window forecasting technique using VAR
>>> model. Will it give what i expect (Avoid flat forecast) ? or should i
>>> have
>>> to go with other package.
>>>
>>> > datax.zoo <- read.zoo(datax)> datax.ts <- ts(datax.zoo)> v1b <-
>>> VARselect(datax.ts, lag.max = 10, type = "const")> v1b
>>> $selection
>>> AIC(n)  HQ(n)  SC(n) FPE(n)
>>>  9  7  5  9
>>>
>>> $criteria
>>>   1234
>>> 567
>>> AIC(n) 9.686513 9.657172 9.632444 9.625856
>>> 9.621148 9.619425 9.615396
>>> HQ(n)  9.688951 9.661234 9.638131 9.633167
>>> 9.630085 9.629987 9.627583
>>> SC(n)  9.693514 9.668839 9.648778 9.646856
>>> 9.646815 9.649759 9.650397
>>> FPE(n) 16099.014774 15633.507506 15251.665643 15151.510512
>>> 15080.352425 15054.392389 14993.864861
>>>   89   10
>>> AIC(n) 9.615430 9.615116 9.615990
>>> HQ(n)  9.629241 9.630552 9.633051
>>> SC(n)  9.655098 9.659451 9.664991
>>> FPE(n) 14994.366572 14989.661383 15002.762011
>>> > var7 = VAR(datax.ts, p=7)> serial.test(var7, lags.pt=10, type =
>>> "PT.asymptotic")
>>>
>>> Portmanteau Test (asymptotic)
>>>
>>> data:  Residuals of VAR object var7Chi-squared = 22.745, df = 12,
>>> p-value = 0.02997
>>> > grangertest(datax.ts[,1] ~ datax.ts[,2], order = 7)Granger causality
>>> test
>>> Model 1: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7) + Lags(datax.ts[,
>>> 2], 1:7)Model 2: datax.ts[, 1] ~ Lags(datax.ts[, 1], 1:7)
>>>   Res.Df Df  FPr(>F)1   56862
>>> 5693 -7 16.105 < 2.2e-16 

[R] prcomp: Error in La.svd(x, nu, nv): error code 1 from Lapack routine "dgesdd"

2017-05-23 Thread Fix Ace via R-help
Dear R community,
I have a data matrix (531X314), and would like to apply the prcomp. However, I 
got this error Lapack message. I am using R3.2.2.
I googled a bit and found that it might be related to converge issue.  Just 
wonder if there is a way to get around it?
Thank you very much!
Ace 

On Thursday, December 29, 2016 11:44 AM, Ista Zahn  
wrote:
 

 Use coord_fixed()

--Ista

On Thu, Dec 29, 2016 at 9:59 AM, Fix Ace via R-help
 wrote:
>
>
>
>  Hello, there,
> What exactly does "expand" do for this function?
> I followed the examples from the manual to get a plot:
>
> d <- ggplot(subset(diamonds, carat > 1), aes(cut, clarity)) +geom_jitter()
>
> I would like to have all the dots in a square instead of rectangular range. 
> When I applied d + scale_x_discrete(expand=c(1,1)) and d + 
> scale_x_discrete(expand=c(1,0)), I got the same plot (different from the 
> original one though).
> Could anyone help me to figure out how to use this argument?
> Thank you very much!
> Ace
>
>
>
>
>
>        [[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.


   
[[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] Compiling R with zlib in non-standard location

2017-05-23 Thread David Chin
Hi Marc,

Pre-compiled RPMs for R are up to 3x slower than "self-compiled" R using
Intel MKL.  Yes, I do know about Microsoft R Open, but it wants to
overwrite the default /usr/bin/R and I have AMD machines in my cluster,
which cannot run MRO. So, I want to do my own compilation and install R in
a non-standard location so that it can be used by loading a modulefile.  I
also have users who have varying requirements for versions of R (for
whatever reason), so I need to provide different versions.



On Tue, May 23, 2017 at 12:50 PM, Marc Schwartz 
wrote:

>
> > On May 23, 2017, at 11:07 AM, David Chin 
> wrote:
> >
> > Hi all,
> >
> > I am trying to compile R 3.4.0 on a RHEL 6.5 system. R requires a newer
> > version of zlib than is standard on RHEL 6.5. I do have a newer version
> > that satisfies R's requirement, but the configure script gives no way of
> > specifying a non-standard location of zlib.
> >
> > Is there a way around this? Or should I try to make a feature request?
> >
> > Thanks in advance,
> >Dave
>
>
> Hi,
>
> This was recently asked here:
>
>   https://stat.ethz.ch/pipermail/r-devel/2017-April/074157.html
>
> Martyn provided a resolution in the follow up post, including a pointer to
> the EPEL, where there are pre-compiled RPMs for R.
>
> For future reference, there is a dedicated e-mail list for queries
> pertaining to R on RH/Fedora based distributions:
>
>   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora
>
> Regards,
>
> Marc Schwartz
>
>


-- 
David Chin, Ph.D.
david.c...@drexel.eduSr. Systems Administrator, URCF, Drexel U.
http://www.drexel.edu/research/urcf/
https://linuxfollies.blogspot.com/
+1.215.221.4747 (mobile)
https://github.com/prehensilecode

[[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] Identyfing rows with specific conditions

2017-05-23 Thread David L Carlson
You will generally get a better response if you create a data set that we can 
test our ideas on. You sketched out the data but your final results include 
meal combinations that are not in your Meals data frame. Also using dput() to 
provide the data makes it easier to recreate the data since just printing it 
loses important information such as if the numbers are integer or decimal, or 
if the character variables are characters or factors. Also send your message as 
plain text, not html which messes up columns and other details. Here is a 
modification of your data with the beginnings of a solution:

Meals <- structure(list(mealAcode = c(34L, 89L, 25L, 34L, 25L), mealBcode = 
c(66L, 
39L, 77L, 39L, 34L)), .Names = c("mealAcode", "mealBcode"), row.names = c(NA, 
-5L), class = "data.frame")
Meals
#   mealAcode mealBcode
# 13466
# 28939
# 32577
# 43439
# 52534

Customers <- structure(list(id = c(15L, 11L, 85L), M1 = c(77L, 25L, 89L), 
M2 = c(34L, 34L, 25L), M3 = c(25L, 39L, 77L)), .Names = c("id", 
"M1", "M2", "M3"), class = "data.frame", row.names = c(NA, -3L
))
Customers
#   id M1 M2 M3
# 1 15 77 34 25
# 2 11 25 34 39
# 3 85 89 25 77

Results <- data.frame(mealAcode=NA, mealBcode=NA, id=NA)
k <- 0
for (i in seq_len(nrow(Meals))) {
for (j in seq_len(nrow(Customers))) {
if (any(Customers[j, -1] %in% Meals[i, 1]) & 
any(Customers[j, -1] %in% Meals[i, 2])) {
   k <- k+1
   Results[k, ] <- cbind(Meals[i, ], id=Customers[j, 1])
}
}
rownames(Results) <- NULL
}
Results
#   mealAcode mealBcode id
# 12577 15
# 22577 85
# 33439 11
# 42534 15
# 52534 11

Results is a data frame that can be modified to get various forms of output. 
You mention a data frame with ids in separate columns. That might be unwieldy 
for many types of analysis. The following list shows the ids for each meal 
combination,  the number of meals of each combination consumed, and a matrix 
similar to the one you provided.

Results.lst <- split(Results$id,  paste(Results[ , 1], Results[ , 2], sep=" - 
"))
Results.lst
# $`25 - 34`
# [1] 15 11
# 
# $`25 - 77`
# [1] 15 85
# 
# $`34 - 39`
# [1] 11
table(Results[, 1:2])
#  mealBcode
# mealAcode 34 39 77
#25  2  0  2
#34  0  1  0
maxid <- 5
t(sapply(Results.lst, function(x) c(sort(as.vector(x)), 
 rep(NA, maxid-length(as.vector(x))
# [,1] [,2] [,3] [,4] [,5]
# 25 - 34   11   15   NA   NA   NA
# 25 - 77   15   85   NA   NA   NA
# 34 - 39   11   NA   NA   NA   NA

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352




-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Allaisone 1
Sent: Monday, May 22, 2017 4:41 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Identyfing rows with specific conditions

Dear Bert

I have answered your questions in my last 2 messages. If you did not see them, 
I will answer again. The 2 tables are all data.frames and the order of the 
meals does not matter. The meal cannot be replicated for each person, they are 
all different. The missing values are to the right end of each row as each row 
starts with meal codes first. This task is just a small part of a long 2 years 
project.

Regards

From: Bert Gunter 
Sent: 22 May 2017 14:35:49
To: Allaisone 1
Cc: r-help@r-project.org
Subject: Re: [R] Identyfing rows with specific conditions

You haven't said whether your "table" is a matrix or data frame.
Presumably the latter.

Nor have you answered my question about whether order of your meal
code pairs matters.

Another question: can meals be replicated for an ID or are they all different?

Finally, is this a homework assignment or class project of some sort?
Or is it a real task -- i.e., what is the context?

Again, be sure to cc the list.

-- 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, May 22, 2017 at 1:56 AM, Allaisone 1  wrote:
> Hi Bert ..,
>
>
> The number of meals differ from one customer to other customer. You may find
> one customer with only one meal and another one with 2,3 or even rarely 30
> meals. You may also
>
> find no meal at all for some customers so the entire row takes the missing
> value "\N" . Any
>
> row starts with the meals codes first, then all missing values are to the
> right end of the table.
>
> 
> From: Bert Gunter 
> Sent: 22 May 2017 03:11:11
> To: Allaisone 1
> Cc: r-help@r-project.org
> Subject: Re: [R] Identyfing rows with specific conditions
>
> 

Re: [R] Compiling R with zlib in non-standard location

2017-05-23 Thread Marc Schwartz
Hi David,

It has been a while since I have worked on RH based systems, but looking at 
Martyn's reply, which includes:

CFLAGS="-g -O2 -I/path/to/my/headers" \
LDFLAGS="-L/path/to/my/libs" \
./configure

and references to the R Installation and Administration manual sections B3.3 
and B7, if you used the lines verbatim as above, you will likely need to 
explicitly 'export' the two flag variables. Thus try:

export CFLAGS="-g -O2 -I/path/to/my/headers" \
export LDFLAGS="-L/path/to/my/libs" \
./configure


Using 'export' will ensure that the environment variables are also passed down 
to child processes started within the current shell session, which may be where 
it is failing.

See if that works. If not, subscribe to and post a new thread to R-SIG-Fedora, 
as there will be a focused audience there.

Regards,

Marc


> On May 23, 2017, at 12:02 PM, David Chin  wrote:
> 
> Hi Marc,
> 
> Pre-compiled RPMs for R are up to 3x slower than "self-compiled" R using
> Intel MKL.  Yes, I do know about Microsoft R Open, but it wants to
> overwrite the default /usr/bin/R and I have AMD machines in my cluster,
> which cannot run MRO. So, I want to do my own compilation and install R in
> a non-standard location so that it can be used by loading a modulefile.  I
> also have users who have varying requirements for versions of R (for
> whatever reason), so I need to provide different versions.
> 
> I also tried the suggested solution
> https://stat.ethz.ch/pipermail/r-devel/2017-April/074162.html  -- but it
> did not work for me. The configure script still picked up zlib.h from
> /usr/include and deduced that it was an older version and would quit with
> error.
> 
> Apologies if this is a duplicate. I sent my first response with the wrong
> email address.
> 
> 
> On Tue, May 23, 2017 at 12:50 PM, Marc Schwartz 
> wrote:
> 
>> 
>>> On May 23, 2017, at 11:07 AM, David Chin 
>> wrote:
>>> 
>>> Hi all,
>>> 
>>> I am trying to compile R 3.4.0 on a RHEL 6.5 system. R requires a newer
>>> version of zlib than is standard on RHEL 6.5. I do have a newer version
>>> that satisfies R's requirement, but the configure script gives no way of
>>> specifying a non-standard location of zlib.
>>> 
>>> Is there a way around this? Or should I try to make a feature request?
>>> 
>>> Thanks in advance,
>>>   Dave
>> 
>> 
>> Hi,
>> 
>> This was recently asked here:
>> 
>>  https://stat.ethz.ch/pipermail/r-devel/2017-April/074157.html
>> 
>> Martyn provided a resolution in the follow up post, including a pointer to
>> the EPEL, where there are pre-compiled RPMs for R.
>> 
>> For future reference, there is a dedicated e-mail list for queries
>> pertaining to R on RH/Fedora based distributions:
>> 
>>  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora
>> 
>> Regards,
>> 
>> Marc Schwartz
>> 
>> 

__
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] Compiling R with zlib in non-standard location

2017-05-23 Thread David Chin
Hi Marc,

Pre-compiled RPMs for R are up to 3x slower than "self-compiled" R using
Intel MKL.  Yes, I do know about Microsoft R Open, but it wants to
overwrite the default /usr/bin/R and I have AMD machines in my cluster,
which cannot run MRO. So, I want to do my own compilation and install R in
a non-standard location so that it can be used by loading a modulefile.  I
also have users who have varying requirements for versions of R (for
whatever reason), so I need to provide different versions.

I also tried the suggested solution
https://stat.ethz.ch/pipermail/r-devel/2017-April/074162.html  -- but it
did not work for me. The configure script still picked up zlib.h from
/usr/include and deduced that it was an older version and would quit with
error.

Apologies if this is a duplicate. I sent my first response with the wrong
email address.


On Tue, May 23, 2017 at 12:50 PM, Marc Schwartz 
wrote:

>
> > On May 23, 2017, at 11:07 AM, David Chin 
> wrote:
> >
> > Hi all,
> >
> > I am trying to compile R 3.4.0 on a RHEL 6.5 system. R requires a newer
> > version of zlib than is standard on RHEL 6.5. I do have a newer version
> > that satisfies R's requirement, but the configure script gives no way of
> > specifying a non-standard location of zlib.
> >
> > Is there a way around this? Or should I try to make a feature request?
> >
> > Thanks in advance,
> >Dave
>
>
> Hi,
>
> This was recently asked here:
>
>   https://stat.ethz.ch/pipermail/r-devel/2017-April/074157.html
>
> Martyn provided a resolution in the follow up post, including a pointer to
> the EPEL, where there are pre-compiled RPMs for R.
>
> For future reference, there is a dedicated e-mail list for queries
> pertaining to R on RH/Fedora based distributions:
>
>   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora
>
> Regards,
>
> Marc Schwartz
>
>


-- 
David Chin, Ph.D.
david.c...@drexel.eduSr. Systems Administrator, URCF, Drexel U.
http://www.drexel.edu/research/urcf/
https://linuxfollies.blogspot.com/
215.221.4747 (mobile)
https://github.com/prehensilecode

[[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] Fitdistrplus and Parameter Constraints

2017-05-23 Thread Christophe Dutang
Dear Lorenzo,

Please do read the posting guide (https://www.r-project.org/posting-guide.html) 
: The ‘main’ R mailing list, for discussion about problems and solutions using 
R, about the availability of new functionality for R and documentation of R, 
comparison and compatibility with S-plus, and for the posting of nice examples 
and benchmarks.


For your problem, you could do something like this

x <- rbeta(1000, 3, 3)

dbeta2 <- function(x, shape, ...)
dbeta(x, shape, shape, ...)
pbeta2 <- function(q, shape, ...)
pbeta(q, shape, shape, ...) 

library(fitdistrplus)
fitdist(x, "beta2", start=list(shape=1/2))

x <- rbeta(1000, .3, .3)
fitdist(x, "beta2", start=list(shape=1/2), optim.method="L-BFGS-B", lower=1e-2) 
 
Regards, Christophe
---
Christophe Dutang
LMM, UdM, Le Mans, France
web: http://dutangc.free.fr

> Le 23 mai 2017 à 18:22, Lorenzo Isella  a écrit :
> 
> Dear All,
> In principle it is a simple question, but not idea about how to tackle
> it.
> Suppose you have a distribution depending on two parameters,
> e.g. beta(a,b).
> For some reasons, you want to impose
> that the two parameters of the beta distribution are identical,
> i.e. you want to fit your data to beta(a,a).
> For instance
> 
> x<-rbeta(1000, 0.1, 0.1)
> require(fitdistrplus)
> 
> mm<-fitdist(x, "beta",  method = "mge")
> 
> 
> is how you would normally fit a sample, but I do not know how to
> impose the constrain a=b before the fitting.
> Any suggestion is appreciated.
> Cheers
> 
> Lorenzo

__
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] Compiling R with zlib in non-standard location

2017-05-23 Thread Marc Schwartz

> On May 23, 2017, at 11:07 AM, David Chin  wrote:
> 
> Hi all,
> 
> I am trying to compile R 3.4.0 on a RHEL 6.5 system. R requires a newer
> version of zlib than is standard on RHEL 6.5. I do have a newer version
> that satisfies R's requirement, but the configure script gives no way of
> specifying a non-standard location of zlib.
> 
> Is there a way around this? Or should I try to make a feature request?
> 
> Thanks in advance,
>Dave


Hi,

This was recently asked here:

  https://stat.ethz.ch/pipermail/r-devel/2017-April/074157.html

Martyn provided a resolution in the follow up post, including a pointer to the 
EPEL, where there are pre-compiled RPMs for R.

For future reference, there is a dedicated e-mail list for queries pertaining 
to R on RH/Fedora based distributions:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

Regards,

Marc Schwartz

__
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] Compiling R with zlib in non-standard location

2017-05-23 Thread David Chin
Hi all,

I am trying to compile R 3.4.0 on a RHEL 6.5 system. R requires a newer
version of zlib than is standard on RHEL 6.5. I do have a newer version
that satisfies R's requirement, but the configure script gives no way of
specifying a non-standard location of zlib.

Is there a way around this? Or should I try to make a feature request?

Thanks in advance,
Dave

-- 
David Chin, Ph.D.
david.c...@drexel.eduSr. Systems Administrator, URCF, Drexel U.
http://www.drexel.edu/research/urcf/
https://linuxfollies.blogspot.com/
215.221.4747 (mobile)
https://github.com/prehensilecode

[[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] About change columns and specific rows in R

2017-05-23 Thread lily li
Thanks for all your help. It works now.

On Tue, May 23, 2017 at 1:34 AM, William Michels via R-help <
r-help@r-project.org> wrote:

> Hi Ivan,
>
> I was just writing a follow-up note as your note came in. While the
> code I posted previously works fine, using which() is unnecessary.
>
> > DF <- read.csv("~/lily.csv")
> > DF$product1_1 <- NA
> > DF$product1_1 <- DF[DF$month == 1, "product1"]*3.1
> Error in `$<-.data.frame`(`*tmp*`, "product1_1", value = c(55.8, 58.9,  :
>   replacement has 4 rows, data has 7
> > DF$product1_1 <- DF[which(DF$month == 1), "product1"]*3.1
> Error in `$<-.data.frame`(`*tmp*`, "product1_1", value = c(55.8, 58.9,  :
>   replacement has 4 rows, data has 7
> > DF[DF$month == 1, "product1_1"] <- DF[DF$month == 1, "product1"]*3.1
> > DF
>   year month day product1 product2 product3 product1_1
> 1 1981 1   1   18   56   20   55.8
> 2 1981 1   2   19   45   22   58.9
> 3 1981 1   3   16   48   28   49.6
> 4 1981 1   4   19   50   21   58.9
> 5 1981 2   1   17   49   25 NA
> 6 1981 2   2   20   47   23 NA
> 7 1981 2   3   21   52   27 NA
> >
>
> The two errors above were caused because I failed to specify rows on
> the left hand side of the assignment operator, not because I failed to
> use which(). Once rows and columns are specified on both sides, the
> assignment works fine.
>
> (I do however, prefer to create an "NA" column first. Personal preference
> ;-).
>
> Best Regards,
>
> Bill.
>
>
>
> On Mon, May 22, 2017 at 11:57 PM, Ivan Calandra  wrote:
> > Hi,
> >
> > Actually, you don't need to create the column first, nor to use which:
> > DF[DF$month==1, "product1_1"] = DF[DF$month==1, "product1"] * 3.1
> >
> > The "[" is a great tool that you need to learn. In this case, you don't
> need
> > to combine "[" and $: within the square brackets, the vector before the
> > comma indexes the rows and the one after the comma indexes the columns.
> >
> > The other thing you were missing correctly referencing the rows. You
> have to
> > specify the data.frame you want to look into.
> >
> > And last, learn to use dput() to provide a nice reproducible example.
> >
> > HTH,
> > Ivan
> >
> >
> > --
> > Dr. Ivan Calandra
> > TraCEr, Laboratory for Traceology and Controlled Experiments
> > MONREPOS Archaeological Research Centre and
> > Museum for Human Behavioural Evolution
> > Schloss Monrepos
> > 56567 Neuwied, Germany
> > +49 (0) 2631 9772-243
> > https://www.researchgate.net/profile/Ivan_Calandra
> >
> > On 23/05/2017 08:45, William Michels via R-help wrote:
> >>
> >> Hi Lily,
> >>
> >> You're on the right track, but you should define a new column first
> >> (filled with NA values), then specify the precise rows and columns on
> >> both the left and right hand sides of the assignment operator that
> >> will be altered. Luckily, this is pretty easy...just remember to use
> >> which() on the right hand side of the assignment operator to get the
> >> index of the rows you want. Example below for "product1":
> >>
> >>> DF$product1_1 <- NA
> >>> DF[DF$month == 1, "product1_1"] <- DF[which(DF$month == 1),
> >>> "product1"]*3.1
> >>>
> >>
> >> HTH,
> >>
> >> Bill.
> >>
> >> William Michels, Ph.D.
> >>
> >>
> >>
> >>
> >> On Mon, May 22, 2017 at 9:56 PM, lily li  wrote:
> >>>
> >>> Hi R users,
> >>>
> >>> I have a question about manipulating the dataframe. I want to create a
> >>> new
> >>> dataframe, and to multiply rows with different seasons for different
> >>> constants.
> >>>
> >>> DF
> >>> year   month   day   product1   product2   product3
> >>> 1981 1  1 18  5620
> >>> 1981 1  2 19  4522
> >>> 1981 1  3 16  4828
> >>> 1981 1  4 19  5021
> >>> 1981 2  1 17  4925
> >>> 1981 2  2 20  4723
> >>> 1981 2  3 21  5227
> >>>
> >>> For example, how to multiply product1 in month1 by 3.1, and to multiply
> >>> product3 in month2 by 2.0? I wrote the code like this but does not
> work.
> >>> Thanks for your help.
> >>>
> >>> DF['month'==1, ]$product1_1 = DF['month'==1, ]$product1 * 3.1;
> >>> DF['month'==2, ]$product3_1 = DF['month'==1, ]$product3 * 2.0;
> >>>
> >>>  [[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] Fitdistrplus and Parameter Constraints

2017-05-23 Thread Lorenzo Isella

Dear All,
In principle it is a simple question, but not idea about how to tackle
it.
Suppose you have a distribution depending on two parameters,
e.g. beta(a,b).
For some reasons, you want to impose
that the two parameters of the beta distribution are identical,
i.e. you want to fit your data to beta(a,a).
For instance

x<-rbeta(1000, 0.1, 0.1)
require(fitdistrplus)

mm<-fitdist(x, "beta",  method = "mge")


is how you would normally fit a sample, but I do not know how to
impose the constrain a=b before the fitting.
Any suggestion is appreciated.
Cheers

Lorenzo

__
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] Xtractomatic version 3.3.2 now available on CRAN

2017-05-23 Thread Roy Mendelssohn - NOAA Federal
The xtractomatic package version 3.3.2 is now available on CRAN.  Besides the 
improvements listed below,  this release fixes a problem caused by an update to 
the Apache Tomcat used by the ERDDAP server,  that broke an important function 
in the package.

Many thanks to the CRAN maintainers for help in getting this on CRAN.

List of changes below,  as always the development version is available at 
https://github.com/rmendels/xtractomatic

-Roy

• Fixes problem with newer versions of Apache Tomcat handling of 
special characters in URLS
• dtype as number no longer allowed
• searchData() now takes a list of objects of the form 
"searchType:searchString"
• new datasets added
• inactive or out of date datasets removed



**
"The contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

__
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] Installing ranger package in Ubuntu 14

2017-05-23 Thread Jeff Newmiller
A) This should be asked on R-sig-debian or R-devel. This list is about the R 
language and basic installation issues... compiled installation debugging 
requires OS and C language skills that are OT here. 

B) You should read and follow the advice in the Posting Guide for all R mailing 
lists,  specifically about posting using plain text email. 

C) You need to use the same compiler setup for the package as you used to 
install R. If you are not using the system package manager then you should 
probably be clear in your question about what your original configure setup was 
for R when you ask for help elsewhere. Beyond that I have no experience to 
offer, as using the system package manager has been adequate for my needs.
-- 
Sent from my phone. Please excuse my brevity.

On May 22, 2017 2:35:33 PM PDT, "Iván Blanco"  wrote:
>I'm trying to install ranger package (any version) in Ubuntu 14 from a
>tar.gz file already downloaded, but unsuccessfully. System admin has
>already installed gcc 5.4 and g++ 5.4 and I've created a ~/.R/Makevars
>file pointing to these compilers instead of gcc 4.8 that comes in
>Ubuntu 14 by default.  Ranger requires gcc 4.9 or higher. That Makevars
>file looks like this:
>
>CC=/storage/home/user/bin/gcc-5
>CCXX=/storage/home/user/bin/g++-5
>FC=/storage/home/user/bin/gfortran-6
>F77=/storage/home/user/bin/gfortran-6
>
>I don’t have admin rights and system admin can't change gcc path for
>the whole server. Output error is this one:
>
>=
>* installing *source* package ârangerâ ...
>** package ârangerâ successfully unpacked and MD5 sums checked
>** libs
>g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DR_BUILD
>-I"/storage/home/user/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"  
>-fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security
>-Wdate-time -D_FORTIFY_SOURCE=2 -g -c AAA_check_cpp11.cpp -o
>AAA_check_cpp11.o
>g++: error: unrecognized command line option â-fstack-protector-strongâ
>g++: error: unrecognized command line option â-Wdate-timeâ
>/usr/lib/R/etc/Makeconf:168: recipe for target 'AAA_check_cpp11.o'
>failed
>make: *** [AAA_check_cpp11.o] Error 1
>ERROR: compilation failed for package ârangerâ
>* removing
>â/storage/home/u382324/R/x86_64-pc-linux-gnu-library/3.4/rangerâ
>
>The downloaded source packages are in
>â/tmp/RtmpXUQwl6/downloaded_packagesâ
>Warning message:
>In install.packages("ranger") :
>  installation of package ârangerâ had non-zero exit status
>==
>
>It seems I’m missing some flag defintion in my Makevars and R is using
>the default gcc 4.8 compiler, I don’t know. Any advice about how to
>procceed would be very helpful. Thanks.
>
>Kind regards,
>
>Ivan
>
>   [[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.

[R] [R-pkgs] Announcing snakecase 0.4.0

2017-05-23 Thread Malte Grosser via R-packages
I am pleased to announce a fresh and simple approach on automatic
caseconversion with a concise design philosophy via the snakecase-pkg (
https://cran.r-project.org/package=snakecase).

Just use to_any_case(string, case) and (if the cases are too complex for
the default options) provide its most important arguments with further
information about:
- how a string should be parsed (regular expressions)
- how the result should be split (character).
On the way you can achieve things like special character handling and minor
customizations as also documented on github (
https://github.com/Tazinho/snakecase)

Examples:
- Easy case conversions:
"RStudio" to "R_Studio" (parsed) "r_studio", "R_STUDIO", "rStudio",
"RStudio"  or choose any other separator than the default "_" or "".
- More complex (different meanings of dots (separator or decimal) and
umlauts)
"R.Stüdio: v.1.0.143" to "rstüdio_v_1_0_143" or "r_stüdio_v_1.0.143", "R
Stuedio v 1.0.143",...

Note that the usecases are not only formatting for naming conventions
itself, but also for automated pretty printing like "RStudio" to "R Studio".

Best,
Malte Grosser

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

Re: [R] R-help Digest, Vol 171, Issue 20

2017-05-23 Thread Crump, Ron
Hi Brigitte,

>Did somebody know why asreml does not provide the same REML loglikehood
>as coxme, lme4 or lmne.

I don't know the answer to this, but I'd guess it is either to do with the
use of the average information REML algorithm or asreml-r is for some
reason ending up with a different subset of the data.

>If it was just a constant value between the two models (with or without
>the fixed effect) it would not be important. But it is not.
>I checked that the variance component estimators were equal.

I'm still not clear that it is important (if the data subset analysed is
the same). You would only use the REML likelihoods to compare models with
different random effects and the same fixed effect structure (is there
another use for the REML likelihood other than that?), so then it is
really a question of whether for a given pair of random effect models and
the same data the likelihood ratio test statistic  changes across analysis
methods. Unless for some reason you are comparing two random effect models
fitted with different routines (one of which is asreml-r).

Ron.

__
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] Installing ranger package in Ubuntu 14

2017-05-23 Thread Iván Blanco
I'm trying to install ranger package (any version) in Ubuntu 14 from a tar.gz 
file already downloaded, but unsuccessfully. System admin has already installed 
gcc 5.4 and g++ 5.4 and I've created a ~/.R/Makevars file pointing to these 
compilers instead of gcc 4.8 that comes in Ubuntu 14 by default.  Ranger 
requires gcc 4.9 or higher. That Makevars file looks like this:

CC=/storage/home/user/bin/gcc-5
CCXX=/storage/home/user/bin/g++-5
FC=/storage/home/user/bin/gfortran-6
F77=/storage/home/user/bin/gfortran-6

I don’t have admin rights and system admin can't change gcc path for the whole 
server. Output error is this one:

=
* installing *source* package ârangerâ ...
** package ârangerâ successfully unpacked and MD5 sums checked
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DR_BUILD 
-I"/storage/home/user/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"-fpic  
-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -c AAA_check_cpp11.cpp -o AAA_check_cpp11.o
g++: error: unrecognized command line option â-fstack-protector-strongâ
g++: error: unrecognized command line option â-Wdate-timeâ
/usr/lib/R/etc/Makeconf:168: recipe for target 'AAA_check_cpp11.o' failed
make: *** [AAA_check_cpp11.o] Error 1
ERROR: compilation failed for package ârangerâ
* removing â/storage/home/u382324/R/x86_64-pc-linux-gnu-library/3.4/rangerâ

The downloaded source packages are in
â/tmp/RtmpXUQwl6/downloaded_packagesâ
Warning message:
In install.packages("ranger") :
  installation of package ârangerâ had non-zero exit status
==

It seems I’m missing some flag defintion in my Makevars and R is using the 
default gcc 4.8 compiler, I don’t know. Any advice about how to procceed would 
be very helpful. Thanks.

Kind regards,

Ivan

[[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] P value of VAR model from Portmanteau Test

2017-05-23 Thread Rui Barradas

Hello,

It seems to be right.
You have Chi-squared = 23.724, df = 8, p-value = 0.002549. So try the R 
function ?pchisq:


pchisq(23.724, df = 8, lower = FALSE)
[1] 0.002549054

Hope this helps,

Rui Barradas

Em 23-05-2017 13:08, Dhivya Narayanasamy escreveu:

Hi,

I am working with bivariate time series data. I used VAR model to fit and
forecast.
But the "*p*" value from seria.test (Portmanteau Test) gives values *p<<
0.05*. Is that okay?



var1 = VAR(datax.ts, p= 8)
serial.test(var1, lags.pt=10, type = "PT.asymptotic")


Portmanteau Test (asymptotic)

data:  Residuals of VAR object var1
Chi-squared = 23.724, df = 8, p-value = 0.002549

Am i doing it correct? or Is this wrong? Should the value of P supposed to
be greater than >> 0.05 ?  When i forecast this VAR model, it gives *flat
forecast* which is again wrong. Please help me.


Regards| Mit freundlichen Grüßen,

Dhivya Narayanasamy



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

[R] P value of VAR model from Portmanteau Test

2017-05-23 Thread Dhivya Narayanasamy
Hi,

I am working with bivariate time series data. I used VAR model to fit and
forecast.
But the "*p*" value from seria.test (Portmanteau Test) gives values *p<<
0.05*. Is that okay?


> var1 = VAR(datax.ts, p= 8)
> serial.test(var1, lags.pt=10, type = "PT.asymptotic")

Portmanteau Test (asymptotic)

data:  Residuals of VAR object var1
Chi-squared = 23.724, df = 8, p-value = 0.002549

Am i doing it correct? or Is this wrong? Should the value of P supposed to
be greater than >> 0.05 ?  When i forecast this VAR model, it gives *flat
forecast* which is again wrong. Please help me.


Regards| Mit freundlichen Grüßen,
> Dhivya Narayanasamy
>

[[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] Error in readRDS(dest) (was Re: Error with installed.packages with R 3.4.0 on Windows)

2017-05-23 Thread Martin Maechler
> Patrick Connolly 
> on Tue, 23 May 2017 20:47:22 +1200 writes:

> On Mon, 22-May-2017 at 05:43AM -0400, Martin Morgan wrote:
> |> On 05/22/2017 05:10 AM, Patrick Connolly wrote:

> |> >Apparently it isn't harmless.
> |> >
> |> >>install.packages("withr")
> |> >Error in readRDS(dest) : error reading from connection
> |> 
> |> that seems like a plain-old network connectivity issue, or perhaps
> |> an issue with the CRAN mirror you're using. Can you debug on your
> |> end, e.g,.
> |> 
> |>   options(error=recover)
> |>   install.packages("withr")
> |>   ...
> |> 
> |> then select the 'frame' where the error occurs, look around
> |> 
> |>   ls()
> |> 
> |> find the value of 'dest', and e.g., try to open dest in your  browser.

> This is what I get

>> options(error=recover)
>> install.packages("withr")
> ^C

> Enter a frame number, or 0 to exit   

> 1: install.packages("withr")
> 2: available.packages(contriburl = contriburl, method = method)
> 3: tryCatch({
> download.file(url = paste0(repos, "/PACKAGES.rds"), destfile
> 4: tryCatchList(expr, classes, parentenv, handlers)
> 5: tryCatchOne(expr, names, parentenv, handlers[[1]])
> 6: doTryCatch(return(expr), name, parentenv, handler)
> 7: download.file(url = paste0(repos, "/PACKAGES.rds"), destfile = dest, 
method

> Selection: 7

'7'  was the wrong choice:  'dest' exists in the frame that
 *calls* download.file, in this case, it is frame 2, i.e.,
 inside available.packages(.)  where the  tryCatch() call to
 download.file() happens.

Given the above stack trace. 
It may be easier to just do

debugonce(available.packages)
install.packages("withr")

and then inside available.packages, (using 'n') step to the
point _before_ the tryCatch(...) call happens; there, e.g. use

  ls.str()

which gives an str() of all your local objects, notably 'dest'
and 'method'.
but you can also try other things once inside
available.packages().

Martin


> Called from: eval(substitute(browser(skipCalls = skip), list(skip = 7 - 
which)), 
> envir = sys.frame(which))
> Browse[1]> dest
> Error during wrapup: object 'dest' not found

> That indicates to me that the problem is further back but I have no
> idea how make use of that information.


> Browse[1]> ls()
> [1] "cacheOK"  "destfile" "extra""method"   "mode" "quiet"
"url" 
> Browse[1]> url
> [1] "http://cran.stat.auckland.ac.nz/src/contrib/PACKAGES.rds;
> Browse[1]> destfile
> [1] 
"/tmp/RtmpplJSrB/repos_http%3A%2F%2Fcran.stat.auckland.ac.nz%2Fsrc%2Fcontrib.rds"
> Browse[1]> 

> The destfile above is zero-length and I suppose is where dest is
> intended to end up.

> Where else should I be looking?  Earlier installations never had this
> issue so I don't have anything to compare.

> TIA
> --

__
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] Duplicate row names are not allowed

2017-05-23 Thread peter dalgaard
Presumably, RCommander's readXL generates an invalid data frame (John?). To 
investigate, look at

row.names(Dataset)

and to fix 

row.names(Dataset) <- NULL

If the issue is that Dataset really isn't a data frame, maybe try Dataset <- 
as.data.frame(Dataset).

[Your screenshot made it through to here, but not the data. Notice, as a 
general matter, that it is preferable to give your code as part of the message 
text; it is hard to copy-paste from a .png]

-pd

> On 22 May 2017, at 21:02 , ville iiskola via R-help  
> wrote:
> 
> Hi
> I read a book where was shown an example how to create a probability model 
> with mlogit. I tried to do like the instruction said but i get error message 
> that "duplicate row names are not allowed". What could i do to fix it?
> 
> I had the data in excel and imported it to R using R commander. I attach the 
> data file and print sqreen of my code to here if somebody could help the 
> novice. Ville<2017-05-21 
> (1).png>__
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.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.


[R] Error in readRDS(dest) (was Re: Error with installed.packages with R 3.4.0 on Windows)

2017-05-23 Thread Patrick Connolly
On Mon, 22-May-2017 at 05:43AM -0400, Martin Morgan wrote:

|> On 05/22/2017 05:10 AM, Patrick Connolly wrote:

|> >Apparently it isn't harmless.
|> >
|> >>install.packages("withr")
|> >Error in readRDS(dest) : error reading from connection
|> 
|> that seems like a plain-old network connectivity issue, or perhaps
|> an issue with the CRAN mirror you're using. Can you debug on your
|> end, e.g,.
|> 
|>   options(error=recover)
|>   install.packages("withr")
|>   ...
|> 
|> then select the 'frame' where the error occurs, look around
|> 
|>   ls()
|> 
|> find the value of 'dest', and e.g., try to open dest in your  browser.

This is what I get

>   options(error=recover)
>   install.packages("withr")
^C

Enter a frame number, or 0 to exit   

1: install.packages("withr")
2: available.packages(contriburl = contriburl, method = method)
3: tryCatch({
download.file(url = paste0(repos, "/PACKAGES.rds"), destfile
4: tryCatchList(expr, classes, parentenv, handlers)
5: tryCatchOne(expr, names, parentenv, handlers[[1]])
6: doTryCatch(return(expr), name, parentenv, handler)
7: download.file(url = paste0(repos, "/PACKAGES.rds"), destfile = dest, method

Selection: 7
Called from: eval(substitute(browser(skipCalls = skip), list(skip = 7 - 
which)), 
envir = sys.frame(which))
Browse[1]> dest
Error during wrapup: object 'dest' not found

That indicates to me that the problem is further back but I have no
idea how make use of that information.


Browse[1]> ls()
[1] "cacheOK"  "destfile" "extra""method"   "mode" "quiet""url" 
Browse[1]> url
[1] "http://cran.stat.auckland.ac.nz/src/contrib/PACKAGES.rds;
Browse[1]> destfile
[1] 
"/tmp/RtmpplJSrB/repos_http%3A%2F%2Fcran.stat.auckland.ac.nz%2Fsrc%2Fcontrib.rds"
Browse[1]> 

The destfile above is zero-length and I suppose is where dest is
intended to end up.

Where else should I be looking?  Earlier installations never had this
issue so I don't have anything to compare.

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.


Re: [R] About change columns and specific rows in R

2017-05-23 Thread William Michels via R-help
Hi Ivan,

I was just writing a follow-up note as your note came in. While the
code I posted previously works fine, using which() is unnecessary.

> DF <- read.csv("~/lily.csv")
> DF$product1_1 <- NA
> DF$product1_1 <- DF[DF$month == 1, "product1"]*3.1
Error in `$<-.data.frame`(`*tmp*`, "product1_1", value = c(55.8, 58.9,  :
  replacement has 4 rows, data has 7
> DF$product1_1 <- DF[which(DF$month == 1), "product1"]*3.1
Error in `$<-.data.frame`(`*tmp*`, "product1_1", value = c(55.8, 58.9,  :
  replacement has 4 rows, data has 7
> DF[DF$month == 1, "product1_1"] <- DF[DF$month == 1, "product1"]*3.1
> DF
  year month day product1 product2 product3 product1_1
1 1981 1   1   18   56   20   55.8
2 1981 1   2   19   45   22   58.9
3 1981 1   3   16   48   28   49.6
4 1981 1   4   19   50   21   58.9
5 1981 2   1   17   49   25 NA
6 1981 2   2   20   47   23 NA
7 1981 2   3   21   52   27 NA
>

The two errors above were caused because I failed to specify rows on
the left hand side of the assignment operator, not because I failed to
use which(). Once rows and columns are specified on both sides, the
assignment works fine.

(I do however, prefer to create an "NA" column first. Personal preference ;-).

Best Regards,

Bill.



On Mon, May 22, 2017 at 11:57 PM, Ivan Calandra  wrote:
> Hi,
>
> Actually, you don't need to create the column first, nor to use which:
> DF[DF$month==1, "product1_1"] = DF[DF$month==1, "product1"] * 3.1
>
> The "[" is a great tool that you need to learn. In this case, you don't need
> to combine "[" and $: within the square brackets, the vector before the
> comma indexes the rows and the one after the comma indexes the columns.
>
> The other thing you were missing correctly referencing the rows. You have to
> specify the data.frame you want to look into.
>
> And last, learn to use dput() to provide a nice reproducible example.
>
> HTH,
> Ivan
>
>
> --
> Dr. Ivan Calandra
> TraCEr, Laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 23/05/2017 08:45, William Michels via R-help wrote:
>>
>> Hi Lily,
>>
>> You're on the right track, but you should define a new column first
>> (filled with NA values), then specify the precise rows and columns on
>> both the left and right hand sides of the assignment operator that
>> will be altered. Luckily, this is pretty easy...just remember to use
>> which() on the right hand side of the assignment operator to get the
>> index of the rows you want. Example below for "product1":
>>
>>> DF$product1_1 <- NA
>>> DF[DF$month == 1, "product1_1"] <- DF[which(DF$month == 1),
>>> "product1"]*3.1
>>>
>>
>> HTH,
>>
>> Bill.
>>
>> William Michels, Ph.D.
>>
>>
>>
>>
>> On Mon, May 22, 2017 at 9:56 PM, lily li  wrote:
>>>
>>> Hi R users,
>>>
>>> I have a question about manipulating the dataframe. I want to create a
>>> new
>>> dataframe, and to multiply rows with different seasons for different
>>> constants.
>>>
>>> DF
>>> year   month   day   product1   product2   product3
>>> 1981 1  1 18  5620
>>> 1981 1  2 19  4522
>>> 1981 1  3 16  4828
>>> 1981 1  4 19  5021
>>> 1981 2  1 17  4925
>>> 1981 2  2 20  4723
>>> 1981 2  3 21  5227
>>>
>>> For example, how to multiply product1 in month1 by 3.1, and to multiply
>>> product3 in month2 by 2.0? I wrote the code like this but does not work.
>>> Thanks for your help.
>>>
>>> DF['month'==1, ]$product1_1 = DF['month'==1, ]$product1 * 3.1;
>>> DF['month'==2, ]$product3_1 = DF['month'==1, ]$product3 * 2.0;
>>>
>>>  [[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.
>>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 

Re: [R] About change columns and specific rows in R

2017-05-23 Thread Ivan Calandra

Hi,

Actually, you don't need to create the column first, nor to use which:
DF[DF$month==1, "product1_1"] = DF[DF$month==1, "product1"] * 3.1

The "[" is a great tool that you need to learn. In this case, you don't 
need to combine "[" and $: within the square brackets, the vector before 
the comma indexes the rows and the one after the comma indexes the columns.


The other thing you were missing correctly referencing the rows. You 
have to specify the data.frame you want to look into.


And last, learn to use dput() to provide a nice reproducible example.

HTH,
Ivan


--
Dr. Ivan Calandra
TraCEr, Laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 23/05/2017 08:45, William Michels via R-help wrote:

Hi Lily,

You're on the right track, but you should define a new column first
(filled with NA values), then specify the precise rows and columns on
both the left and right hand sides of the assignment operator that
will be altered. Luckily, this is pretty easy...just remember to use
which() on the right hand side of the assignment operator to get the
index of the rows you want. Example below for "product1":


DF$product1_1 <- NA
DF[DF$month == 1, "product1_1"] <- DF[which(DF$month == 1), "product1"]*3.1



HTH,

Bill.

William Michels, Ph.D.




On Mon, May 22, 2017 at 9:56 PM, lily li  wrote:

Hi R users,

I have a question about manipulating the dataframe. I want to create a new
dataframe, and to multiply rows with different seasons for different
constants.

DF
year   month   day   product1   product2   product3
1981 1  1 18  5620
1981 1  2 19  4522
1981 1  3 16  4828
1981 1  4 19  5021
1981 2  1 17  4925
1981 2  2 20  4723
1981 2  3 21  5227

For example, how to multiply product1 in month1 by 3.1, and to multiply
product3 in month2 by 2.0? I wrote the code like this but does not work.
Thanks for your help.

DF['month'==1, ]$product1_1 = DF['month'==1, ]$product1 * 3.1;
DF['month'==2, ]$product3_1 = DF['month'==1, ]$product3 * 2.0;

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



__
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] About change columns and specific rows in R

2017-05-23 Thread William Michels via R-help
Hi Lily,

You're on the right track, but you should define a new column first
(filled with NA values), then specify the precise rows and columns on
both the left and right hand sides of the assignment operator that
will be altered. Luckily, this is pretty easy...just remember to use
which() on the right hand side of the assignment operator to get the
index of the rows you want. Example below for "product1":

> DF$product1_1 <- NA
> DF[DF$month == 1, "product1_1"] <- DF[which(DF$month == 1), "product1"]*3.1
>


HTH,

Bill.

William Michels, Ph.D.




On Mon, May 22, 2017 at 9:56 PM, lily li  wrote:
> Hi R users,
>
> I have a question about manipulating the dataframe. I want to create a new
> dataframe, and to multiply rows with different seasons for different
> constants.
>
> DF
> year   month   day   product1   product2   product3
> 1981 1  1 18  5620
> 1981 1  2 19  4522
> 1981 1  3 16  4828
> 1981 1  4 19  5021
> 1981 2  1 17  4925
> 1981 2  2 20  4723
> 1981 2  3 21  5227
>
> For example, how to multiply product1 in month1 by 3.1, and to multiply
> product3 in month2 by 2.0? I wrote the code like this but does not work.
> Thanks for your help.
>
> DF['month'==1, ]$product1_1 = DF['month'==1, ]$product1 * 3.1;
> DF['month'==2, ]$product3_1 = DF['month'==1, ]$product3 * 2.0;
>
> [[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.