[R] Problem using stepAIC/addterm (MASS package)

2005-02-25 Thread BEER Michael
Hello,

I'm currently dealing with a rather strange problem when using the
function stepAIC (MASS package).  The setting is the following: From
model learning data sets (learndata), I want to be able to build
prediction functions (in order to save them in a file for further use).
This is done by the function pred.function (see below). Therein, I'd
like to use stepAIC for model selection.

However, if I try to evaluate pred.function for a specific data set, R
sometimes stops with the message

---
Error in inherits(x, data.frame) : Object learndata not found
---

Debugging stepAIC showed me that the problem occurs in the step where
addterm is called. addterm somehow doesn't seem to see the object
learndata which is present (?) in the function's environment.

Here is my code. The dataset BostonHousing is just an example for
which this problem can be observed. my.MC is inspired by the Lexical
scoping section in the R FAQ
(http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html#Lexical-scoping).

---
data(BostonHousing, package = mlbench)
my.MC - function (f, env) f  # make closure

pred.function - function (learndata) {

my.model - lm(medv ~ ., learndata)

if (!require(MASS))
stop(Package MASS not loadable.)

my.model - stepAIC(my.model, 
scope = list(lower = medv ~ 1, 
upper = medv ~ .))

my.MC(function(newdata) {
predict(my.model, newdata)
},
list(my.model = my.model)
)
}

pf - pred.function(BostonHousing)
---

How can I tell addterm (or stepAIC) where to find learndata?

Thanks for your help.

Regards
Michael

-- 
Michael Beer, dipl. math., University of Freiburg/Fribourg Switzerland
Seminar of Statistics, Av. de Beauregard 13, CH-1700 Freiburg
Phone +41 26 300 8278, Fax +41 26 300 9781
E-mail: [EMAIL PROTECTED], Web: http://www.unifr.ch/stat/

__
R-help@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


Re: [R] Database Connection Problem with RMySQL package

2005-01-29 Thread BEER Michael
 My setup is as follows:
 
 Microsoft Windows XP 5.1.2600
 MySQL 4.1.9
 R 2.0.1
 DBI 0.1-8
 RMySQL 0.5-5
 
 [...] 

  dbname=campus)
 Error in mysqlNewConnection(drv, ...) : RS-DBI driver: (could 
 not connect [EMAIL PROTECTED] on dbname campus)
 
 What am I doing wrong with?... It is really an annoying question.
 Thank you very much for your help and patience.


Make sure your MySQL server accepts pre-4.1-style passwords for the user
you log on with (cf. http://dev.mysql.com/doc/mysql/en/old-client.html).
The MySQL library included in RMySQL 0.5-5 comes from the 4.0.18
distribution and uses an old authentication protocol that isn't
compatible with the one implemented in MySQL 4.1.x.

Hope this helps.

Michael

__
R-help@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


[R] Parallel computations using snow: how to combine boot objects?

2005-01-21 Thread BEER Michael
Hello,

I'm trying to do some bootstrapping in a parallel environment (Linux
cluster) in order to estimate confidence intervals for a certain
parameter. Following the example in the documentation of the snow
package (http://www.stat.uiowa.edu/~luke/R/cluster/cluster.html), I
launch my computations by something like

 cl.nuke.boot -
+ clusterCall(cl,boot,nuke.data, nuke.fun, R=500, m=1,
+ fit.pred=new.fit, x.pred=new.data)

which gives me a list of n boot objects (where n is the number of nodes
in my cluster). So far, so good.

However, if I now want to go further, I need to combine all these boot
objects to a single one which I can pass to boot.ci for example. Is
there a recommended way to do this?

Thanks,
Michael

__
R-help@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


RE: [R] PHP MySQL and R

2004-12-17 Thread BEER Michael
 ---
 Problem #1:
 ...
 ---

Consider using the library RMySQL (available at
http://stat.bell-labs.com/RS-DBI/download/) for directly accessing your
MySQL database from R.

--- bla.R ---
library(RMySQL)
con - dbConnect(dbDriver(MySQL), 
  group = your group name as defined in $HOME/.my.cnf)
res - dbSendQuery(con, 
  SELECT x,y,lagged FROM DATA WHERE ds_id=(whatever dataset))
userdata - fetch(res, n = -1)
...
--- * ---

The only parameter you need to pass to your script from PHP would thus
be the current dataset ID. Maybe someone else can advise you on how to
do this in an elegant way.

 
 ---
 Problem #2:
 ...
 -

Paste the appropriate values of summary.lm into an SQL statement
(INSERT INTO ...) and send this command to your database using
dbSendQuery(...) again.

Yours, Michael.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html