Re: [R] Hmisc describe error

2012-10-01 Thread stephenb
The error is just a misleading error message. loading the data produced
column sdate as 
 str(prostate)
$ sdate :Classes 'labelled', 'dates'  atomic [1:502] 2778 2820 2933 2999
3002 ...
  .. ..- attr(*, format)= symbol ddmmmyy
  .. ..- attr(*, label)= chr Date on study

prostate$sdate - as.Date(prostate$sdate,origin=1970-01-01)  # fixes the
problem and 'describe' runs

just as a comment: maybe the R dataset should have sdate as a Date class.



--
View this message in context: 
http://r.789695.n4.nabble.com/Hmisc-describe-error-tp4644708p4644711.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] odfWeave fails to load

2012-05-29 Thread stephenb
R version 2.15.0 (2012-03-30)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)


package ‘survey’ successfully unpacked and MD5 sums checked
package ‘odfWeave.survey’ successfully unpacked and MD5 sums checked


 library(odfWeave.survey)
Loading required package: odfWeave
Error: package ‘odfWeave’ could not be loaded

any ideas, anybody?? I had odfSweave on 2.12, but no such thing on 2.15 just
odfWeave.survey and it won't load.

--
View this message in context: 
http://r.789695.n4.nabble.com/odfWeave-fails-to-load-tp4631700.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] aggregate with cumsum

2011-02-25 Thread stephenb

Bill,

what will be the fastest way to output not just single lines but small data
frames of about 60 rows?

I prefer writing to a text file because the final output is large 47k times
60 rows and since I do not know the size of it I have to use rbind to build
the object which creates the memory problems described here:

http://www.matthewckeller.com/html/memory.html

look at the swiss cheese paragraph.

kind regards
Stephen
-- 
View this message in context: 
http://r.789695.n4.nabble.com/aggregate-with-cumsum-tp2992383p3324610.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] Prediction confidence intervals for a Poisson GLM

2010-09-09 Thread stephenb

I am following up on an old post. Please, comment:

it appears that 

predict(glm.model,type=response,se.fit=T)

will do all the conversions and give se on the scale of the response. This
only takes into account the error in parameter estimation. what a
prediction interval is meant to be usually means it has to capture the
error due to both parameter estimation and sampling variation ie it
encompasses the actual realizations.
for a given parameter there is sampling variation and that is not included
in the output of predict. the discreteness of models makes it quite
difficult to estimate a percentile interval, though. for binary outcomes, I
think it does not make sense. for Poisson and binomial (grouped binary) I
think it is possible to get approximations at least and this is what the
original poster needed I think.

so, let's say we have plow and pup for an observation from predict. if
size=100 for that obs.
predlow=qbinom(.025,100,plow)
predup=qbinom(.975,100,pup)

will give the prediction bounds. this I think partly ignores possible
overdispersion. Please, suggest a better way taking overdispersion into
account (in the qbinom part).

Thanks everybody.
Stephen B.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Prediction-confidence-intervals-for-a-Poisson-GLM-tp841577p2533070.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] Comparing COXPH models, one with age as a continuous variable, one with age as a three-level factor

2010-09-02 Thread stephenb

sorry to bump in late, but I am doing similar things now and was browsing.

IMHO anova is not appropriate here. it applies when the richer model has p
more variables than the simpler model. this is not the case here. the
competing models use different variables.

you are left with IC. 

by transforming a continuous variable into categorical you are smoothing,
which is the idea of GAM. if you look at what is offered in GAMs you may
find better approximations f(age) as well as tools for testing among
different f(age) transformations.

regards.
S.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-design-matrix-tp891987p2524289.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] Data Manipulations and SQL

2010-08-26 Thread stephenb

Greetings Gabor,

is it possible to open a channel to a data frame in the default environment?
there are cases when using a sql update statement is the simplest
alternative, so instead of dumping the df and then updating and then
reimporting it I would like to update the df directly in R.

Thank you.
Stephen
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Manipulations-and-SQL-tp860420p2340098.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] unable to get bigglm working, ATTN: Thomas Lumley

2010-07-05 Thread stephenb

the model fails to converge after more than 3 hours ( I went home so don't
know how long it took)

 bigglm (formula = resp ~ relage+I(relage^2)+termfac+ri , 
+   data = a, family = binomial(link='logit')); 
Large data regression model: bigglm(formula = resp ~ relage + I(relage^2) +
termfac + ri, 
data = a, family = binomial(link = logit))
Sample size =  12758187 
failed to converge after 8  iterations
Warning message:
In bigglm.function(formula = resp ~ relage + I(relage^2) + termfac +  :
  ran out of iterations and failed to converge

SAS converges 
NOTE: PROC LOGISTIC is modeling the probability that resp='1'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 12758187 observations read from the data set
SRVRUSER.COMMIT.
NOTE: The data set WORK.OUT3 has 11 observations and 15 variables.
NOTE: PROCEDURE LOGISTIC used (Total process time):
  real time   2:25.42
  cpu time1:16.79

I did not see a trace argument in bigglm. is there another way to see what
is happening?
Thank you.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2278381.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] unable to get bigglm working, ATTN: Thomas Lumley

2010-07-05 Thread stephenb

I decided to give it 1 more variable, which is strongly significant to help
the optimization and it throws:

 bigglm (formula = resp ~ relage+relage2+termfac+ri+sn , 
+   data = a, family = binomial(link='logit')); 
Error in bigglm.function(formula = resp ~ relage + relage2 + termfac +  : 
  model matrices incompatible
-- 
View this message in context: 
http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2278734.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] unable to get bigglm working, ATTN: Thomas Lumley

2010-07-02 Thread stephenb

I am using an example posted in this help forum to work with a file. the head
of the file looks like:
97 2007-03-05 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 0 0
97 2007-03-06 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 1 0
97 2007-03-07 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 2 0
97 2007-03-08 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 3 0
97 2007-03-09 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 4 0
97 2007-03-12 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 7 0
97 2007-03-13 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 8 0
97 2007-03-14 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 9 0
97 2007-03-15 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 10 0
97 2007-03-16 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 11 0

the code is:
make.data - function (filename, chunksize, ...) { 
  conn-NULL; 
  function (reset=FALSE) { 
if (reset) { 
  if (!is.null(conn)) { 
close(conn); 
  }; 
  conn - file (description=filename, open=r); 
} else { 
  rval - read.table (conn, nrows=chunksize,sep=' ', 
skip=0, header=FALSE,...); 
  if (nrow(rval)==0) { 
close(conn); 
conn-NULL; 
rval-NULL; 
  } else { 
rval$relage - rval$loctime/rval$term; 

  }; 
return(rval); 
} 
  } 
};

a - make.data ( filename = G:/sqldata/newf4.csv, chunksize = 10, 
  colClasses = list (NULL, Date,Date, integer,
factor,rep(numeric,5),rep(integer,2)), 
  col.names = c(id,dt, promdt,term, termfac,
commintr,commbal,issuebal,intr,ri,loctime,resp) 
)
library(biglm); 

bigglm (formula = resp ~ poly(relage,2,raw=TRUE)+termfac+ri , 
  data = a, family = binomial(link='logit')); 
###   output:
 bigglm (formula = resp ~ poly(relage,2,raw=TRUE)+termfac+ri , 
+   data = a, family = binomial(link='logit')); 
Error in is(object, Class) : 
  trying to get slot className from an object of a basic class (list)
with no slots
 

### the following can create a df, so the problem is not loading the data
(maybe :-)
a - read.table ( G:/sqldata/newf4.csv, nrows= 50, sep=' ',head=F,
  colClasses = c(NULL,
Date,Date,integer,factor,rep(numeric,5),rep(integer,2)),
  col.names = (id,dt, promdt,term, termfac,
commintr,commbal,issuebal,intr,ri,loctime,resp) 
)

Thanks everybody.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2276524.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] unable to get bigglm working, ATTN: Thomas Lumley

2010-07-02 Thread stephenb

Sincere apologies and many thanks. The pasted code from the help forum has the 
error and I did not see it. When I wrote my own import I used c as I should.
See:
http://r.789695.n4.nabble.com/R-Example-function-for-bigglm-biglm-data-input-from-file-td816496.html#a816496

Stephen Bond
| Senior Analyst | Treasury Analytics | 416-956-3092

From: Thomas Lumley [via R] 
[mailto:ml-node+2276661-800075919-75...@n4.nabble.com]
Sent: Friday, July 02, 2010 12:38 PM
To: Bond, Stephen
Subject: Re: unable to get bigglm working, ATTN: Thomas Lumley



Actually, I think the problem *is* reading in the data

If I try reading in your supplied lines of data with the read.table arguments() 
in your make.data() function I get your error message.
 data-read.table(tmp-textConnection(
+ 97 2007-03-05 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 0 0
+ 97 2007-03-06 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 1 0
+ 97 2007-03-07 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 2 0
+ 97 2007-03-08 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 3 0
+ 97 2007-03-09 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 4 0
+ 97 2007-03-12 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 7 0
+ 97 2007-03-13 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 8 0
+ 97 2007-03-14 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 9 0
+ 97 2007-03-15 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 10 0
+ 97 2007-03-16 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 11 0
+ ), colClasses = list (NULL, Date,Date, integer,
+ factor,rep(numeric,5),rep(integer,2)),
+   col.names = c(id,dt, promdt,term, termfac,
+ commintr,commbal,issuebal,intr,ri,loctime,resp)
+ )
Error in is(object, Class) :
   trying to get slot className from an object of a basic class (list) with 
no slots

My guess is that the problem is that you use list() instead of c() for 
constructing your colClasses argument.  In the code for reading the file that 
you didn't have a problem with, you used c().

-thomas


On Fri, 2 Jul 2010, stephenb wrote:


 I am using an example posted in this help forum to work with a file. the head
 of the file looks like:
 97 2007-03-05 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 0 0
 97 2007-03-06 2007-06-01 90 3 5.450 205500.00 999.00 999.000 0.000 1 0
 97 2007-03-07 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 2 0
 97 2007-03-08 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 3 0
 97 2007-03-09 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 4 0
 97 2007-03-12 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 7 0
 97 2007-03-13 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 8 0
 97 2007-03-14 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 9 0
 97 2007-03-15 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 10 0
 97 2007-03-16 2007-06-01 90 3 5.450 205500.00 999.00 999.000 -0.100 11 0

 the code is:
 make.data - function (filename, chunksize, ...) {
  conn-NULL;
  function (reset=FALSE) {
if (reset) {
  if (!is.null(conn)) {
close(conn);
  };
  conn - file (description=filename, open=r);
} else {
  rval - read.table (conn, nrows=chunksize,sep=' ',
skip=0, header=FALSE,...);
  if (nrow(rval)==0) {
close(conn);
conn-NULL;
rval-NULL;
  } else {
rval$relage - rval$loctime/rval$term;

  };
return(rval);
}
  }
 };

 a - make.data ( filename = G:/sqldata/newf4.csv, chunksize = 10,
  colClasses = list (NULL, Date,Date, integer,
 factor,rep(numeric,5),rep(integer,2)),
  col.names = c(id,dt, promdt,term, termfac,
 commintr,commbal,issuebal,intr,ri,loctime,resp)
 )
 library(biglm);

 bigglm (formula = resp ~ poly(relage,2,raw=TRUE)+termfac+ri ,
  data = a, family = binomial(link='logit'));
 ###   output:
 bigglm (formula = resp ~ poly(relage,2,raw=TRUE)+termfac+ri ,
 +   data = a, family = binomial(link='logit'));
 Error in is(object, Class) :
  trying to get slot className from an object of a basic class (list)
 with no slots


 ### the following can create a df, so the problem is not loading the data
 (maybe :-)
 a - read.table ( G:/sqldata/newf4.csv, nrows= 50, sep=' ',head=F,
  colClasses = c(NULL,
 Date,Date,integer,factor,rep(numeric,5),rep(integer,2)),
  col.names = (id,dt, promdt,term, termfac,
 commintr,commbal,issuebal,intr,ri,loctime,resp)
 )

 Thanks everybody.
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2276524.htmlhttp://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2276524.html?by-user=t
 Sent from the R help mailing list archive at Nabble.com.

 __
 [hidden email]/user/SendEmail.jtp?type=nodenode=2276661i=0 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] unable to get bigglm working, ATTN: Thomas Lumley

2010-07-02 Thread stephenb

after correcting the error spotted by Thomas, I tried again and it goes to
work, but there is no result after 1 hour. 
is there anything I can do to debug?
the dataset has 12mln rows and SAS on a server will produce results in 15
secs. I am running this on PC with XP (hence mem limit of 2.5 gigs) fresh
after restart and no other applications.
thank you.
Stephen
-- 
View this message in context: 
http://r.789695.n4.nabble.com/unable-to-get-bigglm-working-ATTN-Thomas-Lumley-tp2276524p2276747.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] Example function for bigglm (biglm) data input from file

2010-05-25 Thread stephenb

Richard,

do you have an example for an ODBC connection?
Thank you
Stephen
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-Example-function-for-bigglm-biglm-data-input-from-file-tp816496p2230710.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] multiplicative contraint in LS

2010-03-11 Thread stephenb

I have a model that can be estimated in nls

mod.base -
deriv(~(Jan+a1*Feb+a2*Mar+a3*Apr+a4*May+a5*Jun+a6*Jul+a7*Aug+a8*Sep+a9*Oct+a10*Nov+a11*Dec)*(b2*relAge+b3*relAge^2),
  
c(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,b2,b3),
  
function(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,b2,b3,relAge,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec){})

nls1 -
nls(y~mod.base(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,b2,b3,relAge,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec),data=fix1,
start=list(a1=.99,a2=1.01,a3=1.02,a4=1.04,a5=1,a6=1.05,a7=1.06,a8=1.07,a9=1.08,a10=1.09,a11=1.1,b2=.02,b3=-.02))

I would like to estimate with lm/gls to use the greater
decoration/diagnostics available in lm/gls

calling

lm(y~poly(relAge,2,raw=T)*sn-sn-poly(relAge,2,raw=T)-1,data=fix1)

gives me parameters that are not constrained across season eg when I divide 

poly(relAge, 2, raw = T)1:snFeb  / poly(relAge, 2, raw = T)1:snJan 

I get a number which is not identical to 

poly(relAge, 2, raw = T)2:snFeb / poly(relAge, 2, raw = T)2:snJan

which is to be expecetd as I do not constrain. Please, help with
constraining.

The obvious reparametrization leads me to the nls, which does not have
correlation and variance funcs as gls.
Thank you

-- 
View this message in context: 
http://n4.nabble.com/multiplicative-contraint-in-LS-tp1589181p1589181.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] Problem with rcmd SHLIB

2010-03-11 Thread stephenb

I have never got it working with rcmd SHLIB. it is much easier to create a
shared library separately with the C compiler and then load it with dyn.load

the makefiles for SHLIB are quite big and going through them will give you a
headache, so just use the flag for a dll when you compile.
-- 
View this message in context: 
http://n4.nabble.com/Problem-with-rcmd-SHLIB-tp1589180p1589188.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] RPostgreSQL: unable to load shared library

2009-11-04 Thread stephenb

I am trying the same as the post above and the actual error is:

the ordinal 284 could not be located in the dynamic link library
SSLEAY32.dll

I searched for that dll and it is not to be found. windows forums provide
vague directions to reinstall Windows, which I cannot do because this is a
company PC and IT will be happy to tell me that's why open source programs
are not supported and not encouraged.

any suggestions are appreciated.

Stephen


Prof Brian Ripley wrote:
 
 On Wed, 14 Oct 2009, Fanfaar wrote:
 
 Hello list,

 I'm using R 2.9.2 on a WinXP system, and I installed the RPostgreSQL
 library using the package installer. When trying to load it, I get the
 following error:

 library('RPostgreSQL')
 Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
 'C:/PROGRA~1/R/R/library/RPostgreSQL/libs/RPostgreSQL.dll':
  LoadLibrary failure:  The operating system cannot run %1.

 Error: package/namespace load failed for 'RPostgreSQL'

 So one way or the other, the DLL is not found... Does anyone know how
 
 That is not what it says: it says it cannot *load* the DLL.  You need 
 the PostgreSQL client dll in your path, and I guess that (or its 
 version) is the problem.  (Usually Windows gives you a popup with more 
 information, and indeed on my laptop it told me LIBPQ.DLL could not be 
 found.) And pedump suggests that it is linked against entry points by 
 number not name, a very fragile arrangement.
 
 I always worry that packages that link to external DLLs can be very 
 dependent on the version of that DLL (and see the above comment).  I 
 could not see a description of the version of PostgreSQL used on Uwe's 
 ReadMe (assuming this is a binary from CRAN), and suggest (as did the 
 rw-FAQ) that you install RPostgreSQL from source against your own 
 PostgreSQL installation.  (That's what I do on my Windows desktop 
 which does have PostgreSQL installed, and when I updated PostgreSQL I 
 had to re-install PostgreSQL )
 
 to fix this? I don't suppose DLL should be directly in my PATH, right?

 Thanks for any hints,
 Arnout

 __
 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.
 
 Yes another person who thinks that does not apply to them.
 
 
 -- 
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://old.nabble.com/RPostgreSQL%3A-unable-to-load-shared-library-tp25895592p26197137.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] R and Python

2009-11-04 Thread stephenb

Not only RSPython does not support Windows, but it won't compile on most Unix
platforms and fixing it may be more time than writing a package on your own.

Like the other post, I use Python for pre-processing and then load into R.
If you need text processing with line by line access you can also use Java,
which will communicate to R.

cheers
Stephen


Ryan Sheftel-2 wrote:
 
 I am a long time user of R for financial time series analysis (xts, zoo,
 etc) and for my next project I am thinking of adding the Python language
 to
 the mix. The reason for adding Python is primarily its non-statistical
 capabilities.
 
 So my questions are what have people's experiences been with using interop
 between R and Python. I see there are two items, rPy and RSPython. It
 looks
 like rPy makes it possible to call R code from Python, and RSPython goes
 both ways. My needs would be to use Python to drive R to get it's
 extensive
 time series and stats, and also to get to Python objects from inside R.
 
 I searched the list archives and it looks like many people use rPy, but
 what
 about RSPython for calling Python from R? It looks like rPy only goes from
 R
 into Python, and RSPython has not been updated since 2005?
 
 Other messages in the archives state that RSPython only works on Unix?
 
 Would I be foolish to build anything mission critical on RSPython? Is
 there
 a better way to get at Python from R?
 
 Thanks as always.
 
   [[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.
 
 

-- 
View this message in context: 
http://old.nabble.com/R-and-Python-tp26166781p26199643.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] glmmPQL model selection

2009-08-26 Thread stephenb

Sorry for the late reply. 

Just use the first 90% of your data to fit and then predict the last 10% and
see which one is better.
If the random effects are not good it will become very obvious.

If the concern is with fixed effects then just use gls which puts the random
effects in the error and select model as usual.


Emmanuelle TASTARD wrote:
 
 Hi,
 I’m sorry, I know that it is a recurrent question but I have not been
 able to find the response in the Rhelp archives.
 I think my data require the use of the glmmPQL function but I do not
 know how to make the model selection. Since the AIC and log-likelihood
 are apparently meaningless, how can we select the parameters for a model
 and compare the models to find which one fits best the data?  
 Thanks a lot
 Emmanuelle Tastard
  
 Emmanuelle TASTARD
 UMR 5174 'Evolution et Diversité Biologique'  
 Université Paul Sabatier Bat 4R3
 31062 TOULOUSE CEDEX 9 France
 tel : 05 61 55 67 59
  
 
   [[alternative HTML version deleted]]
 
 
 __
 r-h...@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 

-- 
View this message in context: 
http://www.nabble.com/glmmPQL-model-selection-tp3027224p25151417.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] glmmPQL and variance structure

2009-08-26 Thread stephenb

this is very late, but I saw this now as I am dealing with it now:

I think varPower should not be needed here. The family should be one of the
quasi families eg quasibinomial and that will automatically allow
variance/dispersion to become a function of the fit. This is a feature of
glm inherently, which does not exist in lme, so it is called with varPower
(in lme).

If you see that, pls post whether it works as expected on the original
dataset.

regards
Stephen




Spencer Graves wrote:
 
 Thanks for providing a partially reproducible example.  I believe the 
 error message you cite came from lme.  I say this, because I modified 
 your call to glmmPQL2 to call lme and got the following:
 
   library(nlme)
   fit.lme - lme(y ~ trt + I(week  2), random = ~ 1 | ID,
 +  data = bacteria, weights=varPower(~1))
 Error in unlist(x, recursive, use.names) :
   argument not a list
 
 I consulted Pinheiro and Bates (2000) Mixed-Effects Models in S and 
 S-Plus (Springer, sec. 5.2, p.211) to see that the syntax for varPower 
 appears to be correct.  I removed ~ and it worked, mostly:
 
   fit.lme - lme(y ~ trt + I(week  2), random = ~ 1 | ID,
 +  data = bacteria, weights=varPower(1))
 Warning message:
 - not meaningful for factors in: Ops.factor(y[revOrder], Fitted)
 
 I got an answer, though with a warning and not for the problem you 
 want to solve.  However, I then made this modification to a call to my 
 own modification of Venables and Ripley's glmmPQL and it worked:
 
   fit. - glmmPQL.(y ~ trt + I(week  2), random = ~ 1 | ID,
 +  family = binomial, data = bacteria,
 +  weights.lme=varPower(1))
 iteration 1
 iteration 2
 iteration 3
   fit.
 Linear mixed-effects model fit by maximum likelihood
Data: bacteria
Log-likelihood: -541.0882
Fixed: y ~ trt + I(week  2)
  (Intercept) trtdrugtrtdrug+ I(week  2)TRUE
2.7742329  -1.0852566  -0.5896635  -1.2682626
 
 Random effects:
   Formula: ~1 | ID
   (Intercept) Residual
 StdDev: 4.940885e-05 2.519018
 
 Variance function:
   Structure: Power of variance covariate
   Formula: ~fitted(.)
   Parameter estimates:
  power
 0.3926788
 Number of Observations: 220
 Number of Groups: 50
  
 This function glmmPQL. adds an argument weights.lme to Venables 
 and Ripley's glmmPQL and uses that in place of 
 'quote(varFixed(~invwt))' when provided;  see below.
 
 hope this helps.
 spencer graves
 glmmPQL. -
 function (fixed, random, family, data, correlation, weights,
  weights.lme, control, niter = 10, verbose = TRUE, ...)
 {
  if (!require(nlme))
  stop(package 'nlme' is essential)
  if (is.character(family))
  family - get(family)
  if (is.function(family))
  family - family()
  if (is.null(family$family)) {
  print(family)
  stop('family' not recognized)
  }
  m - mcall - Call - match.call()
  nm - names(m)[-1]
  wts.lme - mcall$weights.lme
  keep - is.element(nm, c(weights, data, subset, na.action))
  for (i in nm[!keep]) m[[i]] - NULL
  allvars - if (is.list(random))
  allvars - c(all.vars(fixed), names(random),
 unlist(lapply(random,
  function(x) all.vars(formula(x)
  else c(all.vars(fixed), all.vars(random))
  Terms - if (missing(data))
  terms(fixed)
  else terms(fixed, data = data)
  off - attr(Terms, offset)
  if (length(off - attr(Terms, offset)))
  allvars - c(allvars, as.character(attr(Terms, variables))[off
 +
  1])
  m$formula - as.formula(paste(~, paste(allvars, collapse = +)))
  environment(m$formula) - environment(fixed)
  m$drop.unused.levels - TRUE
  m[[1]] - as.name(model.frame)
  mf - eval.parent(m)
  off - model.offset(mf)
  if (is.null(off))
  off - 0
  w - model.weights(mf)
  if (is.null(w))
  w - rep(1, nrow(mf))
  mf$wts - w
  fit0 - glm(formula = fixed, family = family, data = mf,
  weights = wts, ...)
  w - fit0$prior.weights
  eta - fit0$linear.predictor
  zz - eta + fit0$residuals - off
  wz - fit0$weights
  fam - family
  nm - names(mcall)[-1]
  keep - is.element(nm, c(fixed, random, data, subset,
  na.action, control))
  for (i in nm[!keep]) mcall[[i]] - NULL
  fixed[[2]] - quote(zz)
  mcall[[fixed]] - fixed
  mcall[[1]] - as.name(lme)
  mcall$random - random
  mcall$method - ML
  if (!missing(correlation))
  mcall$correlation - correlation
 #   weights.lme
  {
   if(is.null(wts.lme))
 mcall$weights - quote(varFixed(~invwt))
   else
 mcall$weights - wts.lme
 }
  mf$zz - zz
  mf$invwt - 1/wz
  mcall$data - mf
  for (i in 1:niter) {
  if (verbose)
  cat(iteration, i, \n)
  fit - eval(mcall)
  etaold - eta
  eta - 

Re: [R] how to specify two variance effects in gls

2009-08-20 Thread stephenb

I got the answer:

weights=varComb(varFixed(~1/n),varPower(~Age))



Bond, Stephen-2 wrote:
 
 Hello everybody,
 
 I have a dataset where each row has number of subjects and that gives me
 natural weights for the variance function. Additionally I see that
 variance increases with Age, which is a regressor.
 So using gls I have
 
 
 
 weights=varFixed(~1/n)
 
 but don't know how to include the extra effect of the regressor.
 Fitted values show a quadratic curve vs. age, not sure if that helps.
 
 Thanks everybody.
 Stephen
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/how-to-specify-two-variance-effects-in-gls-tp25044356p25061604.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] .RData signature

2009-07-13 Thread stephenb

any ideas? has anybody tried to recover RData files before?




Duncan Murdoch-2 wrote:
 
 On 7/13/2009 3:38 PM, sten...@go.com wrote:
Is there a way to identify the beginning and end of an .RData file?
I am trying to restore lost files on opensolaris where the table of
 contents
is overwritten and will be reading the raw disk byte by byte.
I looked at several files in hex and the end seems different, while
 most of
them, but not all begin with RDX2.X
 
 No, there is nothing special written at the end of a file.  Many .RData 
 files are compressed (by internal gzip), so the RDX2 header is hidden, 
 and you'll see bytes 1F 8B instead.  (I don't think we write the trailer 
 bytes on the gzip stream, but I'm not sure about that.)
 
 Duncan Murdoch
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/.RData-signature-tp24468047p24472875.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] text() to label points in ggplot

2009-05-14 Thread stephenb

is there a way to label points in a graph using text(locator(1),text)
after ggplot() or qplot() ?

 qplot(date, psavert, data = economics, geom = line,main=jhdjd)-p
 p+opts(text(locator(1),),new=T)

does not work.
-- 
View this message in context: 
http://www.nabble.com/text%28%29-to-label-points-in-ggplot-tp23545135p23545135.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] Merging data frames, or one column/vector with a data frame filling out empty rows with NA's

2009-04-27 Thread stephenb

You are exceeding your max memory here, so R will not be able to do that. 
dump both tables into a db such as mysql and then run the query either from
RMySQL or from mysql directly. then output the result and import back in R.

that will take care of the merge, but not sure what will happen when you
actually try to run some stats on the object. it is very likely the
operation will exceed memory again.

in the end you may have to write your own code which does not attempt to
load everything in memory, it could be either R or a lower level language.

if you have SAS it will probably work as it deals with large sets in long
format well. depending on what you do R may be able to deal with it after a
reshape() to a wide format.


joe1985 wrote:
 
 Hello
 
 I have two data frames, SNP4 and SNP1:
 
 head(SNP4)
   Animal MarkerY
 3213 194073197  P1001 0.021088
 1295 194073197  P1002 0.021088
 915   194073197  P1004 0.021088
 2833 194073197  P1005 0.021088
 1487 194073197  P1006 0.021088
 1885 194073197  P1007 0.021088
 
 head(SNP1)
AnimalMarker x
 3213 194073197  P1001 2
 1295 194073197  P1002 1
 915   194073197  P1004 2
 2833 194073197  P1005 0
 1487 194073197  P1006 2
 1885 194073197  P1007 0
 
 I want these two data frames merged by 'Marker', but when i try 
 
 SNP5 - merge(SNP4, SNP1, by = 'Marker', all = TRUE)
 Error: cannot allocate vector of size 2.4 Gb
 In addition: Warning messages:
 1: In merge.data.frame(SNP4, SNP1, by = Marker, all = TRUE) :
   Reached total allocation of 1535Mb: see help(memory.size)
 2: In merge.data.frame(SNP4, SNP1, by = Marker, all = TRUE) :
   Reached total allocation of 1535Mb: see help(memory.size)
 3: In merge.data.frame(SNP4, SNP1, by = Marker, all = TRUE) :
   Reached total allocation of 1535Mb: see help(memory.size)
 4: In merge.data.frame(SNP4, SNP1, by = Marker, all = TRUE) :
   Reached total allocation of 1535Mb: see help(memory.size)
 
 And error occurs.
 
 What i want is the column SNP1$x merged together with SNP4 by Marker, so
 some markers will have NA's in the 'x'-column in the SNP5 dataset.
 
 I also tried this
 
 SNP5 - merge(SNP4, SNP1$x, by.x = 'Marker', by.y = 'Marker', all = TRUE) 
 Error in fix.by(by.y, y) : 'by' must specify valid column(s)
 
 I won't work either. 
 
 Does anyone have any idea how to solve this.
 
 Regards,
 
 Johannes.
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Merging-data-frames%2C-or-one-column-vector-with-a-data-frame-filling-out-empty-rows-with-NA%27s-tp23171110p23259062.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] dll problem

2008-07-14 Thread stephenb

I am trying to load a dll compiled with the latest cygwin into R 2.7.0
R version 2.7.0 (2008-04-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

I have:
Sys.getenv(Path)

 
Path
C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Program
Files\\MBTrading\\MBT Navigator;C:\\Program
Files\\R\\R-2.7.0\\bin;C:\\cygwin\\bin

the source is:
!!! f1.f
   SUBROUTINE f1(a)

  INTEGER :: a, i
  a=2

  RETURN

  END SUBROUTINE f1

compiled by

g77 -shared -o f1.dll f1.f

R freezes and I have to kill it with task manager
when I try:
dyn.load(f1.dll)

Please, help.
-- 
View this message in context: 
http://www.nabble.com/dll-problem-tp18448005p18448005.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.