[R] Decision tree model using rpart ( classification

2011-11-04 Thread aajit75
Hi Experts,

I am new to R, using decision tree model for getting segmentation rules.
A) Using behavioural data (attributes defining customer behaviour, ( example
balances, number of accounts etc.)
1. Clustering:  Cluster behavioural data to suitable number of clusters
2. Decision Tree: Using rpart classification tree for generating rules for
segmentation using cluster number(cluster id) as target variable and
variables from behavioural data as input variables.

B) Using profile data (customers  demographic data )
1. Clustering:  Cluster profile data to suitable number of clusters
2. Decision Tree: Using rpart classification tree for generating rules for
segmentation using cluster number(cluster id) as target variable and
variables from profile data as input variables.

C) Using profile data (customers  demographic data ) and deciles created
based on behaviour
1. Deciles:  Deciles customers to 10 groups based on some behavioural data
2. Decision Tree: Using rpart classification for generating rules for
segmentation using Deciles  as target variable and variables from profile
data as input variables.

In first two cases A and B decision tree model using rpart finish the
execution in a minute or two, But in third case (C) it continues to run for
infinite amount of time( monitored and running even after 14 hours).
 fit - rpart(decile ~., method=class,data=dtm_ip)
Is there anything wrong with my approach?

Thanks for the help in advance.
-Ajit


--
View this message in context: 
http://r.789695.n4.nabble.com/Decision-tree-model-using-rpart-classification-tp3989162p3989162.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Reading parameters from dataframe and loading as objects

2011-11-04 Thread Aher
Hi List,

I want to read several parameters from data frame and load them as object
into R session, Is there any package or function in R for this?? 

Here is example
 
param -c(clust_num, minsamp_size, maxsamp_size, min_pct, max_pct) 
value -c(15, 2, 20, 0.001, .999) 
data - data.frame ( cbind(param , value))
data
 param   value
1clust_num 15
2 minsamp_size2
3 maxsamp_size   2e+05
4  min_pct  0.001
5  max_pct 0.999

My data contains many such parameters, I need to read each parameter and its
value from the data and load it as objects  in R session as below:

clust_num  -   15
minsamp_size  -2
maxsamp_size -2e+05
min_pct -0.001
max_pct -0.999

The way right now I am doing it is as creating as many variables as
parameters in the data frame and one observation for value of each
parameter.  
example:
clust_num   minsamp_sizemaxsamp_sizemin_pct max_pct
15  2   20  0.001   0.999

data$ clust_num  , data$minsamp_size,  .

Is there any better way for doing this?


--
View this message in context: 
http://r.789695.n4.nabble.com/Reading-parameters-from-dataframe-and-loading-as-objects-tp3989150p3989150.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Decision tree model using rpart ( classification

2011-11-04 Thread Tal Galili
Hi Ajit,
Please send the code you are running in each case.

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Nov 4, 2011 at 8:36 AM, aajit75 aaji...@yahoo.co.in wrote:

 Hi Experts,

 I am new to R, using decision tree model for getting segmentation rules.
 A) Using behavioural data (attributes defining customer behaviour, (
 example
 balances, number of accounts etc.)
 1. Clustering:  Cluster behavioural data to suitable number of clusters
 2. Decision Tree: Using rpart classification tree for generating rules for
 segmentation using cluster number(cluster id) as target variable and
 variables from behavioural data as input variables.

 B) Using profile data (customers  demographic data )
 1. Clustering:  Cluster profile data to suitable number of clusters
 2. Decision Tree: Using rpart classification tree for generating rules for
 segmentation using cluster number(cluster id) as target variable and
 variables from profile data as input variables.

 C) Using profile data (customers  demographic data ) and deciles created
 based on behaviour
 1. Deciles:  Deciles customers to 10 groups based on some behavioural data
 2. Decision Tree: Using rpart classification for generating rules for
 segmentation using Deciles  as target variable and variables from profile
 data as input variables.

 In first two cases A and B decision tree model using rpart finish the
 execution in a minute or two, But in third case (C) it continues to run for
 infinite amount of time( monitored and running even after 14 hours).
  fit - rpart(decile ~., method=class,data=dtm_ip)
 Is there anything wrong with my approach?

 Thanks for the help in advance.
 -Ajit


 --
 View this message in context:
 http://r.789695.n4.nabble.com/Decision-tree-model-using-rpart-classification-tp3989162p3989162.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Reading parameters from dataframe and loading as objects

2011-11-04 Thread Eric Lecoutre
Hi,

Did you program in SAS previously? :)

You don't really want data.frame but a named list (note that data frames
are lists but for columns).


mypars - as.list(value)
names(mypars) - param
mypars$max_pct

If you really want to use data.frame you can assign rownames and access
parameters through:

datapars - data.frame(value=value)
rownames(datapars) - param
datapars[max_pct,value]

But this really seems more complicated way ins't it?

HTH

Eric


On 4 November 2011 07:24, Aher ajit.a...@cedar-consulting.com wrote:

 Hi List,

 I want to read several parameters from data frame and load them as object
 into R session, Is there any package or function in R for this??

 Here is example

 param -c(clust_num, minsamp_size, maxsamp_size, min_pct,
 max_pct)
 value -c(15, 2, 20, 0.001, .999)
 data - data.frame ( cbind(param , value))
 data
 param   value
 1clust_num 15
 2 minsamp_size2
 3 maxsamp_size   2e+05
 4  min_pct  0.001
 5  max_pct 0.999

 My data contains many such parameters, I need to read each parameter and
 its
 value from the data and load it as objects  in R session as below:

 clust_num  -   15
 minsamp_size  -2
 maxsamp_size -2e+05
 min_pct -0.001
 max_pct -0.999

 The way right now I am doing it is as creating as many variables as
 parameters in the data frame and one observation for value of each
 parameter.
 example:
 clust_num   minsamp_sizemaxsamp_sizemin_pct max_pct
 15  2   20  0.001   0.999

 data$ clust_num  , data$minsamp_size,  .

 Is there any better way for doing this?


 --
 View this message in context:
 http://r.789695.n4.nabble.com/Reading-parameters-from-dataframe-and-loading-as-objects-tp3989150p3989150.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Eric Lecoutre
Consultant - Business  Decision
Business Intelligence  Customer Intelligence

[[alternative HTML version deleted]]

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


Re: [R] how to count number of occurrences

2011-11-04 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of uka
 Sent: Thursday, November 03, 2011 4:10 PM
 To: r-help@r-project.org
 Subject: Re: [R] how to count number of occurrences
 
 This was very helpful. Thank you very much. Just one question, I notice
 that
 it does not count the number of X's before the first Y. I want the
 result be
 1 4 0 0 0 5 0 0 0 0. I tried combining this output with the first value
 of
 rle output, but realized that rle doesn't give me the 0s. So, if my
 first
 observation was Y, then I want it to show that there are 0 Xs before
 that.
 Thank you again.
 

You should really provide the relevant context from previous posts so that 
potential helpers don't need to go looking for it.  That being said, you could 
try something like

samp - c(X, Y, X, X, X, X, Y, Y, Y, Y, X, X, X, X, 
X, Y, Y, Y, Y, Y)
diff(which(c('Y', samp)=='Y'))-1 


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


__
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] array manipulation

2011-11-04 Thread Simone Salvadei
This worked example, hoping to be helpful, has been requested after a (my)
further enquiry about array manipulation.

I was looking for a command that is equivalent to repmat() in matlab and
that could also be applied to array.

(for Matlab users)
The Matlal code was the following:


temp_u=zeros(d,c,T);  -creation of an array of dimensions d x
c x T full of zeroes
temp_u(1,:,:)=m_u;-filling the first row of each 'stratum'
with the rows of
the matrix 'm_u'
temp_u=repmat(temp_u(1,:,:),d,1); -filling the remaining rows (full of
zeroes) of 'temp_u' with
copies of the corrensponding 1st row

-- 
---

Simone Salvadei

Faculty of Economics
Department of Financial and Economic Studies and Quantitative Methods
University of Rome Tor Vergata
e-mail: simone.salva...@uniroma2.it federico.belo...@uniroma2.it
url: http://www.economia.uniroma2.it/phd/econometricsempiricaleconomics/
http://www.econometrics.it/
---

[[alternative HTML version deleted]]

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


[R] replace double backslash with singel backslash

2011-11-04 Thread Kay Cichini
I want to replace \\ with \ in:
str -
C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg

and tried:
gsub(, \\, str)

but this removes the \\ without replacing them by \

Any help much appreciated,
Kay

-

Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck


--
View this message in context: 
http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Decision tree model using rpart ( classification

2011-11-04 Thread aajit75
Hi,

Thanks for the responce, code for each case is as:

c_c_factor - 0.001  
min_obs_split - 80

A)

fit - rpart(segment ~., method=class, 
   control=rpart.control(minsplit=min_obs_split, cp=c_c_factor), 
   data=Beh_cluster_out)

B)
fit - rpart(segment ~., method=class, 
   control=rpart.control(minsplit=min_obs_split, cp=c_c_factor), 
   data=profile_cluster_out)

 C)
fit - rpart(decile ~., method=class, 
   control=rpart.control(minsplit=min_obs_split, cp=c_c_factor), 
   data=dtm_ip)

In A and B target variable 'segment' is from the clustering data using same
set of input variables , while in C target variable 'decile' is derived from
behavioural variables and input variables are from profile data. Number of
rows in the input table in all three cases are same.

Regards,
-Ajit


--
View this message in context: 
http://r.789695.n4.nabble.com/Decision-tree-model-using-rpart-classification-tp3989162p3989320.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] array manipulation

2011-11-04 Thread Simone Salvadei
This worked example, hoping to be helpful, has been requested after a (my)
further enquiry about array manipulation.

I was looking for a command that is equivalent to repmat() in matlab and
that could also be applied to array.

(for Matlab users)
The Matlal code was the following:


1)temp_u=zeros(d,c,T);  -creation of an array of dimensions d
x c x T full of zeroes
2)temp_u(1,:,:)=m_u;-filling the first row of each
'stratum' with the rows of
the matrix 'm_u'
3)temp_u=repmat(temp_u(1,:,:),d,1); -filling the remaining rows (full of
zeroes) of 'temp_u' with
copies of the corrensponding 1st row

(what's happening if you are not a Matlab users)
(numerical example d=2,c=4,T=4)
1)temp_u=zeros(d,c,T)
 temp_u(:,:,1) =

 0 0 0 0
 0 0 0 0


temp_u(:,:,2) =

 0 0 0 0
 0 0 0 0


temp_u(:,:,3) =

 0 0 0 0
 0 0 0 0


temp_u(:,:,4) =

 0 0 0 0
 0 0 0 0

2)temp_u(1,:,:)=m_u
temp_u(:,:,1) =

0.96040.01560.02300.0009
 0 0 0 0


temp_u(:,:,2) =

0.39060.29480.09810.2165
 0 0 0 0


temp_u(:,:,3) =

0.53900.24820.11400.0988
 0 0 0 0


temp_u(:,:,4) =

0.45460.26410.07940.2019
 0 0 0 0

3)temp_u=repmat(temp_u(1,:,:),d,1)

temp_u(:,:,1) =

0.96040.01560.02300.0009
0.96040.01560.02300.0009


temp_u(:,:,2) =

0.39060.29480.09810.2165
0.39060.29480.09810.2165


temp_u(:,:,3) =

0.53900.24820.11400.0988
0.53900.24820.11400.0988


temp_u(:,:,4) =

0.45460.26410.07940.2019
0.45460.26410.07940.2019


Now, in order to reply this exercise in R I used the following code:

temp_u=array(0,dim=c(1,c,T))
temp_u[1,,]=m_u
temp_u=kronecker(temp_u,matrix(rep(1,d),nr=d))


A special thank to David Winsemius,William Dunlap and Patrick Burns.
I hope I have been helpful.





---

Simone Salvadei

Faculty of Economics
Department of Financial and Economic Studies and Quantitative Methods
University of Rome Tor Vergata
e-mail: simone.salva...@uniroma2.it federico.belo...@uniroma2.it
url: http://www.economia.uniroma2.it/phd/econometricsempiricaleconomics/
http://www.econometrics.it/
---

[[alternative HTML version deleted]]

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


Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Jim Holtman
what is the problem that you are trying to solve?  you need the double \\ since 
they have a special meaning in quoted strings.  in this case they represent a 
since backslash.  if you really had a single one, then something like this '\n' 
would be a carriage return.  

Sent from my iPad

On Nov 4, 2011, at 5:35, Kay Cichini kay.cich...@uibk.ac.at wrote:

 I want to replace \\ with \ in:
 str -
 C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg
 
 and tried:
 gsub(, \\, str)
 
 but this removes the \\ without replacing them by \
 
 Any help much appreciated,
 Kay
 
 -
 
 Kay Cichini
 Postgraduate student
 Institute of Botany
 Univ. of Innsbruck
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Extract Data from Yahoo Finance

2011-11-04 Thread Joshua Ulrich
Deb,

Sorry, you can't do that with getQuote because Yahoo does not make
those data available historically.  Generally, you will need to pay
for historical bid/ask (tick) data.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Fri, Nov 4, 2011 at 6:10 AM, Deb Midya debmi...@yahoo.com wrote:
 Joshua,

 Thank you very much for your response.

 How can I use getQuote to download data for a stock for a certain period of
 time, say, 1 October 2011 to 31 October 2011.

 Once again, thank very much for the time you have given.

 Regards,

 Deb
 From: Joshua Ulrich josh.m.ulr...@gmail.com
 To: Deb Midya debmi...@yahoo.com
 Cc: R. Michael Weylandt michael.weyla...@gmail.com; r-help@r-project.org
 r-help@r-project.org
 Sent: Friday, 4 November 2011 4:12 PM
 Subject: Re: [R] Extract Data from Yahoo Finance

 Deb,

 See getQuote in the quantmod package.  For example:
 getQuote(SPY)

 Be sure to read ?getQuote.

 Best,
 --
 Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



 On Thu, Nov 3, 2011 at 5:05 PM, Deb Midya debmi...@yahoo.com wrote:
 Michael,

 Thanks for your response.

 The link to the page is: http://www.gummy-stuff.org/Yahoo-data.htm

 I like to download the fields (mentioned under special tags) for a period
 of time and for a particular stock (or for a list of stocks).

 Once again, thank you very much for the time you have given.

 Regards,

 Deb

 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: Deb Midya debmi...@yahoo.com
 Cc: r-help@r-project.org r-help@r-project.org
 Sent: Friday, 4 November 2011 12:13 AM
 Subject: Re: [R] Extract Data from Yahoo Finance

 The quantmod package can probably do what you are asking, but it's a
 little hard to be certain since you provide neither a list of all the
 fields you are actually talking about nor a link to the page with the
 fields in question.

 Michael

 On Thu, Nov 3, 2011 at 12:02 AM, Deb Midya debmi...@yahoo.com wrote:
 Hi R –users,

 I am using R-2.14.0 on Windows XP.

 May I request you to assist me for the following please.

 I like to extract all the fields (example: a : Ask, b : Bid, ……, w :
 52-week Range, x: Stock Exchange)  for certain period of time, say, 1
 October 2011 to 31 October 2011.

 Is there any R-Package(s)  any R- script please?

 Once again, thank you very much for the time you have given.

 Regards,

 Deb

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

        [[alternative HTML version deleted]]


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






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


[R] Counting number of common elements between the rows of two different matrices

2011-11-04 Thread Parodi, Pietro
 
Hello

I'm trying to solve this problem without using a for loop but I have so
far failed to find a solution.

I have two matrices of K columns each, e.g. (K=5), and with numbers of
row N_A and N_B respectively

A = (1 5 3 8 15;
 2 7 20 11 13;
 12 19 20 21 43)

B = (2 6 30 8 16;
 3 8 19 11 13)

(the actual matrices have hundreds of thousands of entry, that's why I'm
keen to avoid for loops)

And what I need to do is to apply a function which counts the number of
common elements between ANY row of A and ANY row of B, giving a result
like this:


A1 vs B1:  1  # (8 is a common element)
A1 vs B2:  1  # (8 is a common element)
A2 vs B1:  1  # (2 is a common element)
A2 vs B2:  1  # 11, 13 are common elements
Etc.

I've built a function that counts the number of common elements between
two vectors, based on the intersect function in the R manual

common_elements - function(x,y) length(y[match(x,y,nomatch=0)])

And a double loop who solves my problem would be something like
(pseudo-code)

For(i in 1:N_A){
for(j in 1:N_B){
ce(i,j)=common_elements(a(i),b(j))
}
} 

Is there an efficient, clean way to do the same job and give as an
output a matrix N_A x N_B such as that above?

Thanks a lot for your help

Regards

Pietro

__

For information pertaining to Willis' email confidentiality and monitoring 
policy, usage restrictions, or for specific company registration and regulatory 
status information, please visit http://www.willis.com/email_trailer.aspx

We are now able to offer our clients an encrypted email capability for secure 
communication purposes. If you wish to take advantage of this service or learn 
more about it, please let me know or contact your Client Advocate for full 
details. ~W67897

__
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] Select some, but not all, variables stepwise

2011-11-04 Thread Andre Easom
Hi,

I would like to fit a linear model where some but not all explanators are 
chosen stepwise - ie I definitely want to include some terms, but others only 
if they are deemed significant (by AIC or whatever other approach is 
available).  For example if I wanted to definitely include x1 and x2, but only 
include z1 and z2 if they are significant, something like this:

df - data.frame(y=c(4,2,6,7,3,9,5,7,6,2), x1=c(2,3,4,0,5,8,8,1,1,2), 
x2=c(0,0,0,0,1,1,0,0,0,1), z1=c(0,1,0,0,0,1,1,0,1,1), z2=c(1,1,1,0,0,1,1,1,1,0))
model - lm(y  ~ x1 + x2 + stepwise(z1 + z2))

Any help would be appreciated.

Cheers,
Andre
**
This email and any attachments are confidential, protect...{{dropped:22}}

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


Re: [R] Select some, but not all, variables stepwise

2011-11-04 Thread Frank Harrell
Resist the temptation.  Stepwise analysis without shrinkage will ruin model
inferences without helping with predictive accuracy.
Frank

AndreE wrote:
 
 Hi,
 
 I would like to fit a linear model where some but not all explanators are
 chosen stepwise - ie I definitely want to include some terms, but others
 only if they are deemed significant (by AIC or whatever other approach is
 available).  For example if I wanted to definitely include x1 and x2, but
 only include z1 and z2 if they are significant, something like this:
 
 df - data.frame(y=c(4,2,6,7,3,9,5,7,6,2), x1=c(2,3,4,0,5,8,8,1,1,2),
 x2=c(0,0,0,0,1,1,0,0,0,1), z1=c(0,1,0,0,0,1,1,0,1,1),
 z2=c(1,1,1,0,0,1,1,1,1,0))
 model - lm(y  ~ x1 + x2 + stepwise(z1 + z2))
 
 Any help would be appreciated.
 
 Cheers,
 Andre
 **
 This email and any attachments are confidential, protect...{{dropped:22}}
 
 __
 R-help@ 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.
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990026.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Plotting skewed normal distribution with a bar plot

2011-11-04 Thread Steve Friedman
Hi Michael,

Thanks for pointing me fGarch.  I actually started there, but it is not yet
available for 2.13.2 so I went directly to the (sn-package).

I've briefly explored your suggestion and think it will work.

Thanks
Steve
On Nov 3, 2011 10:41 PM, R. Michael Weylandt michael.weyla...@gmail.com
wrote:

 It seems like you'll need to apply some sort of MLE to estimate the
 parameters directly from the data before using dsn() to get the
 density. This might help with some of it:
 http://help.rmetrics.org/fGarch/html/snorm.html

 Michael

 On Thu, Nov 3, 2011 at 2:54 PM,  steve_fried...@nps.gov wrote:
 
  Hi,
 
  I need to create a plot (type = h)  and then overlay a skewed-normal
  curve on this distribution, but I'm not finding a procedure to accomplish
  this. I want to use the plot function here in order to control the bin
  distributions.
 
  I have explored the sn library and found the dsn function.  dsn uses
 known
  location, scaling and shape parameters associated with a given input
 vector
  of probabilities.  However, how can I calculate the skewed-normal curve
 if
  I don't know these parameters in advance?
 
  Is there another function to calculate the skew-normal, perhaps in a
  different package?
 
 
  I'm working with R 2.13.2 on a windows based machine.
 
  Steve Friedman Ph. D.
  Ecologist  / Spatial Statistical Analyst
  Everglades and Dry Tortugas National Park
  950 N Krome Ave (3rd Floor)
  Homestead, Florida 33034
 
  steve_fried...@nps.gov
  Office (305) 224 - 4282
  Fax (305) 224 - 4147
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


[[alternative HTML version deleted]]

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


Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Michael Friendly

On 11/4/2011 5:35 AM, Kay Cichini wrote:

I want to replace \\ with \ in:
str-
C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg

and tried:
gsub(, \\, str)

but this removes the \\ without replacing them by \



You may be able to avoid this simply by using forward slashes in path 
names. Otherwise,

?normalizePath
may help.


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Counting number of common elements between the rows of two different matrices

2011-11-04 Thread jim holtman
Try this:

# create dummy data
a - matrix(sample(20, 50, TRUE), ncol = 5)
b - matrix(sample(20, 50, TRUE), ncol = 5)
# create combinations to test
x - expand.grid(seq(nrow(a)), seq(nrow(b)))
# test
result - mapply(function(m1, m2) any(a[m1, ] %in% b[m2, ])
, x[, 1]
, x[, 2]
)
# create the output matrix
result.m - matrix(result, nrow = nrow(a), ncol = nrow(b))

On Fri, Nov 4, 2011 at 8:51 AM, Parodi, Pietro pietro.par...@willis.com wrote:

 Hello

 I'm trying to solve this problem without using a for loop but I have so
 far failed to find a solution.

 I have two matrices of K columns each, e.g. (K=5), and with numbers of
 row N_A and N_B respectively

 A =     (1 5 3 8 15;
         2 7 20 11 13;
         12 19 20 21 43)

 B =     (2 6 30 8 16;
         3 8 19 11 13)

 (the actual matrices have hundreds of thousands of entry, that's why I'm
 keen to avoid for loops)

 And what I need to do is to apply a function which counts the number of
 common elements between ANY row of A and ANY row of B, giving a result
 like this:


 A1 vs B1:  1  # (8 is a common element)
 A1 vs B2:  1  # (8 is a common element)
 A2 vs B1:  1  # (2 is a common element)
 A2 vs B2:  1  # 11, 13 are common elements
 Etc.

 I've built a function that counts the number of common elements between
 two vectors, based on the intersect function in the R manual

 common_elements - function(x,y) length(y[match(x,y,nomatch=0)])

 And a double loop who solves my problem would be something like
 (pseudo-code)

 For(i in 1:N_A){
        for(j in 1:N_B){
                ce(i,j)=common_elements(a(i),b(j))
                }
        }

 Is there an efficient, clean way to do the same job and give as an
 output a matrix N_A x N_B such as that above?

 Thanks a lot for your help

 Regards

 Pietro

 __

 For information pertaining to Willis' email confidentiality and monitoring 
 policy, usage restrictions, or for specific company registration and 
 regulatory status information, please visit 
 http://www.willis.com/email_trailer.aspx

 We are now able to offer our clients an encrypted email capability for secure 
 communication purposes. If you wish to take advantage of this service or 
 learn more about it, please let me know or contact your Client Advocate for 
 full details. ~W67897

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




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Jeff Newmiller
Your str does not have any double backslashes to replace. You need to revisit 
the concept of escape characters in the documentation. In brief, every \\ in 
a quoted string is actually a single character as stored in memory.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Kay Cichini kay.cich...@uibk.ac.at wrote:

I want to replace \\ with \ in:
str -
C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg

and tried:
gsub(, \\, str)

but this removes the \\ without replacing them by \

Any help much appreciated,
Kay

-

Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck


--
View this message in context: 
http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.

_

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


[[alternative HTML version deleted]]

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


Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Gene Leynes
I think that people are afraid to say You can't do that in R...
But I think the real answer is: you can't do that in R.

Although, it is helpful to understand Jeff's reply.  I hadn't fully
realized why this particular problem occurs before reading that.  It's odd
to me that // and / are both stored as /, but that makes sense given my
experience in R.

Also, the other replies are good advice, working with R's path functions or
sticking with forward slashes is the way to go (don't fight the
assimilation, the borg needs you).

Personally, I think some of these seemingly small problems actually
encumber R's mainstream adoption quite a bit, but then I'm not the one
writing R.  Plus, it's is still pretty dang awesome even with its minor
annoyances.


On Fri, Nov 4, 2011 at 8:45 AM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote:

 Your str does not have any double backslashes to replace. You need to
 revisit the concept of escape characters in the documentation. In brief,
 every \\ in a quoted string is actually a single character as stored in
 memory.
 ---
 Jeff Newmiller The . . Go Live...
 DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
 Live: OO#.. Dead: OO#.. Playing
 Research Engineer (Solar/Batteries O.O#. #.O#. with
 /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 Kay Cichini kay.cich...@uibk.ac.at wrote:

 I want to replace \\ with \ in:
 str -
 C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg

 and tried:
 gsub(, \\, str)

 but this removes the \\ without replacing them by \

 Any help much appreciated,
 Kay

 -
 
 Kay Cichini
 Postgraduate student
 Institute of Botany
 Univ. of Innsbruck
 

 --
 View this message in context:
 http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
 Sent from the R help mailing list archive at Nabble.com.

 _

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


 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] How to write a shapefile with projection

2011-11-04 Thread Monica Pisica



Hi,

 

I am trying to write a shapefile with projection. I have
my data in a data.frame called try and consists in xy coordinates and a
numerical attribute value z1.

 

Libraries loaded are: sp, rgdal, raster, maptools

 

head(try)

 x       y                    z1

1 610237.1  3375751
 8.221

2 610236.1  3375750
 8.153

3 610236.1  3375749
 8.275

4 610236.1  3375748
 8.251

5 610236.1  3375747
 8.217

6 610236.1  3375746
 8.196

 

#Get the projection from a raster  named llev I have loaded before:

crs - projection(llev)

 

# get a spatial point data frame from my data

crest.sp - SpatialPointsDataFrame(try[,1:2], try,
proj4string=CRS(crs))

 

summary(crest.sp)

Object of class SpatialPointsDataFrame

Coordinates:

    min       max

x  610235.1     610354.1

y 3374862.4    3375751.4

Is projected: TRUE 

proj4string :

[+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m
+no_defs +towgs84=0,0,0]

Number of points: 890

Data attributes:

    x  y z1   

 Min.   :  610235   Min. : 3374862   Min.: 6.966  

 1st
Qu.:610269   1st Qu.:3375085   1st Qu.:7.570  

 Median
:610298   Median :3375307   Median :7.901  

 Mean   :610300  
Mean   :3375307  
Mean   :7.882  

 3rd
Qu.:610334   3rd Qu.:3375529   3rd Qu.:8.180  

 Max.   :610354  
Max.   :3375751   Max.  
:8.756  

 

#write the shapefile

writePointsShape(crest.sp, I:/LA_levee/Shape/llev_crest_pts6)

 

If I load this shapefile in ArcGIS is has no projection.
I also looked at the write.shapefile command from shapefiles library and again I
get a file without projection. Is there any way to write the projection for the
shapefile in R? Probably I can do something in ArcGIS, but I would like to have
my shapefile from R complete.

 

Thanks,

 

Monica

 

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


Re: [R] How to use 'prcomp' with CLUSPLOT?

2011-11-04 Thread R. Michael Weylandt
Hello Jo,

Full disclosure: I don't know much about clustering/partition cluster
analysis/etc so I've only attacked this as an R problem. However, this
might get you going in the right direction:

df - 
read.table(textConnection(PRVID,VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9,VAR10,VAR11
PRV1,0,54463,53049,62847,75060,184925,0,0,0,0,0
PRV2,0,2100,76,131274,0,0,0,0,0,0,18
PRV3,967,0,0,0,0,0,0,0,0,3634,0
PRV4,817,18344,3274,9264,1862,0,0,141,0,0,0
PRV5,0,0,0,0,0,0,29044,0,0,0,0
PRV6,59,6924,825,3008,377,926,0,0,10156,0,
PRV7,11,24902,36040,47223,20086,0,0,749,415,0,0), header = T, sep =
,, stringsAsFactors = T)
closeAllConnections()
library(cluster)

mat - as.matrix(df[,-1])
newtble - prop.table(mat, 1) * 100
num.clust - 3

clusplotMW - cluster:::clusplot.default # Create a copy of the two
necessary functions for clusplot that route to princomp
mkCheckMW - cluster:::mkCheckX
body(mkCheckMW) - parse(text=gsub(princomp,
prcomp,deparse(body(mkCheckMW # replace princomp with prcomp in
our copy
body(clusplotMW) - parse(text=gsub(mkCheckX,
mkCheckMW,deparse(body(clusplotMW # route our clusplot to our
mkCheckX

clusplotMW(newtble, fitnw$cluster, color = T, shade = T, lines = 0)

Since you didn't provide a working example, I can't verify this, but
let me know if it works for you.

Michael


On Thu, Nov 3, 2011 at 8:10 PM, Jo Frabetti jfrabe...@sdsc.edu wrote:
 Hello,

 I have a large data set that has more columns than rows (sample data below).  
 I am trying to perform a partitioning cluster analysis and then plot that 
 using pca.  I have tried using CLUSPLOT(), but that only allows for 
 'princomp' where I need 'prcomp' as I do not want to reduce my columns. Is 
 there a way to edit the CLUSPLOT() code to use 'prcomp', please?

 # sample of my data
 PRVID,VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9,VAR10,VAR11
 PRV1,0,54463,53049,62847,75060,184925,0,0,0,0,0
 PRV2,0,2100,76,131274,0,0,0,0,0,0,18
 PRV3,967,0,0,0,0,0,0,0,0,3634,0
 PRV4,817,18344,3274,9264,1862,0,0,141,0,0,0
 PRV5,0,0,0,0,0,0,29044,0,0,0,0
 PRV6,59,6924,825,3008,377,926,0,0,10156,0,
 PRV7,11,24902,36040,47223,20086,0,0,749,415,0,0

 library(cluster)
 fn   = big.csv;
 tbl  = read.table(fn,  header=TRUE, sep=,, row.names=1);
 mat - as.matrix(tbl);
 newtbl - prop.table(mat,1)*100;

 num.clust - 3;
 fitnw - kmeans(newtbl, num.clust);
 clusplot(newtbl, fitnw$cluster, color=TRUE, shade=TRUE, lines=0, main= 
 paste('Principal Components plot - Kmeans ', clust.level, ' Clusters') )

 Error in princomp.default(x, scores = TRUE, cor = ncol(x) != 2) :
  'princomp' can only be used with more units than variables

 Thank you for R and any assistance you may offer!

 Jo

        [[alternative HTML version deleted]]

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


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


[R] formatting a dataframe

2011-11-04 Thread ATANU
http://r.789695.n4.nabble.com/file/n3989638/tab3.gif 

i want to create a dataframe like the one given in the pictures having names
of sub categories of columns. the table may be presented either in the
console or in an excel sheet. anyone please suggest me a technique.
thanks in advance.

-atanu

--
View this message in context: 
http://r.789695.n4.nabble.com/formatting-a-dataframe-tp3989638p3989638.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread clangkamp
I have tried this method, but the result is not working, at least not as I
expect:
I used the CreditMetrics package transition matrix
rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
M - matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
0, 0, 0, 0, 0, 0, 0, 100
)/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)

then followed through with the steps:

nth_root - X %*% L_star %*% X_inv 

But the check (going back 12 to the power again) doesn't yield the original
matrix. Now some rounding errors can be expected, but I didn't expect a
perfectly diagonal matrix, when the initial matrix isn't diagonal at all.
 round(nth_root^12,4)
   [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7] [,8]
[1,] 0.9078 0. 0. 0. 0. 0. 0.0
[2,] 0. 0.9053 0. 0. 0. 0. 0.0
[3,] 0. 0. 0.9079 0. 0. 0. 0.0
[4,] 0. 0. 0. 0.8553 0. 0. 0.0
[5,] 0. 0. 0. 0. 0.7998 0. 0.0
[6,] 0. 0. 0. 0. 0. 0.8285 0.0
[7,] 0. 0. 0. 0. 0. 0. 0.64570
[8,] 0. 0. 0. 0. 0. 0. 0.1

Any takers


-
Christian Langkamp
christian.langkamp-at-gmxpro.de

--
View this message in context: 
http://r.789695.n4.nabble.com/12th-Root-of-a-Square-Transition-Matrix-tp2259736p3989618.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] nproc parameter in efpFunctional

2011-11-04 Thread bonda
The 2006 CSDA paper is really very informative, perhaps, I'm trying to
understand the things lying beyond. If we have e.g. k=3, then taking nproc=3
for the functional maxBB we get a critical value (boundary)

maxBB$computeCritval(0.05,nproc=3)
[1] 1.544421,

and this for nproc=NULL (Bonferroni approximation) will be

maxBB$computeCritval(0.05)
[1] 1.358099.

Aggregating 3 Brownian bridges first over components, we obtain time series
process. Now, we wonder if maximum value of the process (aggregation over
time) lies over boundary. Which boundary - 1.544421 or 1.358099 - should one
take? They look too different and, for instance, lead to unfair computing
of empirical size (as rejection rate of null hypothesis) or empirical power
(as acception rate of alternative). 




--
View this message in context: 
http://r.789695.n4.nabble.com/nproc-parameter-in-efpFunctional-tp3972419p3989598.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Plotting skewed normal distribution with a bar plot

2011-11-04 Thread boylangc
Steve,

   I don't profess to be an expert in R (by ANY means), but I've used the 
sn.mle function in package sn to do something similar. So, for example, if you 
have data (y), you can do the following:

y = c(5,4,6,4,5,6,7,7,55,64,23,13,1,4,1,14,1,15,11,12)
sn.mle(y=y)

I just made up this stream of data, so please forgive if it doesn't make sense. 
 The function will produce a number of things, including the mles for the mean, 
sd, and skew, as well as a histogram with the density overlayed onto it.

Maybe this helps? Hope so.

Greg

-Original Message-
From: R. Michael Weylandt michael.weyla...@gmail.com
Sent: Nov 3, 2011 10:39 PM
To: steve_fried...@nps.gov
Cc: r-help@r-project.org
Subject: Re: [R] Plotting skewed normal distribution with a bar plot

It seems like you'll need to apply some sort of MLE to estimate the
parameters directly from the data before using dsn() to get the
density. This might help with some of it:
http://help.rmetrics.org/fGarch/html/snorm.html

Michael

On Thu, Nov 3, 2011 at 2:54 PM,  steve_fried...@nps.gov wrote:

 Hi,

 I need to create a plot (type = h)  and then overlay a skewed-normal
 curve on this distribution, but I'm not finding a procedure to accomplish
 this. I want to use the plot function here in order to control the bin
 distributions.

 I have explored the sn library and found the dsn function.  dsn uses known
 location, scaling and shape parameters associated with a given input vector
 of probabilities.  However, how can I calculate the skewed-normal curve if
 I don't know these parameters in advance?

 Is there another function to calculate the skew-normal, perhaps in a
 different package?


 I'm working with R 2.13.2 on a windows based machine.

 Steve Friedman Ph. D.
 Ecologist  / Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax     (305) 224 - 4147

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


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

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


[R] How to write a shapefile with projection - problem solved

2011-11-04 Thread Monica Pisica

Hi,

Sorry i have put such a detailed question to the list about writing a shapefile 
with projection. I realized that if i use writeOGR from rgdal and not the other 
write shapefile functions i can get a shapefile with projection recognized by 
ArcGIS. The command is (in case anybody wonders):

 writeOGR(crest.sp, I:\\LA_levee\\Shape, llev_crest_pts6, driver = ESRI 
Shapefile)

where crest.sp is a spatial point data frame with projection.

Thanks,

Monica



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


Re: [R] Select some, but not all, variables stepwise

2011-11-04 Thread Francisco Mora Ardila
Hi Andre

I don´t know if it will work, but I´ve tried the MuMIn package, were you can 
evaluate 
all possible models (usin for example AIC) at one time. Maybe you can focus on 
comparing 
those models which retain the explanators you want.

Best wishes
Francisco

On Fri, 4 Nov 2011 13:06:09 +, Andre Easom wrote
 Hi,
 
 I would like to fit a linear model where some but not all explanators are 
 chosen stepwise - ie I definitely want to include some terms, but others only 
 if they are deemed significant (by AIC or whatever other approach is 
 available)
 .  For example if I wanted to definitely include x1 and x2, but only include 
 z1 and z2 if they are significant, something like this:
 
 df - data.frame(y=c(4,2,6,7,3,9,5,7,6,2), x1=c(2,3,4,0,5,8,8,1,1,2), 
 x2=c(0,0,
 0,0,1,1,0,0,0,1), z1=c(0,1,0,0,0,1,1,0,1,1), z2=c(1,1,1,0,0,1,1,1,1,0)) model 
 - lm(y  ~ x1 + x2 + stepwise(z1 + z2))
 
 Any help would be appreciated.
 
 Cheers,
 Andre
 **
 This email and any attachments are confidential, protect...{{dropped:22}}
 
 __
 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.


Francisco Mora Ardila
Laboratorio de Biodiversidad y Funcionamiento del Ecosistema
Centro de Investigaciones en Ecosistemas
UNAM-Campus Morelia
Tel 3222777 ext. 42621
Morelia , MIchoacán, México.

--
Open WebMail Project (http://openwebmail.org)

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


[R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread Jose Iparraguirre
Hi,

Imagine I have the following data frame:

 a - c(1,NA,3)
 b - c(2,NA,NA)
 c - data.frame(cbind(a,b))
 c
   a  b
1  1  2
2 NA NA
3  3 NA

I want to delete the second row. If I use na.omit, that would also affect the 
third row. I tried to use a loop and an ifelse clause with is.na to get R 
identify that row in which all records are missing, as opposed to the first row 
in which no records are missing or the third one, in which only one record is 
missing. How can I get R identify the row in which all records are missing? Or, 
how can I get R delete/omit only this row?
Thanks in advance,

José


José Iparraguirre
Chief Economist
Age UK

T 020 303 31482
E jose.iparragui...@ageuk.org.ukmailto:jose.iparragui...@ageuk.org.uk

Tavis House, 1- 6 Tavistock Square
London, WC1H 9NB
www.ageuk.org.ukhttp://www.ageuk.org.uk | 
ageukblog.org.ukhttp://ageukblog.org.uk/ | 
@AgeUKPAhttp://twitter.com/ageukpa


Age UK  Improving later life

www.ageuk.org.uk





---

Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). Registered office: 
Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed 
Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the 
purposes of introducing potential annuity and health cash plans customers 
respectively.  Age UK Enterprises Limited, JLT Benefit Solutions Limited and 
Simplyhealth Access are all authorised and regulated by the Financial Services 
Authority. 



 

--

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you receive a message in error, please advise the sender and delete immediately.



Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not necessarily 
reflect the opinions of Age UK or its subsidiaries and associated companies. 
Age UK monitors all e-mail transmissions passing through its network and may 
block or modify mails which are deemed to be unsuitable.





Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged on 1st April 
2009.  Together they have formed the Age UK Group, dedicated to improving the 
lives of people in later life.  The three national Age Concerns in Scotland, 
Northern Ireland and Wales have also merged with Help the Aged in these nations 
to form three registered charities: Age Scotland, Age NI, Age Cymru.


























[[alternative HTML version deleted]]

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


[R] survfit function?

2011-11-04 Thread Ying Zhou

Hi, I
 am working on fitting a proportional hazard model to predict the 
probability of default for mortgage loans.  I have a question regarding 
survfit function. My
 historical data set is a pool of loans with monthly observed default 
status for the next 24 months. The data is left truncated (delayed entry
 to observation window after the loan is opened) and right censored.  I 
would like to fit the model with time varying covariate such as 
unemployment rates and time constant variables at loan application, and 
then use the model to predict the probability of default in the next 24 
month for the pool of loans we have right now, by using function 
survfit. When loans are outside of the observed time window, is it 
reliable to use survfit function to do the prediction? If it’s not 
reliable, how to deal with this problem? Is there another way to set the
 model? Any thoughts are appreciated. Thanks so much in advance. Ying(Cindy)
  
[[alternative HTML version deleted]]

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


Re: [R] Counting number of common elements between the rows of two different matrices

2011-11-04 Thread Parodi, Pietro
Jim

I tried that and it works. Thank you very much for your help!

Regards

Pietro


-Original Message-
From: jim holtman [mailto:jholt...@gmail.com] 
Sent: 04 November 2011 13:38
To: Parodi, Pietro
Cc: r-help@r-project.org
Subject: Re: [R] Counting number of common elements between the rows of two 
different matrices

Try this:

# create dummy data
a - matrix(sample(20, 50, TRUE), ncol = 5)
b - matrix(sample(20, 50, TRUE), ncol = 5)
# create combinations to test
x - expand.grid(seq(nrow(a)), seq(nrow(b)))
# test
result - mapply(function(m1, m2) any(a[m1, ] %in% b[m2, ])
, x[, 1]
, x[, 2]
)
# create the output matrix
result.m - matrix(result, nrow = nrow(a), ncol = nrow(b))

On Fri, Nov 4, 2011 at 8:51 AM, Parodi, Pietro pietro.par...@willis.com wrote:

 Hello

 I'm trying to solve this problem without using a for loop but I have so
 far failed to find a solution.

 I have two matrices of K columns each, e.g. (K=5), and with numbers of
 row N_A and N_B respectively

 A =     (1 5 3 8 15;
         2 7 20 11 13;
         12 19 20 21 43)

 B =     (2 6 30 8 16;
         3 8 19 11 13)

 (the actual matrices have hundreds of thousands of entry, that's why I'm
 keen to avoid for loops)

 And what I need to do is to apply a function which counts the number of
 common elements between ANY row of A and ANY row of B, giving a result
 like this:


 A1 vs B1:  1  # (8 is a common element)
 A1 vs B2:  1  # (8 is a common element)
 A2 vs B1:  1  # (2 is a common element)
 A2 vs B2:  1  # 11, 13 are common elements
 Etc.

 I've built a function that counts the number of common elements between
 two vectors, based on the intersect function in the R manual

 common_elements - function(x,y) length(y[match(x,y,nomatch=0)])

 And a double loop who solves my problem would be something like
 (pseudo-code)

 For(i in 1:N_A){
        for(j in 1:N_B){
                ce(i,j)=common_elements(a(i),b(j))
                }
        }

 Is there an efficient, clean way to do the same job and give as an
 output a matrix N_A x N_B such as that above?

 Thanks a lot for your help

 Regards

 Pietro

 __

 For information pertaining to Willis' email confidentiality and monitoring 
 policy, usage restrictions, or for specific company registration and 
 regulatory status information, please visit 
 http://www.willis.com/email_trailer.aspx

 We are now able to offer our clients an encrypted email capability for secure 
 communication purposes. If you wish to take advantage of this service or 
 learn more about it, please let me know or contact your Client Advocate for 
 full details. ~W67897

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




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread R. Michael Weylandt
Perhaps something like this will work.

df[!(rowSums(is.na(df))==NCOL(df)),]

Michael

On Fri, Nov 4, 2011 at 9:27 AM, Jose Iparraguirre
jose.iparragui...@ageuk.org.uk wrote:
 Hi,

 Imagine I have the following data frame:

 a - c(1,NA,3)
 b - c(2,NA,NA)
 c - data.frame(cbind(a,b))
 c
   a  b
 1  1  2
 2 NA NA
 3  3 NA

 I want to delete the second row. If I use na.omit, that would also affect the 
 third row. I tried to use a loop and an ifelse clause with is.na to get R 
 identify that row in which all records are missing, as opposed to the first 
 row in which no records are missing or the third one, in which only one 
 record is missing. How can I get R identify the row in which all records are 
 missing? Or, how can I get R delete/omit only this row?
 Thanks in advance,

 José


 José Iparraguirre
 Chief Economist
 Age UK

 T 020 303 31482
 E jose.iparragui...@ageuk.org.ukmailto:jose.iparragui...@ageuk.org.uk

 Tavis House, 1- 6 Tavistock Square
 London, WC1H 9NB
 www.ageuk.org.ukhttp://www.ageuk.org.uk | 
 ageukblog.org.ukhttp://ageukblog.org.uk/ | 
 @AgeUKPAhttp://twitter.com/ageukpa


 Age UK  Improving later life

 www.ageuk.org.uk





 ---

 Age UK is a registered charity and company limited by guarantee, (registered 
 charity number 1128267, registered company number 6825798). Registered 
 office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

 For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
 Representative of Age UK Enterprises Limited, Age UK is an Introducer 
 Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
 Access for the purposes of introducing potential annuity and health cash 
 plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
 Solutions Limited and Simplyhealth Access are all authorised and regulated by 
 the Financial Services Authority.





 --

 This email and any files transmitted with it are confidential and intended 
 solely for the use of the individual or entity to whom they are addressed. If 
 you receive a message in error, please advise the sender and delete 
 immediately.



 Except where this email is sent in the usual course of our business, any 
 opinions expressed in this email are those of the author and do not 
 necessarily reflect the opinions of Age UK or its subsidiaries and associated 
 companies. Age UK monitors all e-mail transmissions passing through its 
 network and may block or modify mails which are deemed to be unsuitable.





 Age Concern England (charity number 261794) and Help the Aged (charity number 
 272786) and their trading and other associated companies merged on 1st April 
 2009.  Together they have formed the Age UK Group, dedicated to improving the 
 lives of people in later life.  The three national Age Concerns in Scotland, 
 Northern Ireland and Wales have also merged with Help the Aged in these 
 nations to form three registered charities: Age Scotland, Age NI, Age Cymru.


























        [[alternative HTML version deleted]]


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



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


Re: [R] Select some, but not all, variables stepwise

2011-11-04 Thread AndreE
Thanks Francisco - I've actually realized that ?step can do pretty much
exactly what I want.
Andre

--
View this message in context: 
http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990516.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Jeff Newmiller
A) you wrote // when you meant \\. This behavior does not apply to forward 
slash.

B) if you want the ability to represent any arbitrary character in a string, 
some version of this feature is required. Visual Basic doesn't allow arbitrary 
characters unless you concatenate chr() function calls, though it does allow 
you to embed quotes () by repeating them (), sort of like \\, but much less 
useful.

Learning to understand escaping is a significant step, because it occurs in 
both the parsing of string literals and in regular expressions. Since 
specifying a regex often involves using a string literal to specify a regex, 
you have to escape the escape characters. Once you realize how useful this is 
you never want to return to the simplicity of VB, and simplifying the R 
language doesn't seem so attractive anymore.

So, just remember that \ is special in strings, and go reread the documentation 
whenever it crops up to figure out what should go after it to get a particular 
character into the string, and remember that a regex gets processed by two 
different sets of rules one after the other.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Gene Leynes gleyne...@gmail.com wrote:

I think that people are afraid to say You can't do that in R... 
But I think the real answer is: you can't do that in R.

Although, it is helpful to understand Jeff's reply.  I hadn't fully realized 
why this particular problem occurs before reading that.  It's odd to me that // 
and / are both stored as /, but that makes sense given my experience in R.

Also, the other replies are good advice, working with R's path functions or 
sticking with forward slashes is the way to go (don't fight the assimilation, 
the borg needs you).

Personally, I think some of these seemingly small problems actually encumber 
R's mainstream adoption quite a bit, but then I'm not the one writing R.  Plus, 
it's is still pretty dang awesome even with its minor annoyances.


On Fri, Nov 4, 2011 at 8:45 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:

Your str does not have any double backslashes to replace. You need to revisit 
the concept of escape characters in the documentation. In brief, every \\ in 
a quoted string is actually a single character as stored in memory.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---
Sent from my phone. Please excuse my brevity.


Kay Cichini kay.cich...@uibk.ac.at wrote:

I want to replace \\ with \ in:
str -
C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg

and tried:
gsub(, \\, str)

but this removes the \\ without replacing them by \

Any help much appreciated,
Kay

-

Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck


--
View this message in context: 
http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.

_

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


   [[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


Re: [R] Select some, but not all, variables stepwise

2011-11-04 Thread Frank Harrell
Why do any of that?  Those procedures are statistically invalid.
Frank

AndreE wrote:
 
 Thanks Francisco - I've actually realized that ?step can do pretty much
 exactly what I want.
 Andre
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Select-some-but-not-all-variables-stepwise-tp3990002p3990598.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] zoo performance regression noticed (1.6-5 is faster...)

2011-11-04 Thread James Marca
Good morning,

I have discovered what I believe to be a performance regression
between Zoo 1.6x and Zoo 1.7-6 in the application of rollapply.
On zoo 1.6x, rollapply of my function over my data takes about 20
minutes. Using 1.7-6, the same code takes about 6 hours.

R --version 
R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

Two versions of zoo 1.6 run *fast*  On one machine I am running 

 less /usr/lib64/R/library/zoo/DESCRIPTION 
 Package: zoo
 Version: 1.6-3
 Date: 2010-04-23
 Title: Z's ordered observations
 ...
 Packaged: 2010-04-23 07:28:47 UTC; zeileis
 Repository: CRAN
 Date/Publication: 2010-04-23 07:43:54
 Built: R 2.10.1; ; 2010-04-25 06:41:34 UTC; unix

(Thankfully I forgot to upgrade.packages() on this machine!)

On the other

 Package: zoo
 Version: 1.6-5
 Date: 2011-04-08
 ...
 Packaged: 2011-04-08 17:13:47 UTC; zeileis
 Repository: CRAN
 Date/Publication: 2011-04-08 17:27:47
 Built: R 2.13.1; ; 2011-11-04 15:49:54 UTC; unix

I have stripped out zoo 1.7-6 from all my machines.

I tried to ensure all libraries were identical on the two machines
(using lsof), and after finally downgrading zoo I got the second
machine to be as fast as the first, so I am quite certain the
difference in speed is down to the Zoo version used.

My code runs a fairly simple function over a time series using the
following call to process a year of 30s data (9 columns, about a
million rows):

vals - rollapply(data=ts.data[,c(n.3.cols, o.3.cols,volocc.cols)]
  ,width=40
  
,FUN=rolling.function.fn(n.cols=n.3.cols,o.cols=o.3.cols,vo.cols=volocc.cols)
  ,by.column=FALSE
  ,align='right')


(The rolling.function.fn call returns a function that is initialized
with the initial call above (a trick I learned from Javascript))

If this is a known situation with the new 1.7 generation Zoo, my
apologies and I'll go away.  If my code could be turned into a useful
test, I'd be happy to help out as much as I'm able.  Given the extreme
runtime difference though, I thought I should offer my help in this
case, since zoo is such a useful package in my work.

Regards,
James Marca


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


Re: [R] zoo performance regression noticed (1.6-5 is faster...)

2011-11-04 Thread Gabor Grothendieck
On Fri, Nov 4, 2011 at 12:34 PM, James Marca
jma...@translab.its.uci.edu wrote:
 Good morning,

 I have discovered what I believe to be a performance regression
 between Zoo 1.6x and Zoo 1.7-6 in the application of rollapply.
 On zoo 1.6x, rollapply of my function over my data takes about 20
 minutes. Using 1.7-6, the same code takes about 6 hours.

 R --version
 R version 2.13.1 (2011-07-08)
 Copyright (C) 2011 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-pc-linux-gnu (64-bit)

 Two versions of zoo 1.6 run *fast*  On one machine I am running

  less /usr/lib64/R/library/zoo/DESCRIPTION
  Package: zoo
  Version: 1.6-3
  Date: 2010-04-23
  Title: Z's ordered observations
  ...
  Packaged: 2010-04-23 07:28:47 UTC; zeileis
  Repository: CRAN
  Date/Publication: 2010-04-23 07:43:54
  Built: R 2.10.1; ; 2010-04-25 06:41:34 UTC; unix

 (Thankfully I forgot to upgrade.packages() on this machine!)

 On the other

  Package: zoo
  Version: 1.6-5
  Date: 2011-04-08
  ...
  Packaged: 2011-04-08 17:13:47 UTC; zeileis
  Repository: CRAN
  Date/Publication: 2011-04-08 17:27:47
  Built: R 2.13.1; ; 2011-11-04 15:49:54 UTC; unix

 I have stripped out zoo 1.7-6 from all my machines.

 I tried to ensure all libraries were identical on the two machines
 (using lsof), and after finally downgrading zoo I got the second
 machine to be as fast as the first, so I am quite certain the
 difference in speed is down to the Zoo version used.

 My code runs a fairly simple function over a time series using the
 following call to process a year of 30s data (9 columns, about a
 million rows):

    vals - rollapply(data=ts.data[,c(n.3.cols, o.3.cols,volocc.cols)]
                  ,width=40
                  
 ,FUN=rolling.function.fn(n.cols=n.3.cols,o.cols=o.3.cols,vo.cols=volocc.cols)
                  ,by.column=FALSE
                  ,align='right')


 (The rolling.function.fn call returns a function that is initialized
 with the initial call above (a trick I learned from Javascript))

 If this is a known situation with the new 1.7 generation Zoo, my
 apologies and I'll go away.  If my code could be turned into a useful
 test, I'd be happy to help out as much as I'm able.  Given the extreme
 runtime difference though, I thought I should offer my help in this
 case, since zoo is such a useful package in my work.

This was a known problem and was fixed but if its still there then
there must be some other condition under which it can occur as well.
If you can provide a small self contained reproducible example it
would help in tracking it down.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Decision tree model using rpart ( classification

2011-11-04 Thread Tal Galili
Could you please repeat the error massage you get for C ?


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Nov 4, 2011 at 10:32 AM, aajit75 aaji...@yahoo.co.in wrote:

 Hi,

 Thanks for the responce, code for each case is as:

 c_c_factor - 0.001
 min_obs_split - 80

 A)

 fit - rpart(segment ~., method=class,
   control=rpart.control(minsplit=min_obs_split, cp=c_c_factor),
   data=Beh_cluster_out)

 B)
 fit - rpart(segment ~., method=class,
   control=rpart.control(minsplit=min_obs_split, cp=c_c_factor),
   data=profile_cluster_out)

  C)
 fit - rpart(decile ~., method=class,
control=rpart.control(minsplit=min_obs_split, cp=c_c_factor),
   data=dtm_ip)

 In A and B target variable 'segment' is from the clustering data using same
 set of input variables , while in C target variable 'decile' is derived
 from
 behavioural variables and input variables are from profile data. Number of
 rows in the input table in all three cases are same.

 Regards,
 -Ajit


 --
 View this message in context:
 http://r.789695.n4.nabble.com/Decision-tree-model-using-rpart-classification-tp3989162p3989320.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] zoo performance regression noticed (1.6-5 is faster...)

2011-11-04 Thread Gabor Grothendieck
On Fri, Nov 4, 2011 at 12:56 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Fri, Nov 4, 2011 at 12:34 PM, James Marca
 jma...@translab.its.uci.edu wrote:
 Good morning,

 I have discovered what I believe to be a performance regression
 between Zoo 1.6x and Zoo 1.7-6 in the application of rollapply.
 On zoo 1.6x, rollapply of my function over my data takes about 20
 minutes. Using 1.7-6, the same code takes about 6 hours.

 R --version
 R version 2.13.1 (2011-07-08)
 Copyright (C) 2011 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-pc-linux-gnu (64-bit)

 Two versions of zoo 1.6 run *fast*  On one machine I am running

  less /usr/lib64/R/library/zoo/DESCRIPTION
  Package: zoo
  Version: 1.6-3
  Date: 2010-04-23
  Title: Z's ordered observations
  ...
  Packaged: 2010-04-23 07:28:47 UTC; zeileis
  Repository: CRAN
  Date/Publication: 2010-04-23 07:43:54
  Built: R 2.10.1; ; 2010-04-25 06:41:34 UTC; unix

 (Thankfully I forgot to upgrade.packages() on this machine!)

 On the other

  Package: zoo
  Version: 1.6-5
  Date: 2011-04-08
  ...
  Packaged: 2011-04-08 17:13:47 UTC; zeileis
  Repository: CRAN
  Date/Publication: 2011-04-08 17:27:47
  Built: R 2.13.1; ; 2011-11-04 15:49:54 UTC; unix

 I have stripped out zoo 1.7-6 from all my machines.

 I tried to ensure all libraries were identical on the two machines
 (using lsof), and after finally downgrading zoo I got the second
 machine to be as fast as the first, so I am quite certain the
 difference in speed is down to the Zoo version used.

 My code runs a fairly simple function over a time series using the
 following call to process a year of 30s data (9 columns, about a
 million rows):

    vals - rollapply(data=ts.data[,c(n.3.cols, o.3.cols,volocc.cols)]
                  ,width=40
                  
 ,FUN=rolling.function.fn(n.cols=n.3.cols,o.cols=o.3.cols,vo.cols=volocc.cols)
                  ,by.column=FALSE
                  ,align='right')


 (The rolling.function.fn call returns a function that is initialized
 with the initial call above (a trick I learned from Javascript))

 If this is a known situation with the new 1.7 generation Zoo, my
 apologies and I'll go away.  If my code could be turned into a useful
 test, I'd be happy to help out as much as I'm able.  Given the extreme
 runtime difference though, I thought I should offer my help in this
 case, since zoo is such a useful package in my work.

 This was a known problem and was fixed but if its still there then
 there must be some other condition under which it can occur as well.
 If you can provide a small self contained reproducible example it
 would help in tracking it down.

 --
 Statistics  Software Consulting
 GKX Group, GKX Associates Inc.
 tel: 1-877-GKX-GROUP
 email: ggrothendieck at gmail.com


Also, as a workaround you can try this to use an old rollapply in a
new version of zoo:

library(zoo)
source(http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/rollapply.R?revision=817root=zoo;)
rollapply(...whatever...)

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] query about counting rows of a dataframe

2011-11-04 Thread David Winsemius


On Nov 3, 2011, at 12:28 PM, Stefano Sofia wrote:


Dear R users,
I have got the following data frame, called my_df:

  gender day_birth month_birth year_birth labour
1   F 22  10
2001  1
2   M29  10
2001  2
3   M  1   11   
2001  1
4   F   3  11
2001  1
5   M  3  11
2001  2
6   F  4   11
2001  1
7   F  4   11
2001  2
8   F  5   12
2001  2
9   M   22   14
2001  2
10 F   29   13
2001  2

...

I need to count data in different ways:

1. count the births for each day (having 0 when necessary)  
independently from the value of the labour column


xtabs sometimes give better results. If you want all 31 days then make  
day_birth a factor with levels=1:31)


 xtabs(  ~ day_birth + month_birth + year_birth, data=dat)
, , year_birth = 2001

 month_birth
day_birth 10 11 12 13 14
   1   0  1  0  0  0
   3   0  2  0  0  0
   4   0  2  0  0  0
   5   0  0  1  0  0
   22  1  0  0  0  1
   29  1  0  0  1  0



2. count the births for each day (having 0 when necessary), divided  
by the value of labour (which can have two valuers, 1 or 2)


Cannot figure out what is being asked here. What to do with the two  
values? Just count them? This would give a partitioned count


 xtabs( labour==1 ~ day_birth + month_birth , data=dat)
 month_birth
day_birth 10 11 12 13 14
   1   0  1  0  0  0
   3   0  1  0  0  0
   4   0  1  0  0  0
   5   0  0  0  0  0
   22  1  0  0  0  0
   29  0  0  0  0  0
 xtabs( labour==2 ~ day_birth + month_birth , data=dat)
 month_birth
day_birth 10 11 12 13 14
   1   0  0  0  0  0
   3   0  1  0  0  0
   4   0  1  0  0  0
   5   0  0  1  0  0
   22  0  0  0  0  1
   29  1  0  0  1  0




3. count the births for each day of all the years (i.e. the 22nd of  
October of all the years present in the data frame) independently  
from the value of labour


If I understand correctly:

 xtabs(  ~ day_birth + month_birth + year_birth, data=dat)
, , year_birth = 2001

 month_birth
day_birth 10 11 12 13 14
   1   0  1  0  0  0
   3   0  2  0  0  0
   4   0  2  0  0  0
   5   0  0  1  0  0
   22  1  0  0  0  1
   29  1  0  0  1  0



4. count the births for each day of all the years (i.e. the 22nd of  
October of all the years present in the data frame), divided by the  
value of labour


Again confusing. Do you mean to use separate tables for labour==1 and  
labour==2? Perhaps context to explain what these values represent.  
Some of us are concrete. The results of xtabs are tables and can be  
divided like matrices.




I tried with the command

table(my_df$year_birth, my_df$month_birth, my_df$day_birth)

which satisfies (partially) question numer 1 (I am not able to have  
0 in the not available days).


Is there a smart way to do that without invoking too many loops?

thank you for your help



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Plotting skewed normal distribution with a bar plot

2011-11-04 Thread R. Michael Weylandt
You might want to check again: I'm running fGarch on 2.13.2, Mac OSX 10.5.8.

Michael

On Fri, Nov 4, 2011 at 9:36 AM, Steve Friedman skfgla...@gmail.com wrote:
 Hi Michael,

 Thanks for pointing me fGarch.  I actually started there, but it is not yet
 available for 2.13.2 so I went directly to the (sn-package).

 I've briefly explored your suggestion and think it will work.

 Thanks
 Steve

 On Nov 3, 2011 10:41 PM, R. Michael Weylandt michael.weyla...@gmail.com
 wrote:

 It seems like you'll need to apply some sort of MLE to estimate the
 parameters directly from the data before using dsn() to get the
 density. This might help with some of it:
 http://help.rmetrics.org/fGarch/html/snorm.html

 Michael

 On Thu, Nov 3, 2011 at 2:54 PM,  steve_fried...@nps.gov wrote:
 
  Hi,
 
  I need to create a plot (type = h)  and then overlay a skewed-normal
  curve on this distribution, but I'm not finding a procedure to
  accomplish
  this. I want to use the plot function here in order to control the bin
  distributions.
 
  I have explored the sn library and found the dsn function.  dsn uses
  known
  location, scaling and shape parameters associated with a given input
  vector
  of probabilities.  However, how can I calculate the skewed-normal curve
  if
  I don't know these parameters in advance?
 
  Is there another function to calculate the skew-normal, perhaps in a
  different package?
 
 
  I'm working with R 2.13.2 on a windows based machine.
 
  Steve Friedman Ph. D.
  Ecologist  / Spatial Statistical Analyst
  Everglades and Dry Tortugas National Park
  950 N Krome Ave (3rd Floor)
  Homestead, Florida 33034
 
  steve_fried...@nps.gov
  Office (305) 224 - 4282
  Fax     (305) 224 - 4147
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


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


[R] barplot as histogram

2011-11-04 Thread Jesse Brown

Hello:

I'm dealing with an issue currently that I'm not sure the best way to 
approach. I've got a very large (10G+) dataset that I'm trying to create 
a histogram for. I don't seem to be able to use hist directly as I can 
not create an R vector of size greater than 2.2G. I considered 
condensing the data  previous to loading it into R  and just plotting 
the frequencies as a barplot; unfortunately, barplot does not support 
plotting the values according to a set of x-axis positions.


What I have is something similar to:

ys - c(12,3,7,22,10)
xs - c(1,30,35,39,60)

and I'd like the bars (ys) to appear at the positions described by xs. I 
can get this to work on smaller sets by filling zero values in for 
missing ys for the entire range of xs but in my case this would again 
create a vector too large for R.


Is there another way to use the two vectors to create a simulated 
frequency histogram? Is there a way to create a histogram object (as 
returned by hist) from the condensed data so that plot would handle it 
correctly?


Thanks in advance,

Jesse

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


Re: [R] barplot as histogram

2011-11-04 Thread R. Michael Weylandt
Perhaps

plot(xs, ys, type = h, lwd = 3)

will work?

I'm not sure that a direct call to hist(, plot = F) will get around
the data problems. If you type getAnywhere(hist.default) you can see
the code that runs hist(): perhaps you can extract the working bits
you need.

Michael

On Fri, Nov 4, 2011 at 2:04 PM, Jesse Brown jesse.r.br...@lmco.com wrote:
 Hello:

 I'm dealing with an issue currently that I'm not sure the best way to
 approach. I've got a very large (10G+) dataset that I'm trying to create a
 histogram for. I don't seem to be able to use hist directly as I can not
 create an R vector of size greater than 2.2G. I considered condensing the
 data  previous to loading it into R  and just plotting the frequencies as a
 barplot; unfortunately, barplot does not support plotting the values
 according to a set of x-axis positions.

 What I have is something similar to:

 ys - c(12,3,7,22,10)
 xs - c(1,30,35,39,60)

 and I'd like the bars (ys) to appear at the positions described by xs. I can
 get this to work on smaller sets by filling zero values in for missing ys
 for the entire range of xs but in my case this would again create a vector
 too large for R.

 Is there another way to use the two vectors to create a simulated frequency
 histogram? Is there a way to create a histogram object (as returned by hist)
 from the condensed data so that plot would handle it correctly?

 Thanks in advance,

 Jesse

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


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


Re: [R] barplot as histogram

2011-11-04 Thread Duncan Murdoch

On 04/11/2011 2:04 PM, Jesse Brown wrote:

Hello:

I'm dealing with an issue currently that I'm not sure the best way to
approach. I've got a very large (10G+) dataset that I'm trying to create
a histogram for. I don't seem to be able to use hist directly as I can
not create an R vector of size greater than 2.2G. I considered
condensing the data  previous to loading it into R  and just plotting
the frequencies as a barplot; unfortunately, barplot does not support
plotting the values according to a set of x-axis positions.

What I have is something similar to:

ys- c(12,3,7,22,10)
xs- c(1,30,35,39,60)

and I'd like the bars (ys) to appear at the positions described by xs. I
can get this to work on smaller sets by filling zero values in for
missing ys for the entire range of xs but in my case this would again
create a vector too large for R.

Is there another way to use the two vectors to create a simulated
frequency histogram? Is there a way to create a histogram object (as
returned by hist) from the condensed data so that plot would handle it
correctly?


Follow your own last suggestion.  Take a small subset of your data, and 
calculate


x - hist(data, plot=FALSE)

str(x) will show you the structure of the object in x.  Modify the 
entries to reflect your full dataset, and then


plot(x)

will show it.

Duncan Murdoch

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


[R] Random multinomial variable

2011-11-04 Thread Scott Raynaud
I need some help interpreting the following code which is part of a mutlilevel 
model simulation with 2 levels.  I've put in comments with my understanding of 
the code, but I'm not sure how [i2id] is functioning.  It's defined in another 
part of the program as l2id-rep(c(1:n2),each=n1) which looks like a number 
corresponding to the level 1 and 2 sample size (n1, n2).  Can someone explain 
what [i2id] is telling x[,3] and x[,4]?
 
macpred-rmultinom(n2,1,c(0.15,0.30,0.55))
## generate one multinomial variable of length=1 with probabilities of .15, .30 
and .55 and do this n2 times
 
x[,3]-macpred[1,][l2id]
 ##assign the first mutinomial value to column 3
 
x[,4]-macpred[2,][l2id]
##assign the second multinomial value to column 4

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


Re: [R] Fit continuous distribution to truncated empirical values

2011-11-04 Thread David Winsemius


On Nov 3, 2011, at 7:54 AM, Michele Mazzucco wrote:


Hi all,

I am trying to fit a distribution to some data about survival times.
I am interested only in a specific interval, e.g., while the data  
lies in the interval (0,, 600), I want the best for the interval  
(0,..., 24).


I have tried both fitdistr (MASS package) and fitdist (from the  
fitdistrplus package), but I could not get them working, e.g.


fitdistr(left, weibull, upper=24)
Error in optim(x = c(529L, 528L, 527L, 526L, 525L, 524L, 523L, 522L,  
521L,  :

 L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In dweibull(x, shape, scale, log) : NaNs produced

Am I doing something wrong?


You didn't supply data to test,  but shouldn't you supply a lower  
bound if you want to fit weibull? It is, after all, bounded at 0.


 left - c(529L, 528L, 527L, 526L, 525L, 524L, 523L, 522L, 521L,  
50*runif(100))

 fitdistr(left, weibull, upper=24)
Error in optim(x = c(529, 528, 527, 526, 525, 524, 523, 522, 521,  
18.3964251773432,  :

  L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In dweibull(x, shape, scale, log) : NaNs produced

 fitdistr(left, weibull, upper=24, lower=0.5)
  shape scale
   0.58195013   24.
 ( 0.04046087) ( 3.38621367)




Thanks,
Michele


p.s. I have seen similar posts, e.g., http://tolstoy.newcastle.edu.au/R/help/05/02/11558.html 
, but I am not sure whether I can apply the same approach here.

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] barplot as histogram

2011-11-04 Thread Jesse Brown


I believe that plot(..., type='h') will do the trick. I had tried that 
earlier but forgot to play with the lwd parameter.


Incidentally, I didn't know about getAnywhere(hist.default) - really 
handy. I was reading the code to find the details.


Thanks!

Jesse


R. Michael Weylandt wrote:

Perhaps

plot(xs, ys, type = h, lwd = 3)

will work?

I'm not sure that a direct call to hist(, plot = F) will get around
the data problems. If you type getAnywhere(hist.default) you can see
the code that runs hist(): perhaps you can extract the working bits
you need.

Michael

On Fri, Nov 4, 2011 at 2:04 PM, Jesse Brown jesse.r.br...@lmco.com wrote:
  

Hello:

I'm dealing with an issue currently that I'm not sure the best way to
approach. I've got a very large (10G+) dataset that I'm trying to create a
histogram for. I don't seem to be able to use hist directly as I can not
create an R vector of size greater than 2.2G. I considered condensing the
data  previous to loading it into R  and just plotting the frequencies as a
barplot; unfortunately, barplot does not support plotting the values
according to a set of x-axis positions.

What I have is something similar to:

ys - c(12,3,7,22,10)
xs - c(1,30,35,39,60)

and I'd like the bars (ys) to appear at the positions described by xs. I can
get this to work on smaller sets by filling zero values in for missing ys
for the entire range of xs but in my case this would again create a vector
too large for R.

Is there another way to use the two vectors to create a simulated frequency
histogram? Is there a way to create a histogram object (as returned by hist)
from the condensed data so that plot would handle it correctly?

Thanks in advance,

Jesse

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







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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread David Winsemius


On Nov 4, 2011, at 6:34 AM, clangkamp wrote:

I have tried this method, but the result is not working, at least  
not as I

expect:
I used the CreditMetrics package transition matrix
rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
M - matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
0, 0, 0, 0, 0, 0, 0, 100
)/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)

then followed through with the steps:

nth_root - X %*% L_star %*% X_inv


Despite my (distant) physics training, I am no matrix mechanic, so I  
cannot comment on that method. I would instead search for an nth-root  
matrix function 


http://search.r-project.org/cgi-bin/namazu.cgi?query=nth+root+of+matrixmax=100result=normalsort=scoreidxname=functionsidxname=vignettesidxname=views

And finding one in package 'pracma', see if it succeeds:

 nthroot(M, 12)
  AAAAA A   BBBBB B
CCC D
AAA 0.9919988 0.8129311 0.6597444 0.5389055 0.5519810 0.4917592  
0.4641589 0.4641589
AA  0.6613401 0.9918530 0.8084034 0.6564198 0.5389055 0.5747716  
0.4917592 0.4641589
A   0.5574256 0.7294611 0.9922170 0.7855279 0.6644097 0.6089493  
0.4641589 0.5389055
BBB 0.4917592 0.6211686 0.7904537 0.9874431 0.7828700 0.6902644  
0.6877567 0.5905718
BB  0.5086590 0.5783322 0.6589304 0.8078827 0.9821168 0.8169667  
0.6812921 0.6846083
B   0.4641589 0.5668255 0.6049010 0.6350224 0.7960944 0.9850460  
0.7658309 0.7816283
CCC 0.5982072 0.000 0.6005307 0.6963517 0.7323434 0.8334839  
0.9645648 0.8737164
D   0.000 0.000 0.000 0.000 0.000 0.000  
0.000 1.000


 nthroot(M, 12)^12
   AAA AA  ABBB BB  BCCC  D
AAA 0.9081 0.0833 0.0068 0.0006 0.0008 0.0002 0.0001 0.0001
AA  0.0070 0.9065 0.0779 0.0064 0.0006 0.0013 0.0002 0.0001
A   0.0009 0.0227 0.9105 0.0552 0.0074 0.0026 0.0001 0.0006
BBB 0.0002 0.0033 0.0595 0.8593 0.0530 0.0117 0.0112 0.0018
BB  0.0003 0.0014 0.0067 0.0773 0.8053 0.0884 0.0100 0.0106
B   0.0001 0.0011 0.0024 0.0043 0.0648 0.8346 0.0407 0.0520
CCC 0.0021 0. 0.0022 0.0130 0.0238 0.1124 0.6486 0.1979
D   0. 0. 0. 0. 0. 0. 0. 1.
 all.equal(M , nthroot(M, 12)^12)
[1] TRUE

Success!

--
David.



But the check (going back 12 to the power again) doesn't yield the  
original
matrix. Now some rounding errors can be expected, but I didn't  
expect a
perfectly diagonal matrix, when the initial matrix isn't diagonal at  
all.

round(nth_root^12,4)

  [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7] [,8]
[1,] 0.9078 0. 0. 0. 0. 0. 0.0
[2,] 0. 0.9053 0. 0. 0. 0. 0.0
[3,] 0. 0. 0.9079 0. 0. 0. 0.0
[4,] 0. 0. 0. 0.8553 0. 0. 0.0
[5,] 0. 0. 0. 0. 0.7998 0. 0.0
[6,] 0. 0. 0. 0. 0. 0.8285 0.0
[7,] 0. 0. 0. 0. 0. 0. 0.64570
[8,] 0. 0. 0. 0. 0. 0. 0.1

Any takers




--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread Peter Langfelder
Is it just me or are you confusing the 12th root of a matrix with
taking the 12th root of each entry? Because your formula involving the
eigenvectors and eigenvalues calculates the 12th root of the matrix,
while

round(nth_root^12,4)

will print out a matrix whose components are powers of 12 of the
nth_root, which is very different. To find the 12th power of a matrix,
you can either search for an appropriate function, or do

res = nth_root;
for (p in 1:11)
  res = res %*% nth_root

then compare res to your original matrix M.

Peter

On Fri, Nov 4, 2011 at 3:34 AM, clangkamp christian.langk...@gmxpro.de wrote:
 I have tried this method, but the result is not working, at least not as I
 expect:
 I used the CreditMetrics package transition matrix
 rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
 M - matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
 0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
 0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
 0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
 0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
 0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
 0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
 0, 0, 0, 0, 0, 0, 0, 100
 )/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)

 then followed through with the steps:

 nth_root - X %*% L_star %*% X_inv

 But the check (going back 12 to the power again) doesn't yield the original
 matrix. Now some rounding errors can be expected, but I didn't expect a
 perfectly diagonal matrix, when the initial matrix isn't diagonal at all.
 round(nth_root^12,4)
       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7] [,8]
 [1,] 0.9078 0. 0. 0. 0. 0. 0.    0
 [2,] 0. 0.9053 0. 0. 0. 0. 0.    0
 [3,] 0. 0. 0.9079 0. 0. 0. 0.    0
 [4,] 0. 0. 0. 0.8553 0. 0. 0.    0
 [5,] 0. 0. 0. 0. 0.7998 0. 0.    0
 [6,] 0. 0. 0. 0. 0. 0.8285 0.    0
 [7,] 0. 0. 0. 0. 0. 0. 0.6457    0
 [8,] 0. 0. 0. 0. 0. 0. 0.    1

 Any takers


 -
 Christian Langkamp
 christian.langkamp-at-gmxpro.de

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/12th-Root-of-a-Square-Transition-Matrix-tp2259736p3989618.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Sent from my Linux computer. Way better than iPad :)

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


Re: [R] nproc parameter in efpFunctional

2011-11-04 Thread Achim Zeileis

On Fri, 4 Nov 2011, bonda wrote:

The 2006 CSDA paper is really very informative, perhaps, I'm trying to 
understand the things lying beyond. If we have e.g. k=3, then taking 
nproc=3 for the functional maxBB we get a critical value (boundary)


maxBB$computeCritval(0.05,nproc=3)
[1] 1.544421,

and this for nproc=NULL (Bonferroni approximation) will be

maxBB$computeCritval(0.05)
[1] 1.358099.


No. In the latter case no Bonferroni approximation is applied. If you want 
to use it, you can do so via the rule of thumb


R maxBB$computeCritval(0.05/3, nproc = 1)
[1] 1.547175

which essentially matches the critical value computed for nproc = 3. If 
you use the more precise value 1 - (1 - 0.05)^(1/3) instead of 0.05/3, you 
get a match (up to some small numerical differences).


Setting nproc=NULL is only possible in efpFunctional():
efpFunctional() sets up the computeCritval() and computePval() functions 
via simulation methods (unless closed form solutions are supplied). For 
the simulation two strategies are available: Simulate nproc = 1, 2, 3, ...
explicitly. Simulate only nproc = 1 and apply a Bonferroni correction. The 
last option is chosen if you set nproc=NULL -- it makes only sense if you 
aggregate via the maximum across the components.


The resulting computeCritval() and computePval() function always need to 
have the correct nproc supplied (i.e., nproc=NULL makes no sense).



Aggregating 3 Brownian bridges first over components, we obtain time series
process. Now, we wonder if maximum value of the process (aggregation over
time) lies over boundary. Which boundary - 1.544421 or 1.358099 - should one
take? They look too different and, for instance, lead to unfair computing
of empirical size (as rejection rate of null hypothesis) or empirical power
(as acception rate of alternative).




--
View this message in context: 
http://r.789695.n4.nabble.com/nproc-parameter-in-efpFunctional-tp3972419p3989598.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Lattice plots and missing x-axis labels on second page

2011-11-04 Thread David Winsemius


On Nov 2, 2011, at 8:23 PM, Evans, David G (DFG) wrote:


I should say I'm using Windows-7, R version 2.13.0 and lattice version
0.19-33.  I've pared down my code to this :

pdat = read.table(RGRAPHSDGE.csv,header=T,sep=,,fill=T)
print(xyplot(pdat$NITRATE~pdat$DATEYR|pdat$WELL,


I generally try to avoid building lattice plots this way. It is better  
to use data=pdat and shorten the formula specification. That way the  
functions can use the aggregate information in the dataframe. Try:


xyplot( NITRATE~ DATEYR| WELL, data=pdat,



as.table=TRUE,
layout=c(3,4),


You may want to try layout=c(3,4,2)

See help(xyplot) subsection layout, where Sarkar says that pages are  
somethimes incorrectly calculated.



xlab=Year,
ylab=Nitrate mg / litre,
strip=FALSE
))

First 3 lines of pdat looks like this:
   WELL   DATEYR NITRATE
1 ALASKA CHILDRENS SERVICES 1993.8360.81
2 ALASKA CHILDRENS SERVICES 1994.8500.91
3 ALASKA CHILDRENS SERVICES 1995.8030.94

Thanks again.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

On Behalf Of Evans, David G (DFG)
Sent: Wednesday, November 02, 2011 3:24 PM
To: r-help@r-project.org
Subject: [R] Lattice plots and missing x-axis labels on second page

Hello,
I'm trying to make a lattice plot (using xyplot()). I have included a
layout=c(3,4) statement, giving me 12 plots per page and an
as.table=TRUE statement, directing the way the plots are laid  
out.  I

have 18 plots altogether and so 6 of them end up on the second page.





Everything looks fine for the first page, but the x-axis labels (e.g.
1993, 1994...) are all missing on the second page.  The x-axis  
variable

name (Year) is there at the bottom, however.   Any help is
appreciated. Thanks.

David G. Evans
Biometrician
Division of Sport Fish
Alaska Dept . of Fish and Game
Anchorage, Ak 99518

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

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Lattice plots and missing x-axis labels on second page

2011-11-04 Thread David Winsemius


On Nov 2, 2011, at 8:23 PM, Evans, David G (DFG) wrote:


I should say I'm using Windows-7, R version 2.13.0 and lattice version
0.19-33.  I've pared down my code to this :

pdat = read.table(RGRAPHSDGE.csv,header=T,sep=,,fill=T)
print(xyplot(pdat$NITRATE~pdat$DATEYR|pdat$WELL,


I generally try to avoid building lattice plots this way. It is better  
to use data=pdat and shorten the formula specification. That way the  
functions can use the aggregate information in the dataframe. Try:


xyplot( NITRATE~ DATEYR| WELL, data=pdat,



as.table=TRUE,
layout=c(3,4),


You may want to try layout=c(3,4,2)

See help(xyplot) subsection layout, where Sarkar says that pages are  
somethimes incorrectly calculated.



xlab=Year,
ylab=Nitrate mg / litre,
strip=FALSE
))

First 3 lines of pdat looks like this:
   WELL   DATEYR NITRATE
1 ALASKA CHILDRENS SERVICES 1993.8360.81
2 ALASKA CHILDRENS SERVICES 1994.8500.91
3 ALASKA CHILDRENS SERVICES 1995.8030.94

Thanks again.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

On Behalf Of Evans, David G (DFG)
Sent: Wednesday, November 02, 2011 3:24 PM
To: r-help@r-project.org
Subject: [R] Lattice plots and missing x-axis labels on second page

Hello,
I'm trying to make a lattice plot (using xyplot()). I have included a
layout=c(3,4) statement, giving me 12 plots per page and an
as.table=TRUE statement, directing the way the plots are laid  
out.  I

have 18 plots altogether and so 6 of them end up on the second page.





Everything looks fine for the first page, but the x-axis labels (e.g.
1993, 1994...) are all missing on the second page.  The x-axis  
variable

name (Year) is there at the bottom, however.   Any help is
appreciated. Thanks.

David G. Evans
Biometrician
Division of Sport Fish
Alaska Dept . of Fish and Game
Anchorage, Ak 99518

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

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread David Winsemius


On Nov 4, 2011, at 4:04 PM, Peter Langfelder wrote:


Is it just me or are you confusing the 12th root of a matrix with
taking the 12th root of each entry?


I think I got confused as well. Thanks for clarifying.


Because your formula involving the
eigenvectors and eigenvalues calculates the 12th root of the matrix,
while

round(nth_root^12,4)

will print out a matrix whose components are powers of 12 of the
nth_root, which is very different. To find the 12th power of a matrix,
you can either search for an appropriate function, or do

res = nth_root;
for (p in 1:11)
 res = res %*% nth_root



The 12th (matrix) root of M: e^( 1/n * log(M) )

 require(Matrix)
 M1.12 - expm( (1/12)*logm(M) )

 res = M1.12; nth_root=M1.12
 for (p in 1:11)
+  res = res %*% nth_root

# Check accuracy
 round(res, 4)
   [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]
[1,] 0.9081 0.0833 0.0068 0.0006 0.0008 0.0002 0.0001 0.0001
[2,] 0.0070 0.9065 0.0779 0.0064 0.0006 0.0013 0.0002 0.0001
[3,] 0.0009 0.0227 0.9105 0.0552 0.0074 0.0026 0.0001 0.0006
[4,] 0.0002 0.0033 0.0595 0.8593 0.0530 0.0117 0.0112 0.0018
[5,] 0.0003 0.0014 0.0067 0.0773 0.8053 0.0884 0.0100 0.0106
[6,] 0.0001 0.0011 0.0024 0.0043 0.0648 0.8346 0.0407 0.0520
[7,] 0.0021 0. 0.0022 0.0130 0.0238 0.1124 0.6486 0.1979
[8,] 0. 0. 0. 0. 0. 0. 0. 1.

 M
   AAA AA  ABBB BB  BCCC  D
AAA 0.9081 0.0833 0.0068 0.0006 0.0008 0.0002 0.0001 0.0001
AA  0.0070 0.9065 0.0779 0.0064 0.0006 0.0013 0.0002 0.0001
A   0.0009 0.0227 0.9105 0.0552 0.0074 0.0026 0.0001 0.0006
BBB 0.0002 0.0033 0.0595 0.8593 0.0530 0.0117 0.0112 0.0018
BB  0.0003 0.0014 0.0067 0.0773 0.8053 0.0884 0.0100 0.0106
B   0.0001 0.0011 0.0024 0.0043 0.0648 0.8346 0.0407 0.0520
CCC 0.0021 0. 0.0022 0.0130 0.0238 0.1124 0.6486 0.1979
D   0. 0. 0. 0. 0. 0. 0. 1.

Rather good agreement to 4 decimal places anyway.




then compare res to your original matrix M.

Peter

On Fri, Nov 4, 2011 at 3:34 AM, clangkamp christian.langk...@gmxpro.de 
 wrote:
I have tried this method, but the result is not working, at least  
not as I

expect:
I used the CreditMetrics package transition matrix
rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
M - matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
0, 0, 0, 0, 0, 0, 0, 100
)/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)

then followed through with the steps:

nth_root - X %*% L_star %*% X_inv

But the check (going back 12 to the power again) doesn't yield the  
original
matrix. Now some rounding errors can be expected, but I didn't  
expect a
perfectly diagonal matrix, when the initial matrix isn't diagonal  
at all.

round(nth_root^12,4)

  [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7] [,8]
[1,] 0.9078 0. 0. 0. 0. 0. 0.0
[2,] 0. 0.9053 0. 0. 0. 0. 0.0
[3,] 0. 0. 0.9079 0. 0. 0. 0.0
[4,] 0. 0. 0. 0.8553 0. 0. 0.0
[5,] 0. 0. 0. 0. 0.7998 0. 0.0
[6,] 0. 0. 0. 0. 0. 0.8285 0.0
[7,] 0. 0. 0. 0. 0. 0. 0.64570
[8,] 0. 0. 0. 0. 0. 0. 0.1

Any takers


-
Christian Langkamp
christian.langkamp-at-gmxpro.de

--
View this message in context: 
http://r.789695.n4.nabble.com/12th-Root-of-a-Square-Transition-Matrix-tp2259736p3989618.html
Sent from the R help mailing list archive at Nabble.com.

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





--
Sent from my Linux computer. Way better than iPad :)

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread Peter Langfelder
On Fri, Nov 4, 2011 at 2:37 PM, David Winsemius dwinsem...@comcast.net wrote:


 The 12th (matrix) root of M: e^( 1/n * log(M) )

 require(Matrix)
 M1.12 - expm( (1/12)*logm(M) )

I like this - haven't thought of the matrix algebra functions in Matrix.

Thanks,

Peter

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


Re: [R] Decision tree model using rpart ( classification

2011-11-04 Thread Andrew Ziem
aajit75 aajit75 at yahoo.co.in writes:
 fit - rpart(decile ~., method=class, 
  control=rpart.control(minsplit=min_obs_split, cp=c_c_factor), 
  data=dtm_ip)
 
 In A and B target variable 'segment' is from the clustering data using same
 set of input variables , while in C target variable 'decile' is derived from
 behavioural variables and input variables are from profile data. Number of
 rows in the input table in all three cases are same.

What is the value of modeling the deciles as the target? They are a lower
resolution version of information you already have, and without this model that
doesn't finish fitting you should already be able to assign a decile to every
customer.



Andrew

__
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] Determining r2 values for a SEM

2011-11-04 Thread K Stewart
Hello, 

I have been using the SEM package and developed 4 models that all have an
adequate fit.  I require r2 values for the variables in my SEM and cannot
find a way to get r2 values for a SEM.  I have attempted using the smc
(squared multiple correlation) function, but this only takes the initial
covariance matrix and not the fitted SEM as arguements, so the r2 values
cannot be correct.  Is there a way to determine r2 values for an SEM in the
SEM package or another way to get these values in R?

Thank you for your assistance, 

Katherine Stewart

--
View this message in context: 
http://r.789695.n4.nabble.com/Determining-r2-values-for-a-SEM-tp3990855p3990855.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to delete only those rows in a dataframe in which all records are missing

2011-11-04 Thread Jose Iparraguirre
It does! 
Thanks,
José


-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: 04 November 2011 15:18
To: Jose Iparraguirre
Cc: r-help@r-project.org
Subject: Re: [R] How to delete only those rows in a dataframe in which all 
records are missing

Perhaps something like this will work.

df[!(rowSums(is.na(df))==NCOL(df)),]

Michael

On Fri, Nov 4, 2011 at 9:27 AM, Jose Iparraguirre
jose.iparragui...@ageuk.org.uk wrote:
 Hi,

 Imagine I have the following data frame:

 a - c(1,NA,3)
 b - c(2,NA,NA)
 c - data.frame(cbind(a,b))
 c
   a  b
 1  1  2
 2 NA NA
 3  3 NA

 I want to delete the second row. If I use na.omit, that would also affect the 
 third row. I tried to use a loop and an ifelse clause with is.na to get R 
 identify that row in which all records are missing, as opposed to the first 
 row in which no records are missing or the third one, in which only one 
 record is missing. How can I get R identify the row in which all records are 
 missing? Or, how can I get R delete/omit only this row?
 Thanks in advance,

 José


 José Iparraguirre
 Chief Economist
 Age UK

 T 020 303 31482
 E jose.iparragui...@ageuk.org.ukmailto:jose.iparragui...@ageuk.org.uk

 Tavis House, 1- 6 Tavistock Square
 London, WC1H 9NB
 www.ageuk.org.ukhttp://www.ageuk.org.uk | 
 ageukblog.org.ukhttp://ageukblog.org.uk/ | 
 @AgeUKPAhttp://twitter.com/ageukpa


 Age UK  Improving later life

 www.ageuk.org.uk





 ---

 Age UK is a registered charity and company limited by guarantee, (registered 
 charity number 1128267, registered company number 6825798). Registered 
 office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

 For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
 Representative of Age UK Enterprises Limited, Age UK is an Introducer 
 Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
 Access for the purposes of introducing potential annuity and health cash 
 plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
 Solutions Limited and Simplyhealth Access are all authorised and regulated by 
 the Financial Services Authority.





 --

 This email and any files transmitted with it are confidential and intended 
 solely for the use of the individual or entity to whom they are addressed. If 
 you receive a message in error, please advise the sender and delete 
 immediately.



 Except where this email is sent in the usual course of our business, any 
 opinions expressed in this email are those of the author and do not 
 necessarily reflect the opinions of Age UK or its subsidiaries and associated 
 companies. Age UK monitors all e-mail transmissions passing through its 
 network and may block or modify mails which are deemed to be unsuitable.





 Age Concern England (charity number 261794) and Help the Aged (charity number 
 272786) and their trading and other associated companies merged on 1st April 
 2009.  Together they have formed the Age UK Group, dedicated to improving the 
 lives of people in later life.  The three national Age Concerns in Scotland, 
 Northern Ireland and Wales have also merged with Help the Aged in these 
 nations to form three registered charities: Age Scotland, Age NI, Age Cymru.


























        [[alternative HTML version deleted]]


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


Age UK  Improving later life
www.ageuk.org.uk


---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). Registered office: 
Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed 
Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the 
purposes of introducing potential annuity and health cash plans customers 
respectively.  Age UK Enterprises Limited, JLT Benefit Solutions Limited and 
Simplyhealth Access are all authorised and regulated by the Financial Services 
Authority. 

 
--
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you receive a message in error, please advise the sender and delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not necessarily 
reflect the opinions of Age UK or its subsidiaries and associated companies. 
Age UK monitors all e-mail transmissions passing through its 

[R] HoltWinters in R 2.14.0

2011-11-04 Thread TimothyDalbey
Hey All,

First time on these forums.  Thanks in advance.  

S...  I have a process that was functioning well before the 2.14 update. 
Now the HoltWinters function is throwing an error whereby I get the
following: 

Error in HoltWinters(sales.ts) : optimization failure

I've been looking around to determine why this happens (see if I can test
the data beforehand) but I haven't come across anything.  

Any help appreciated!


--
View this message in context: 
http://r.789695.n4.nabble.com/HoltWinters-in-R-2-14-0-tp3991247p3991247.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Reading parameters from dataframe and loading as objects

2011-11-04 Thread Francois Pepin
Hi,

assign is your friend here:
apply(data,1,function(x)assign(x[1],x[2],envir = .GlobalEnv))

As a note, you probably don't want to use data as a variable because it 
overwrites the data function, leading to unwanted side-effects if you ever use 
it.

Cheers,

François Pepin
Scientist
 
Sequenta, Inc.
400 E. Jamie Court, Suite 301
South San Francisco, CA 94080
 
650 243 3929 p
 
francois.pe...@sequentainc.com
www.sequentainc.com
 
The contents of this e-mail message and any attachments are intended solely for 
the addressee(s) named in this message.  This communication is intended to be 
and to remain confidential and may be subject to applicable attorney/client 
and/or work product privileges.  If you are not the intended recipient of this 
message, or if this message has been addressed to you in error, please 
immediately alert the sender by reply e-mail and then delete this message and 
its attachments.  Do not deliver, distribute or copy this message and/or any 
attachments and if you are not the intended recipient, do not disclose the 
contents or take any action in reliance upon the information contained in this 
communication or any attachments.

On Nov 3, 2011, at 23:24 , Aher wrote:

 Hi List,
 
 I want to read several parameters from data frame and load them as object
 into R session, Is there any package or function in R for this?? 
 
 Here is example
 
 param -c(clust_num, minsamp_size, maxsamp_size, min_pct, max_pct) 
 value -c(15, 2, 20, 0.001, .999) 
 data - data.frame ( cbind(param , value))
 data
 param   value
 1clust_num 15
 2 minsamp_size2
 3 maxsamp_size   2e+05
 4  min_pct  0.001
 5  max_pct 0.999
 
 My data contains many such parameters, I need to read each parameter and its
 value from the data and load it as objects  in R session as below:
 
 clust_num  -   15
 minsamp_size  -2
 maxsamp_size -2e+05
 min_pct -0.001
 max_pct -0.999
 
 The way right now I am doing it is as creating as many variables as
 parameters in the data frame and one observation for value of each
 parameter.  
 example:
 clust_num minsamp_sizemaxsamp_sizemin_pct max_pct
 152   20  0.001   0.999
 
 data$ clust_num  , data$minsamp_size,  .
 
 Is there any better way for doing this?
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Reading-parameters-from-dataframe-and-loading-as-objects-tp3989150p3989150.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Determining r2 values for a SEM

2011-11-04 Thread Mark Difford
On Nov 04, 2011 at 6:55pm Katherine Stewart wrote:

  Is there a way to determine r2 values for an SEM in the SEM package or
 another way to get 
 these values in R?

Katherine,

rsquare.sem() in package sem.additions will do it for you.

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Determining-r2-values-for-a-SEM-tp3990855p3991279.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] error message

2011-11-04 Thread JulianaMF
Hello,
I am a PhD candidate at University of Sao Paulo, finishing the thesis and
know nothing about R language... I am trying to analyze a structure data set
(STRs) with 82 samples and 10 loci (missing data = -9) and I keep getting
the same Error in text[(last line - n + 1):last line] : only 0's may be
mixed with negative subscripts message. I read this thread and tried the
traceback () function, but all I got after I typed it was 1:
read.structure(file = SimStru3.str)...
When I import the data using the read.table function, it works well, but
then I am not being able to transform the data frame in a genind object... I
know I may be asking very stupid things, but I really could use the help...
Thank you so much!
Juliana

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

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


[R] representing wind date using windrose

2011-11-04 Thread Norman Khine
hello,
i am new to R and want to use it for a small project to draw a wind
data from a microclimate datasource, can someone give me an example of
how i can represent this in a neat way?

for example, i have:
speed, direction
0.3,NNE
0.45,NNE
0.32,NE
0.28,N
0.30,NE

how do i put this data to get a windrose graph?

many thanks

norman

-- 

% .join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )

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


Re: [R] How to use 'prcomp' with CLUSPLOT?

2011-11-04 Thread jo
Hello Michael,

Thank you for replying to my post!  That was an interesting solution - good
to know, but I am now getting a different error:
/Error in if (length(clus) != n) stop(The clustering vector is of incorrect
length) : 
  argument is of length zero/
which brought me here:
https://svn.r-project.org/R-packages/trunk/cluster/R/plotpart.q
I am trying to figure that out now...

FYI, as a test set, one could just delete columns until they are = to the
number of rows...

clusplot has some nice extras, but I am also looking at just plotting
w/pca...


Thank you again,
Jo

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-prcomp-with-CLUSPLOT-tp3989022p3991868.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Unused Arguments Error Even Though I'm Using Them?

2011-11-04 Thread Christopher Simons
Greetings,

I am running into an error I can't seem to get past; something tells
me I am making an obvious mistake as I am new to R, but everything
looks fine to me.  Basically, I'm getting the message unused
arguments even though my arguments are all being used.  I have posted
my code at the following URL:

http://textsnip.com/8af5b2

Thanks for any help,


CLS

__
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] ANCOVA with many levels of one factor

2011-11-04 Thread suzzy
I am trying to do and ANCOVA with ten sites that I want to compare condition
at, with Length as a covariate. 
Most examples I have found only deal with two levels and I am unsure if the
same code applies for more than two levels. Here is what I have, and I just
wanted to double check that I am on the right track


ancova-lm(Condition~site+Length+site:Length)
summary(ancova)
anova(ancova)
ancova1-update(ancova,~.-site:Length)
anova(ancova,ancova1)
summary(ancova1)

Any help/suggestions welcome! 
Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/ANCOVA-with-many-levels-of-one-factor-tp3991474p3991474.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to interpret vglm output?

2011-11-04 Thread Akram Khaleghei Ghosheh balagh
Hello ,
I need to estimate the parameters of generalized poisson regression model.
I found that I could use :
vglm(formula, family,.., data), but I dont know how to interpret the
output!!!

  min  1Q Median 3Q Max
elogit (lambda)-.66   -.61-.46 -.06 35.33
log(theta) -10.2-.02 .11  .64   1.2

coefficients: value stdt.value
intercept:1  .76 .019   39.32
intercept:2   1.02   .0239.88
sex .55 1.216.00
log-likelihood -990.83,


I dont know what is the exactly meaning of these two intercept?
Thanks in advance for your help.
Akram

[[alternative HTML version deleted]]

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


Re: [R] Reading parameters from dataframe and loading as objects

2011-11-04 Thread David Winsemius


On Nov 4, 2011, at 1:50 PM, Francois Pepin francois.pe...@sequentainc.com 
wrote:

 Hi,
 
 assign is your friend here:
 apply(data,1,function(x)assign(x[1],x[2],envir = .GlobalEnv))
 
 As a note, you probably don't want to use data as a variable because it 
 overwrites the data function, leading to unwanted side-effects if you ever 
 use it.

While it is true that using data as an object name is a bad choice, the 
specific reason offered is incorrect. Functions are kept in a different list 
from other named objects and creating a data data.frame will NOT overwrite 
the data function.

-- 
David.

 
 Cheers,
 
 François Pepin
 Scientist
 
 Sequenta, Inc.
 400 E. Jamie Court, Suite 301
 South San Francisco, CA 94080
 
 650 243 3929 p
 
 francois.pe...@sequentainc.com
 www.sequentainc.com
 
 The contents of this e-mail message and any attachments are intended solely 
 for the addressee(s) named in this message.  This communication is intended 
 to be and to remain confidential and may be subject to applicable 
 attorney/client and/or work product privileges.  If you are not the intended 
 recipient of this message, or if this message has been addressed to you in 
 error, please immediately alert the sender by reply e-mail and then delete 
 this message and its attachments.  Do not deliver, distribute or copy this 
 message and/or any attachments and if you are not the intended recipient, do 
 not disclose the contents or take any action in reliance upon the information 
 contained in this communication or any attachments.
 
 On Nov 3, 2011, at 23:24 , Aher wrote:
 
 Hi List,
 
 I want to read several parameters from data frame and load them as object
 into R session, Is there any package or function in R for this?? 
 
 Here is example
 
 param -c(clust_num, minsamp_size, maxsamp_size, min_pct, max_pct) 
 value -c(15, 2, 20, 0.001, .999) 
 data - data.frame ( cbind(param , value))
 data
param   value
 1clust_num 15
 2 minsamp_size2
 3 maxsamp_size   2e+05
 4  min_pct  0.001
 5  max_pct 0.999
 
 My data contains many such parameters, I need to read each parameter and its
 value from the data and load it as objects  in R session as below:
 
 clust_num  -   15
 minsamp_size  -2
 maxsamp_size -2e+05
 min_pct -0.001
 max_pct -0.999
 
 The way right now I am doing it is as creating as many variables as
 parameters in the data frame and one observation for value of each
 parameter.  
 example:
 clust_numminsamp_sizemaxsamp_sizemin_pctmax_pct
 152200.0010.999
 
 data$ clust_num  , data$minsamp_size,  .
 
 Is there any better way for doing this?
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Reading-parameters-from-dataframe-and-loading-as-objects-tp3989150p3989150.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-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] Creating a sequence from two samples with several constraints (frequency and repeats)

2011-11-04 Thread Jeremy Wang
I'm attempting to create a sequence for an experiment and am hoping I can
use R to create it. It has several constraints:

(1) It is made up of two sequences (red and green) that have 4 different
repeating triplets (e.g. T1=ABC T2=DEF T3=GHI JKL)
(2) Each sequence has the following constraints: (a) there cannot be
repeating triplets (e.g. T1 T1), (b) there cannot be repeating triplet
pairs (e.g. T1 T2 T1 T2)
(3) Triplets occur with the following frequency: T1=20, T2=23, T3=26, T4=36
(same for red and green sequences)
(4) Red and green sequences are then interleaved, such that you never get
more than 6 in a row of one color.

(For those that are interested, I'm trying to replicate Turke-Browne,
Junge,  Scholl, 2005, *JEP*, but with frequency manipulations to the
triplets)

Thanks in advance for any help.

[[alternative HTML version deleted]]

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


Re: [R] XLConnect Error

2011-11-04 Thread Martin Studer
Hi Daniel,

you can get Java from http://www.java.com/en/download/manual.jsp?locale=en
Simply download and follow the instructions.
Hope that helps.

Martin

--
View this message in context: 
http://r.789695.n4.nabble.com/XLConnect-Error-tp3628528p3991681.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] bug calculating ROC with caret and earth?

2011-11-04 Thread Andrew Ziem
Does caret have a bug calculating ROC with earth?  When using caret and earth 
on any of my data sets, caret's ROC never varies.  This could mean earth is 
finding the same model (for example, because of using an nprune parameter that 
is too high).  However, if that were true, sensitivity and specificity would 
also not vary, but they do vary.  Also, I verified nprune is not too high.

I am attaching sample output from R 2.14.0 on Windows 7 64-bit with earth 3.2 
and caret 5.07.

I don't have this problem with caret and ctree.



Andrew

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 # install and load packages, as needed
 for (pkg in c('caret','earth','mlbench', 'e1071')) {
+ if (!require(pkg, character.only=T)) {install.packages(pkg)}
+ require(pkg, character.only=T)
+ }
Loading required package: caret
Loading required package: lattice
Loading required package: reshape
Loading required package: plyr

Attaching package: ‘reshape’

The following object(s) are masked from ‘package:plyr’:

rename, round_any

Loading required package: cluster
Loading required package: foreach
Loading required package: iterators
Loading required package: codetools
foreach: simple, scalable parallel programming from Revolution Analytics
Use Revolution R for scalability, fault tolerance and more.
http://www.revolutionanalytics.com
Loading required package: earth
Loading required package: leaps
Loading required package: plotmo
Loading required package: plotrix
Loading required package: mlbench
Loading required package: e1071
Loading required package: class

Attaching package: ‘class’

The following object(s) are masked from ‘package:reshape’:

condense

 
 # system information
 installed.packages()[c('earth','caret'),'Version']
 earth  caret 
   3.2-1 5.07-001 
 
 
 # prepare data
 data(etitanic)
 mydata - etitanic
 mydata$survived - as.factor(ifelse(etitanic$survived==1, 'T', 'F'))
 summary(mydata)
 pclasssurvived sex   age  sibspparch   

 1st:284   F:619female:388   Min.   : 0.1667   Min.   :0.   Min.   
:0.  
 2nd:261   T:427male  :658   1st Qu.:21.   1st Qu.:0.   1st 
Qu.:0.  
 3rd:501 Median :28.   Median :0.   Median 
:0.  
 Mean   :29.8811   Mean   :0.5029   Mean   
:0.4207  
 3rd Qu.:39.   3rd Qu.:1.   3rd 
Qu.:1.  
 Max.   :80.   Max.   :8.   Max.   
:6.  
 
 # show natural maximum pruning is 9
 fit - earth(survived ~ ., data=mydata)
 summary(fit, style=max)
Call: earth(formula=survived~., data=mydata)

T =
  1.094732
  -   0.2113713 * max(0, pclass2nd - 0) 
  -   0.3413489 * max(0, pclass3rd - 0) 
  -   0.4851343 * max(0,   sexmale - 0) 
  - 0.004222467 * max(0,   age -10) 
  +  0.02569032 * max(0,10 -   age) 
  -  0.09699376 * max(0, sibsp - 1) 
  -  0.06266133 * max(0, parch - 1) 
  -  0.09015484 * max(0, 1 - parch) 

Selected 9 of 10 terms, and 6 of 6 predictors 
Importance: sexmale, pclass3rd, age, pclass2nd, sibsp, parch
Number of terms at each degree of interaction: 1 8 (additive model)
GCV 0.1519922RSS 153.8581GRSq 0.3720351RSq 0.3911174
 
 # custom metric
 twoClassSummaryPlus - function (data,
+ lev = NULL,
+ model = NULL)
+ 
+ {
+   out1 - twoClassSummary(data, lev, model)
+   out2 - defaultSummary(data, lev, model)
+   #browser() # debug
+   #print(out1)
+   #print(dim(data))
+   c(out1, out2)
+ }
 
 
 # tne
 train_earth - function(nprune)
+ {
+ # prepare tuning parameters
+ grid - expand.grid(.degree=c(1), .nprune=nprune)
+ 
+ trControl- trainControl(summaryFunction = twoClassSummaryPlus,
+ classProbs = T,
+   verboseIter=T)
+ 
+ # tune
+ mydata.best - train(survived ~ .,
+ data = mydata,
+ method = earth,
+ trControl = trControl,
+ metric=Sens,
+ tuneGrid=grid)
+ 
+ # show tuned
+ print(mydata.best)
+ }
 
 train_earth(c(1:9)) # ROC is constant 
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: degree=1, nprune=9
Fitting: 

Re: [R] representing wind date using windrose

2011-11-04 Thread David Winsemius
There are several windrose functions in various packages. Try this

RSiteSearch(winrose)

-- 
David 

On Nov 4, 2011, at 6:06 PM, Norman Khine nor...@khine.net wrote:

 hello,
 i am new to R and want to use it for a small project to draw a wind
 data from a microclimate datasource, can someone give me an example of
 how i can represent this in a neat way?
 
 for example, i have:
 speed, direction
 0.3,NNE
 0.45,NNE
 0.32,NE
 0.28,N
 0.30,NE
 
 how do i put this data to get a windrose graph?
 
 many thanks
 
 norman
 
 -- 
 
 % .join( [ {'*':'@','^':'.'}.get(c,None) or
 chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] representing wind date using windrose

2011-11-04 Thread R. Michael Weylandt
Try this: http://rss.acs.unt.edu/Rdoc/library/climatol/html/rosavent.html

Michael

On Fri, Nov 4, 2011 at 6:06 PM, Norman Khine nor...@khine.net wrote:
 hello,
 i am new to R and want to use it for a small project to draw a wind
 data from a microclimate datasource, can someone give me an example of
 how i can represent this in a neat way?

 for example, i have:
 speed, direction
 0.3,NNE
 0.45,NNE
 0.32,NE
 0.28,N
 0.30,NE

 how do i put this data to get a windrose graph?

 many thanks

 norman

 --

 % .join( [ {'*':'@','^':'.'}.get(c,None) or
 chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )

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


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


Re: [R] Determining r2 values for a SEM

2011-11-04 Thread John Fox
Dear Mark and Katherine,

As well, version 2.0-0 of the sem package on R-Forge, and soon to be on
CRAN, includes R^2 values as part of the summary() output (along with many
other enhancements).

Best,
 John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mark Difford
 Sent: November-04-11 3:06 PM
 To: r-help@r-project.org
 Subject: Re: [R] Determining r2 values for a SEM
 
 On Nov 04, 2011 at 6:55pm Katherine Stewart wrote:
 
   Is there a way to determine r2 values for an SEM in the SEM package
  or another way to get these values in R?
 
 Katherine,
 
 rsquare.sem() in package sem.additions will do it for you.
 
 Regards, Mark.
 
 -
 Mark Difford (Ph.D.)
 Research Associate
 Botany Department
 Nelson Mandela Metropolitan University
 Port Elizabeth, South Africa
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Determining-r2-values-for-a-SEM-
 tp3990855p3991279.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] HoltWinters in R 2.14.0

2011-11-04 Thread R. Michael Weylandt
I believe there were some changes to Holt-Winters, specifically in re
optimization that probably lead to your problem, but you'll have to
provide more details. See the NEWS file for citations about the
change. If you put example code/data others may be able to help you --
I haven't updated yet so I can't be of much help.

Michael


On Fri, Nov 4, 2011 at 2:55 PM, TimothyDalbey tmdal...@gmail.com wrote:
 Hey All,

 First time on these forums.  Thanks in advance.

 S...  I have a process that was functioning well before the 2.14 update.
 Now the HoltWinters function is throwing an error whereby I get the
 following:

 Error in HoltWinters(sales.ts) : optimization failure

 I've been looking around to determine why this happens (see if I can test
 the data beforehand) but I haven't come across anything.

 Any help appreciated!


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/HoltWinters-in-R-2-14-0-tp3991247p3991247.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Unused Arguments Error Even Though I'm Using Them?

2011-11-04 Thread R. Michael Weylandt
I can't see anything in your code at first glance that would lead to
that error: could you perhaps provide some self-contained code that
reproduces that error?

Michael

On Fri, Nov 4, 2011 at 3:21 PM, Christopher Simons
christopherleesim...@gmail.com wrote:
 Greetings,

 I am running into an error I can't seem to get past; something tells
 me I am making an obvious mistake as I am new to R, but everything
 looks fine to me.  Basically, I'm getting the message unused
 arguments even though my arguments are all being used.  I have posted
 my code at the following URL:

 http://textsnip.com/8af5b2

 Thanks for any help,


 CLS

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


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


Re: [R] representing wind date using windrose

2011-11-04 Thread Clint Bowman
I'm also very impressed with openair 
http://www.openair-project.org/,

also
cran.r-project.org/package=openair

Clint

--
Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600


USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274


On Fri, 4 Nov 2011, R. Michael Weylandt wrote:


Try this: http://rss.acs.unt.edu/Rdoc/library/climatol/html/rosavent.html

Michael

On Fri, Nov 4, 2011 at 6:06 PM, Norman Khine nor...@khine.net wrote:

hello,
i am new to R and want to use it for a small project to draw a wind
data from a microclimate datasource, can someone give me an example of
how i can represent this in a neat way?

for example, i have:
speed, direction
0.3,NNE
0.45,NNE
0.32,NE
0.28,N
0.30,NE

how do i put this data to get a windrose graph?

many thanks

norman

--

% .join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ,adym,*)uzq^zqf ] )

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



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



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


Re: [R] Creating a sequence from two samples with several constraints (frequency and repeats)

2011-11-04 Thread R. Michael Weylandt
I believe the permute package is set up to generate restricted permutations.

Michael

On Fri, Nov 4, 2011 at 4:59 PM, Jeremy Wang wang0...@umn.edu wrote:
 I'm attempting to create a sequence for an experiment and am hoping I can
 use R to create it. It has several constraints:

 (1) It is made up of two sequences (red and green) that have 4 different
 repeating triplets (e.g. T1=ABC T2=DEF T3=GHI JKL)
 (2) Each sequence has the following constraints: (a) there cannot be
 repeating triplets (e.g. T1 T1), (b) there cannot be repeating triplet
 pairs (e.g. T1 T2 T1 T2)
 (3) Triplets occur with the following frequency: T1=20, T2=23, T3=26, T4=36
 (same for red and green sequences)
 (4) Red and green sequences are then interleaved, such that you never get
 more than 6 in a row of one color.

 (For those that are interested, I'm trying to replicate Turke-Browne,
 Junge,  Scholl, 2005, *JEP*, but with frequency manipulations to the
 triplets)

 Thanks in advance for any help.

        [[alternative HTML version deleted]]

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


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


Re: [R] error message

2011-11-04 Thread R. Michael Weylandt
Could you provide an example of your code? The error is coming up
because lastLine - n + 1  0 but obviously I can't tell you why it's
happening in your code without seeing it.

Michael

On Fri, Nov 4, 2011 at 2:06 PM, JulianaMF j...@ib.usp.br wrote:
 Hello,
 I am a PhD candidate at University of Sao Paulo, finishing the thesis and
 know nothing about R language... I am trying to analyze a structure data set
 (STRs) with 82 samples and 10 loci (missing data = -9) and I keep getting
 the same Error in text[(last line - n + 1):last line] : only 0's may be
 mixed with negative subscripts message. I read this thread and tried the
 traceback () function, but all I got after I typed it was 1:
 read.structure(file = SimStru3.str)...
 When I import the data using the read.table function, it works well, but
 then I am not being able to transform the data frame in a genind object... I
 know I may be asking very stupid things, but I really could use the help...
 Thank you so much!
 Juliana

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

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


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


[R] set seed for random draws

2011-11-04 Thread Md Desa, Zairul Nor Deana Binti
Hello, all!
I need help on these two problems:

1) If I want to randomly draw numbers from standard normal (or other 
distributions) in loops e.g.:
 ty=0; ks=0
for (i in 1:5) {
set.seed(14537+i)
k-rnorm(1)
ks[i]-.3*k+.9
if (ty==0) {
while ((ks.2)||(ks3)) {
#set.seed(13237+i*100)
k-rnorm(1)
ks[i]-.3*k+.9 }
}
 }



 }

Question: Here I draw initial a, then if the drawn initial a satisfied 2 
conditions I redraw a. I set.seed(13237) in the first draw of a, should I 
set.seed() in the redraw part?

2) I also have more loops after this i loop that also draw from normal(0,1). I 
want to randomly draws from normal(0,1) for loop j (inside loop j I draw 
another random numbers from N(0,1))
My question: Should I or shouldn't I set seed again and again for each loop? 
Why or why not.

I guess this problem concerned about setting seed as I want to have different 
number for each i.

Thanks!

Deana

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


Re: [R] set seed for random draws

2011-11-04 Thread R. Michael Weylandt
This might be more fundamental, but why do you feel the need to reset
the seed each loop? There's nothing that suggests you need to...

Michael

On Fri, Nov 4, 2011 at 8:38 PM, Md Desa, Zairul Nor Deana Binti
znde...@ku.edu wrote:
 Hello, all!
 I need help on these two problems:

 1) If I want to randomly draw numbers from standard normal (or other 
 distributions) in loops e.g.:
  ty=0; ks=0
 for (i in 1:5) {
        set.seed(14537+i)
        k-rnorm(1)
        ks[i]-.3*k+.9
        if (ty==0) {
            while ((ks.2)||(ks3)) {
            #set.seed(13237+i*100)
            k-rnorm(1)
            ks[i]-.3*k+.9 }
        }
     }
 
 
 
     }

 Question: Here I draw initial a, then if the drawn initial a satisfied 2 
 conditions I redraw a. I set.seed(13237) in the first draw of a, should I 
 set.seed() in the redraw part?

 2) I also have more loops after this i loop that also draw from normal(0,1). 
 I want to randomly draws from normal(0,1) for loop j (inside loop j I draw 
 another random numbers from N(0,1))
 My question: Should I or shouldn't I set seed again and again for each loop? 
 Why or why not.

 I guess this problem concerned about setting seed as I want to have different 
 number for each i.

 Thanks!

 Deana

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


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


[R] Matrix element-by-element multiplication

2011-11-04 Thread Steven Yen
is there a way to do element-by-element multiplication as in Gauss 
and MATLAB, as shown below? Thanks.

---
a

1.000
2.000
3.000
x

1.0002.0003.000
2.0004.0006.000
3.0006.0009.000
a.*x

1.0002.0003.000
4.0008.00012.00
9.00018.0027.00


--
Steven T. Yen, Professor of Agricultural Economics
The University of Tennessee
http://web.utk.edu/~syen/  
[[alternative HTML version deleted]]

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


Re: [R] How to avoid ifelse statement converting factor to character

2011-11-04 Thread clint
most all those posts were right in sourcing the problemits just that
nobody actually offered a viable solution

the problem is that the new level C was not one of the original levels in
$social status

add C as a level and then just do the ol fashioned way and it works just
fine

do this:
data$SOCIAL_STATUS - factor(data$SOCIAL_STATUS, levels =
c(levels(data$SOCIAL_STATUS), C))

then this:
data$SOCIAL_STATUS-ifelse(data$SOCIAL_STATUS==B  data$MALE4, C, 
data$SOCIAL_STATUS)  

it is sooo much more helpful when someone who has addressed the specific
problem being asked replies instead of people just throwing random ideas out
there


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-avoid-ifelse-statement-converting-factor-to-character-tp895726p3992067.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] nested for loops

2011-11-04 Thread nick_pan
Hi all , I have written a code with nested for loops . 
The aim is to estimate the maximum likelihood by creating 3 vectors with the
same length( sequence ) 
and then to utilize 3 for loops to make combinations among the 3 vectors ,
which are (length)^3 in number , and find the one that maximize the
likelihood ( maximum likelihood estimator).


The code I created, runs but I think something goes wrong...because when I 
change the length of the vectors but not the bounds the result is the
same!!!

I will give a simple example(irrelevant but proportional to the above) to
make it more clear...

Lets say we want to find the combination that maximize the multiplication of
the entries of some vectors.

V1-c(1,2,3)
V2-c(5, 2 , 4)
V3-c( 4, 3, 6)

The combination we look for is ( 3 , 5 , 6) that give us 3*5*6 = 90

If I apply the following in R , I won't take this result

V1-c(1,2,3)
V2-c(5, 2 , 4)
V3-c( 4, 3, 6)

for( i in V1){
  for( j in V2) {
 for( k in V3){

l- i*j*k

}
}
}
l

Then  l- i*j*k  is  number and not vector(of all multiplications of all
the combinations) , and is 3*4*6 = 72.

How can I fix the code?




--
View this message in context: 
http://r.789695.n4.nabble.com/nested-for-loops-tp3992089p3992089.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Matrix element-by-element multiplication

2011-11-04 Thread R. Michael Weylandt
Did you even try?

a - 1:3
x -  matrix(c(1,2,3,2,4,6,3,6,9),3)
a*x

 [,1] [,2] [,3]
[1,]123
[2,]48   12
[3,]9   18   27

Michael

On Fri, Nov 4, 2011 at 7:26 PM, Steven Yen s...@utk.edu wrote:
 is there a way to do element-by-element multiplication as in Gauss
 and MATLAB, as shown below? Thanks.

 ---
 a

        1.000
        2.000
        3.000
 x

        1.000        2.000        3.000
        2.000        4.000        6.000
        3.000        6.000        9.000
 a.*x

        1.000        2.000        3.000
        4.000        8.000        12.00
        9.000        18.00        27.00


 --
 Steven T. Yen, Professor of Agricultural Economics
 The University of Tennessee
 http://web.utk.edu/~syen/
        [[alternative HTML version deleted]]

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


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


Re: [R] nested for loops

2011-11-04 Thread R. Michael Weylandt
Your problem is that you redefine l each time through the loops and
don't record old values; you could do so by using c() for
concatenation, but perhaps this is what you are looking for:

exp(rowSums(log(expand.grid(V1, V2, V3

Hope this helps,

Michael

On Fri, Nov 4, 2011 at 7:49 PM, nick_pan nick_pa...@yahoo.gr wrote:
 Hi all , I have written a code with nested for loops .
 The aim is to estimate the maximum likelihood by creating 3 vectors with the
 same length( sequence )
 and then to utilize 3 for loops to make combinations among the 3 vectors ,
 which are (length)^3 in number , and find the one that maximize the
 likelihood ( maximum likelihood estimator).


 The code I created, runs but I think something goes wrong...because when I
 change the length of the vectors but not the bounds the result is the
 same!!!

 I will give a simple example(irrelevant but proportional to the above) to
 make it more clear...

 Lets say we want to find the combination that maximize the multiplication of
 the entries of some vectors.

 V1-c(1,2,3)
 V2-c(5, 2 , 4)
 V3-c( 4, 3, 6)

 The combination we look for is ( 3 , 5 , 6) that give us 3*5*6 = 90

 If I apply the following in R , I won't take this result

 V1-c(1,2,3)
 V2-c(5, 2 , 4)
 V3-c( 4, 3, 6)

 for( i in V1){
  for( j in V2) {
     for( k in V3){

 l- i*j*k

 }
 }
 }
 l

 Then  l- i*j*k  is  number and not vector(of all multiplications of all
 the combinations) , and is 3*4*6 = 72.

 How can I fix the code?




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nested-for-loops-tp3992089p3992089.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] How to avoid ifelse statement converting factor to character

2011-11-04 Thread David Winsemius



On Nov 4, 2011, at 7:33 PM, clint cl...@ucsd.edu wrote:

 most all those posts were right in sourcing the problemits just that
 nobody actually offered a viable solution

Very few problems that are posed with a test dataset go unanswered.



 
 the problem is that the new level C was not one of the original levels in
 $social status
 
 add C as a level and then just do the ol fashioned way and it works just
 fine
 
 do this:
 data$SOCIAL_STATUS - factor(data$SOCIAL_STATUS, levels =
 c(levels(data$SOCIAL_STATUS), C))
 
 then this:
 data$SOCIAL_STATUS-ifelse(data$SOCIAL_STATUS==B  data$MALE4, C, 
 data$SOCIAL_STATUS)  
 
 it is sooo much more helpful when someone who has addressed the specific
 problem being asked replies instead of people just throwing random ideas out
 there
 
Just a little Friday night trolling? This was a posting from 2 years ago.

-- 
David
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-avoid-ifelse-statement-converting-factor-to-character-tp895726p3992067.html
 Sent from the R help mailing list archive at Nabble.com.
 
This is a mailing list. Nabble users who fail to include context who replying 
to ancient threads should not be throwing stones.


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

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


Re: [R] 12th Root of a Square (Transition) Matrix

2011-11-04 Thread David Winsemius
This is just one of many 12-th roots. (Peter knows this i'm sure.) The negative 
of this would also be an nth root, and I read that there are quite few others 
that arise from solutions based on permuting negatives of eigen values of a 
triangularized form. But as I said , I'm not a matrix mechanic, so no code for 
that.

-- 
David.

On Nov 4, 2011, at 6:10 PM, Peter Langfelder peter.langfel...@gmail.com wrote:

 On Fri, Nov 4, 2011 at 2:37 PM, David Winsemius dwinsem...@comcast.net 
 wrote:
 
 
 The 12th (matrix) root of M: e^( 1/n * log(M) )
 
 require(Matrix)
 M1.12 - expm( (1/12)*logm(M) )
 
 I like this - haven't thought of the matrix algebra functions in Matrix.
 
 Thanks,
 
 Peter

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


Re: [R] HoltWinters in R 2.14.0

2011-11-04 Thread Prof Brian Ripley

On Fri, 4 Nov 2011, R. Michael Weylandt wrote:


I believe there were some changes to Holt-Winters, specifically in re
optimization that probably lead to your problem, but you'll have to
provide more details. See the NEWS file for citations about the
change. If you put example code/data others may be able to help you --
I haven't updated yet so I can't be of much help.

Michael


On Fri, Nov 4, 2011 at 2:55 PM, TimothyDalbey tmdal...@gmail.com wrote:

Hey All,

First time on these forums.  Thanks in advance.

S...  I have a process that was functioning well before the 2.14 update.
Now the HoltWinters function is throwing an error whereby I get the
following:

Error in HoltWinters(sales.ts) : optimization failure


Most likely it was incorrect before.  You cannot assume that it was 
actually 'functioning well': all the cases where we have seen this 
message it was giving incorrect answers before and not detecting them. 
And in all those cases the model was a bad fit and using starting 
values for the optimization helped.



I've been looking around to determine why this happens (see if I can test
the data beforehand) but I haven't come across anything.

Any help appreciated!


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplot as histogram

2011-11-04 Thread Jim Lemon

On 11/05/2011 05:04 AM, Jesse Brown wrote:

Hello:

I'm dealing with an issue currently that I'm not sure the best way to
approach. I've got a very large (10G+) dataset that I'm trying to create
a histogram for. I don't seem to be able to use hist directly as I can
not create an R vector of size greater than 2.2G. I considered
condensing the data previous to loading it into R and just plotting the
frequencies as a barplot; unfortunately, barplot does not support
plotting the values according to a set of x-axis positions.

What I have is something similar to:

ys - c(12,3,7,22,10)
xs - c(1,30,35,39,60)

and I'd like the bars (ys) to appear at the positions described by xs. I
can get this to work on smaller sets by filling zero values in for
missing ys for the entire range of xs but in my case this would again
create a vector too large for R.

Is there another way to use the two vectors to create a simulated
frequency histogram? Is there a way to create a histogram object (as
returned by hist) from the condensed data so that plot would handle it
correctly?


Hi Jesse,
I think that barp (plotrix) will get you out of trouble.

Jim

__
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] acf?

2011-11-04 Thread Kevin Burton
I started to check what I thought I knew with autocovariance and it doesn’t
jive with the the calculations given by ‘R’. I was wondering if there is
some scaling or something that I am not aware of.

 

Take the example

 

Ø  d - 1:10

Ø  (a - acf(d, type=covariance, demean=FALSE, plot=FALSE))

 

Autocovariances of series ‘d’, by lag

 

   0123456789 

38.5 33.0 27.6 22.4 17.5 13.0  9.0  5.6  2.9  1.0

 

But when I calculate it manually (for lag of 1) like:

 

Ø  y1 - d – mean(d)

Ø  dl - c(d[-1], d[1])

Ø  y2 - dl – mean(d)

Ø  mean(y1*y2)

[1] 3.75

 

What am I missing to get this basic concept? Isn’t it E[(Yt – ut)(Ys – us)]?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

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


Re: [R] acf?

2011-11-04 Thread Gabor Grothendieck
On Sat, Nov 5, 2011 at 12:26 AM, Kevin Burton rkevinbur...@charter.net wrote:
 I started to check what I thought I knew with autocovariance and it doesn’t
 jive with the the calculations given by ‘R’. I was wondering if there is
 some scaling or something that I am not aware of.



 Take the example



 Ø  d - 1:10

 Ø  (a - acf(d, type=covariance, demean=FALSE, plot=FALSE))



 Autocovariances of series ‘d’, by lag



   0    1    2    3    4    5    6    7    8    9

 38.5 33.0 27.6 22.4 17.5 13.0  9.0  5.6  2.9  1.0



 But when I calculate it manually (for lag of 1) like:



 Ø  y1 - d – mean(d)

 Ø  dl - c(d[-1], d[1])

 Ø  y2 - dl – mean(d)

 Ø  mean(y1*y2)

 [1] 3.75



 What am I missing to get this basic concept? Isn’t it E[(Yt – ut)(Ys – us)]?


Try this:

 d - 1:10
 dm - d - mean(d)
 sum(dm[-1] * dm[-10]) / 10
[1] 5.775
 acf(d, type = cov, plot = FALSE)[1]

Autocovariances of series ‘d’, by lag

   1
5.78
-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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