Re: [R] Changing UTC time to a time zone different from system time zone

2014-12-29 Thread Prof Brian Ripley

On 28/12/2014 21:52, Jeff Newmiller wrote:

Very few attachment file types are allowed through the mailing list, and
yours did not make it.

I noticed that your format strings did not appear consistent... see the
format string I use below, and make sure the characters between the
numeric parts of your format are correct for your case. Did you read the
help file ?strptime ?

Note that there are two steps... importing the character data to a
POSIXct type, and then choosing how you want to display those instants
of time in whatever time zones you wish. That is, regardless of time
zone, the POSIXct value represents the same instant of time regardless
of time zone you want to display it in, while POSIXlt will in general
have different internal representations that match the external
representations.

Note that you really do need to read ?timezone, because the below code
only works if your system understands the GMT and Australia/Darwin
timezones, and that is operating-system-specific behavior.  This was
successfully run on Ubuntu... you did not mention your operating system.


Correct, but for R = 3.1.0 that help page says

'Almost all R platforms make use of a time-zone database originally
 compiled by Arthur David Olson and now managed by IANA, in which
 the preferred way to refer to a time zone is by a location ...'

and GMT is always supported although UTC is preferred.

All the platforms documented in 'R Installation and Administration' do 
make such use; however occasionally we hear of new ports, hence the 
cautious use of 'Almost'.


However, we were also not told the R version 




tst - 2014-12-25 00:00 # GMT
tstct - as.POSIXct( tst, format=%Y-%m-%d %H:%M, tz=GMT )
tstct

[1] 2014-12-25 GMT

unclass(tstct)

[1] 1419465600
attr(,tzone)
[1] GMT

tstlt - as.POSIXlt( tstct, tz=Australia/Darwin )
tstlt

[1] 2014-12-25 09:30:00 ACST

unclass(tstlt)

$sec
[1] 0

$min
[1] 30

$hour
[1] 9

$mday
[1] 25

$mon
[1] 11

$year
[1] 114

$wday
[1] 4

$yday
[1] 358

$isdst
[1] 0

$zone
[1] ACST

$gmtoff
[1] 34200

attr(,tzone)
[1] Australia/Darwin ACST ACDT

tstct2 - as.POSIXct( tstlt )
tstct2

[1] 2014-12-25 09:30:00 ACST

unclass(tstct2)

[1] 1419465600
attr(,tzone)
[1] Australia/Darwin


On Sun, 28 Dec 2014, Faranak Golestaneh wrote:


Dear Friends, I?ve just started using R. I am working on a database
containing date-time as well as numeric values. Firstly I have changed
the
class of the data/time column from factor to POSIXlt. Time and date are
based on UTC time but I need to change them to a local time ( not my
local
time, my zone is Singapore but the data are from Australia) so I need to
change the time and date to Australia time say e.g AEST. I tried one
way or
another but all failed. The following is example of the command I used.
Also one of my .CSV files is attached.

Data_Power - read.table(train15.csv,header = TRUE, sep = ,,
row.names
= NULL);

Date_clm=Data_Power$TIMESTAMP;

Date_original - strptime(Date_clm, %Y %m %d %H:%M, tz=GMT)

Date_local =format(Date_original, format=%c, tz=America/New_York)

Date_local - strptime(Date_original, %Y %m %d %H:%M +0800)

Date_local=as.POSIXlt(Date_original, Australia/Darwin)

Date_local=as.POSIXlt(Date_original,  AEST )

I would be so thankful if you help me out. Thanks



Cheers,

Faranak



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
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] RAxML using R

2014-12-29 Thread Rui Barradas

Hello,

You can put the code of that function in a separate file, say raxml.R 
and then use source(raxml.R). See the help page ?source.


Hope this helps,

Rui Barradas

Em 28-12-2014 23:09, Luigi Marongiu escreveu:

Dear all,
I would like to run RAxML for phylogenetic analysis as indicated on
Paradis' Analysis of phylogenetic and evolution with R (p. 158) thus I
tried to use the package phyloch and its function raxml(). I am using
Linux Ubuntu 14 and I was able to successfully install RAxML on my machine.
However phyloch is not supported by CRAN and the package as provided by
the author on http://www.christophheibl.de/Rpackages.html cannot be
installed -- or at least I could not using the Software centre.
I found a function on http://www.christophheibl.de/raxml.R that should
be the actual script of the function raxml(). However I do not know how
to implement such function. Shall I just copy it into my script? But
then I will have hundreds of lines of code that will mess with my
script. Can I create a kind of package that I can call from my code? Or
is there another way to send the data to the linux shell and call the
raxml function?
Could anybody help?
Thank you
Luigi

__
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] half-logistic distribution

2014-12-29 Thread Therneau, Terry M., Ph.D.



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

i want to analyse survival data using typeI HALF LOGISTIC
DISTRIBUTION.how can i go about it?it installed one on R in the
survival package didn't include the distribution...or i need a code to
use maximum likelihood to estimate the parameter in survival
analysis.a typical example of distribution other than that installed
in R will help.thanks



I am the author of the survival package, and had never heard of the type I half-logistic 
before.
New distributions can be added to survreg() if they can be represented as location-scale 
families; I don't think that your distribution can be written in that way.


Look at survival under the Task Views tab (upper left corner) of the cran.org web page 
-- someone else may have already done it.


Terry T.

__
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] Legend (guides) for point and two line graph

2014-12-29 Thread Ista Zahn
Hi David,

1) set size to a fixed value instead of mapping it to a constant,
i.e., geom_line(size = 2) instead of geom_line(aes(size = 2))

2) perhaps

ggplot(rtest, aes(x=Time, y=Calculated,color=Model, group=Model)) +
  geom_line(size = 2) +
  geom_point(aes(y=Observed, shape=),
 size=6, colour=black) +
   scale_colour_manual(values=c(green,red)) +
  guides(shape = guide_legend(Observed,
  override.aes=list(shape = 16)))

though this is a bit of a hack.

3) legends are automatically created when you map something to an
aesthetic. see ?guide and guide_legend etc. for customization.

Best,
Ista


On Mon, Oct 13, 2014 at 4:43 PM, David Bourne da...@boomer.org wrote:
 I’m trying to generate a plot with a series of data points and best fit lines 
 from two stat models. I’m generating the best-fits with another program. I 
 have the data in a csv file as:

 Time,Observed,Calculated,Model
 0.000,0.0,13.0810,1C
 0.2500,15.,12.5298,1C
 0.5000,12.,12.0018,1C
 1.000,9.0,11.0117,1C
 2.000,8.0,9.26969,1C
 4.000,6.5,6.56882,1C
 6.000,4.8,4.65489,1C
 9.000,3.2,2.77680,1C
 12.00,2.1,1.65641,1C
 18.00,1.8,0.589422,1C
 24.00,0.90,0.209736,1C
 0.000,0.0,21.7130,2C
 0.2500,15.,15.0512,2C
 0.5000,12.,11.8203,2C
 1.000,9.0,9.29374,2C
 2.000,8.0,7.82242,2C
 4.000,6.5,6.20213,2C
 6.000,4.8,4.93346,2C
 9.000,3.2,3.50010,2C
 12.00,2.1,2.48310,2C
 18.00,1.8,1.24979,2C
 24.00,0.90,0.629039,2C

 I read in the data with (R 3.1.1 GUI 1.65 Mavericks build (6784)):

rtest - read.csv(rtest.csv,header=TRUE)

 Checked with

rtest
 Time Observed Calculated Model
 1   0.00  0.0  13.0810001C
 2   0.25 15.0  12.5298001C
 3   0.50 12.0  12.0018001C
 4   1.00  9.0  11.0117001C
 5   2.00  8.0   9.2696901C
 6   4.00  6.5   6.5688201C
 7   6.00  4.8   4.6548901C
 8   9.00  3.2   2.7768001C
 9  12.00  2.1   1.6564101C
 10 18.00  1.8   0.5894221C
 11 24.00  0.9   0.2097361C
 12  0.00  0.0  21.7130002C
 13  0.25 15.0  15.0512002C
 14  0.50 12.0  11.8203002C
 15  1.00  9.0   9.2937402C
 16  2.00  8.0   7.8224202C
 17  4.00  6.5   6.2021302C
 18  6.00  4.8   4.9334602C
 19  9.00  3.2   3.5001002C
 20 12.00  2.1   2.4831002C
 21 18.00  1.8   1.2497902C
 22 24.00  0.9   0.6290392C

 Generated the graph with:

 ggplot(rtest, aes(x=Time, y=Calculated,color=Model, group=Model)) + 
 geom_line(aes(size=2)) + geom_point(aes(y=Observed, size=Observed), size=6, 
 colour=black) + scale_colour_manual(values=c(green,red)) + 
 labs(size=Observed”)

 Which resulted in the plot:

 http://www.boomer.org/rtest/rtest.pdf

 I’d like to:

 1) get rid of the Observed / 2 legend(guide)
 2) maybe keep the Observed and have a circle, i.e., loose the ‘2’
 3) understand how to create, format the legend

 This seems like a common enough problem but the online documentation, R for 
 Dummies nor the R Graphic Cookbook seems to have an answer (from my reading).

 Thanks for any clues/suggestion.

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

2014-12-29 Thread Luigi Marongiu

Dear Rui,
thanks for the reply. I tried it but there were serious problems with 
the function itself: I can't use it as is because there were different 
error messages according to the parameters passed to it.
Such function has to be re-written on purpose or I should call the RAxML 
function from Linux Shell with some kind of interface.

Best regards
Luigi


On 29/12/14 11:18, Rui Barradas wrote:

Hello,

You can put the code of that function in a separate file, say 
raxml.R and then use source(raxml.R). See the help page ?source.


Hope this helps,

Rui Barradas

Em 28-12-2014 23:09, Luigi Marongiu escreveu:

Dear all,
I would like to run RAxML for phylogenetic analysis as indicated on
Paradis' Analysis of phylogenetic and evolution with R (p. 158) thus I
tried to use the package phyloch and its function raxml(). I am using
Linux Ubuntu 14 and I was able to successfully install RAxML on my 
machine.

However phyloch is not supported by CRAN and the package as provided by
the author on http://www.christophheibl.de/Rpackages.html cannot be
installed -- or at least I could not using the Software centre.
I found a function on http://www.christophheibl.de/raxml.R that should
be the actual script of the function raxml(). However I do not know how
to implement such function. Shall I just copy it into my script? But
then I will have hundreds of lines of code that will mess with my
script. Can I create a kind of package that I can call from my code? Or
is there another way to send the data to the linux shell and call the
raxml function?
Could anybody help?
Thank you
Luigi

__
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] RAxML using R

2014-12-29 Thread Ista Zahn
Let's step back for a moment and look at the larger picture. There are
real advantages to using packages on CRAN, including convenient
installation, updates, etc., so let's see if we can find a package on
cran that does what we want:

install.packages(sos)
library(sos)
findFn(raxml)

This suggests that the ips package does what we want, so let's install
it and test it out:

install.packages(ips)
library(ips)
example(raxml)

If for some reason this does not do what you want, and you really need
to install packages outside the standard R package repositories, the
devtools package will make this easier:

library(devtools)
nstall_url(http://www.christophheibl.de/phyloch_1.5-5.tar.gz;)
library(phyloch)
example(raxml)

HTH,
Ista

On Mon, Dec 29, 2014 at 9:23 AM, Luigi Marongiu
marongiu.lu...@gmail.com wrote:
 Dear Rui,
 thanks for the reply. I tried it but there were serious problems with the
 function itself: I can't use it as is because there were different error
 messages according to the parameters passed to it.
 Such function has to be re-written on purpose or I should call the RAxML
 function from Linux Shell with some kind of interface.
 Best regards
 Luigi



 On 29/12/14 11:18, Rui Barradas wrote:

 Hello,

 You can put the code of that function in a separate file, say raxml.R
 and then use source(raxml.R). See the help page ?source.

 Hope this helps,

 Rui Barradas

 Em 28-12-2014 23:09, Luigi Marongiu escreveu:

 Dear all,
 I would like to run RAxML for phylogenetic analysis as indicated on
 Paradis' Analysis of phylogenetic and evolution with R (p. 158) thus I
 tried to use the package phyloch and its function raxml(). I am using
 Linux Ubuntu 14 and I was able to successfully install RAxML on my
 machine.
 However phyloch is not supported by CRAN and the package as provided by
 the author on http://www.christophheibl.de/Rpackages.html cannot be
 installed -- or at least I could not using the Software centre.
 I found a function on http://www.christophheibl.de/raxml.R that should
 be the actual script of the function raxml(). However I do not know how
 to implement such function. Shall I just copy it into my script? But
 then I will have hundreds of lines of code that will mess with my
 script. Can I create a kind of package that I can call from my code? Or
 is there another way to send the data to the linux shell and call the
 raxml function?
 Could anybody help?
 Thank you
 Luigi

 __
 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] Getting HR from Cox model in R

2014-12-29 Thread Michael Dewey

Comments in line

On 24/12/2014 22:09, Ruzan Udumyan wrote:

Dear Michael,

Thank you very much for your reply. The more complete information is as
follows:

I want to do a mediation analysis following the below-mentioned syntax
from:
http://www.biomedcentral.com/content/supplementary/1471-2288-14-9-s1.pdf

I did not define categorical variables as logical variables. I modelled
them as /*factor.X, factor.Xstar*/, etc. the X variable has 3 levels.

It is all sorted but I am not sure about the last bit: to return the
values. For example, I could not figure out what unname stands for, and
whether it is correct to use when variables are modelled as factor.X.

I wrote the syntax as:

  TE2 = exp(sum(coef(cox)[c('factor(X)2', 'factor(Xstar)2')]))   # level
2 vs level 1(ref)
  TE3 = exp(sum(coef(cox)[c('factor(X)3', 'factor(Xstar)3')]))   # level
3 vs level 1(ref)

   DE2 = exp(unname(coef(cox)['factor(X)2']))
   DE3 = exp(unname(coef(cox)['factor(X)3']))

   IE2 = exp(sum(coef(cox)['factor(Xstar)2']))
   IE3 = exp(sum(coef(cox)['factor(Xstar)3']))
   PM2 = log(IE2) / log(TE2)
   PM3 = log(IE3) / log(TE3)


Thank you very much for your help.

Wishing you happy holidays,
Ruzan


*The script from the link:*
doEffectDecomp = function(d)
{
  # Step 1: Replicate exposure variable, predict mediator
  d$TrialTemp = d$Trial
  MOpti = glm(Opti ~ TrialTemp + Age5 + ECOG + Ascit + Comorb + Histo +
  Grade, family=binomial(), data=d)
# Step 2: Replicate data with different exposures for the mediator
  d1 = d2 = d
  d1$Med = d1$Trial
  d2$Med = !d2$Trial
  newd = rbind(d1, d2)
# Step 3: Compute weights for the mediator
  newd$TrialTemp = newd$Trial
  w = predict(MOpti, newdata=newd, type='response')
  direct = ifelse(newd$Opti, w, 1-w)
  newd$TrialTemp = newd$Med
  w = predict(MOpti, newdata=newd, type='response')
  indirect = ifelse(newd$Opti, w, 1-w)
  newd$W = indirect/direct
# Step 4: Weighted Cox Model
  cox = coxph(Surv(OS, Status) ~ Trial + Med + Age5 + ECOG + Ascit +
  Comorb + Histo + Grade, weight=W, data=newd)
# Return value: Estimates for total, direct, indirect effect
  TE = exp(sum(coef(cox)[c('TrialTRUE', 'MedTRUE')]))
  DE = exp(unname(coef(cox)['TrialTRUE']))
  IE = exp(sum(coef(cox)['MedTRUE']))
  PM = log(IE) / log(TE)
  return(c(exp(coef(cox)), TE=TE, DE=DE, IE=IE, PM=PM))
}

On Tue, Dec 23, 2014 at 6:21 PM, Michael Dewey i...@aghmed.fsnet.co.uk
mailto:i...@aghmed.fsnet.co.uk wrote:

Inline comments

On 23/12/2014 09:42, Ruzan Udumyan wrote:

Dear All,

I am not familiar with R language well. Could you please help me
interpret
these commands?:


   TE = exp(sum(coef(cox)[c('aTRUE', 'bTRUE')]))   - does it
mean exp(coef(a
variable) + coef(b variable)) ?


You have not given us much to go on here.
I assume if you go
coef(cox)
you will find elements labelled aTRUE and bTRUE which implies the
existence of a logical covariate with values TRUE and FALSE.


You now tell me my assumption was wrong. Presumably you know what you 
are trying to do but we do not and you are not really helping us by 
giving us a load of code to read through with any details of the dataset.


 The

author of the code is trying to do what you suggest.

   DE = exp(unname(coef(cox)['aTRUE'])__)  - what is unname for ?


?unname

Thank you very much beforehand for your help.

Wishing you happy holidays,
Ruzan

 [[alternative HTML version deleted]]
  PLEASE do read the posting guide
http://www.R-project.org/__posting-guide.html
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


If you post again please do read the message above.



Commented, minimal, self-contained, reproducible code was asked for.




-
No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2015.0.5577 / Virus Database: 4257/8792 - Release Date:
12/23/14



--
Michael
http://www.dewey.myzen.co.uk


No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2015.0.5577 / Virus Database: 4257/8833 - Release Date: 12/29/14



--
Michael
http://www.dewey.myzen.co.uk

__
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] attribute and main value

2014-12-29 Thread Gerrit Draisma

Just a curiosity question:

In the documentation for the nlm procedure
a find this example of defining a function
with a gradient attribute:
---
 f - function(x, a)
 {
 res - sum((x-a)^2)
 attr(res, gradient) - 2*(x-a)
 res
 }
---
I get the gradient with
 attr(f(3,2),gradient)
but how do I get the function value it self?

Gerrit

__
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] half-logistic distribution

2014-12-29 Thread Ben Bolker
Therneau, Terry M., Ph.D. therneau at mayo.edu writes:

 
 
 On 12/26/2014 05:00 AM, r-help-request at r-project.org wrote:
  i want to analyse survival data using typeI HALF LOGISTIC
  DISTRIBUTION.how can i go about it?it installed one on R in the
  survival package didn't include the distribution...or i need a code to
  use maximum likelihood to estimate the parameter in survival
  analysis.a typical example of distribution other than that installed
  in R will help.thanks
 
 
 I am the author of the survival package, and had never heard of the
 type I half-logistic before.  New distributions can be added to
 survreg() if they can be represented as location-scale families; I
 don't think that your distribution can be written in that way.  Look
 at survival under the Task Views tab (upper left corner) of the
 cran.org web page

  I don't know about 'type I' but based on

http://en.wikipedia.org/wiki/Half-logistic_distribution

   you could try

dhalflogist - function(x,s,log=FALSE) {
r - log(2)-log(s)-x/s-2*log(1+exp(-x/s))
if (log) r else exp(r)
}
phalflogist - function(q,s) { (1-exp(-q/s))/(1+exp(-(q/s))) }
rhalflogist - function(n,s) { abs(rlogis(n,scale=s)) }
set.seed(101)
rr - rhalflogist(1,2)
hist(rr,freq=FALSE,breaks=80,col=gray)
curve(dhalflogist(x,2),add=TRUE,col=2,lwd=2)

d - data.frame(rr)
library(bbmle)
m1 - mle2(rr~dhalflogist(s=exp(logs)),start=list(logs=0),data=d)

  If you want to fit multiple groups etc., see the 'parameters'
argument of ?mle2

__
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] attribute and main value

2014-12-29 Thread Duncan Murdoch
On 29/12/2014 10:32 AM, Gerrit Draisma wrote:
 Just a curiosity question:
 
 In the documentation for the nlm procedure
 a find this example of defining a function
 with a gradient attribute:
 ---
   f - function(x, a)
   {
   res - sum((x-a)^2)
   attr(res, gradient) - 2*(x-a)
   res
   }
 ---
 I get the gradient with
   attr(f(3,2),gradient)
 but how do I get the function value it self?

value - f(3,2)
gradient - attr(value, gradient)

Duncan Murdoch

__
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] attribute and main value

2014-12-29 Thread Gerrit Draisma

Thanks Duncan.

But my question was how to extract
simply the function value from value,
without the gradient attribute?

I see that things like value2 give the right answer.
I was curiosity. I found now that value[1]
gives strips the attributes from value:
--
 value
[1] 1
attr(,gradient)
[1] 2
 value[1]
[1] 1
--
Is that the way?

Gerrit


On 12/29/2014 05:05 PM, Duncan Murdoch wrote:

On 29/12/2014 10:32 AM, Gerrit Draisma wrote:

Just a curiosity question:

In the documentation for the nlm procedure
a find this example of defining a function
with a gradient attribute:
---
   f - function(x, a)
   {
   res - sum((x-a)^2)
   attr(res, gradient) - 2*(x-a)
   res
   }
---
I get the gradient with
   attr(f(3,2),gradient)
but how do I get the function value it self?


value - f(3,2)
gradient - attr(value, gradient)

Duncan Murdoch



__
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] attribute and main value

2014-12-29 Thread William Dunlap
as.vector(x) will return x without any attributes and
structure(x, attrA=NULL, attrB=NULL) will return x
without the named attributes.
z - f(1:3, 4)
z
   [1] 14
   attr(,gradient)
   [1] -6 -4 -2
as.vector(z)
   [1] 14
structure(z, gradient=NULL)
   [1] 14

as.vector is a generic function, so for certain classes
(e.g., factor) it may do more than just strip attributes.
Matrix dimensions are attributes and will be removed by
as.vector.



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Dec 29, 2014 at 8:17 AM, Gerrit Draisma gdrai...@xs4all.nl wrote:

 Thanks Duncan.

 But my question was how to extract
 simply the function value from value,
 without the gradient attribute?

 I see that things like value2 give the right answer.
 I was curiosity. I found now that value[1]
 gives strips the attributes from value:
 --
  value
 [1] 1
 attr(,gradient)
 [1] 2
  value[1]
 [1] 1
 --
 Is that the way?

 Gerrit



 On 12/29/2014 05:05 PM, Duncan Murdoch wrote:

 On 29/12/2014 10:32 AM, Gerrit Draisma wrote:

 Just a curiosity question:

 In the documentation for the nlm procedure
 a find this example of defining a function
 with a gradient attribute:
 ---
f - function(x, a)
{
res - sum((x-a)^2)
attr(res, gradient) - 2*(x-a)
res
}
 ---
 I get the gradient with
attr(f(3,2),gradient)
 but how do I get the function value it self?


 value - f(3,2)
 gradient - attr(value, gradient)

 Duncan Murdoch


 __
 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] attribute and main value

2014-12-29 Thread Gerrit Draisma

Thanks Bill,
That is what I was looking for.
Gerrit

On 12/29/2014 05:53 PM, William Dunlap wrote:

as.vector(x) will return x without any attributes and
structure(x, attrA=NULL, attrB=NULL) will return x
without the named attributes.
 z - f(1:3, 4)
 z
[1] 14
attr(,gradient)
[1] -6 -4 -2
 as.vector(z)
[1] 14
 structure(z, gradient=NULL)
[1] 14

as.vector is a generic function, so for certain classes
(e.g., factor) it may do more than just strip attributes.
Matrix dimensions are attributes and will be removed by
as.vector.



Bill Dunlap
TIBCO Software
wdunlap tibco.com http://tibco.com

On Mon, Dec 29, 2014 at 8:17 AM, Gerrit Draisma gdrai...@xs4all.nl
mailto:gdrai...@xs4all.nl wrote:

Thanks Duncan.

But my question was how to extract
simply the function value from value,
without the gradient attribute?

I see that things like value2 give the right answer.
I was curiosity. I found now that value[1]
gives strips the attributes from value:
--
  value
[1] 1
attr(,gradient)
[1] 2
  value[1]
[1] 1
--
Is that the way?

Gerrit



On 12/29/2014 05:05 PM, Duncan Murdoch wrote:

On 29/12/2014 10:32 AM, Gerrit Draisma wrote:

Just a curiosity question:

In the documentation for the nlm procedure
a find this example of defining a function
with a gradient attribute:
---
f - function(x, a)
{
res - sum((x-a)^2)
attr(res, gradient) - 2*(x-a)
res
}
---
I get the gradient with
attr(f(3,2),gradient)
but how do I get the function value it self?


value - f(3,2)
gradient - attr(value, gradient)

Duncan Murdoch



R-help@r-project.org mailto:R-help@r-project.org mailing list --
To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/__listinfo/r-help
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/__posting-guide.html
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] Add labels to my geom_hlines...

2014-12-29 Thread Levent TERLEMEZ
Dear Users,

Would you pls help me to write a proper geom_text addition to geom_hline of my 
ggplot2.

This is d.oran

   Tarih  EUROUSD   USDJPY  EUROJPY
1 2005-01-01 1.378200 1.034654 1.425960
2 2005-01-02 1.373217 1.027268 1.410662
3 2005-01-03 1.364489 1.024884 1.398443
4 2005-01-04 1.352766 1.026722 1.388914
5 2005-01-05 1.338793 1.033870 1.384138

this is d.oran.ist

  x_barstd_sap
EUROUSD 1.3405613 0.08739358
USDJPY  0.9909699 0.13757461
EUROJPY 1.3265161 0.18982005

and both of them are (in function) data frames. Here is my ggplot and i'd like 
to add texts to left edge of hlines like -3sigma, -2sigma,..., 3sigma.

Here is my ggplot line:

ggplot(data=d.oran)+geom_line(aes(x=Tarih,y=EUROUSD))+geom_hline(data=d.oran.ist,yintercept=x_bar[1]+c(-3:3)*std_sap[1],color=c(red,green,blue,black,blue,green,red),linetype=dashed,lwd=1)


Thanks in advance.
Levent TERLEMEZ.

[[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] Some questions on R

2014-12-29 Thread Suzuki Kenta
To whom it may concern

My name is Kenta Suzuki. Today I subscribed the R-help. I do not know about
this R-help in detail but I send this e-mail since I have some trouble on
programming R. When I type help() in general id dose not work properly. For
instance, when I type,  help(plot)  in R, it shows; Error in file(out,
wt) : cannot open the connection on the Internet. Beside the problem,
when I try to install packages like rgl, it always shows; Warning in
install.packages(rgl) : 'lib = C:/Program Files/R/R-3.1.2/library' is
not writable Error in install.packages(rgl) : unable to create
‘C:\Users\U+5065U+592A\Documents/R/win-library/3.1’ In addition:
Warning message: In dir.create(userdir, recursive = TRUE) : cannot create
dir 'C:\Users\U+5065U+592A', reason 'Invalid argument'

How can I fix these problems? I would be great if you give me the
solutions.

Yours Sincerely,
Kenta Suzuki

[[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] fuction to find outlier

2014-12-29 Thread Methekar, Pushpa (GE Transportation, Non-GE)
Hi all, I am stuck on outlier, while doing regression analysis. I done up to 
modelling ,I got lm model for each y and x.
Now I want to find out outlier in that models. How do I find out outlier and 
remove them.


for(i in 1:10){
t1=print(outlierTest(fitted.modely1.temp.l ,cutoff=0.05, n.max=1, order=TRUE))
print(outlierTest(fitted.modely2.avg.pcp,cutoff=0.05, n.max=1, order=TRUE))
outlierTest(fitted.modely3.bshc,cutoff=0.05, n.max=1, order=TRUE )

outlierTest(fitted.modely4.bsco ,cutoff=0.05, n.max=1, order=TRUE)

outlierTest(fitted.modely5.gets ,cutoff=0.05, n.max=1, order=TRUE)

outlierTest(fitted.modely6.gimep,cutoff=0.05, n.max=1, order=TRUE )

outlierTest(fitted.modely7.ts ,cutoff=0.05, n.max=1, order=TRUE)

outlierTest(fitted.modely8.imp ,cutoff=0.05, n.max=1, order=TRUE)
outlierTest(fitted.modely9.maf ,cutoff=0.05, n.max=1, order=TRUE)
i-i+1
}
fix(xsys)

[[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] Difference between eigs() and eigen()

2014-12-29 Thread Pierrick Bruneau
Dear R users and contributors,

I recently observed a difference between the outputs of the classic
eigen() function, and the Arnoldi variant eigs() that extracts only
the few first eigenpairs. Here is some sample code illustrating the
problem:

library(rARPACK)
library(speccalt)
set.seed(1)

# compute kernel matrix from rows of synth5
# then its Laplacian
kern - local.rbfdot(synth5)
diag(kern) - 0
deg - sapply(1:(dim(synth5)[1]), function(i) {
return(sum(kern[i,]))
})
L - diag(1/sqrt(deg)) %*% kern %*% diag(1/sqrt(deg))

eig1 - eigs(L, 6)
eig2 - eigen(L, symmetric=TRUE)

eig1$values then reads:
1.000 1.000 0.9993805 0.9992561 0.9985084 0.9975311

whereas eig2$values reads:
1.000 1.000 1.000 1.000 0.9993805 0.9992561
which is the correct result (eigenvalue 1 has multiplicity 4 in that example).

I guess there is an issue between Arnoldi methods and eigenvalues with
multiplicities greater than 1 (indeed at the end of the series the
unique eigenvals look identical), but as the problem is not documented
in the package PDF, I'm quite unclear if this is
implementation-specific or Arnoldi-general... The issue is quite
important in my case, as the associated eigenvectors then differ quite
significantly, and this impacts negatively my further operations.

I guess the next step is to dig into the mathematical literature, but
before this I wondered if someone already encountered this issue?

Any help would be appreciated,
Pierrick

__
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] Memory hungry routines

2014-12-29 Thread ALBERTO VIEIRA FERREIRA MONTEIRO
Is there any way to detect which calls are consuming memory?

I run a program whose global variables take up about 50 Megabytes of
memory, but when I monitor the progress of the program it seems to
allocating 150 Megabytes of memory, with peaks of up to 2 Gigabytes.

I know that the global variables aren't copied many times by the
routines, but I suspect something weird must be happening.

Alberto Monteiro

PS: the lines, below, count the memory allocated to all global
variables, probably it could be adapted to track the local variables:

y - ls(pat=)   # get all names of the variables
z - rep(0, length(y))  # create array of sizes
for (i in 1:length(y)) z[i] - object.size(get(y[i]))  # loop: get all
sizes (in bytes) of the variables
# BTW, is there any way to vectorialize the above loop?
xix - sort.int(z, index.return = TRUE)  # sort the sizes
y - y[xix$ix]  # apply the sort to the variables
z - z[xix$ix]  # apply the sort to the sizes
y - c(y, total)  # add a totalizator
z - c(z, sum(z))  # sum them all
cbind(y, z)  # ugly way to list them

__
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] Difference between eigs() and eigen()

2014-12-29 Thread Uwe Ligges
eigs() is from a contributed package. No idea what it is about, but my 
guess is these are actually numerical differences coming from different 
algorithms used to calculate the eigenvalues.

For details, please ask the author of the corresponding contributed package.

Best,
Uwe Ligges


On 29.12.2014 19:02, Pierrick Bruneau wrote:

Dear R users and contributors,

I recently observed a difference between the outputs of the classic
eigen() function, and the Arnoldi variant eigs() that extracts only
the few first eigenpairs. Here is some sample code illustrating the
problem:

library(rARPACK)
library(speccalt)
set.seed(1)

# compute kernel matrix from rows of synth5
# then its Laplacian
kern - local.rbfdot(synth5)
diag(kern) - 0
deg - sapply(1:(dim(synth5)[1]), function(i) {
return(sum(kern[i,]))
})
L - diag(1/sqrt(deg)) %*% kern %*% diag(1/sqrt(deg))

eig1 - eigs(L, 6)
eig2 - eigen(L, symmetric=TRUE)

eig1$values then reads:
1.000 1.000 0.9993805 0.9992561 0.9985084 0.9975311

whereas eig2$values reads:
1.000 1.000 1.000 1.000 0.9993805 0.9992561
which is the correct result (eigenvalue 1 has multiplicity 4 in that example).

I guess there is an issue between Arnoldi methods and eigenvalues with
multiplicities greater than 1 (indeed at the end of the series the
unique eigenvals look identical), but as the problem is not documented
in the package PDF, I'm quite unclear if this is
implementation-specific or Arnoldi-general... The issue is quite
important in my case, as the associated eigenvectors then differ quite
significantly, and this impacts negatively my further operations.

I guess the next step is to dig into the mathematical literature, but
before this I wondered if someone already encountered this issue?

Any help would be appreciated,
Pierrick

__
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] Memory hungry routines

2014-12-29 Thread Duncan Murdoch
On 29/12/2014 1:52 PM, ALBERTO VIEIRA FERREIRA MONTEIRO wrote:
 Is there any way to detect which calls are consuming memory?

The Rprofmem() function can do this, but you need to build R to enable
it.Rprof() does a more limited version of the same thing if run with
memory.profiling = TRUE.

Duncan Murdoch

 
 I run a program whose global variables take up about 50 Megabytes of
 memory, but when I monitor the progress of the program it seems to
 allocating 150 Megabytes of memory, with peaks of up to 2 Gigabytes.
 
 I know that the global variables aren't copied many times by the
 routines, but I suspect something weird must be happening.
 
 Alberto Monteiro
 
 PS: the lines, below, count the memory allocated to all global
 variables, probably it could be adapted to track the local variables:
 
 y - ls(pat=)   # get all names of the variables
 z - rep(0, length(y))  # create array of sizes
 for (i in 1:length(y)) z[i] - object.size(get(y[i]))  # loop: get all
 sizes (in bytes) of the variables
 # BTW, is there any way to vectorialize the above loop?
 xix - sort.int(z, index.return = TRUE)  # sort the sizes
 y - y[xix$ix]  # apply the sort to the variables
 z - z[xix$ix]  # apply the sort to the sizes
 y - c(y, total)  # add a totalizator
 z - c(z, sum(z))  # sum them all
 cbind(y, z)  # ugly way to list them
 
 __
 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] fuction to find outlier

2014-12-29 Thread John Fox
Dear Pushpa Methekar,

This apparently uses the outlierTest() function in the car package. I'm
afraid that I find your code incomprehensible and there's not enough
information here to reproduce what you've done. You're looping over the
index i in 1:10, explicitly incrementing the loop index at the end of the
loop (which, thankfully, will have no effect), and doing the same things in
each iteration -- i.e., repeatedly executing several commands without
modification. All this seems terribly confused and not clearly related to
locating and dealing with outliers. 

Furthermore, it's not clear to me that what you propose is sensible -- to
delete outliers after performing statistical tests, in each case for a
single outlier, apparently mechanically and without investigating what's
going on in each case. It would probably be a good idea to consult a
competent statistician to help you decide how to proceed.

All that said, to answer your question directly, probably the easiest way to
remove an observation from a fitted model is to use update() with the subset
argument. For example model.1 - update(model, subset = -6) would remove
case 6 from model and assign the result to model.1.

Best,
 John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.socsci.mcmaster.ca/jfox/



 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
 Methekar, Pushpa (GE Transportation, Non-GE)
 Sent: Monday, December 29, 2014 7:37 AM
 To: r-help@r-project.org
 Subject: [R] fuction to find outlier
 
 Hi all, I am stuck on outlier, while doing regression analysis. I done
 up to modelling ,I got lm model for each y and x.
 Now I want to find out outlier in that models. How do I find out outlier
 and remove them.
 
 
 for(i in 1:10){
 t1=print(outlierTest(fitted.modely1.temp.l ,cutoff=0.05, n.max=1,
 order=TRUE))
 print(outlierTest(fitted.modely2.avg.pcp,cutoff=0.05, n.max=1,
 order=TRUE))
 outlierTest(fitted.modely3.bshc,cutoff=0.05, n.max=1, order=TRUE )
 
 outlierTest(fitted.modely4.bsco ,cutoff=0.05, n.max=1, order=TRUE)
 
 outlierTest(fitted.modely5.gets ,cutoff=0.05, n.max=1, order=TRUE)
 
 outlierTest(fitted.modely6.gimep,cutoff=0.05, n.max=1, order=TRUE )
 
 outlierTest(fitted.modely7.ts ,cutoff=0.05, n.max=1, order=TRUE)
 
 outlierTest(fitted.modely8.imp ,cutoff=0.05, n.max=1, order=TRUE)
 outlierTest(fitted.modely9.maf ,cutoff=0.05, n.max=1, order=TRUE)
 i-i+1
 }
 fix(xsys)
 
   [[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] Installation Help

2014-12-29 Thread Bros
I guess I skipped an option during installation. I removed the program now.

 

Do u think I should choose something else than administrator?

 

From: emorway [via R] [mailto:ml-node+s789695n4701164...@n4.nabble.com] 
Sent: Monday, December 29, 2014 12:13 AM
To: Bros
Subject: Re: Installation Help

 

do you have write permissions to your c: drive?  If you're on a machine that
requires administrative privileges, it might only allow you to write to
c:/users.   

  _  

If you reply to this email, your message will be added to the discussion
below:

http://r.789695.n4.nabble.com/Installation-Help-tp4701143p4701164.html 

To unsubscribe from Installation Help, click here
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by
_codenode=4701143code=aHVzZXlpbi5rYXJhZ3VsQGdtYWlsLmNvbXw0NzAxMTQzfDEyNDE4
NzE1MjE= .
 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_vieweri
d=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamesp
ace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNa
mespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%
21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml NAML 



---
This email has been checked for viruses by Avast antivirus software.





--
View this message in context: 
http://r.789695.n4.nabble.com/Installation-Help-tp4701143p4701190.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Installation Help

2014-12-29 Thread Jeff Newmiller
Let windows prompt you for your password when it is needed... don't run 
anything as  Administrator directly unless you are prepared to fix the problems 
that occur.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On December 29, 2014 11:46:35 AM PST, Bros huseyin.kara...@gmail.com wrote:
I guess I skipped an option during installation. I removed the program
now.

 

Do u think I should choose something else than administrator?

 

From: emorway [via R] [mailto:ml-node+s789695n4701164...@n4.nabble.com]

Sent: Monday, December 29, 2014 12:13 AM
To: Bros
Subject: Re: Installation Help

 

do you have write permissions to your c: drive?  If you're on a machine
that
requires administrative privileges, it might only allow you to write to
c:/users.   

  _  

If you reply to this email, your message will be added to the
discussion
below:

http://r.789695.n4.nabble.com/Installation-Help-tp4701143p4701164.html 

To unsubscribe from Installation Help, click here
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by
_codenode=4701143code=aHVzZXlpbi5rYXJhZ3VsQGdtYWlsLmNvbXw0NzAxMTQzfDEyNDE4
NzE1MjE= .
 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_vieweri
d=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamesp
ace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNa
mespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%
21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml NAML 



---
This email has been checked for viruses by Avast antivirus software.





--
View this message in context:
http://r.789695.n4.nabble.com/Installation-Help-tp4701143p4701190.html
Sent from the R help mailing list archive at Nabble.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-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] fuction to find outlier

2014-12-29 Thread Greg Snow
Pushpa,

To extend John Fox's answer a little.

Look at the outliers dataset in the TeachingDemos package, see
?outliers and run the examples on that help page.  Then ask yourself if
you are comfortable with the automatic outlier removal shown in the example.

On Mon, Dec 29, 2014 at 12:39 PM, John Fox j...@mcmaster.ca wrote:

 Dear Pushpa Methekar,

 This apparently uses the outlierTest() function in the car package. I'm
 afraid that I find your code incomprehensible and there's not enough
 information here to reproduce what you've done. You're looping over the
 index i in 1:10, explicitly incrementing the loop index at the end of the
 loop (which, thankfully, will have no effect), and doing the same things in
 each iteration -- i.e., repeatedly executing several commands without
 modification. All this seems terribly confused and not clearly related to
 locating and dealing with outliers.

 Furthermore, it's not clear to me that what you propose is sensible -- to
 delete outliers after performing statistical tests, in each case for a
 single outlier, apparently mechanically and without investigating what's
 going on in each case. It would probably be a good idea to consult a
 competent statistician to help you decide how to proceed.

 All that said, to answer your question directly, probably the easiest way
 to
 remove an observation from a fitted model is to use update() with the
 subset
 argument. For example model.1 - update(model, subset = -6) would remove
 case 6 from model and assign the result to model.1.

 Best,
  John

 ---
 John Fox, Professor
 McMaster University
 Hamilton, Ontario, Canada
 http://socserv.socsci.mcmaster.ca/jfox/



  -Original Message-
  From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
  Methekar, Pushpa (GE Transportation, Non-GE)
  Sent: Monday, December 29, 2014 7:37 AM
  To: r-help@r-project.org
  Subject: [R] fuction to find outlier
 
  Hi all, I am stuck on outlier, while doing regression analysis. I done
  up to modelling ,I got lm model for each y and x.
  Now I want to find out outlier in that models. How do I find out outlier
  and remove them.
 
 
  for(i in 1:10){
  t1=print(outlierTest(fitted.modely1.temp.l ,cutoff=0.05, n.max=1,
  order=TRUE))
  print(outlierTest(fitted.modely2.avg.pcp,cutoff=0.05, n.max=1,
  order=TRUE))
  outlierTest(fitted.modely3.bshc,cutoff=0.05, n.max=1, order=TRUE )
 
  outlierTest(fitted.modely4.bsco ,cutoff=0.05, n.max=1, order=TRUE)
 
  outlierTest(fitted.modely5.gets ,cutoff=0.05, n.max=1, order=TRUE)
 
  outlierTest(fitted.modely6.gimep,cutoff=0.05, n.max=1, order=TRUE )
 
  outlierTest(fitted.modely7.ts ,cutoff=0.05, n.max=1, order=TRUE)
 
  outlierTest(fitted.modely8.imp ,cutoff=0.05, n.max=1, order=TRUE)
  outlierTest(fitted.modely9.maf ,cutoff=0.05, n.max=1, order=TRUE)
  i-i+1
  }
  fix(xsys)
 
[[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.




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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.


Re: [R] Memory hungry routines

2014-12-29 Thread Hadley Wickham
You might find the advice at http://adv-r.had.co.nz/memory.html helpful.
Hadley

On Tue, Dec 30, 2014 at 7:52 AM, ALBERTO VIEIRA FERREIRA MONTEIRO
albm...@centroin.com.br wrote:
 Is there any way to detect which calls are consuming memory?

 I run a program whose global variables take up about 50 Megabytes of
 memory, but when I monitor the progress of the program it seems to
 allocating 150 Megabytes of memory, with peaks of up to 2 Gigabytes.

 I know that the global variables aren't copied many times by the
 routines, but I suspect something weird must be happening.

 Alberto Monteiro

 PS: the lines, below, count the memory allocated to all global
 variables, probably it could be adapted to track the local variables:

 y - ls(pat=)   # get all names of the variables
 z - rep(0, length(y))  # create array of sizes
 for (i in 1:length(y)) z[i] - object.size(get(y[i]))  # loop: get all
 sizes (in bytes) of the variables
 # BTW, is there any way to vectorialize the above loop?
 xix - sort.int(z, index.return = TRUE)  # sort the sizes
 y - y[xix$ix]  # apply the sort to the variables
 z - z[xix$ix]  # apply the sort to the sizes
 y - c(y, total)  # add a totalizator
 z - c(z, sum(z))  # sum them all
 cbind(y, z)  # ugly way to list them

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



-- 
http://had.co.nz/

__
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] Memory hungry routines

2014-12-29 Thread Henrik Bengtsson
On Mon, Dec 29, 2014 at 10:52 AM, ALBERTO VIEIRA FERREIRA MONTEIRO
albm...@centroin.com.br wrote:
 Is there any way to detect which calls are consuming memory?

 I run a program whose global variables take up about 50 Megabytes of
 memory, but when I monitor the progress of the program it seems to
 allocating 150 Megabytes of memory, with peaks of up to 2 Gigabytes.

 I know that the global variables aren't copied many times by the
 routines, but I suspect something weird must be happening.

 Alberto Monteiro

 PS: the lines, below, count the memory allocated to all global
 variables, probably it could be adapted to track the local variables:

 y - ls(pat=)   # get all names of the variables
 z - rep(0, length(y))  # create array of sizes
 for (i in 1:length(y)) z[i] - object.size(get(y[i]))  # loop: get all
 sizes (in bytes) of the variables
 # BTW, is there any way to vectorialize the above loop?
 xix - sort.int(z, index.return = TRUE)  # sort the sizes
 y - y[xix$ix]  # apply the sort to the variables
 z - z[xix$ix]  # apply the sort to the sizes
 y - c(y, total)  # add a totalizator
 z - c(z, sum(z))  # sum them all
 cbind(y, z)  # ugly way to list them

Duncan already suggested Rprofmem().  For a neat interface to that,
see also lineprof package.

Common memory hogs are cbind(), rbind() and other ways of
incrementally building up objects.  These can often be avoided by
pre-allocating the final object up front and populating it as you go.
Another source of unnecessary memory duplication is coercion of data
types, e.g. allocating an integer matrix but populating it with
doubles.  A related mistake is to use matrix(nrow, ncol) for allocate
matrices that will hold numeric values.  That is actually doing
matrix(NA, nrow, ncol), which becomes a *logical* matrix, which will
be coerced (involving copying and large memory allocation) the first
thing as soon as it get's populated with a numeric value. One should
have used matrix(NA_real_, nrow, ncol) here.

For listing objects, their sizes and more, you can use ll() in the
R.oo package which returns a data.frame, e.g.

 example(iris)
 a - 1:1e6
 R.oo::ll()
  member data.class dimension objectSize
1  anumeric   100440
2   dni3   list 3600
3 ii data.frame  c(150,5)   7088
4   iris data.frame  c(150,5)   7088

 R.oo::ll(sortBy=objectSize)
  member data.class dimension objectSize
2   dni3   list 3600
3 ii data.frame  c(150,5)   7088
4   iris data.frame  c(150,5)   7088
1  anumeric   100440

 tbl - R.oo::ll()
 tbl - tbl[order(tbl$objectSize, decreasing=TRUE),]
 tbl
  member data.class dimension objectSize
1  anumeric   100440
3 ii data.frame  c(150,5)   7088
4   iris data.frame  c(150,5)   7088
5   objs data.framec(4,4)   2760
2   dni3   list 3600
 sum(tbl$objectSize)
[1] 4017576


/Henrik


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