Re: [R] Unusual separators

2011-08-20 Thread peter dalgaard

On Aug 17, 2011, at 05:57 , Jim Holtman wrote:

 just read in the file using the tab as the separator.  if this is a problem 
 because a tab might appear by itself, then use readLines to read in the file, 
 gsub to replace the blank/tab with a new separator, writeLines to write out 
 to a temporary and then read in from the temporary file.

You can skip the write and read back step by reading from a text connection. In 
R 2.14-to-be, there's a text= argument to read.table (and scan too), so you'll 
be able to do the whole thing on the fly: 

read.table( text=gsub(readLines(.)))


 
 Sent from my iPad
 
 On Aug 16, 2011, at 11:02, Matt Curcio matt.curcio...@gmail.com wrote:
 
 Hi all,
 I have a list that I got from a web page that I would like to crunch.
 Unfortunately, the list has some unusual separators in it.  I believe
 the columns are separated by 1 space and 1 tab.  I tried to insert
 this into the read.table( ..., sep= \t, ...) but got an error that
 said something like 'only one byte separators can be used.
 I have thought about using a gsub to 'swap out' the space + tab and
 replace it with commas, etc but thought there might be another way.
 Any suggestions?
 M
 -- 
 
 
 Matt Curcio
 M: 401-316-5358
 E: matt.curcio...@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.
 
 __
 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com
Døden skal tape! --- Nordahl Grieg

__
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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread peter dalgaard

On Aug 19, 2011, at 20:40 , David Winsemius wrote:

 
 On Aug 19, 2011, at 1:28 PM, Stephen Davies wrote:
 
 I'm using chisq.test() on a matrix of categorical data, and I see that the
 residuals attribute of the returned object will give me the Pearson 
 residuals.
 That's cool. However, what I'd really like is the standardized (adjusted)
 Pearson residuals, which have a N(0,1) distribution. Is there a way to do 
 that
 in R (other than by me programming it myself?)
 
 ?scale

chisq.test(...)$stdres, more likely.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com
Døden skal tape! --- Nordahl Grieg

__
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] Raw epoch time from XTS

2011-08-20 Thread Noah Silverman
Hi,

I have a very large data set stored as an xts object.

xts is very nice about showing row labels as human readable dates and times.

I want the actual epoch values that are stored internally.  The only way I can 
find to access them is one-at-a-time using the internal function: xcoredata()

Calling this in an entire column, the R way doesn't work.  It will only 
return a single value.  Calling it in a loop for each row works but is 
painfully slow.

Since the epoch is stored internally, there must be some way to just grab it as 
a vector.  Does anyone know how?

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095

__
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] Raw epoch time from XTS

2011-08-20 Thread Joshua Wiley
Hi Noah,

This is one of those cases where following the posting guide
(particularly the minimal, reproducible example part) would have
really helped.  Are you saying that calling:
xcoredata(your_xts_object) does not give you the internal
representation of time that you want?

data(sample_matrix)
sample.xts - as.xts(sample_matrix, descr='my new xts object')
# returns a list, the index is the numeric representation of time
displayed in the rows
xcoredata(sample.xts)

You could also try the more direct:

attr(xts_object, index)

If this is not what you want or is not working for you, providing us
the output of dput() from the first few rows of your dataset and an
example of what you do want would be spectacular.

Cheers,

Josh

On Sat, Aug 20, 2011 at 12:44 AM, Noah Silverman noahsilver...@ucla.edu wrote:
 Hi,

 I have a very large data set stored as an xts object.

 xts is very nice about showing row labels as human readable dates and times.

 I want the actual epoch values that are stored internally.  The only way I 
 can find to access them is one-at-a-time using the internal function: 
 xcoredata()

 Calling this in an entire column, the R way doesn't work.  It will only 
 return a single value.  Calling it in a loop for each row works but is 
 painfully slow.

 Since the epoch is stored internally, there must be some way to just grab it 
 as a vector.  Does anyone know how?

 Thanks!

 --
 Noah Silverman
 UCLA Department of Statistics
 8117 Math Sciences Building
 Los Angeles, CA 90095

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.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] hetlp_type text doen't work on Ubuntu

2011-08-20 Thread Amol Jadhav
Hi,

I' using Ubuntu 10.10/11.04 and on both of the systems help doesn't
work unless I set options(help_type=html). I hate to change context
and help_type='html' distracts me. I want text based help inside
console. Where should I look to fix this problem?

--
Amol

__
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] Unusual separators

2011-08-20 Thread Jim Holtman
In the current version (2.13.1) textConnection is much slower if you have a 
large file (1 lines) than using a temporary output file.  Try timing a 
script using the two different approachs to get an appreciation for the 
difference.

Sent from my iPad

On Aug 20, 2011, at 3:39, peter dalgaard pda...@gmail.com wrote:

 
 On Aug 17, 2011, at 05:57 , Jim Holtman wrote:
 
 just read in the file using the tab as the separator.  if this is a problem 
 because a tab might appear by itself, then use readLines to read in the 
 file, gsub to replace the blank/tab with a new separator, writeLines to 
 write out to a temporary and then read in from the temporary file.
 
 You can skip the write and read back step by reading from a text connection. 
 In R 2.14-to-be, there's a text= argument to read.table (and scan too), so 
 you'll be able to do the whole thing on the fly: 
 
 read.table( text=gsub(readLines(.)))
 
 
 
 Sent from my iPad
 
 On Aug 16, 2011, at 11:02, Matt Curcio matt.curcio...@gmail.com wrote:
 
 Hi all,
 I have a list that I got from a web page that I would like to crunch.
 Unfortunately, the list has some unusual separators in it.  I believe
 the columns are separated by 1 space and 1 tab.  I tried to insert
 this into the read.table( ..., sep= \t, ...) but got an error that
 said something like 'only one byte separators can be used.
 I have thought about using a gsub to 'swap out' the space + tab and
 replace it with commas, etc but thought there might be another way.
 Any suggestions?
 M
 -- 
 
 
 Matt Curcio
 M: 401-316-5358
 E: matt.curcio...@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.
 
 __
 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.
 
 -- 
 Peter Dalgaard, Professor,
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@gmail.com
 Døden skal tape! --- Nordahl Grieg
 
 
 
 
 
 
 

__
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] Groups and bwplot

2011-08-20 Thread Sébastien Bihorel
Dear R-users,

A while ago, Deepayan Sarkar suggested some code that uses the group
argument in bwplot to create some 'side-by-side' boxplots
(https://stat.ethz.ch/pipermail/r-help/2010-February/230065.html). The
example he gave was relatively specific and I wanted to generalize his
approach into a function. Unfortunately, I seem to have some issues
passing the correct arguments to the panel function, and would greatly
appreciate any suggestions to solve these issues:

require(lattice)

mybwplot - function(x,y,data,groups){

  if (missing(groups)||is.null(groups)) {
groups - NULL
ngroups - 1
  } else {
data[[groups]] - as.factor(data[[groups]])
ngroups - nlevels(data[[groups]])
  }
  mywidth - 1/(ngroups+1)

  mypanel - function(x,y,groups,...){
if (missing(groups)||is.null(groups)) {
  panel.bwplot(x,y,...)
} else {
  panel.superpose(x,y,...)
}
  }

  mypanel.groups - function(x,y,groups,ngroups,...){
if (missing(groups)||is.null(groups)){
  NULL
} else {
  function(x, y, ..., group.number) {
panel.bwplot(x+(group.number-0.5*(ngroups+1))/(ngroups+1),y, ...)}
}
  }

  bwplot(formula(paste(y,x,sep=' ~ ')),
   data = data,
   groups = 'Plant',
   ngroups=ngroups,
   pch = |,
   box.width = mywidth,
   panel = mypanel,
   panel.groups = mypanel.groups)

}

myCO2 - CO2
myCO2$year - 2011
summary(myCO2)

mybwplot('Type','uptake',myCO2) # works

mybwplot('Type','uptake',myCO2,'Treatment') # Error using packet 1,
'x' is missing

mybwplot('Type','uptake',myCO2,'year') # Error using packet 1, 'x' is missing

# Deepayan Sarkar suggested code (adapted to myC02)
# bwplot(uptake ~ Plant, data = myCO2, groups = Treatment,
#pch = |, box.width = 1/3,
#panel = panel.superpose,
#panel.groups = function(x, y, ..., group.number) {
#panel.bwplot(x + (group.number-1.5)/3, y, ...)
#})

__
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 PC1 of PCA and dim1 of MCA as a predictor in logistic regression model for data reduction

2011-08-20 Thread khosoda

Dear Mark,

Thank you very much for your advice.
I will try it.

I really appreciate your all kind advice.
Thanks a lot again.

Best regards,

Kohkichi


(11/08/19 22:28), Mark Difford wrote:

On Aug 19, 2011 khosoda wrote:


I used x10.homals4$objscores[, 1] as a predictor for logistic regression
as in the same way as PC1 in PCA.
Am I going the right way?


Hi Kohkichi,

Yes, but maybe explore the sets= argument (set Response as the target
variable and the others as the predictor variables). Then use Dim1 scores.
Also think about fitting a rank-1 restricted model, combined with the sets=
option.

See the vignette to the package and look at

@ARTICLE{MIC98,
   author = {Michailides, G. and de Leeuw, J.},
   title = {The {G}ifi system of descriptive multivariate analysis},
   journal = {Statistical Science},
   year = {1998},
   volume = {13},
   pages = {307--336},
   abstract = {}
}

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/How-to-use-PC1-of-PCA-and-dim1-of-MCA-as-a-predictor-in-logistic-regression-model-for-data-reduction-tp3750251p3755163.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] Build a package - check error

2011-08-20 Thread Uwe Ligges



On 20.08.2011 00:41, Eduardo Mendes wrote:

Hi

I have modified the path to

dyn.load(paste(Sys.getenv(R_LIBS_USER),/fortran/src/fortran.so,sep=))



Hmmm, looks like you never took a look into the relevant manual Writing 
R Extensions nor in the help files I cited below.


?.First.lib has an example:

## Suppose a package needs to call a DLL named 'fooEXT',
## where 'EXT' is the system-specific extension.  Then you should use
.First.lib - function(lib, pkg)
  library.dynam(foo, pkg, lib)


You cannot know that the package is in Sys.getenv(R_LIBS_USER)

Note also that the .so file won't be in the path /src/... but in 
.../lib/... once you install the package in the recommended way using R 
CMD INSTALL.


Really, please do read manual!!!






and the package could installed, loaded and the lines with dyn.load worked.
It does not look like a pretty solution but works on my linux (I am not sure
if it works on my mac or windows).

I am not sure if this is what you meant but as I have no clue what
.First.lib does or NAMESPACES means this is the best I come up with.


So again time to read the manual and the help pages.

Best,
Uwe Ligges




Please correct me if I am wrong.

Many thanks

Ed



On Fri, Aug 19, 2011 at 6:03 PM, Uwe Liggeslig...@statistik.tu-dortmund.de

wrote:





On 19.08.2011 22:53, Eduardo Mendes wrote:


Dear R-users

I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  To get
my
own functions available on R section I have decided to learn how to build
  a
R package. I choose a simple example with a few Fortran and R functions
(wrapper).

The fortran sources are located at src and the R functions at R (as
recommended).  The building process went ok but R CMD check did not. The
error mgs was

Error in dyn.load(fortran.so) :
   unable to load shared object
'/home/eduardo/R_packages/**test.Rcheck/fortran.so':

Although I can see that R cannot find the compiled fortran code I do not
know what to do.   I believe it is something to do with the following
lines
in  the R-wrapper file

if (!is.loaded('calnpr'))
dyn.load(fortran.so)




1. If the package is called calnpr, the shared library is also called that
way.
2. you have to provide the path to the shared library.

See ?.First.lib for how to do it in a package without NAMESPACE (and note
that NAMESPACES are forced for the next R release).

Best,
Uwe Ligges


  How to add the path so that once the package is installed the compiled

fortran code can be found?

Many thanks

Cheers

Ed

[[alternative HTML version deleted]]

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





[[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] hetlp_type text doen't work on Ubuntu

2011-08-20 Thread Uwe Ligges



On 20.08.2011 08:25, Amol Jadhav wrote:

Hi,

I' using Ubuntu 10.10/11.04 and on both of the systems help doesn't
work unless I set options(help_type=html). I hate to change context
and help_type='html' distracts me. I want text based help inside
console. Where should I look to fix this problem?


What's wrong with the text help? What does doesn't work mean? What is 
the output? Error message? R version? .


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html


Uwe Ligges



--
Amol

__
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 add horizontal lines above bar graph to display p-values?

2011-08-20 Thread Uwe Ligges



On 19.08.2011 22:27, Sébastien Vigneau wrote:

Hi,

I would like to draw horizontal lines above a bar graph, in order to display
the p-values of a Fisher test. Here is an
examplehttp://thejns.org/action/showPopup?citid=citart1id=f3-1060501doi=10.3171%2Fped.2007.106.6.501of
the type of display I would like to have. Is there a way to draw the
horizontal lines


See ?abline, ?lines, ?segments, 



and write their associated p-values in R?


See ?text

Uwe Ligges




Thanks for you help!

Sebastien Vigneau

[[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] adding text to a plot created with strat.plot() from package rioja

2011-08-20 Thread Uwe Ligges



On 19.08.2011 18:40, Jason Paul Joines wrote:

I have a plot created with strat.plot() from package rioja. When the
plot is created with scale.percent=FALSE, each x axes is labeled at 0
and its maximum. However, when scale.percent=TRUE, the x axes are not
labeled. I need to use scale.percent=TRUE and I need labels for the x axes.

I have been able to add labels to the x axes with mtext but it is very
tedious to find the correct position. Is there a better way to do this
or a better way to find the desired coordinates than trial and error?


Yes: You can change the code and suggest your improvements to the 
package maintainer, for example. The relevant line in that function 
obviously is:


axis(side = 1, at = seq(0, colM[i], by = 10), labels = FALSE)

Uwe Ligges





Jason
===

__
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] questions about metafor package

2011-08-20 Thread Michael Dewey

At 16:21 17/08/2011, Emilie MAILLARD wrote:

Hello,
Â
I would like to do a meta-analysis with the 
package « metafor ». Ideally I would like to 
use a mixed model because I’m interested to 
see the effect of some moderators. But the data 
set I managed to collect from literature presents two limits.

Â
-Â Â Â Â Â Â Â Â  Firstly, for each observation, 
I have means for a treatment and for a control, 
but I don’t always have corresponding standard 
deviations (52 of a total of 93 observations 
don’t have standard deviations). Nevertheless 
I have the sample sizes for all observations so 
I wonder if it was possible to weight 
observations by sample size in the package « metafor ».
-Â Â Â Â Â Â Â Â  Secondly, some observations 
are probably not independent as I have sometimes 
several relevant observations for a same design. 
More precisely, for these cases, the control 
mean is identical but treatment means varied. 
Ideally, I would not like to do a weighted 
average for these non-independent observations 
because these observations represent levels of a 
moderator. I know that the package « metafor 
» is not designed for the analysis of 
correlated outcomes. What are the dangers of 
using the package even if observations are not really independent ? Â


Emilie,
I am not sure whether this is the answer to your 
problem of observations which are not independent 
but you might also look at the metaSEM package

http://courses.nus.edu.sg/course/psycwlm/internet/metaSEM/
I am still trying to understand his paper on this 
(see link for reference) but he is trying to 
embed meta-analysis within the structural 
equation framework and it may be possible to cope 
with lack of independence in that way. But as I 
say I am still trying to come to grips with the paper.




Â
Thank you for your help,
Â
Émilie.
[[alternative HTML version deleted]]


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

__
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] R training course

2011-08-20 Thread Mehrshad Koleini
Dear Sir/Madam

Hi. I am a general paediatrician who works in Middle-East. I will be in UK
on September, and October 2011. Would you mind writing for me, please, if
you suggest a good and appropriate training course for *new R* users in UK?



-- 
Kind regards

Mehrshad Koleini, MD
General Paediatrician

[[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 extract smoothed plot data?

2011-08-20 Thread derek
Dear R,

I have this script which from my data points creates smoothed plot:

require(graphics)
require(stats)
A=read.table(some.txt,header =FALSE,sep = , dec = ,,fileEncoding = ,
encoding = unknown, skip=18,nrows=400)
attach(A)
plot(A$V1, A$V2,col=white)
lines(smooth.spline(A$V1, A$V2,spar=0.4),col=green,lwd=3)

I would like to export points coordinates from smoothed plot to file, so
that I can then use new data for further analysis. In other words to pipe
defined sequence of x coordinates and corresponding y values to file.


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-extract-smoothed-plot-data-tp3756894p3756894.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] hetlp_type text doen't work on Ubuntu

2011-08-20 Thread Amol Jadhav
Don't know the internals behind, but when I did this:
 help.search('qplot', rebuild=T)
the text help started working. It would be interesting to know why it
worked that way. Also if it is happens always, it should have been
documented somewhere -- so that new users (who needs help) will not
get disappointed [I was using R without help until i found about
option(help_type='html')].

Anyway, i'm glad that it started working.

--
Amol

On Sat, Aug 20, 2011 at 11:55 AM, Amol Jadhav amolj.1...@gmail.com wrote:
 Hi,

 I' using Ubuntu 10.10/11.04 and on both of the systems help doesn't
 work unless I set options(help_type=html). I hate to change context
 and help_type='html' distracts me. I want text based help inside
 console. Where should I look to fix this problem?

 --
 Amol


__
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 extract smoothed plot data?

2011-08-20 Thread Uwe Ligges



On 20.08.2011 12:57, derek wrote:

Dear R,

I have this script which from my data points creates smoothed plot:

require(graphics)
require(stats)
A=read.table(some.txt,header =FALSE,sep = , dec = ,,fileEncoding = ,
encoding = unknown, skip=18,nrows=400)
attach(A)
plot(A$V1, A$V2,col=white)
lines(smooth.spline(A$V1, A$V2,spar=0.4),col=green,lwd=3)


sspline - smooth.spline(A$V1, A$V2, spar=0.4)
write.table(data.frame(sspline[c(x, y)]), file = ...)


Uwe Ligges



I would like to export points coordinates from smoothed plot to file, so
that I can then use new data for further analysis. In other words to pipe
defined sequence of x coordinates and corresponding y values to file.


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-extract-smoothed-plot-data-tp3756894p3756894.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] Pattern names matching

2011-08-20 Thread Orvalho Augusto
Dear R magic guys.. I have two tables (actually will be dataframes), both
with names to be matched.

The names on the first dataframe are from a study with antenatal visits on
some health centers here. It happens that we need the delivery info. And
half and some thing else of the women decided to delivery some where else
our health units. We managed to get the names from some other places but now
we have to match our 4000 original names with over 2 other names.

To make thing more bitter some names have badly written. So I need some
algorithm like Levenstein or sondex or phonix or something better already on
R. Can you help me?

Orvalho

[[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] Build a package - check error

2011-08-20 Thread Eduardo M. A. M.Mendes
Hi there

Many thanks.

Just to be clear I did read the manual (section 5 and all) and  have even
looked at the package expm which has a src dir with codes in fortran and C
to understand what it is going on.  

I have also read the help for .First.lib.  

Cheers

Ed


-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Saturday, August 20, 2011 10:38 AM
To: Eduardo Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Build a package - check error



On 20.08.2011 00:41, Eduardo Mendes wrote:
 Hi

 I have modified the path to

 dyn.load(paste(Sys.getenv(R_LIBS_USER),/fortran/src/fortran.so,sep
 =))


Hmmm, looks like you never took a look into the relevant manual Writing R
Extensions nor in the help files I cited below.

?.First.lib has an example:

## Suppose a package needs to call a DLL named 'fooEXT', ## where 'EXT' is
the system-specific extension.  Then you should use .First.lib -
function(lib, pkg)
   library.dynam(foo, pkg, lib)


You cannot know that the package is in Sys.getenv(R_LIBS_USER)

Note also that the .so file won't be in the path /src/... but in
.../lib/... once you install the package in the recommended way using R CMD
INSTALL.

Really, please do read manual!!!





 and the package could installed, loaded and the lines with dyn.load
worked.
 It does not look like a pretty solution but works on my linux (I am 
 not sure if it works on my mac or windows).

 I am not sure if this is what you meant but as I have no clue what 
 .First.lib does or NAMESPACES means this is the best I come up with.

So again time to read the manual and the help pages.

Best,
Uwe Ligges



 Please correct me if I am wrong.

 Many thanks

 Ed



 On Fri, Aug 19, 2011 at 6:03 PM, Uwe 
 Liggeslig...@statistik.tu-dortmund.de
 wrote:



 On 19.08.2011 22:53, Eduardo Mendes wrote:

 Dear R-users

 I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  
 To get my own functions available on R section I have decided to 
 learn how to build
   a
 R package. I choose a simple example with a few Fortran and R 
 functions (wrapper).

 The fortran sources are located at src and the R functions at R (as 
 recommended).  The building process went ok but R CMD check did not. 
 The error mgs was

 Error in dyn.load(fortran.so) :
unable to load shared object
 '/home/eduardo/R_packages/**test.Rcheck/fortran.so':

 Although I can see that R cannot find the compiled fortran code I do not
 know what to do.   I believe it is something to do with the following
 lines
 in  the R-wrapper file

 if (!is.loaded('calnpr'))
 dyn.load(fortran.so)



 1. If the package is called calnpr, the shared library is also called 
 that way.
 2. you have to provide the path to the shared library.

 See ?.First.lib for how to do it in a package without NAMESPACE (and 
 note that NAMESPACES are forced for the next R release).

 Best,
 Uwe Ligges


   How to add the path so that once the package is installed the 
 compiled
 fortran code can be found?

 Many thanks

 Cheers

 Ed

 [[alternative HTML version deleted]]

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



   [[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] RMysql on Windows 7

2011-08-20 Thread Twaha Mlwilo

Hello all,
good day
I have installed R 1.13.0 on windows 7. then  configured R  + latex + sweave to 
use eclipse indigo.Then would like to be able to work with  R + mysql 5.5(full 
package + connectors) which I have already installed.My problem is to build 
RMYSQL binary package, using Rtools.Should I remove  existing R and install 
RTools?.
thank you for your help
Udd
  
[[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] Pattern names matching

2011-08-20 Thread Doran, Harold
See the stringMatch function in the MiscPsycho package for an implementation of 
Levenshtein

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Orvalho Augusto [orvaq...@gmail.com]
Sent: Saturday, August 20, 2011 11:08 AM
To: r-help@r-project.org
Subject: [R] Pattern names matching

Dear R magic guys.. I have two tables (actually will be dataframes), both
with names to be matched.

The names on the first dataframe are from a study with antenatal visits on
some health centers here. It happens that we need the delivery info. And
half and some thing else of the women decided to delivery some where else
our health units. We managed to get the names from some other places but now
we have to match our 4000 original names with over 2 other names.

To make thing more bitter some names have badly written. So I need some
algorithm like Levenstein or sondex or phonix or something better already on
R. Can you help me?

Orvalho

[[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] RMysql on Windows 7

2011-08-20 Thread Uwe Ligges



On 20.08.2011 17:22, Twaha Mlwilo wrote:


Hello all,
good day
I have installed R 1.13.0 on windows 7. then  configured R  + latex + sweave to 
use eclipse indigo.Then would like to be able to work with  R + mysql 5.5(full 
package + connectors) which I have already installed.My problem is to build 
RMYSQL binary package, using Rtools.Should I remove  existing R and install 
RTools?.


You need the Rtools *in addition* to R. See the manual R Installation 
and Administration for details.


Uwe ligges




thank you for your help
Udd

[[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] AFT model time-dependent with weibull distribution

2011-08-20 Thread Göran Broström
On Sat, Aug 20, 2011 at 4:19 AM, JPF xpfen...@gmail.com wrote:

 JPF wrote:



 weibullaft-aftreg(Surv(sta,time,S) ~ TDC1 + TIC1, dist=weibull,
 data.frame=Data)

 ## aftreg gives an error when I add an ID argument... That should be used
 for controlling for time-varying variables.

 Error in aftreg.fit(X, Y, dist, strats, offset, init, shape, id, control,
 :
   *Overlapping intervals for id  2 *

 From help(aftreg): id If there are more than one spell per individual, it
 is essential to keep spells together by the id argument. This allows for
 time-varying covariates.



 This is solved. It gave the overlapping intervals error, but now it is
 solved: /id=ID/, just as before.

Good. Do you still need answers to your other questions?

G.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3756502.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.




-- 
Göran Broström

__
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 with nls fitting

2011-08-20 Thread Paola Lecca
Dear all,

I'm trying to fit the following function

slope_pp3_mrna = ( (k3 * v3_K_d *p1^v3_h) / ( (v3_Kd^v3_h) + p2^v3_h ) ) *
   ( 1/(1 + (p2/v4_Kd)^v4_h) )  - pp3_mrna


to this experimental data in the datafraeme Data_pp3_mrna (see it at the
end of this e-mail)

I'm using the nls function in the following code. IN the last step of the
fit fm_pp3_mrna_4, when I add to the funziont the paramter v4_Kd something
goes wrong, and I reeive this message


Error in numericDeriv(form[[3L]], names(ind), env) :
  Missing value or an infinity produced when evaluating the model
What could be the error? I tried with differnet intial values of v4_Kd, but
I did not fix the problem.

Here below the code. Thanks in advance,
Paola.

Data_pp3_mrna - data.frame(
p1 = protein_1,
p2 = protein_2,
pp3_mrna = protein_3_mrna,
slope_pp3_mrna = stinemanSlopes(times,
protein_3_mrna)
)

one_par - nls(slope_pp3_mrna ~ ( (k3 * p1) / ( (1) + p1 ) ) *
( 1/(1 + (p2)) )  - pp3_mrna,
data=Data_pp3_mrna,
start=list(
   k3=0.1
  ))
summary(one_par)

fm_pp3_mrna_1 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1) / ( (v3_Kd) + p1 ) )
*
   ( 1/(1 + (p2)) )  - pp3_mrna,
data=Data_pp3_mrna,
start=list(k3=24,
   v3_Kd=1
   ))
summary(fm_pp3_mrna_1)

fm_pp3_mrna_2 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / (
(v3_Kd)^v3_h + p1^v3_h ) ) *
   ( 1/(1 + (p2)) )  - pp3_mrna,
control = list(maxiter = 500),
data=Data_pp3_mrna,
start=list(k3=69,
   v3_Kd=0.3238,
   v3_h=1
   ))
summary(fm_pp3_mrna_2)

fm_pp3_mrna_3 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / (
(v3_Kd)^v3_h + p1^v3_h ) ) *
   ( 1/(1 + (p2)^v4_h) )  - pp3_mrna,
control = list(maxiter = 500),
data=Data_pp3_mrna,
start=list(k3=37.451,
   v3_Kd=0.59,
   v3_h=2.013,
   v4_h=0.01
   ))

summary(fm_pp3_mrna_3)

fm_pp3_mrna_4 - nls(slope_pp3_mrna ~ ((k3 * v3_Kd *p1^v3_h) / (
(v3_Kd)^v3_h + p1^v3_h ) ) *
   ( 1/(1 + (p2/v4_Kd)^v4_h) )  - pp3_mrna,
control = list(maxiter = 500),
data=Data_pp3_mrna,
start=list(k3=56.2823,
   v3_Kd=0.3366,
   v3_h=1.8040,
   v4_Kd=0.03,
   v4_h=0.7693
   ))

Here the data.


 Data_pp3_mrna
   p1 p2  pp3_mrna slope_pp3_mrna
1   1.006  0.921 0.041 8.63741887
2   2.235  2.047 2.9069031 2.82619343
3   3.744  3.937 4.052 0.84354113
4   4.222  9.340 4.3237353 0.47577213
5   9.022 14.609 4.531-0.03940131
6  11.326 22.765 3.510-2.0420
7   6.899 17.852 2.489-1.86822481
8  10.709 27.777 1.6222048-1.55625973
9  14.084 27.785 0.911-0.48800514
10 14.922 23.613 0.826-0.1700
11 14.340 18.422 0.741-0.22560156
12 13.066 24.085 0.599-0.2840
13 17.553 18.594 0.457-0.13847372
14 14.803 16.831 0.4550965 0.03588624
15 11.945 14.495 0.493 0.09536674
16 11.427 12.458 0.5505361 0.15549062
17 11.556  9.082 0.649 0.49638596
18 20.107  9.987 1.2486525 1.36871828
19 15.999 10.305 2.059 1.87868197
20 16.094  5.793 3.2285000 2.3390
21 11.752  6.944 4.398 0.80395869
22 15.841  5.575 4.651 0.5060
23 12.601  5.221 4.904 0.80270128
24 13.598  2.872 5.819 1.8300
25 13.879  2.883 6.734-0.03571884
26 16.270  2.213 6.4135000-0.6410
27 17.176  3.381 6.093-0.33913760
28 12.332  2.781 6.032-0.1220
29 12.373  3.073 5.971-0.41224459
30 14.781  2.948 5.489-0.9640
31 17.578  3.953 5.007-0.68258311
32 18.865  2.279 4.7568901-0.39425557
33 14.735  2.806 4.606 0.13264481
34 16.160  1.676 4.987 0.7620
35 13.416  2.478 5.368 0.63914248
36 13.864  1.394 5.6374239 0.45419096
37 16.219  2.299 5.827-0.12540453
38 13.249  1.457 5.2505000-1.1530
39 14.445  2.325 4.674-0.09880849
40 13.210  2.230 5.5576966 2.17200142
41 12.358  2.116 8.94711.38521228


-- 
*Paola Lecca, PhD*
*The Microsoft Research - University of Trento*
*Centre for Computational and Systems Biology*
*Piazza Manci 17 38123 Povo/Trento, Italy*
*Phome: +39 0461282843*
*Fax: +39 0461282814*

[[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] Groups and bwplot

2011-08-20 Thread Weidong Gu
You may want to consult a recent post by Felix
(https://stat.ethz.ch/pipermail/r-help/2011-August/286707.html) on how
to pass group parameter.

Weidong Gu

On Sat, Aug 20, 2011 at 6:59 AM, Sébastien Bihorel pomc...@free.fr wrote:
 Dear R-users,

 A while ago, Deepayan Sarkar suggested some code that uses the group
 argument in bwplot to create some 'side-by-side' boxplots
 (https://stat.ethz.ch/pipermail/r-help/2010-February/230065.html). The
 example he gave was relatively specific and I wanted to generalize his
 approach into a function. Unfortunately, I seem to have some issues
 passing the correct arguments to the panel function, and would greatly
 appreciate any suggestions to solve these issues:

 require(lattice)

 mybwplot - function(x,y,data,groups){

  if (missing(groups)||is.null(groups)) {
    groups - NULL
    ngroups - 1
  } else {
    data[[groups]] - as.factor(data[[groups]])
    ngroups - nlevels(data[[groups]])
  }
  mywidth - 1/(ngroups+1)

  mypanel - function(x,y,groups,...){
    if (missing(groups)||is.null(groups)) {
      panel.bwplot(x,y,...)
    } else {
      panel.superpose(x,y,...)
    }
  }

  mypanel.groups - function(x,y,groups,ngroups,...){
    if (missing(groups)||is.null(groups)){
      NULL
    } else {
      function(x, y, ..., group.number) {
        panel.bwplot(x+(group.number-0.5*(ngroups+1))/(ngroups+1),y, ...)}
    }
  }

  bwplot(formula(paste(y,x,sep=' ~ ')),
       data = data,
       groups = 'Plant',
       ngroups=ngroups,
       pch = |,
       box.width = mywidth,
       panel = mypanel,
       panel.groups = mypanel.groups)

 }

 myCO2 - CO2
 myCO2$year - 2011
 summary(myCO2)

 mybwplot('Type','uptake',myCO2) # works

 mybwplot('Type','uptake',myCO2,'Treatment') # Error using packet 1,
 'x' is missing

 mybwplot('Type','uptake',myCO2,'year') # Error using packet 1, 'x' is missing

 # Deepayan Sarkar suggested code (adapted to myC02)
 # bwplot(uptake ~ Plant, data = myCO2, groups = Treatment,
 #        pch = |, box.width = 1/3,
 #        panel = panel.superpose,
 #        panel.groups = function(x, y, ..., group.number) {
 #            panel.bwplot(x + (group.number-1.5)/3, y, ...)
 #        })

 __
 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 p value from coxme object

2011-08-20 Thread Uwe Ligges

Cleaning up some old messages, I found this one:

The p-values are not stored in the coxme object. They are calculated on 
the fly when you ask to rpint the object. See

  coxme:::print.coxme
for the code.

Uwe Ligges




On 02.08.2011 17:26, Catarina Miranda wrote:

Dear R experts;

I am trying to extract the p values from a coxme object (package coxme). I
can see the value in the model output, but I wanted to have the result with
a higher number of decimal places.
I have searched the mailing list and followed equivalent suggestions for
nlme/lme objects, but I wasn't successful.

Thanks;

Catarina

[[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] Problem Installing/Uninstalling Rattle

2011-08-20 Thread Uwe Ligges

Cleaning up some old messages, I found this one


On 02.08.2011 14:51, adarwish wrote:

Rattle won't install properly on my Windows 7 64 bit laptop.

Here is what I've tried:

I've followed the instructions here:
http://rattle.togaware.com/rattle-install-mswindows.html
I had R installed already.
I downloaded the GTK+ packages, unzipped the 32 bit one into c:\gtkwin32.



See  the repository's ReadMe in
http://cran.r-project.org/bin/windows/contrib/2.13/ReadMe
that tells you:

- Package RGtk2 requires an an installation of Gtk+ aka Gtk2 = 2.20.
  For 32-bit R, version 2.20 or later from
http://www.gtk.org/download/win32.php, e.g.

http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.0-20101016_win32.zip
  For 64-bit R, version 2.20 or later from
http://www.gtk.org/download/win64.php, e.g.

http://ftp.gnome.org/pub/gnome/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.0-20101016_win64.zip
  In each case, unpack the zip file in a suitable empty directory and
put the 'bin' directory in your path.  NB: the 32-bit and 64-bit
distributions contain DLLs of the same names, and so you must ensure
that you have the 32-bit version in your path when running 32-bit R
and the 64-bit version when running 64-bit R - and the error
messages you get with the wrong version are confusing.



I put c:\gtkwin32\bin in the system variables PATH.

I launched R, installed the rattle package, called the rattle library,
called rattle().

It told me RGtk2 could not be found and asked to install it.  I let it
download it to install, but still nothing.

Restarting/resintalling R has not helped.  And when I try
remove.packages(rattle) I get the error:

Removing package(s) from ‘C:/Users/darwish/Documents/R/win-library/2.13’
(as ‘lib’ is unspecified)
Error in match(x, table, nomatch = 0L) :
   'match' requires vector arguments


The package name has to be quotes (i.e. specified as character rather 
than symbol).


Uwe Ligges




I've restarted R before trying anything multiple times.


From what I understand, I need to clean everything off and start anew.  How

do I remove rattle so I can start fresh?  What did I do wrong in my steps?

Thanks in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-Installing-Uninstalling-Rattle-tp3712221p3712221.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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 3:43 AM, peter dalgaard wrote:



On Aug 19, 2011, at 20:40 , David Winsemius wrote:



On Aug 19, 2011, at 1:28 PM, Stephen Davies wrote:

I'm using chisq.test() on a matrix of categorical data, and I see  
that the
residuals attribute of the returned object will give me the  
Pearson residuals.


Actually they are not an attribute in the R sense, but rather a list  
value.


That's cool. However, what I'd really like is the standardized  
(adjusted)
Pearson residuals, which have a N(0,1) distribution. Is there a  
way to do that

in R (other than by me programming it myself?)


?scale


chisq.test(...)$stdres, more likely.


Agree that does have a much greater chance of keeping the questioner  
in the mainstream of statistics terminology and is most likely what he  
was looking for, but do not think the result will in general have an  
N(1,0) distribution. I believe the correct statement is that  
standardized residuals would (in the statistical asymptotic sense)  
have an N(1,0) distribution if and when the null hypothesis of  
marginal homogeneity were true, but should not be N(1,0) in any case  
when an alternate hypothesis holds. My error was in taking the  
questioner's request at face value.


--
David Winsemius, MD
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] Pattern names matching

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 11:25 AM, Doran, Harold wrote:

See the stringMatch function in the MiscPsycho package for an  
implementation of Levenshtein


The agrep function in base R also returns a Levenshtein distance.

--
David.


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On  
Behalf Of Orvalho Augusto [orvaq...@gmail.com]

Sent: Saturday, August 20, 2011 11:08 AM
To: r-help@r-project.org
Subject: [R] Pattern names matching

Dear R magic guys.. I have two tables (actually will be dataframes),  
both

with names to be matched.

The names on the first dataframe are from a study with antenatal  
visits on
some health centers here. It happens that we need the delivery info.  
And
half and some thing else of the women decided to delivery some where  
else
our health units. We managed to get the names from some other places  
but now

we have to match our 4000 original names with over 2 other names.

To make thing more bitter some names have badly written. So I need  
some
algorithm like Levenstein or sondex or phonix or something better  
already on

R. Can you help me?

Orvalho


David Winsemius, MD
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] reshape a matrix

2011-08-20 Thread Wendy
Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2' in rows
and 'control' and 'sample' in columns. Is there a function for doing this
easily?

Thank you in advance.

Wendy

--
View this message in context: 
http://r.789695.n4.nabble.com/reshape-a-matrix-tp3757179p3757179.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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread Stephen Davies

  I'm using chisq.test() on a matrix of categorical data, and I see  
  that the
  residuals attribute of the returned object will give me the  
  Pearson residuals.
 
 Actually they are not an attribute in the R sense, but rather a list  
 value.

Oh. I was just going by:

 attributes(my.chisq.test)
$names
[1] statistic parameter p.value   methoddata.name observed 
[7] expected  residuals

$class
[1] htest

which I interpreted as this object has 8 attributes, called 'statistic',
'parameter', ..., 'residuals'. Is that not the right terminology?


  That's cool. However, what I'd really like is the standardized  
  (adjusted)
  Pearson residuals, which have a N(0,1) distribution. Is there a  
  way to do that
  in R (other than by me programming it myself?)
 
  ?scale
 
  chisq.test(...)$stdres, more likely.

scale is not what I want. As for $stdres, that would be wonderful, but
as you can see from the above list of attributes, it's not one of the 8
returned. What am I missing?

- Stephen

__
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] reshape a matrix

2011-08-20 Thread Uwe Ligges



On 20.08.2011 17:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2' in rows
and 'control' and 'sample' in columns. Is there a function for doing this
easily?


See ?reshape

reshape(data=dataframe, idvar=A, timevar=B, direction=wide)

Uwe Ligges






Thank you in advance.

Wendy

--
View this message in context: 
http://r.789695.n4.nabble.com/reshape-a-matrix-tp3757179p3757179.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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 12:04 PM, Stephen Davies wrote:




I'm using chisq.test() on a matrix of categorical data, and I see
that the
residuals attribute of the returned object will give me the
Pearson residuals.


Actually they are not an attribute in the R sense, but rather a list
value.


   Oh. I was just going by:


attributes(my.chisq.test)

$names
[1] statistic parameter p.value   methoddata.name  
observed

[7] expected  residuals

$class
[1] htest

   which I interpreted as this object has 8 attributes, called  
'statistic',

'parameter', ..., 'residuals'. Is that not the right terminology?


The names attribute let's you know what characters to use if you want  
to access values in a list. Unless you are doing programming  
attributes is not a particular useful function. It is much more common  
to access the names attribute with the  `names` function:


 names(Xsq)
[1] statistic parameter p.value   methoddata.name  
observed  expected

[8] residuals stdres

So stdres is not an attribute but rather one value in a particular  
attribute called names.


You would get (much) more information by using str on the htest object  
as below:


 str(Xsq)
List of 9
 $ statistic: Named num 30.1
  ..- attr(*, names)= chr X-squared
 $ parameter: Named num 2
  ..- attr(*, names)= chr df
 $ p.value  : num 2.95e-07
 $ method   : chr Pearson's Chi-squared test
 $ data.name: chr M
 $ observed : table [1:2, 1:3] 762 484 327 239 468 477
  ..- attr(*, dimnames)=List of 2
  .. ..$ gender: chr [1:2] M F
  .. ..$ party : chr [1:3] Democrat Independent Republican
 $ expected : num [1:2, 1:3] 704 542 320 246 534 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ gender: chr [1:2] M F
  .. ..$ party : chr [1:3] Democrat Independent Republican
 $ residuals: table [1:2, 1:3] 2.199 -2.505 0.411 -0.469 -2.843 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ gender: chr [1:2] M F
  .. ..$ party : chr [1:3] Democrat Independent Republican
 $ stdres   : table [1:2, 1:3] 4.502 -4.502 0.699 -0.699 -5.316 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ gender: chr [1:2] M F
  .. ..$ party : chr [1:3] Democrat Independent Republican
 - attr(*, class)= chr htest

Now you can see that the values in the stdres object are really a list  
element and are in a table with particular row and column names. You  
get that object one of two ways. you ca use the $ method as Dalgaard  
suggested or you can use [[ with the name of the object:


Xsq[[stdres]]






That's cool. However, what I'd really like is the standardized
(adjusted)
Pearson residuals, which have a N(0,1) distribution. Is there a
way to do that
in R (other than by me programming it myself?)


?scale


chisq.test(...)$stdres, more likely.


   scale is not what I want. As for $stdres, that would be  
wonderful, but
as you can see from the above list of attributes, it's not one of  
the 8

returned. What am I missing?


David Winsemius, MD
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] t() prior to data rotation

2011-08-20 Thread Carl Witthoft

Well, did you try it with a simple test case to see what comes out?
Do you have a sample mydata.txt file so you know how it's ordered in 
the first place?


Carl

quote
From: christopher stratton cfstratton_at_gmail.com
Date: Fri, 19 Aug 2011 23:10:07 -0400

Dear All,

I have come upon an R-mode PCA protocol that uses the following 
arguments, where mydata.txt is an nxm matrix of n objects and m variables:


 a - read.table(mydata.txt)
 b - t(a)
 c - prcomp(b)
 c$rotation
The user then plots the coordinates given by c$rotation (PC1 and PC2) as 
the scores of their PCA plot.


This doesn't make sense to me as the user transposed the matrix prior to 
rotating the data, so they have solved for the eigenvectors of the 
objects and by plotting the values of c$rotation the user is in effect 
plotting the loading matrix and not the scores. If anything, this looks 
like a Q-mode PCA where the rotation matrix should be multiplied by the 
original data matrix to give scores for the variables.


Am I missing something or does this procedure look incorrect?

Thank you for your time,
Chris
/quote
--
-
Sent from my Cray XK6

__
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] hetlp_type text doen't work on Ubuntu

2011-08-20 Thread Ben Bolker
Amol Jadhav amolj.1306 at gmail.com writes:

 Don't know the internals behind, but when I did this:
  help.search('qplot', rebuild=T)
 the text help started working. It would be interesting to know why it
 worked that way. Also if it is happens always, it should have been
 documented somewhere -- so that new users (who needs help) will not
 get disappointed [I was using R without help until i found about
 option(help_type='html')].
 
 Anyway, i'm glad that it started working.


  I'm glad it started working too, but it seems extremely likely
that your problem was specific to your system. R's help system does
normally work fine out of the box -- there are thousands of Ubuntu
users, and none that I'm aware of has ever reported this particular 
problem before.

   Ben Bolker

__
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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread peter dalgaard

On Aug 20, 2011, at 18:04 , Stephen Davies wrote:

  As for $stdres, that would be wonderful, but
 as you can see from the above list of attributes, it's not one of the 8
 returned. What am I missing?

An upgrade, most likely.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com
Døden skal tape! --- Nordahl Grieg

__
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] reshape a matrix

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 12:32 PM, Uwe Ligges wrote:


On 20.08.2011 17:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and  
'd2' in rows
and 'control' and 'sample' in columns. Is there a function for  
doing this

easily?


See ?reshape

reshape(data=dataframe, idvar=A, timevar=B, direction=wide)

Uwe Ligges


Many people have experienced problems understanding the mechanics of  
the base function 'reshape'. If you do not and if do continue to use  
it, you would be doing the world a great service by writing a tutorial  
manual with a bunch of worked examples. I have never found a tutorial  
that clarified how I should use it in the variety of situations where  
I have needed it.


 So Hadley wrote an alternate facility   ... the reshape package that  
does not have a reshape function in it but rather two functions 'melt'  
and 'cast'. Your data is all ready molten, i.e. it is in the long  
format (in the terminology of the base reshape function) with  
identifier values in each row and a single column of values.


 library(reshape)
 cast(dataframe,A~B)
Using C as value column.  Use the value argument to cast to override  
this choice

   A control sample
1 d0   1e+05  1e+05
2 d1   2e+02  3e+02
3 d2   4e+02  5e+02

Basically the cast formula keeps the LHS variables in the rows and hte  
RHD variables get arranges in columns. (For reasons that are unclear  
to me the dataframe argument was placed first when using positional  
argument passing, unlike most other formula methods in R.)

--

David Winsemius, MD
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] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 12:57 PM, peter dalgaard wrote:



On Aug 20, 2011, at 18:04 , Stephen Davies wrote:


As for $stdres, that would be wonderful, but
as you can see from the above list of attributes, it's not one of  
the 8

returned. What am I missing?


An upgrade, most likely.


Whoosh. Sometimes I am simply clueless. I didn't notice that 'stdres'  
was missing from the names in Stephen's output. Laura Thompson has a  
very nice R/S accompaniment to Agresti's Categorical Data Analysis  
text and she shows how to adjust the Pearson residuals to make them  
standardized. What follows is directly from pages 37-38 of her work:


#--#
resid.pear - residuals(fit.glm, type = pearson)

Note that the sum of the squared Pearson residuals equals the Pearson  
chi-squared statistic:


sum(resid.pear^2)
[1] 69.11429

To get the standardized residuals, just modify resid.pear according to  
the formula on p. 81 of Agresti.


ni-rowSums(table.3.2.array) # row sums

nj-colSums(table.3.2.array) # column sums
n-sum(table.3.2.array)  # total sample size
resid.pear.mat-matrix(resid.pear, nc=3, byrow=T,  
dimnames=list(c(HS,HS or JH,

Bachelor or Grad),c(Fund, Mod, Lib)))

n*resid.pear.mat/sqrt(outer(n-ni,n-nj,*) ) # standardized Pearson  
residuals


  FundMod   Lib
 HS  4.534062 -2.5520482 -1.941537
HS or JH  2.552988  1.2859745 -3.994669
Bachelor or Grad -6.806638  0.7007539  6.250329

#--#

You can also look at the code (once you upgrade) and the method in R  
is quite similar, although the R codes calcualtes the stdres values  
separately rather than adjusting the Pearson residuals




--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School



David Winsemius, MD
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] reshape a matrix

2011-08-20 Thread Uwe Ligges



On 20.08.2011 19:04, David Winsemius wrote:


On Aug 20, 2011, at 12:32 PM, Uwe Ligges wrote:


On 20.08.2011 17:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2'
in rows
and 'control' and 'sample' in columns. Is there a function for doing
this
easily?


See ?reshape

reshape(data=dataframe, idvar=A, timevar=B, direction=wide)

Uwe Ligges


Many people have experienced problems understanding the mechanics of the
base function 'reshape'. If you do not and if do continue to use it, you
would be doing the world a great service by writing a tutorial manual
with a bunch of worked examples. I have never found a tutorial that
clarified how I should use it in the variety of situations where I have
needed it.


David,

I think there are some good examples on the help page. What is missing? 
What is not clearly explained? If a longer tutorial is needed, that may 
be an article for the R Help Desk in The R Journal. Anybody volunteering?


Best,
Uwe




So Hadley wrote an alternate facility ... the reshape package that does
not have a reshape function in it but rather two functions 'melt' and
'cast'.


 Your data is all ready molten, i.e. it is in the long format

(in the terminology of the base reshape function) with identifier values
in each row and a single column of values.

  library(reshape)
  cast(dataframe,A~B)
Using C as value column. Use the value argument to cast to override this
choice
A control sample
1 d0 1e+05 1e+05
2 d1 2e+02 3e+02
3 d2 4e+02 5e+02

Basically the cast formula keeps the LHS variables in the rows and hte
RHD variables get arranges in columns. (For reasons that are unclear to
me the dataframe argument was placed first when using positional
argument passing, unlike most other formula methods in R.)


__
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] Groups and bwplot

2011-08-20 Thread Sébastien Bihorel
Thanks for your input and this link. I realize that there was a typo
in my example code that impacted the group argument... That's king of
stupid.

However, even with the implementation of Felix's syntax, the Error
using packet 1, 'x' is missing error message is still displayed, even
if the call appears correct. So I believe that group argument in not
the issue but rather my panel functions. (Plus, Felix's notation
creates side-issues such as the calculation of ngroups, which I have
hard-coded in the following modified example).

require(lattice)

mybwplot - function(x,data,groups){

  if (missing(groups)) {
ngroups - 1
  } else {
ngroups - 2
  }

  mywidth - 1/(ngroups+1)

  mypanel - function(x,y,groups,...){
if (missing(groups)||is.null(groups)) {
  panel.bwplot(x,y,...)
} else {
  panel.superpose(x,y,...)
}
  }

  mypanel.groups - function(x,y,groups,ngroups,group.number,...){
if (missing(groups)||is.null(groups)){
  NULL
} else {
  panel.bwplot(x+(group.number-0.5*(ngroups+1))/(ngroups+1),y, ...)
}
  }

  ccall - quote(bwplot(x,
data = data,
ngroups=ngroups,
pch = |,
box.width = mywidth,
panel = mypanel,
panel.groups = mypanel.groups))
  ccall$groups - substitute(groups)
  str(ccall)
  eval(ccall)

}

myCO2 - CO2
myCO2$year - 2011

mybwplot(uptake~Type,myCO2) # works

mybwplot(uptake~Type,myCO2,groups=Treatment) # Error using packet 1,
'x' is missing

#mybwplot(uptake~Type,myCO2,groups=year) # Error using packet 1, 'x' is missing

# Deepayan Sarkar suggested code (adapted to myC02)
# bwplot(uptake ~ Type, data = myCO2, groups = Treatment,
#pch = |, box.width = 1/3,
#panel = panel.superpose,
#panel.groups = function(x, y, ..., group.number) {
#panel.bwplot(x + (group.number-1.5)/3, y, ...)
#})

On Sat, Aug 20, 2011 at 11:38 AM, Weidong Gu anopheles...@gmail.com wrote:
 You may want to consult a recent post by Felix
 (https://stat.ethz.ch/pipermail/r-help/2011-August/286707.html) on how
 to pass group parameter.

 Weidong Gu

 On Sat, Aug 20, 2011 at 6:59 AM, Sébastien Bihorel pomc...@free.fr wrote:
 Dear R-users,

 A while ago, Deepayan Sarkar suggested some code that uses the group
 argument in bwplot to create some 'side-by-side' boxplots
 (https://stat.ethz.ch/pipermail/r-help/2010-February/230065.html). The
 example he gave was relatively specific and I wanted to generalize his
 approach into a function. Unfortunately, I seem to have some issues
 passing the correct arguments to the panel function, and would greatly
 appreciate any suggestions to solve these issues:

 require(lattice)

 mybwplot - function(x,y,data,groups){

  if (missing(groups)||is.null(groups)) {
    groups - NULL
    ngroups - 1
  } else {
    data[[groups]] - as.factor(data[[groups]])
    ngroups - nlevels(data[[groups]])
  }
  mywidth - 1/(ngroups+1)

  mypanel - function(x,y,groups,...){
    if (missing(groups)||is.null(groups)) {
      panel.bwplot(x,y,...)
    } else {
      panel.superpose(x,y,...)
    }
  }

  mypanel.groups - function(x,y,groups,ngroups,...){
    if (missing(groups)||is.null(groups)){
      NULL
    } else {
      function(x, y, ..., group.number) {
        panel.bwplot(x+(group.number-0.5*(ngroups+1))/(ngroups+1),y, ...)}
    }
  }

  bwplot(formula(paste(y,x,sep=' ~ ')),
       data = data,
       groups = 'Plant',
       ngroups=ngroups,
       pch = |,
       box.width = mywidth,
       panel = mypanel,
       panel.groups = mypanel.groups)

 }

 myCO2 - CO2
 myCO2$year - 2011
 summary(myCO2)

 mybwplot('Type','uptake',myCO2) # works

 mybwplot('Type','uptake',myCO2,'Treatment') # Error using packet 1,
 'x' is missing

 mybwplot('Type','uptake',myCO2,'year') # Error using packet 1, 'x' is missing

 # Deepayan Sarkar suggested code (adapted to myC02)
 # bwplot(uptake ~ Plant, data = myCO2, groups = Treatment,
 #        pch = |, box.width = 1/3,
 #        panel = panel.superpose,
 #        panel.groups = function(x, y, ..., group.number) {
 #            panel.bwplot(x + (group.number-1.5)/3, y, ...)
 #        })

 __
 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] reshape a matrix

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 1:21 PM, Uwe Ligges wrote:




On 20.08.2011 19:04, David Winsemius wrote:


On Aug 20, 2011, at 12:32 PM, Uwe Ligges wrote:


On 20.08.2011 17:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and  
'd2'

in rows
and 'control' and 'sample' in columns. Is there a function for  
doing

this
easily?


See ?reshape

reshape(data=dataframe, idvar=A, timevar=B, direction=wide)

Uwe Ligges


Many people have experienced problems understanding the mechanics  
of the
base function 'reshape'. If you do not and if do continue to use  
it, you

would be doing the world a great service by writing a tutorial manual
with a bunch of worked examples. I have never found a tutorial that
clarified how I should use it in the variety of situations where I  
have

needed it.


David,

I think there are some good examples on the help page. What is  
missing? What is not clearly explained?


The stumbling blocks I have encountered are in trying to figure out  
which of the multiple arguments are needed a) in going from wide to  
long and b) in going from long to wide, c) and what are the reasons  
for the various error messages I provoke . I am almost never able to  
do it correctly on the first try and rarely able to do it even on the  
fourth try. I bought Spector's book in hopes of understanding it  
better, but his efforts did not take root in my brain.


In the instance above, how would I have know how to apply the help  
page description of timevar (below) to this problem?


timevar
the variable in long format that differentiates multiple records from  
the same group or individual.


To my reading that does not distinguish the purpose of 'timevar' from  
the purpose of 'idvar' and then reading the 'idvar' definition just  
below it does not help at all.


--
David.


If a longer tutorial is needed, that may be an article for the R  
Help Desk in The R Journal. Anybody volunteering?


Best,
Uwe




So Hadley wrote an alternate facility ... the reshape package that  
does

not have a reshape function in it but rather two functions 'melt' and
'cast'.


 Your data is all ready molten, i.e. it is in the long format
(in the terminology of the base reshape function) with identifier  
values

in each row and a single column of values.

 library(reshape)
 cast(dataframe,A~B)
Using C as value column. Use the value argument to cast to override  
this

choice
A control sample
1 d0 1e+05 1e+05
2 d1 2e+02 3e+02
3 d2 4e+02 5e+02

Basically the cast formula keeps the LHS variables in the rows and  
hte
RHD variables get arranges in columns. (For reasons that are  
unclear to

me the dataframe argument was placed first when using positional
argument passing, unlike most other formula methods in R.)


David Winsemius, MD
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] 'install package(s) from local zip files': what is the syntax for that?

2011-08-20 Thread Bogaso Christofer
Dear all, if I want to install a package in windows system then generally I
use the 'install package(s) from local zip files' from the 'package' menu.
However I am interested to know that whether there is any syntax which I can
use in the R console instead. I have tried with
install.packages(__package_name, repos = 'f:/), however could not.

 

Any suggestion will be highly appreciated.

 

Thanks,


[[alternative HTML version deleted]]

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


Re: [R] 'install package(s) from local zip files': what is the syntax for that?

2011-08-20 Thread Uwe Ligges



On 20.08.2011 20:07, Bogaso Christofer wrote:

Dear all, if I want to install a package in windows system then generally I
use the 'install package(s) from local zip files' from the 'package' menu.
However I am interested to know that whether there is any syntax which I can
use in the R console instead. I have tried with
install.packages(__package_name, repos = 'f:/), however could not.


Let me read ?install.packages for you:

The description of the first argument tells us:
If repos = NULL, a character vector of file paths of ‘.zip’ files 
containing binary builds of packages.



Hence

install.packages(f:/__package_name, repos = NULL)

seems to be more appropriate here.

Uwe Ligges







Any suggestion will be highly appreciated.



Thanks,


[[alternative HTML version deleted]]

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


__
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] Pattern names matching

2011-08-20 Thread Orvalho Augusto
Thank you.

Orvalho

On Sat, Aug 20, 2011 at 6:02 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Aug 20, 2011, at 11:25 AM, Doran, Harold wrote:

  See the stringMatch function in the MiscPsycho package for an
 implementation of Levenshtein


 The agrep function in base R also returns a Levenshtein distance.

 --
 David.

  __**__
 From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
 Behalf Of Orvalho Augusto [orvaq...@gmail.com]
 Sent: Saturday, August 20, 2011 11:08 AM
 To: r-help@r-project.org
 Subject: [R] Pattern names matching

 Dear R magic guys.. I have two tables (actually will be dataframes), both
 with names to be matched.

 The names on the first dataframe are from a study with antenatal visits on
 some health centers here. It happens that we need the delivery info. And
 half and some thing else of the women decided to delivery some where else
 our health units. We managed to get the names from some other places but
 now
 we have to match our 4000 original names with over 2 other names.

 To make thing more bitter some names have badly written. So I need some
 algorithm like Levenstein or sondex or phonix or something better already
 on
 R. Can you help me?

 Orvalho


 David Winsemius, MD
 West Hartford, CT



[[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] t() prior to data rotation

2011-08-20 Thread christopher stratton
Yes. I know for certain that mydata.txt is ordered as an nxm matrix with n
objects and m variables.

Being that the data is transposed prior to performing the PCA, the rotation
matrix ends up being given in terms of object loadings on the principal
components, rather than variables as it's normally done.

I tried a sample data set and if you plot the values of b$rotation from the
transposed data, you end up with a similar (but, not equivalent) plot as if
you processed the data without transposing it first, i.e.,:

 a - read.table(mydata.txt)
 b - prcomp(a, retx = TRUE)
 b$x

Even though the results are similar, conceptually I am not sure why it's
okay to transpose the data, perform PCA, and then plot the rotation matrix
as though they were scores.

Thanks again,
Chris

On Sat, Aug 20, 2011 at 12:45 PM, Carl Witthoft c...@witthoft.com wrote:

 Well, did you try it with a simple test case to see what comes out?
 Do you have a sample mydata.txt file so you know how it's ordered in the
 first place?

 Carl

 quote
 From: christopher stratton cfstratton_at_gmail.com
 Date: Fri, 19 Aug 2011 23:10:07 -0400


 Dear All,

 I have come upon an R-mode PCA protocol that uses the following arguments,
 where mydata.txt is an nxm matrix of n objects and m variables:

  a - read.table(mydata.txt)
  b - t(a)
  c - prcomp(b)
  c$rotation
 The user then plots the coordinates given by c$rotation (PC1 and PC2) as
 the scores of their PCA plot.

 This doesn't make sense to me as the user transposed the matrix prior to
 rotating the data, so they have solved for the eigenvectors of the objects
 and by plotting the values of c$rotation the user is in effect plotting the
 loading matrix and not the scores. If anything, this looks like a Q-mode PCA
 where the rotation matrix should be multiplied by the original data matrix
 to give scores for the variables.

 Am I missing something or does this procedure look incorrect?

 Thank you for your time,
 Chris
 /quote
 --
 -
 Sent from my Cray XK6

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




-- 
Christopher F. Stratton
Tan Laboratory
Memorial Sloan–Kettering Cancer Center
1275 York Ave., Box 422, ZRC-2131, New York, NY 10065
Tel: 646-888-2229  -  Fax: 646-422-0416

[[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] Build a package - check error

2011-08-20 Thread Eduardo M. A. M.Mendes
Hello

I managed to find what was wrong and it has nothing to do with .First.lib.
The clue was in NAMESPACE and in the way the fortran was called (don't use
dyn.load).

I thank the author of the package digest where I found the lines that help
me to crack what was wrong and Uwe Ligges for pushing me hard.

Cheers

Ed


-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Saturday, August 20, 2011 10:38 AM
To: Eduardo Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Build a package - check error



On 20.08.2011 00:41, Eduardo Mendes wrote:
 Hi

 I have modified the path to

 dyn.load(paste(Sys.getenv(R_LIBS_USER),/fortran/src/fortran.so,sep
 =))


Hmmm, looks like you never took a look into the relevant manual Writing R
Extensions nor in the help files I cited below.

?.First.lib has an example:

## Suppose a package needs to call a DLL named 'fooEXT', ## where 'EXT' is
the system-specific extension.  Then you should use .First.lib -
function(lib, pkg)
   library.dynam(foo, pkg, lib)


You cannot know that the package is in Sys.getenv(R_LIBS_USER)

Note also that the .so file won't be in the path /src/... but in
.../lib/... once you install the package in the recommended way using R CMD
INSTALL.

Really, please do read manual!!!





 and the package could installed, loaded and the lines with dyn.load
worked.
 It does not look like a pretty solution but works on my linux (I am 
 not sure if it works on my mac or windows).

 I am not sure if this is what you meant but as I have no clue what 
 .First.lib does or NAMESPACES means this is the best I come up with.

So again time to read the manual and the help pages.

Best,
Uwe Ligges



 Please correct me if I am wrong.

 Many thanks

 Ed



 On Fri, Aug 19, 2011 at 6:03 PM, Uwe 
 Liggeslig...@statistik.tu-dortmund.de
 wrote:



 On 19.08.2011 22:53, Eduardo Mendes wrote:

 Dear R-users

 I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  
 To get my own functions available on R section I have decided to 
 learn how to build
   a
 R package. I choose a simple example with a few Fortran and R 
 functions (wrapper).

 The fortran sources are located at src and the R functions at R (as 
 recommended).  The building process went ok but R CMD check did not. 
 The error mgs was

 Error in dyn.load(fortran.so) :
unable to load shared object
 '/home/eduardo/R_packages/**test.Rcheck/fortran.so':

 Although I can see that R cannot find the compiled fortran code I do not
 know what to do.   I believe it is something to do with the following
 lines
 in  the R-wrapper file

 if (!is.loaded('calnpr'))
 dyn.load(fortran.so)



 1. If the package is called calnpr, the shared library is also called 
 that way.
 2. you have to provide the path to the shared library.

 See ?.First.lib for how to do it in a package without NAMESPACE (and 
 note that NAMESPACES are forced for the next R release).

 Best,
 Uwe Ligges


   How to add the path so that once the package is installed the 
 compiled
 fortran code can be found?

 Many thanks

 Cheers

 Ed

 [[alternative HTML version deleted]]

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



   [[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] adding text to a plot created with strat.plot() from package rioja

2011-08-20 Thread Jason Paul Joines
I'm pretty new to R and finding the responsible line would not have 
been obvious to me without your help.  I downloaded the source for 
package Rioja and was surprised to see that each function was supplied 
in it's own file.  That made it pretty straightforward to copy, modify, 
and use my own version of it.  Still, it's going to take quite a while 
to get familiar with all of the graphical capabilities of R.



Thanks,

Jason
===



 Original Message 
Subject: Re: [R] adding text to a plot created with strat.plot() from 
package rioja

From: Uwe Ligges lig...@statistik.tu-dortmund.de
To: Jason Paul Joines ja...@joines.org
Date: 2011.08.20.Sat.8:43:30



On 19.08.2011 18:40, Jason Paul Joines wrote:

I have a plot created with strat.plot() from package rioja. When the
plot is created with scale.percent=FALSE, each x axes is labeled at 0
and its maximum. However, when scale.percent=TRUE, the x axes are not
labeled. I need to use scale.percent=TRUE and I need labels for the x 
axes.


I have been able to add labels to the x axes with mtext but it is very
tedious to find the correct position. Is there a better way to do this
or a better way to find the desired coordinates than trial and error?


Yes: You can change the code and suggest your improvements to the 
package maintainer, for example. The relevant line in that function 
obviously is:


axis(side = 1, at = seq(0, colM[i], by = 10), labels = FALSE)

Uwe Ligges





Jason
===

__
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 abort function execution after x-seconds

2011-08-20 Thread Immanuel

Hello all,

I'm running a  parameter grid optimization ( ksvm, kernlab package) and 
the optimizer

seems not to converge for certain parameters and stays in a infinity loop.
Would it be possible to abort the execution after x-seconds and continue
with the next parameter set? Which R function do need to use to 
accomplish this?


I had a look at, try() etc. but they didn't seem so fit my needs.
I would appreciate any suggestions..

best regards

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


Re: [R] How to abort function execution after x-seconds

2011-08-20 Thread Bert Gunter
?proc.time

e.g. something like

time0 - proc.time()[2]
state - not converged
while(proc.time()[2]  time0[2] + 600 ) ## 10 minutes
{
##... Do your thing...
if(get an answer) {state - converged; break}
}

Refinement required, but you get the idea.

Cheers,
Bert

On Sat, Aug 20, 2011 at 1:52 PM, Immanuel mane.d...@googlemail.com wrote:
 Hello all,

 I'm running a  parameter grid optimization ( ksvm, kernlab package) and the
 optimizer
 seems not to converge for certain parameters and stays in a infinity loop.
 Would it be possible to abort the execution after x-seconds and continue
 with the next parameter set? Which R function do need to use to accomplish
 this?

 I had a look at, try() etc. but they didn't seem so fit my needs.
 I would appreciate any suggestions..

 best regards

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




-- 
Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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 abort function execution after x-seconds

2011-08-20 Thread Bert Gunter
I should have said: The below only works if you can get it into the
function code. If you cannot, and the function has no options that
allow you to limit execution time or iterations, then I don't see how
you can do it.

-- Bert

On Sat, Aug 20, 2011 at 2:16 PM, Bert Gunter bgun...@gene.com wrote:
 ?proc.time

 e.g. something like

 time0 - proc.time()[2]
 state - not converged
 while(proc.time()[2]  time0[2] + 600 ) ## 10 minutes
 {
 ##... Do your thing...
 if(get an answer) {state - converged; break}
 }

 Refinement required, but you get the idea.

 Cheers,
 Bert

 On Sat, Aug 20, 2011 at 1:52 PM, Immanuel mane.d...@googlemail.com wrote:
 Hello all,

 I'm running a  parameter grid optimization ( ksvm, kernlab package) and the
 optimizer
 seems not to converge for certain parameters and stays in a infinity loop.
 Would it be possible to abort the execution after x-seconds and continue
 with the next parameter set? Which R function do need to use to accomplish
 this?

 I had a look at, try() etc. but they didn't seem so fit my needs.
 I would appreciate any suggestions..

 best regards

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




 --
 Men by nature long to get on to the ultimate truths, and will often
 be impatient with elementary studies or fight shy of them. If it were
 possible to reach the ultimate truths without the elementary studies
 usually prefixed to them, these would not be preparatory studies but
 superfluous diversions.

 -- Maimonides (1135-1204)

 Bert Gunter
 Genentech Nonclinical Biostatistics




-- 
Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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] val.surv

2011-08-20 Thread Salvo Mac
 Dear R-users,
 
I  have two questions regarding validation and calibration of Survival 
regression models.
 
1.  I am trying to calibrate and validate a cox model using val.surv.
here is my code:
 f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
 test1-test[,age]
 val.surv(f.1, newdata=data.frame(test1), u=10)
 
 but I get an error message:
 
 Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
  dims [product 1797] do not match the length of object [2496]
 In addition: Warning message:
In est.surv + S[, 1] :
  longer object length is not a multiple of shorter object length
 
 I ran the example in the r-documentation but couldn't extract  dxy from result.
 
 What am I doing wrong?  
 
 2.  In validate and calibrate cph functions. If it is frailty fit, does the 
the bootstrap resample clusters or just individuals
 
 regards,
 
 Salvo Mac
[[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] AFT model time-dependent with weibull distribution

2011-08-20 Thread JPF

Göran Broström wrote:
 
 
 Good. Do you still need answers to your other questions?
 
 

Yes. Could answer the following two questions: 

1- Can I use phreg function to estimate  a model with time-dependent
covariates? In case of a positive answer, how? 
 
2- I could not find any example that clearly explains how to interpret
aftreg output. Specially, refering to the diference between survreg and
aftreg output (intercept and sign of the estimates).

I include below an example of output of a regression with coxph, survreg,
phreg and aftreg and a time-independent variable. I would appreciate if you
could explain it or provide an external example that explains how it works.

n=26
events=25
time at risk=45

a/ 

coxph(Surv(time,s) ~ Z1,  data=data.frame(data))

 coef exp(coef)  se(coef)z p
Z1 0.0249  1.03  0.00907 2.75 0.006


b/

phreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist=weibull)

Covariate  W.mean  Coef Exp(Coef)  se(Coef)Wald p
Z1  43.689 0.033 1.033 0.009 0.000 

log(scale)  0.641 1.899 0.065 0.000 
log(shape) 1.172 3.230 0.158 0.000 

Max. log. likelihood  -22.135 
LR test statistic 13.1 
Degrees of freedom1 
Overall p-value   0.000302689


c/

aftreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist=weibull)

Covariate  W.mean  Coef Exp(Coef)  se(Coef)Wald p
mas  43.689   0.0101.010 0.002 0.000 

log(scale)  1.147 3.149 0.141 0.000 
log(shape) 1.172 3.230 0.158 0.000 

Max. log. likelihood  -22.135 
LR test statistic 13.1 
Degrees of freedom1 
Overall p-value 0.000302692


d/

survreg(Surv(time,s) ~ Z1,  data=data.frame(data), dist=weibull)

  Value Std. Error zp
(Intercept)  1.14760.13498 8.50  1.87e-17
mas   -0.0101   0.00232-4.34  1.45e-05
Log(scale)  -1.17240.15787-7.43 1.11e-13

Scale= 0.310 

Weibull distribution
Loglik(model)= -22.1   Loglik(intercept only)= -28.7
Chisq= 13.05 on 1 degrees of freedom, p= 3e-04 
Number of Newton-Raphson Iterations: 5 


Thank you very much, 

J







--
View this message in context: 
http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3757387.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] I have a problem with R!!

2011-08-20 Thread nferreri
Dear all

i´m working with a program i´ve made in R (using functions that others
created)

to run my program i need a sample. if i generate the sample using  for
example, rnorm(n, mu, sigma) i have no problem

but if i obtain a sample from a column in excel and i copy it, the program
says that there is a mistake: it says Error en `[.data.frame`(data,
indices) : undefined columns selected

my program is:

d- read.delim(clipboard, header = T, dec = ,)
#Para determinar los valores de las componentes del vector de capacidad es
necesario definir primero las especificaciones y el valor objetivo, T, así
como el máximo valor admitido para la proporción de producción no
conforme, a cada lado de los límites de especificaciones#
# Ingrese ahora el valor del límite inferior de especificaciones#
LIE - 13
# Ingrese ahora el valor del límite superior de especificaciones#
LSE - 17
# Ingrese ahora el valor objetivo#
T - 14.5
# Ingrese ahora el máximo valor admitido para la proporción de producción
no conforme a cada lado de los límites de especificaciones#
MA- 0.00135
D- min ((LSE-T), (T-LIE))
compo1 - function(data, indices)
{
d- data[indices]
n = length (d)
desvio - sd(d)
y- rep(1:n)
y[x = mean(d)] - 1
y[x mean(d)] - 0
RI1- D/(3*desvio*2*mean(y))
RI2 - D/(3*desvio*2*(1-mean(y)))
return (min (RI1, RI2))
}
compo2- function(data, indices)
{
d - data[indices]
c2 - (abs(mean(d) - T))/D
return (1-c2)
}
compo3-function(data, indices)
{
d- data[indices]
n- length (d)
y- rep(1:n)
y[d  LIE] - 1
y[d = LIE] - 0
INFE - mean (y);
y- rep(1:n)
y[d  LSE] - 1
y[d = LSE] - 0
SUPE- mean (y);
PPI - (1 - INFE)/(1-MA)
PPS - (1 - SUPE)/(1-MA)
return (min (PPI, PPS))
}
save(file = compo1.RData)
save(file = compo2.RData)
save(file = compo3.RData)
compos- function(data, indices)
{
d - data[indices]
capacidad - c(compo1(d), compo2(d), compo3(d))
return(capacidad)
}
save(file = compos.RData)
require (boot)
vectorcapacidad - boot (d, compos, R = 3000)

ETC. ETC.



WHEN I START MY PROGRAM WRITING:
d- rnorm (n, mu, sigma)

I HAVE NO PROBLEM. BUT WHEN I READ A VECTOR FROM EXCEL, R TELLS ME
Error en `[.data.frame`(data, indices) : undefined columns selected


CAN YOU HELP ME THANK YOU VERY MUCH!

NOEMI FERRERI, ROSARIO, ARGENTINA
SCHOOL OF INDUSTRIAL ENGINEERING

__
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] Calculating p-value for 1-tailed test in a linear model

2011-08-20 Thread Campomizzi, Andrew J
My question isn't related to homework.  It is a small part of an actual problem 
I'm trying to solve.  I've been unable to find a solution in R help files and 
discussions, in statistics books, or from colleagues.  The solution may not be 
overly complicated, but any assistance is appreciated.
Thanks,
Andy

- Original Message -
From: Rolf Turner rolf.tur...@xtra.co.nz
To: Andrew Campomizzi acampomi...@tamu.edu
Cc: r-help@r-project.org
Sent: Friday, August 19, 2011 9:18:07 PM GMT -06:00 US/Canada Central
Subject: Re: [R] Calculating p-value for 1-tailed test in a linear model

The r-help mailing list is *not* for giving assistance with homework.

 cheers,

 Rolf Turner


On 20/08/11 10:20, Andrew Campomizzi wrote:
 Hello,

 I'm having trouble figuring out how to calculate a p-value for a 1-tailed
 test of beta_1 in a linear model fit using command lm.  My model has only 1
 continuous, predictor variable.  I want to test the null hypothesis beta_1
 is= 0.  I can calculate the p-value for a 2-tailed test using the code
 2*pt(-abs(t-value), df=degrees.freedom), where t-value and degrees.freedom
 are values provided in the summary of the lm.  The resulting p-value is the
 same as provided by the summary of the lm for beta_1.  I'm unsure how to
 change my calculation of the p-value for a 1-tailed test.

 Thanks for your assistance,

 Andy

__
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 abort function execution after x-seconds

2011-08-20 Thread Immanuel

Hello Bert,

thanks for the suggestion. I should have mentioned that, sadly I can NOT 
change the

function that does the optimization.

best,
Immanuel

__
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] val.surv

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:


 Dear R-users,

I  have two questions regarding validation and calibration of  
Survival regression models.


1.  I am trying to calibrate and validate a cox model using val.surv.
here is my code:
 f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
 test1-test[,age]
 val.surv(f.1, newdata=data.frame(test1), u=10)

 but I get an error message:

 Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
  dims [product 1797] do not match the length of object [2496]
 In addition: Warning message:
In est.surv + S[, 1] :
  longer object length is not a multiple of shorter object length

 I ran the example in the r-documentation but couldn't extract  dxy  
from result.


 What am I doing wrong?


The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object. I would think that if test  
were a dataframe then wrapping data.frame around a vector might not  
get it named correctly as 'age'. You might try newdata= test['age'].  
Just a guess.




 2.  In validate and calibrate cph functions. If it is frailty fit,  
does the the bootstrap resample clusters or just individuals


The code above appears to be dependent on the rms package. The frailty  
function is part of the underlying survival package and I do not see  
it mentioned in the index for Harrell's RMS text. You will probably  
need to wait until Frank comes across this. He is generally very good  
about correction my errors and knowledge gaps.






--

David Winsemius, MD
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] adding text to a plot created with strat.plot() from package rioja

2011-08-20 Thread Jason Paul Joines
I completely missed that entering just the function name prints the 
code for that function making it even easier to copy and create a custom 
version.



Jason
===



 Original Message 
Subject: Re: [R] adding text to a plot created with strat.plot() from 
package rioja

From: Jason Paul Joines ja...@joines.org
To: r-help@r-project.org
Date: 2011.08.20.Sat.14:48:35
I'm pretty new to R and finding the responsible line would not 
have been obvious to me without your help.  I downloaded the source 
for package Rioja and was surprised to see that each function was 
supplied in it's own file.  That made it pretty straightforward to 
copy, modify, and use my own version of it.  Still, it's going to take 
quite a while to get familiar with all of the graphical capabilities 
of R.



Thanks,

Jason
===



 Original Message 
Subject: Re: [R] adding text to a plot created with strat.plot() from 
package rioja

From: Uwe Ligges lig...@statistik.tu-dortmund.de
To: Jason Paul Joines ja...@joines.org
Date: 2011.08.20.Sat.8:43:30



On 19.08.2011 18:40, Jason Paul Joines wrote:

I have a plot created with strat.plot() from package rioja. When the
plot is created with scale.percent=FALSE, each x axes is labeled at 0
and its maximum. However, when scale.percent=TRUE, the x axes are not
labeled. I need to use scale.percent=TRUE and I need labels for the 
x axes.


I have been able to add labels to the x axes with mtext but it is very
tedious to find the correct position. Is there a better way to do this
or a better way to find the desired coordinates than trial and error?


Yes: You can change the code and suggest your improvements to the 
package maintainer, for example. The relevant line in that function 
obviously is:


axis(side = 1, at = seq(0, colM[i], by = 10), labels = FALSE)

Uwe Ligges





Jason
===

__
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] Calculating p-value for 1-tailed test in a linear model

2011-08-20 Thread David Winsemius


On Aug 19, 2011, at 6:20 PM, Andrew Campomizzi wrote:


Hello,

I'm having trouble figuring out how to calculate a p-value for a 1- 
tailed
test of beta_1 in a linear model fit using command lm.  My model has  
only 1
continuous, predictor variable.  I want to test the null hypothesis  
beta_1
is = 0.  I can calculate the p-value for a 2-tailed test using the  
code
2*pt(-abs(t-value), df=degrees.freedom), where t-value and  
degrees.freedom
are values provided in the summary of the lm.  The resulting p-value  
is the
same as provided by the summary of the lm for beta_1.  I'm unsure  
how to

change my calculation of the p-value for a 1-tailed test.


You need to clearly state your hypothesis. Then using the output from  
the regression function should be straightforward.


(Yes. this is a intentionally vague answer designed to elicit further  
information about your understanding of the statistical issues and how  
they relate to your domain knowledge. Many time peole already have the  
data and because they didn't get the answer they wanted, they search  
for other ways to game the system by ad-hoc changes in the  
statistical rules of the road.)


--

David Winsemius, MD
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] Best way to setClass and setMethod for an R package?

2011-08-20 Thread Jonathan Greenberg
Folks:

I'm putting together an R package, and I was wondering where,
specifically, I put both class definitions (via setClass) as well as
setMethod calls?  Is there a particular file name I need to use?
Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
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] reshape a matrix

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 1:39 PM, David Winsemius wrote:



On Aug 20, 2011, at 1:21 PM, Uwe Ligges wrote:




On 20.08.2011 19:04, David Winsemius wrote:


On Aug 20, 2011, at 12:32 PM, Uwe Ligges wrote:


On 20.08.2011 17:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and  
'd2'

in rows
and 'control' and 'sample' in columns. Is there a function for  
doing

this
easily?


See ?reshape

reshape(data=dataframe, idvar=A, timevar=B, direction=wide)

Uwe Ligges


Many people have experienced problems understanding the mechanics  
of the
base function 'reshape'. If you do not and if do continue to use  
it, you
would be doing the world a great service by writing a tutorial  
manual

with a bunch of worked examples. I have never found a tutorial that
clarified how I should use it in the variety of situations where I  
have

needed it.


David,

I think there are some good examples on the help page. What is  
missing? What is not clearly explained?


The stumbling blocks I have encountered are in trying to figure out  
which of the multiple arguments are needed a) in going from wide to  
long and b) in going from long to wide, c) and what are the reasons  
for the various error messages I provoke . I am almost never able to  
do it correctly on the first try and rarely able to do it even on  
the fourth try. I bought Spector's book in hopes of understanding it  
better, but his efforts did not take root in my brain.


In the instance above, how would I have know how to apply the help  
page description of timevar (below) to this problem?


timevar
the variable in long format that differentiates multiple records  
from the same group or individual.


I'm wondering it this would be clearer (if it is correct):

timevar
the variable in long format that order multiple records which vary  
within the same groups or individual specified in idvar.


--
David




To my reading that does not distinguish the purpose of 'timevar'  
from the purpose of 'idvar' and then reading the 'idvar' definition  
just below it does not help at all.


--
David.


If a longer tutorial is needed, that may be an article for the R  
Help Desk in The R Journal. Anybody volunteering?


Best,
Uwe




So Hadley wrote an alternate facility ... the reshape package that  
does
not have a reshape function in it but rather two functions 'melt'  
and

'cast'.


 Your data is all ready molten, i.e. it is in the long format
(in the terminology of the base reshape function) with identifier  
values

in each row and a single column of values.

 library(reshape)
 cast(dataframe,A~B)
Using C as value column. Use the value argument to cast to  
override this

choice
A control sample
1 d0 1e+05 1e+05
2 d1 2e+02 3e+02
3 d2 4e+02 5e+02

Basically the cast formula keeps the LHS variables in the rows and  
hte
RHD variables get arranges in columns. (For reasons that are  
unclear to

me the dataframe argument was placed first when using positional
argument passing, unlike most other formula methods in R.)


David Winsemius, MD
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.


David Winsemius, MD
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] val.surv

2011-08-20 Thread Salvo Mac
Thanks David

However, I tried your trick on val.surv with newdata=test['age'] but still 
didn't work. 
Still gives the same error message:

Error in val.surv(f.1, newdata = test1[age], u = 10) : 
  dims [product 1797] do not match the length of object [2496]
In addition: Warning message:
In est.surv + S[, 1] :
  longer object length is not a multiple of shorter object length


Salvo




From: David Winsemius dwinsem...@comcast.net

Cc: r-help@R-project.org r-help@r-project.org
Sent: Sunday, August 21, 2011 12:55 AM
Subject: Re: [R] val.surv


On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:

  Dear R-users,
 
 I  have two questions regarding validation and calibration of Survival 
 regression models.
 
 1.  I am trying to calibrate and validate a cox model using val.surv.
 here is my code:
  f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
  test1-test[,age]
  val.surv(f.1, newdata=data.frame(test1), u=10)
 
  but I get an error message:
 
  Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
   dims [product 1797] do not match the length of object [2496]
  In addition: Warning message:
 In est.surv + S[, 1] :
   longer object length is not a multiple of shorter object length
 
  I ran the example in the r-documentation but couldn't extract  dxy from 
result.
 
  What am I doing wrong?

The fundamental thing you are doing wrong for q1  is failing to unambiguously 
describe the test object. I would think that if test were a dataframe then 
wrapping data.frame around a vector might not get it named correctly as 'age'. 
You might try newdata= test['age']. Just a guess.

 
  2.  In validate and calibrate cph functions. If it is frailty fit, does the 
the bootstrap resample clusters or just individuals

The code above appears to be dependent on the rms package. The frailty function 
is part of the underlying survival package and I do not see it mentioned in the 
index for Harrell's RMS text. You will probably need to wait until Frank comes 
across this. He is generally very good about correction my errors and knowledge 
gaps.

 

--
David Winsemius, MD
West Hartford, CT
[[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] reshape a matrix

2011-08-20 Thread Rolf Turner

On 21/08/11 03:04, Wendy wrote:

Hi all,

I have a data.frame like following

A-c('d0','d0','d1','d1','d2','d2')
B-rep(c('control','sample'),3)
C-c(rep(10,2),200,300,400,500)
dataframe-data.frame(A,B,C)

I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2' in rows
and 'control' and 'sample' in columns. Is there a function for doing this
easily?


Your question has been answered  But if you remember that a *matrix*
and a *data frame* are ***NOT*** the same thing, you'll get into a lot less
trouble.  Why do you think there are two *different* terms for these sorts
of object if they are the same thing?  Psigh!!!

cheers,

Rolf Turner

__
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] I have a problem with R!!

2011-08-20 Thread Rolf Turner


No, you don't have a problem with R.  You have a problem with Excel.

Solution:  Don't use Excel.

cheers,

Rolf Turner

__
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] val.surv

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 8:08 PM, Salvo Mac wrote:


Thanks David

However, I tried your trick on val.surv with newdata=test['age'] but  
still didn't work.

Still gives the same error message:

Error in val.surv(f.1, newdata = test1[age], u = 10) :
  dims [product 1797] do not match the length of object [2496]
In addition: Warning message:
In est.surv + S[, 1] :
  longer object length is not a multiple of shorter object length



As I said (and you did not act  upon):

The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object.


I said it was a guess. Now stop wasting our time and offer what is  
needed.


--
david.


Salvo




From: David Winsemius dwinsem...@comcast.net

Cc: r-help@R-project.org r-help@r-project.org
Sent: Sunday, August 21, 2011 12:55 AM
Subject: Re: [R] val.surv


On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:


  Dear R-users,

I  have two questions regarding validation and calibration of  
Survival regression models.


1.  I am trying to calibrate and validate a cox model using val.surv.
here is my code:
  f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
  test1-test[,age]
  val.surv(f.1, newdata=data.frame(test1), u=10)

  but I get an error message:

  Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
   dims [product 1797] do not match the length of object [2496]
  In addition: Warning message:
In est.surv + S[, 1] :
   longer object length is not a multiple of shorter object length

  I ran the example in the r-documentation but couldn't extract   
dxy from result.


  What am I doing wrong?


The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object. I would think that if test  
were a dataframe then wrapping data.frame around a vector might not  
get it named correctly as 'age'. You might try newdata= test['age'].  
Just a guess.




  2.  In validate and calibrate cph functions. If it is frailty  
fit, does the the bootstrap resample clusters or just individuals


The code above appears to be dependent on the rms package. The  
frailty function is part of the underlying survival package and I do  
not see it mentioned in the index for Harrell's RMS text. You will  
probably need to wait until Frank comes across this. He is generally  
very good about correction my errors and knowledge gaps.






--
David Winsemius, MD
West Hartford, CT
[[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.


David Winsemius, MD
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] val.surv

2011-08-20 Thread Salvo Mac
The test and train are like split data sets, contain similar variables but from 
different countries so the two sets are somehow  independent. And yes it is 
a data frame. 
So I extracted age, time and event.
So test is data frame,(age, time, event). does that suffice?




From: David Winsemius dwinsem...@comcast.net

Cc: r-help@R-project.org r-help@r-project.org
Sent: Sunday, August 21, 2011 3:19 AM
Subject: Re: [R] val.surv


On Aug 20, 2011, at 8:08 PM, Salvo Mac wrote:

 Thanks David
 
 However, I tried your trick on val.surv with newdata=test['age'] but still 
 didn't work.
 Still gives the same error message:
 
 Error in val.surv(f.1, newdata = test1[age], u = 10) :
   dims [product 1797] do not match the length of object [2496]
 In addition: Warning message:
 In est.surv + S[, 1] :
   longer object length is not a multiple of shorter object length
 

As I said (and you did
 not act  upon):

The fundamental thing you are doing wrong for q1  is failing to unambiguously 
describe the test object.

I said it was a guess. Now stop wasting our time and offer what is needed.

--david.
 
 Salvo
 
 
 
 
 From: David Winsemius dwinsem...@comcast.net
 
 Cc: r-help@R-project.org r-help@r-project.org
 Sent: Sunday, August 21, 2011 12:55 AM
 Subject: Re: [R] val.surv
 
 
 On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:
 
   Dear R-users,
 
 I  have two questions regarding
 validation and calibration of Survival regression models.
 
 1.  I am trying to calibrate and validate a cox model using val.surv.
 here is my code:
   f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
   test1-test[,age]
   val.surv(f.1, newdata=data.frame(test1), u=10)
 
   but I get an error message:
 
   Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
    dims [product 1797] do not match the length of object [2496]
   In addition: Warning message:
 In est.surv + S[, 1] :
    longer object length is not a multiple of shorter object length
 
   I ran the example in the r-documentation but couldn't extract  dxy from 
result.
 
   What am I doing wrong?
 
 The fundamental thing you are doing wrong for q1  is failing to unambiguously 
 describe the test object. I would think that if test were a dataframe then 
 wrapping data.frame around a vector might not get it named correctly as 
 'age'. You might try newdata= test['age']. Just a guess.
 
 
   2.  In validate and calibrate cph functions. If it is frailty fit, does 
the the bootstrap resample clusters or just individuals
 
 The code above appears to be dependent on the rms package. The frailty 
 function is part of the underlying survival package and I do not see it 
 mentioned in the index for Harrell's RMS text. You will probably need to wait 
 until Frank comes across this. He is generally very good about correction my 
 errors and knowledge gaps.
 
 
 
 --
 David Winsemius, MD
 West Hartford, CT
     [[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.

David Winsemius, MD
West Hartford, CT
[[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] val.surv

2011-08-20 Thread David Winsemius


On Aug 20, 2011, at 10:25 PM, Salvo Mac wrote:

The test and train are like split data sets, contain similar  
variables but from different countries so the two sets are somehow   
independent. And yes it is a data frame.


What is a data.frame? test and train may be dataframes, but test[,  
age] is not a dataframe.



So I extracted age, time and event.


Code? The code you offered before would have created a newdata object  
(yes, a data.frame) with a single column bearing the same name as the  
vector argument , test1. Not named age. Try it. do str on such  
an object:


str(dataframe(test1))



So test is data frame,(age, time, event). does that suffice?


It certainly does not allow me to reproduce the error you got (which I  
still think is probably related to the structure of your argument to  
newdata.)


That's all I can say without data and code.

--
David.







From: David Winsemius dwinsem...@comcast.net

Cc: r-help@R-project.org r-help@r-project.org
Sent: Sunday, August 21, 2011 3:19 AM
Subject: Re: [R] val.surv


On Aug 20, 2011, at 8:08 PM, Salvo Mac wrote:


Thanks David

However, I tried your trick on val.surv with newdata=test['age']  
but still didn't work.

Still gives the same error message:

Error in val.surv(f.1, newdata = test1[age], u = 10) :
   dims [product 1797] do not match the length of object [2496]
In addition: Warning message:
In est.surv + S[, 1] :
   longer object length is not a multiple of shorter object length



As I said (and you did
not act  upon):

The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object.


I said it was a guess. Now stop wasting our time and offer what is  
needed.


--david.


Salvo

From: David Winsemius dwinsem...@comcast.net

Cc: r-help@R-project.org r-help@r-project.org
Sent: Sunday, August 21, 2011 12:55 AM
Subject: Re: [R] val.surv


On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:


   Dear R-users,

I  have two questions regarding

validation and calibration of Survival regression models.


1.  I am trying to calibrate and validate a cox model using  
val.surv.

here is my code:
   f.1-cph(Surv(time,event)~age, x=T, y=T, data=train)
   test1-test[,age]
   val.surv(f.1, newdata=data.frame(test1), u=10)

   but I get an error message:

   Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
dims [product 1797] do not match the length of object [2496]
   In addition: Warning message:
In est.surv + S[, 1] :
longer object length is not a multiple of shorter object length

   I ran the example in the r-documentation but couldn't extract   
dxy from result.


   What am I doing wrong?


The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object. I would think that if test  
were a dataframe then wrapping data.frame around a vector might not  
get it named correctly as 'age'. You might try newdata=  
test['age']. Just a guess.




   2.  In validate and calibrate cph functions. If it is frailty  
fit, does the the bootstrap resample clusters or just individuals


The code above appears to be dependent on the rms package. The  
frailty function is part of the underlying survival package and I  
do not see it mentioned in the index for Harrell's RMS text. You  
will probably need to wait until Frank comes across this. He is  
generally very good about correction my errors and knowledge gaps.








David Winsemius, MD
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] AFT model time-dependent with weibull distribution

2011-08-20 Thread JPF

question 2

*aftreg vs. survreg*

for aftreg = S0 *{t/exp(b-BXi)]^a}   a= shape and b= log(scale) 

for survreg and stata S0 *{t*exp(intercept+BXi)]^1/p} p=shape

/intercept, log(scale) and estimates are equivalent with reversed sign./ 

*PH and AFT* 

/phreg.Bhat= aftreg.Bhat * shape /   







--
View this message in context: 
http://r.789695.n4.nabble.com/AFT-model-time-dependent-with-weibull-distribution-tp3755079p3757871.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.