Re: [R] package installation fails only for "sp"

2006-12-01 Thread Prof Brian Ripley
Sorry, I missed that 'i686 redhat' might mean Red Hat, that is a form of 
Linux.  The advice in the first para applies: the current version of 'sp' 
in the source area on CRAN is for R>=2.4.0: see

http://cran.r-project.org/src/contrib/Descriptions/sp.html

If you cannot update your R, there are versions of 'sp' available in the 
Archive area on CRAN that willl work with R 2.3.1.

On Sat, 2 Dec 2006, Prof Brian Ripley wrote:

> One thing you did miss was the request in the posting guide to update to the 
> latest version of R before posting.
>
> Note that it is the download that fails, not the installation.  There is a 
> binary version of 'sp' for R 2.3.x on the CRAN master, so it looks like a 
> problem with the CRAN mirror you are using -- but of course I don't have an 
> outdated version of R installed to cross-check.
>
> On Fri, 1 Dec 2006, Don McKenzie wrote:
>
>> I have escaped Splus for Windows (mostly) and have started using
>> R (v 2.3.1 on i686 redhat).  Installing packages has been routine except
>> for "sp" (classes and methods for spatial data).  I get the following error
>> message
>> 
>> > install.packages("sp")
>> Warning in 
>> download.packages(unique(pkgs),destdir=tmpd,available=available,:
>>no package 'sp'  at the repositories
>> 
>> Clearly I am missing something (probably obvious), but can someone
>> enlighten me
>> as to why the behavior of this package installation is different from
>> others?  sp is
>> listed under "Contributed packages" at the R-project URL.  Thank you
>> for your time.
>> 
>> 
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] package installation fails only for "sp"

2006-12-01 Thread Prof Brian Ripley
One thing you did miss was the request in the posting guide to update to 
the latest version of R before posting.

Note that it is the download that fails, not the installation.  There is a 
binary versioon of 'sp' for R 2.3.x on the CRAN master, so it looks like a 
problem with the CRAN mirror you are using -- but of course I don't have 
an outdated version of R installed to cross-check.

On Fri, 1 Dec 2006, Don McKenzie wrote:

> I have escaped Splus for Windows (mostly) and have started using
> R (v 2.3.1 on i686 redhat).  Installing packages has been routine except
> for "sp" (classes and methods for spatial data).  I get the following error
> message
>
> > install.packages("sp")
> Warning in download.packages(unique(pkgs),destdir=tmpd,available=available,:
>no package 'sp'  at the repositories
>
> Clearly I am missing something (probably obvious), but can someone
> enlighten me
> as to why the behavior of this package installation is different from
> others?  sp is
> listed under "Contributed packages" at the R-project URL.  Thank you
> for your time.
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is there a better way for inputing data manually?

2006-12-01 Thread Duncan Murdoch
On 12/1/2006 11:00 PM, Wei-Wei Guo wrote:
> Dear All,
> 
> I have worked with R for some time. It's a great tool for data analysis. But 
> it's too hard to inputing raw data manually with R (I don't mean importing 
> data. R is good at importing data). Maybe it's not a focused topic in this 
> list, but I don't know other place where I can ask the question. How do you 
> do when inputing data from a paper material, such as questionnaire, or what 
> do you use ?

I would not use R for this.  Depending on how many questionnaires I had, 
from small number to large, I would use:

1.  A text file.
2.  A spreadsheet, like Excel, or the OpenOffice one, or the R data editor.
3.  A custom program written specifically to handle the particular 
questionnaire.

You can do 1 and 2 in R, but you can't do them as well as programs 
dedicated to those tasks, and you can't do 3 at all well.  It depends a 
lot on the specific conventions of the platform you're working on.  R is 
aimed at writing cross-platform programs, and isn't particularly good at 
writing GUI programs, which is what you want here.  I would personally 
use Delphi for this, but there are lots of alternatives.

Duncan Murdoch

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Is there a better way for inputing data manually?

2006-12-01 Thread Wei-Wei Guo

Dear All,

I have worked with R for some time. It's a great tool for data analysis. But 
it's too hard to inputing raw data manually with R (I don't mean importing 
data. R is good at importing data). Maybe it's not a focused topic in this 
list, but I don't know other place where I can ask the question. How do you do 
when inputing data from a paper material, such as questionnaire, or what do you 
use ?

Best wishes,
Wei-Wei

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quadratic Optimization

2006-12-01 Thread Spencer Graves
  Unless I'm missing something, optimizing a linear function with 
quadratic constraints is almost trivial with Langrange multipliers. 

  Maximize a'x subject to x'Ax=c. 

  S = Lagrange objective = a'x+lam*(x'Ax-c). 
  dS/dx = a + 2*lam*Ax. 
 
  Given lam, x1 = solve(A, a)/(2*lam) 

  Then x = c*x1/(x'Ax) 

  In R, you need to know that "t" = transpose of a matrix. 

  I thought I had seen mention of a contributed package for 
optimization with nonlinear constraints.  However, you don't need that 
here. 

  In case this does not solve your problem, my crude engineer's 
approach to constrained optimization includes the following: 

  (1) Find transformation to send the constraints to +/-Inf. 

  (2) If that fails, add the constraints as a penalty.  Start with a 
low penalty and gradually increase it if necessary until you solve the 
problem.  Of course, to do this, you have to make sure your objective 
function returns valid numbers outside the constrained region. 

  How's this? 
  Spencer Graves

amit soni wrote:
> Hi,
>
> I need to solve an optimization problem in R having linear objective function 
> and quadratic constraints(number of variables is around 80).  What are the 
> possible choices to do this in R.
> optim() function only allows box constrained problems. Is it possible in 
> nlm()? Or please tell me if there is any other routine.
>
> Thanks
>
> Amit
>
>
>
>
>  
> 
> Cheap talk?
>
>
>   [[alternative HTML version deleted]]
>
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.
>

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] fixup for debug package and R2.4.0

2006-12-01 Thread Mark.Bravington
A number of users have spotted a terminal problem with the 'debug' package 
under R2.4.0, along the lines of 

> mtrace(x)
> x()
Error in attr(value, "row.names") <- rlabs :
 row names must be 'character' or 'integer', not 'double' 

This arose from a bug in 'rbind.data.frame' in R2.4.0 itself. The bug is fixed 
in R2.4.0 patched, so the best solution is to install the patched version. This 
is painless, at least for Windows, since a binary version of R-patched is 
available on CRAN (I hadn't realized this).

If for reason you desperately don't want to install R-patched, the following 
*ugly* bit of code can be run after loading the 'debug' library [so you could 
put this in your '.First' function]:

Thanks to all who reported the problem

Mark Bravington
[EMAIL PROTECTED]

mvbutils:::assign.to.base( 'rbind.data.frame', function (..., deparse.level = 
1) 
{
match.names <- function(clabs, nmi) {
if (all(clabs == nmi)) 
NULL
else if (length(nmi) == length(clabs) && all(nii <- match(nmi, 
clabs, 0))) {
m <- pmatch(nmi, clabs, 0)
if (any(m == 0)) 
stop("names do not match previous names")
m
}
else stop("names do not match previous names:\n\t", paste(nmi[nii == 
0], collapse = ", "))
}
Make.row.names <- function(nmi, ri, ni, nrow) {
if (nchar(nmi) > 0) {
if (ni == 0) 
character(0)
else if (ni > 1) 
paste(nmi, ri, sep = ".")
else nmi
}
else if (nrow > 0 && identical(ri, 1:ni)) 
as.integer(seq.int(from = nrow + 1, length = ni))
else ri
}
allargs <- list(...)
allargs <- allargs[sapply(allargs, length) > 0]
n <- length(allargs)
if (n == 0) 
return(structure(list(), class = "data.frame", row.names = integer()))
nms <- names(allargs)
if (is.null(nms)) 
nms <- character(length(allargs))
cl <- NULL
perm <- rows <- rlabs <- vector("list", n)
nrow <- 0
value <- clabs <- NULL
all.levs <- list()
for (i in 1:n) {
xi <- allargs[[i]]
nmi <- nms[i]
if (is.matrix(xi)) 
allargs[[i]] <- xi <- as.data.frame(xi)
if (inherits(xi, "data.frame")) {
if (is.null(cl)) 
cl <- oldClass(xi)
ri <- attr(xi, "row.names")
ni <- length(ri)
if (is.null(clabs)) 
clabs <- names(xi)
else {
pi <- match.names(clabs, names(xi))
if (!is.null(pi)) 
  perm[[i]] <- pi
}
rows[[i]] <- seq.int(from = nrow + 1, length = ni)
rlabs[[i]] <- Make.row.names(nmi, ri, ni, nrow)
nrow <- nrow + ni
if (is.null(value)) {
value <- unclass(xi)
nvar <- length(value)
all.levs <- vector("list", nvar)
has.dim <- logical(nvar)
facCol <- logical(nvar)
ordCol <- logical(nvar)
for (j in 1:nvar) {
  xj <- value[[j]]
  if (!is.null(levels(xj))) {
all.levs[[j]] <- levels(xj)
facCol[j] <- TRUE
  }
  else facCol[j] <- is.factor(xj)
  ordCol[j] <- is.ordered(xj)
  has.dim[j] <- length(dim(xj)) == 2
}
}
else for (j in 1:nvar) {
xij <- xi[[j]]
if (is.null(pi) || is.na(jj <- pi[[j]])) 
  jj <- j
if (facCol[jj]) {
  if (length(lij <- levels(xij)) > 0) {
all.levs[[jj]] <- unique(c(all.levs[[jj]], 
  lij))
ordCol[jj] <- ordCol[jj] & is.ordered(xij)
  }
  else if (is.character(xij)) 
all.levs[[jj]] <- unique(c(all.levs[[jj]], 
  xij))
}
}
}
else if (is.list(xi)) {
ni <- range(sapply(xi, length))
if (ni[1] == ni[2]) 
ni <- ni[1]
else stop("invalid list argument: all variables should have the 
same length")
rows[[i]] <- ri <- as.integer(seq.int(from = nrow + 
1, length = ni))
nrow <- nrow + ni
rlabs[[i]] <- Make.row.names(nmi, ri, ni, nrow)
if (length(nmi <- names(xi)) > 0) {
if (is.null(clabs)) 
  clabs <- nmi
else {
  tmp <- match.names(clabs, nmi)
  if (!is.null(tmp)) 
perm[[i]] <- tmp
}
}
}
else if (length(xi) > 0) {
rows[[i]] <- nrow <- nrow + 1
rlabs[[i]] <- if (nchar(nmi) > 0) 
nmi
else as.integer(nrow)

Re: [R] package installation fails only for "sp"

2006-12-01 Thread Peter Dalgaard
Don McKenzie wrote:
> I have escaped Splus for Windows (mostly) and have started using
> R (v 2.3.1 on i686 redhat).  Installing packages has been routine except
> for "sp" (classes and methods for spatial data).  I get the following error
> message
>
>  > install.packages("sp")
> Warning in download.packages(unique(pkgs),destdir=tmpd,available=available,:
> no package 'sp'  at the repositories
>  
> Clearly I am missing something (probably obvious), but can someone 
> enlighten me
> as to why the behavior of this package installation is different from 
> others?  sp is
> listed under "Contributed packages" at the R-project URL.  Thank you
> for your time.
>
>   
Try looking at the Depends: field

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] cloud() question

2006-12-01 Thread Deepayan Sarkar
On 12/1/06, Michelle DePrenger-Levin <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to plot lines in 3 dimensions from a multiple linear model
> to illustrate the interaction of two of the explanatory variables. I'm
> trying to use the cloud function (though I'm open to a different
> function if an easier one exists). I keep getting the error message:
>
> Error in cloud(lmPeHa061201, data = PeHa061201, cex = 0.8, main =
> "Table 99: PeHa",  :
> no applicable method for "cloud"
>
> I have tried to make my command look just like the examples but am at a
> loss as to why I don't have an "applicable method". I enter:
>
> lmPeHa061201=lm(sqrtplants~sqrtPlantsPrev+Site+NumFruitedPrev+HerbPrevious+RainfallJulyJuneprev+RainfallJulyJune+
> (Site*HerbPrevious)+(HerbPrevious*NumFruitedPrev)+(RainfallJulyJune*RainfallJulyJuneprev),
> data=PeHa061201)
>
> par.set <-
> list(axis.line = list(col = "transparent"), clip = list(panel =
> FALSE))
>
> print(cloud(lmPeHa061201, data=PeHa061201, cex = .8,
>  screen = list(z=20, x=-70, y=0),
>  par.settings = par.set,
>  distance = .4, zoom = .6))

What example does this look like exactly? Normally, the first argument
of cloud has to be a formula that looks like 'z ~ x * y'. In your
call, it is the result of a call to lm, which among other things, is
not a formula.

It's difficult to suggest alternatives without a reproducible example.

> If I could get past this error, I'd like to add a line (with abline()
> ??) to show just one (and then potentially others on the same plot) of
> the interaction factors but I'm not sure if this will work either.

Probably not. Adding stuff to 3-d plots are harder than for 2-d plots.

-Deepayan

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] cloud() question

2006-12-01 Thread Michelle DePrenger-Levin
Hello,
 
I am trying to plot lines in 3 dimensions from a multiple linear model
to illustrate the interaction of two of the explanatory variables. I'm
trying to use the cloud function (though I'm open to a different
function if an easier one exists). I keep getting the error message:
 
Error in cloud(lmPeHa061201, data = PeHa061201, cex = 0.8, main =
"Table 99: PeHa",  : 
no applicable method for "cloud"

I have tried to make my command look just like the examples but am at a
loss as to why I don't have an "applicable method". I enter: 
 
lmPeHa061201=lm(sqrtplants~sqrtPlantsPrev+Site+NumFruitedPrev+HerbPrevious+RainfallJulyJuneprev+RainfallJulyJune+
(Site*HerbPrevious)+(HerbPrevious*NumFruitedPrev)+(RainfallJulyJune*RainfallJulyJuneprev),
data=PeHa061201)

par.set <-
list(axis.line = list(col = "transparent"), clip = list(panel =
FALSE))
 
print(cloud(lmPeHa061201, data=PeHa061201, cex = .8, 
 screen = list(z=20, x=-70, y=0),
 par.settings = par.set,
 distance = .4, zoom = .6))
 
If I could get past this error, I'd like to add a line (with abline()
??) to show just one (and then potentially others on the same plot) of
the interaction factors but I'm not sure if this will work either. 
 
Any thoughts?
 
Thanks,
 
Michelle

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error in hetcor function (polycor package)?

2006-12-01 Thread BRENDAN KLICK
Yes, that's it.

 hetcor(x1, x2, y1, y2) 
 hetcor(data, use="pairwise.complete.obs")

works but

 hetcor(x1, x2, y1, y2, use="complete.obs") 
 hetcor(x1, x2, y1, y2, use="pairwise.complete.obs") 

do not.  Thanks very much!

Brendan

>>> John Fox <[EMAIL PROTECTED]> 12/01/06 6:19 PM >>>
Dear Brendan,

That's curious, because the use argument to hetcor() works fine for me
(see
below). Is it possible that you tried to use this argument without
specifying a data frame as the first argument to hetcor? If so, please
see
?hetcor. If not, it would help to have an example.

I hope this helps,
 John

 snip -

> set.seed(12345) # adapting the example in ?hetcor
> R <- matrix(0, 4, 4)
> R[upper.tri(R)] <- runif(6)
> diag(R) <- 1
> R <- cov2cor(t(R) %*% R)
> round(R, 4)  # population correlations
   [,1]   [,2]   [,3]   [,4]
[1,] 1. 0.5848 0.5718 0.6233
[2,] 0.5848 1. 0.7374 0.6249
[3,] 0.5718 0.7374 1. 0.5923
[4,] 0.6233 0.6249 0.5923 1.
> data <- rmvnorm(1000, rep(0, 4), R)
> round(cor(data), 4)   # sample correlations
   [,1]   [,2]   [,3]   [,4]
[1,] 1. 0.5933 0.5659 0.6088
[2,] 0.5933 1. 0.7334 0.6230
[3,] 0.5659 0.7334 1. 0.5802
[4,] 0.6088 0.6230 0.5802 1.
> x1 <- data[,1]
> x2 <- data[,2]
> y1 <- cut(data[,3], c(-Inf, .75, Inf))
> y2 <- cut(data[,4], c(-Inf, -1, .5, 1.5, Inf))
> data <- data.frame(x1, x2, y1, y2)
> data[1,1] <- NA
> hetcor(data) 

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6316 0.5708  1

Standard Errors:
x1  x2 y1
x1   
x2 0.02053   
y1 0.03092 0.02296   
y2 0.02027 0.01995 0.0374

n = 999 

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4782   
y1 0.4023 0.8871
y2 0.1166 0.5077 0.05526

> hetcor(data, use = "complete.obs")

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6316 0.5708  1

Standard Errors:
x1  x2 y1
x1   
x2 0.02053   
y1 0.03092 0.02296   
y2 0.02027 0.01995 0.0374

n = 999 

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4782   
y1 0.4023 0.8871
y2 0.1166 0.5077 0.05526

> hetcor(data, use = "pairwise.complete.obs")

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6317 0.5711  1

Standard Errors/Numbers of Observations:
x1  x2  y1   y2
x1 999 999 999  999
x2 0.0205310001000 1000
y1 0.03092 0.022951000 1000
y2 0.02027 0.01994 0.03738 1000

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4952   
y1 0.4023  0.878
y2 0.1166 0.5255 0.05615


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of BRENDAN KLICK
> Sent: Friday, December 01, 2006 1:42 PM
> To: r-help@stat.math.ethz.ch 
> Subject: [R] error in hetcor function (polycor package)?
> 
> I have been using the hetcor function in the polycor package. 
>  When I don't specify the use option everything runs 
> smoothly.  However, when I specify use either as 
> "pairwise.complete.obs" or "complete.obs" I get this error
>  
> Error in optim(rho, f, control = control, hessian = TRUE, method =
> "BFGS") : 
> non-finite value supplied by optim
> 
> Is this an error in the hetcor function or am I missing something. 
> Thanks for your help.
>  
> Brendan Klick
> Johns Hopkins University School of Medicine [EMAIL PROTECTED] 
> 
>   [[alternative HTML version deleted]]
> 
> __
> 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 
> and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] package installation fails only for "sp"

2006-12-01 Thread Don McKenzie
I have escaped Splus for Windows (mostly) and have started using
R (v 2.3.1 on i686 redhat).  Installing packages has been routine except
for "sp" (classes and methods for spatial data).  I get the following error
message

 > install.packages("sp")
Warning in download.packages(unique(pkgs),destdir=tmpd,available=available,:
no package 'sp'  at the repositories
 
Clearly I am missing something (probably obvious), but can someone 
enlighten me
as to why the behavior of this package installation is different from 
others?  sp is
listed under "Contributed packages" at the R-project URL.  Thank you
for your time.

-- 
___

Don McKenzie, Research Ecologist
Pacific Wildland Fire Sciences Lab
USDA Forest Service
400 N 34th St. #201
Seattle, WA 98103, USA
(206) 732-7824
[EMAIL PROTECTED]

Affiliate Assistant Professor
College of Forest Resources 
CSES Climate Impacts Group
University of Washington
[EMAIL PROTECTED]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error in hetcor function (polycor package)?

2006-12-01 Thread John Fox
Dear Brendan,

That's curious, because the use argument to hetcor() works fine for me (see
below). Is it possible that you tried to use this argument without
specifying a data frame as the first argument to hetcor? If so, please see
?hetcor. If not, it would help to have an example.

I hope this helps,
 John

 snip -

> set.seed(12345) # adapting the example in ?hetcor
> R <- matrix(0, 4, 4)
> R[upper.tri(R)] <- runif(6)
> diag(R) <- 1
> R <- cov2cor(t(R) %*% R)
> round(R, 4)  # population correlations
   [,1]   [,2]   [,3]   [,4]
[1,] 1. 0.5848 0.5718 0.6233
[2,] 0.5848 1. 0.7374 0.6249
[3,] 0.5718 0.7374 1. 0.5923
[4,] 0.6233 0.6249 0.5923 1.
> data <- rmvnorm(1000, rep(0, 4), R)
> round(cor(data), 4)   # sample correlations
   [,1]   [,2]   [,3]   [,4]
[1,] 1. 0.5933 0.5659 0.6088
[2,] 0.5933 1. 0.7334 0.6230
[3,] 0.5659 0.7334 1. 0.5802
[4,] 0.6088 0.6230 0.5802 1.
> x1 <- data[,1]
> x2 <- data[,2]
> y1 <- cut(data[,3], c(-Inf, .75, Inf))
> y2 <- cut(data[,4], c(-Inf, -1, .5, 1.5, Inf))
> data <- data.frame(x1, x2, y1, y2)
> data[1,1] <- NA
> hetcor(data) 

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6316 0.5708  1

Standard Errors:
x1  x2 y1
x1   
x2 0.02053   
y1 0.03092 0.02296   
y2 0.02027 0.01995 0.0374

n = 999 

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4782   
y1 0.4023 0.8871
y2 0.1166 0.5077 0.05526

> hetcor(data, use = "complete.obs")

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6316 0.5708  1

Standard Errors:
x1  x2 y1
x1   
x2 0.02053   
y1 0.03092 0.02296   
y2 0.02027 0.01995 0.0374

n = 999 

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4782   
y1 0.4023 0.8871
y2 0.1166 0.5077 0.05526

> hetcor(data, use = "pairwise.complete.obs")

Two-Step Estimates

Correlations/Type of Correlation:
   x1  x2 y1 y2
x1  1 Pearson Polyserial Polyserial
x2 0.5932   1 Polyserial Polyserial
y1 0.5952  0.7409  1 Polychoric
y2  0.624  0.6317 0.5711  1

Standard Errors/Numbers of Observations:
x1  x2  y1   y2
x1 999 999 999  999
x2 0.0205310001000 1000
y1 0.03092 0.022951000 1000
y2 0.02027 0.01994 0.03738 1000

P-values for Tests of Bivariate Normality:
   x1 x2  y1
x1  
x2 0.4952   
y1 0.4023  0.878
y2 0.1166 0.5255 0.05615


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of BRENDAN KLICK
> Sent: Friday, December 01, 2006 1:42 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] error in hetcor function (polycor package)?
> 
> I have been using the hetcor function in the polycor package. 
>  When I don't specify the use option everything runs 
> smoothly.  However, when I specify use either as 
> "pairwise.complete.obs" or "complete.obs" I get this error
>  
> Error in optim(rho, f, control = control, hessian = TRUE, method =
> "BFGS") : 
> non-finite value supplied by optim
> 
> Is this an error in the hetcor function or am I missing something. 
> Thanks for your help.
>  
> Brendan Klick
> Johns Hopkins University School of Medicine [EMAIL PROTECTED]
> 
>   [[alternative HTML version deleted]]
> 
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newbie: new_data_frame <- selected set of rows

2006-12-01 Thread Darek Kedra
Two missing things:

>distances
 [1] 13 14 10 11  2  4  6  1  3  9  8 12  7  5

#numbers correspond to rows in my_dataframe

> my_dataframe
  V2 V3 V4
V5 V6
ENSP0354687 35660.45 0.04794521 0.05479452
0.06849315 0.07534247
ENSP0355046 38942.77 0.02967359 0.04451039
0.04451039 0.06824926
ENSP0354499 57041.21 0.04700855 0.08760684
0.11965812 0.06196581

ENSP0354687 etc are rownames. 

I am trying to get top five row names with smallest
distances from a given vector as calculated by
distancevector from hopach.



Darek Kedra





 

Cheap talk?

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Confusing difference in S4 summary method dispatch within an S3 summary

2006-12-01 Thread Christopher N. Lawrence
I'm trying to track down a problem I'm having in the Zelig package and
have stumbled across a very odd difference in the method dispatch for
a derived S4 class.

Specifically, I have an object of class ZeligS4vglm, which is a
subclass of vglm and vlm respectively (these are from the VGAM
package).

summary() at the command line prompt of this object calls
summary.vglm, which is what I expect to happen.

However, when summary() is called on this object from within another
summary() (summary.MI in Zelig... MI is an S3 class wrapping a number
of ZeligS4vglm objects in this case), it appears to be using the
generic summary() method and ignoring the summary methods defined for
the object:

Browse[1]> summary(object[[1]])
 Length Class   Mode
[1,] 1  ZeligS4vglm S4

I assume this has something to do with protecting the programmer from
infinite recursion into summary() - i.e. so summary.object <-
function(x) { summary(x) } doesn't blow up the stack - but is there a
workaround?


Chris
-- 
Christopher N. Lawrence <[EMAIL PROTECTED]>
Assistant Professor of Political Science (non-tenure-track)
Saint Louis University
109 Fitzgerald Hall
3500 Lindell Boulevard
St. Louis, Missouri 63103-1021

Website: http://www.cnlawrence.com/

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] AIC for heckit

2006-12-01 Thread Brian Ripley
As I read it hectik() in micEcon does not fit by maximum likelihood, so 
AIC is undefined.  (People seem to have a magic faith in AIC as a 
universal panacea, but it does come with a long list of conditions for 
applicability.)

heckit's $probit is apparently only part of the fitting, but for any model 
fit we would always recommend the extractor functions (e.g. AIC()) over 
messing with components of the fit.

On Fri, 1 Dec 2006, Jay Emerson wrote:

>> I have used the heckit function in micEcon.
>> ...
>> How can I then get the AIC for this model?
>
> It appears that the heckit $probit object is of class 'glm' and so, for
> example:
>
> main.result <- heckit(whateveryouaredoing)# Do your heckit()...
> probit.result <- main.result$probit # The glm object produced by
> heckit()
> probit.aic <- probit.result$aic # The AIC, see ?glm
>
> should have what you need, ready to go.  I used these tedious names and
> three lines of code just to be clear about what is what (I wouldn't really
> do it this way).  !)
>
> Jay
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


[R] R News, volume 6, issue 5 is now available

2006-12-01 Thread p . murrell
Hi

The December 2006 issue of R News is now available on CRAN under the
Documentation/Newsletter link.

Paul
(on behalf of the R News Editorial Board)
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

___
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] memory problem

2006-12-01 Thread Massimo Di Stefano
hi to all,
frustated for this error, to day i buy a 1 GB memory
slot for my laptop
now it have 1,28GB instead the old 512, but i've the
same error :-(
damn!damn!how can i do?
repeat for a little area (about 20X20 km and res=20m)
it work fine!
have you any suggestion?
is ther a method for look if this error depend from my
ram or other?
thanks foe any suggestion!
i need your help.
thanks.
Massimo


Il giorno 01/dic/06, alle ore 16:05, massimodisasha ha
scritto:
hi,
i'm trying to perform a clustering on a big dataframe
the code is this:


print("load required R packages")

require(spgrass6)

require(cluster)

gmeta6 <- gmeta6()

print("read in our 7 raster files from GRASS")

x <-
readFLOAT6sp(c("er","crosc","longc","slope","profc","minic","maxic"))

print("assemble a matrix of our terrain variables")

morph <- data.frame(cbind(x$er, x$crosc, x$longc,
x$slope, x$profc, x$minic, x$maxic))

print("normailize slope by dividing my max(slope)")

morph <- data.frame(cbind(x$er, x$crosc, x$longc,
x$slope/max(x$slope), x$profc, x$minic, x$maxic))

names(morph) <-
c("er","crosc","longc","slope_n","profc","minic","maxic")

print("perform the clustering")

morph.clara <- clara(morph, k=5, stand=F)

x$morph_class <- morph.clara$clustering

print("send result back to GRASS")

rast.put6(x,"morph", zcol="morph_class")



during the step : perform the clustering
after a lot of time,
i've this error:




Errore in sprintf(fmt, ...) : La lunghezza della
stringa eccede la dimensione del buffer di 8192
Inoltre: Warning messages:
1: perl = TRUE è implementato solo nei locale UTF-8
2: perl = TRUE è implementato solo nei locale UTF-8
3: perl = TRUE è implementato solo nei locale UTF-8
4: perl = TRUE è implementato solo nei locale UTF-8
5: perl = TRUE è implementato solo nei locale UTF-8
6: perl = TRUE è implementato solo nei locale UTF-8
7: perl = TRUE è implementato solo nei locale UTF-8
8: La stringa di caratteri verrà probabilmente
troncata
Esecuzione interrotta



if i try the same code on a subregion of my data, it
works very fine!
but for a large region i've this error :-(

obviously i think that is a memory problem, right ?
(i'm working with a notebook PPC-1.33-512ram)
my data are  : 7 raster-map on a region of about 50X40
km at a resolution of 20m.
is there some wolkaround about the memory problems?

an other question is:
what is this :
Warning messages:
1: perl = TRUE è implementato solo nei locale UTF-8
2: perl = TRUE è implementato solo nei locale UTF-8
3: perl = TRUE è implementato solo nei locale UTF-8
4: perl = TRUE è implementato solo nei locale UTF-8
5: perl = TRUE è implementato solo nei locale UTF-8
6: perl = TRUE è implementato solo nei locale UTF-8
7: perl = TRUE è implementato solo nei locale UTF-8

is it about this line of the code :

morph.clara <- clara(morph, k=5, stand=F)
i have an F > false


thanks for any suggestion about,

Massimo

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Demand of help

2006-12-01 Thread Roger Bivand
On Fri, 1 Dec 2006 [EMAIL PROTECTED] wrote:

> Hi, I'm a phd student of economics in Tunisia who is intersted now with
> the seasonal unit roots test of Canova and Hansen. So I've installed the
> package "uroot" in RGUI. I use R 2.4.0. The problem when I apply the
> function to my data, I've always a message from RConsole that it is
> impossible to find the function CH.test. Are there problems as for the
> use of this package? Please help me. Thank you in advance.

library(uroot) ?

>   [[alternative HTML version deleted]]
> 
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Demand of help

2006-12-01 Thread hassen62
Hi, 
I'm a phd student of economics in Tunisia who is intersted now with the 
seasonal unit roots test of Canova and Hansen. So I've installed the package 
"uroot" in RGUI. I use R 2.4.0. The problem when I apply the function to my 
data, I've always a message from RConsole that  it is impossible to find the 
function CH.test. Are there problems as for the use of this package? Please 
help me.
Thank you in advance.
[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make many barplot into one plot

2006-12-01 Thread Deepayan Sarkar
On 12/1/06, Marc Schwartz <[EMAIL PROTECTED]> wrote:
> On Fri, 2006-12-01 at 18:02 +0100, Muhammad Subianto wrote:
> > Dear all,
> > ## I have 4 tables like this:
> >
> > satu  <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4),
> >dimnames=list(c("Negative", "Positive"), c("Black",
> > "Brown", "Red", "Blond")))
> > dua   <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4),
> >dimnames=list(c("Negative", "Positive"), c("Black",
> > "Brown", "Red", "Blond")))
> > tiga  <- array(c(9,16,26,68,12,4,84,12), dim=c(2,4),
> >dimnames=list(c("Negative", "Positive"), c("Black",
> > "Brown", "Red", "Blond")))
> > empat <- array(c(25,13,50,78,19,34,84,101), dim=c(2,4),
> >dimnames=list(c("Negative", "Positive"), c("Black",
> > "Brown", "Red", "Blond")))
> >
> > ## with barplot I can make a plot for each table:
> >
> > barplot(satu, beside=TRUE, legend.text=rownames(satu),
> > ylim = c(0, max(colSums(satu)) * 1.2))
> > x11()
> > barplot(dua, beside=TRUE, legend.text=rownames(dua),
> > ylim = c(0, max(colSums(dua)) * 1.2))
> > x11()
> > barplot(tiga, beside=TRUE, legend.text=rownames(tiga),
> > ylim = c(0, max(colSums(tiga)) * 1.2))
> > x11()
> > barplot(empat, beside=TRUE, legend.text=rownames(empat),
> > ylim = c(0, max(colSums(empat)) * 1.2))
> >
> > ## I can make all barplot above into one plot with
> >
> > x11(width=11,height=8)
> > ## Make a plot with 2 rows and 2 columns
> > oldpar <- par(mfrow=c(2,2),
> >barplot(above)
> > par(oldpar)
> >
> > ## Are there any functions to make all barplot above into one plot?
> > ## I would like to produce barplot like:
> >
> > |   |   |   |
> > |   |   |   |   |   |   |   |   |   |   |   |   |   |
> > |pos|neg|pos|neg|pos|neg|pos|neg|   |pos|neg|pos|neg| ...
> > |   |   |   |   |   |   |   |   |   |   |   |   |   |
> > -   
> >   satu dua tiga   empatsatudua ...
> >   black blond
> >
> > I would be grateful if anybody could help me.
> > Thank you very much.
>
> I would encourage you to look at the barchart() function in the lattice
> package, which in many ways is better suited to doing multi-dimensional
> plots.
>
> That being said:
>
> [snipped]

And here is a lattice alternative:


dflist <- list()
for (nm in c("satu", "dua", "tiga", "empat"))
{
dflist[[nm]] <- as.data.frame.table(get(nm))
}

cdf <- do.call(make.groups, dflist)

barchart(Freq ~ which | Var2, data = cdf,
 groups = Var1, stack = FALSE, origin = 0,
 layout = c(4, 1), auto.key = TRUE)

barchart(which ~ Freq | Var2, data = cdf,
 groups = Var1, stack = TRUE,
 auto.key = TRUE)


-Deepayan

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] combining bclust and kkmeans

2006-12-01 Thread Laurent Valdes
Hi,

I have a very large dataset of 3008 individuals and 800 numerical variables.
In fact it is a table of 3008 36-monthes multivariated time series that I
would like to classify with an unsupervised algorithm

I had a look at the function kkmeans of e1071 package, which seems to be a
kernel weighted version of the algorithm algorithm, and the bclust from the
same package which does bootstrapping of kmean algorithm (bagging)
I had the idea of combining these two functions, in fact using kkmeans in
bclust parameters.

What should I do ? Reducing dimension and then classify, or classifying only
?
Should I use kkmeans only ? or bclust only ?

I'm very interested in your opinions.

Laurent.

-- 
«l'homme chéri ne dure plus d'un jour»
«Moi» @

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3D histogramm

2006-12-01 Thread Ben Bolker
Céline Henzelin  hotmail.com> writes:

> 
> thank you for your answer i checked my code and it now works
> 
> One more question... do you know how to have an 3D histogramm from a known 
> matrix of probabilities
> 
> Cline
> 

  An RSiteSearch on 3d histogram will get you some answers,
as well as a variety of strong opinions about why you shouldn't
plot your data as 3d histograms in the first place.

  Hints:

   demo(hist3d) in the rgl package
   example(scatterplot3d) in the scatterplot3d package
   
  Ben Bolker

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] C structures in R

2006-12-01 Thread Martin Maechler
> "BaRow" == Barry Rowlingson <[EMAIL PROTECTED]>
> on Fri, 01 Dec 2006 14:09:13 + writes:

BaRow> Prof Brian Ripley wrote:
>> The short answer is that quite a bit of code, e.g pwilcox
>> and RODBC, does things like this.  You don't need to pass
>> the pointer back to R, but if you do external pointers
>> are designed for this job.

BaRow>   [reads a bit more of 'Writing R Extensions'...]

BaRow>   Right yes, this does look like the tool for the
BaRow> job. I'll try and come up with a minimal example that
BaRow> duplicates what I'm doing with raw and pointers, it
BaRow> might be a useful illustration in the documentation.

Yes, indeed.  I've wanted to have a small well documented
example on using external pointers more than once.

And if it would end up to be too large for "Writing R Ext..", 
you could put it at least on the R-Wiki.

Thanks in advance!
Martin

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] error in hetcor function (polycor package)?

2006-12-01 Thread BRENDAN KLICK
I have been using the hetcor function in the polycor package.  When I
don't specify the use option everything runs smoothly.  However, when I
specify use either as "pairwise.complete.obs" or "complete.obs" I get
this error
 
Error in optim(rho, f, control = control, hessian = TRUE, method =
"BFGS") : 
non-finite value supplied by optim

Is this an error in the hetcor function or am I missing something. 
Thanks for your help.
 
Brendan Klick
Johns Hopkins University School of Medicine

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] error in hetcor function (polycor package)?

2006-12-01 Thread Klick, Brendan A.

I have been using the hetcor function in the polycor package.  When I don't 
specify the use option everything runs smoothly.  However, when I specify use 
either as "pairwise.complete.obs" or "complete.obs" I get this error
 
Error in optim(rho, f, control = control, hessian = TRUE, method = "BFGS") : 
non-finite value supplied by optim

Is this an error in the hetcor function or am I missing something.  Thanks for 
your help.
 
Brendan Klick
Johns Hopkins University School of Medicine
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] error in hetcor function (polycor package)?

2006-12-01 Thread BRENDAN KLICK
I have been using the hetcor function in the polycor package.  When I
don't specify the use option everything runs smoothly.  However, when I
specify use either as "pairwise.complete.obs" or "complete.obs" I get
this error
 
Error in optim(rho, f, control = control, hessian = TRUE, method =
"BFGS") : 
non-finite value supplied by optim

Is this an error in the hetcor function or am I missing something. 
Thanks for your help.
 
Brendan Klick
Johns Hopkins University School of Medicine
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] analog to the matlab buffer function?

2006-12-01 Thread Gregory R. Warnes
The gtools package also includes a function, 'running', which accomplishes
the desired task:

> library(gtools)
> t(running(1:5, width=3, fun=c))
[,1] [,2] [,3]
1:3123
2:4234
3:5345
>  


On 11/30/06 8:56 PM, "Marc Schwartz" <[EMAIL PROTECTED]> wrote:

> Here is another possibility, though I may be missing how the Matlab
> function handles incomplete rows generated at the end of the source
> vector. I have not fully tested this, so it may yet require some
> tweaking and certainly appropriate error checking.
> 
> I am presuming that the basic premise is that each row is of length
> 'window' and that it overlaps with the END of prior row by 'overlap'.
> 
> 
> Buffer <- function(x, window, overlap)
> {
>   Res <- NULL
> 
>   while (length(x) >= window)
>   {
> Res <- c(Res, x[1:window])
> x <- x[(1 + window - overlap):length(x)]
>   }
> 
>   matrix(Res, ncol = window, byrow = TRUE)
> }
> 
> 
>> Buffer(1:5, 3, 2)
>  [,1] [,2] [,3]
> [1,]123
> [2,]234
> [3,]345
> 
>> Buffer(1:10, 4, 2)
>  [,1] [,2] [,3] [,4]
> [1,]1234
> [2,]3456
> [3,]5678
> [4,]789   10
> 
> HTH,
> 
> Marc Schwartz
> 
> 
> On Thu, 2006-11-30 at 16:32 -0800, Charles C. Berry wrote:
>> See
>> 
>> ?embed
>> 
>> It is not quite the same, but this seems to be what you want - at least
>> for the example you give:
>> 
>>> t( embed(1:5,3) )[3:1,]
>>   [,1] [,2] [,3]
>> [1,]123
>> [2,]234
>> [3,]345
>>> 
>> 
>> On Fri, 1 Dec 2006, Martin Ivanov wrote:
>> 
>>> Hello! I am new to R. I could not find a function analogous to matlab's
>>> function buffer, which is used in signal processing. Is there such a
>>> function in R? What I need to do is as follows. If I apply the function
>>> to the vector c(1:5) for example with a window length 3 and overlapping
>>> 2, I need to get a matrix like this:
>>> 1 2 3
>>> 2 3 4
>>> 3 4 5
>>> In matlab this is achieved with the function buffer. Is there ananalogous R
>>> function?
> 
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] group by

2006-12-01 Thread Alex Brown
Hi Hans,

The short answer is yes.  I suspect you need to look at the 'by',  
'tapply' or 'aggregate' functions, depending upon what your data type  
is, exactly.

In general, it's best to come up with a really simple example which  
illustrates the part you don't know how to do.  If you can do that,  
someone will be able to come up with a simple solution.

-Alex Brown

On 1 Dec 2006, at 15:22, Hans-Juergen Eickelmann wrote:

>
> Dear R-community,
>
>
> I started using R  to control yield and output from different  
> factories by
> production week. A typical example is below.
>
> LocationWeek  ShippedWafer  SortedWafer UnsortedWafer
> WaferYield  GoodDie
> A   479   4   5   0.476   -12
> B   405   5   0
> -0.3262   -9
> B   482   1   1   5.092   18
>
>
> This output was generated from the following sample data. The  
> complete list
> can have more than 5K rows
>
> TransactionWeek   ShipdatePartnumber  TestsideLot  
> Wafer1
>   Wafer2Yieldnorm   Chipnorm
> 4711/20/2006  SWN3A   12WAC00
> 3LU105SOG6  3LU105SOG6  17.23160
> 4711/20/2006  SWN3A   12WAC00
> 3LU108SOE6  NA  NA  NA
> 4010/3/2006   WN30B   0ZQNC00
> 3XM063SOA1  3XM063SOA1  3.146   -12
> 4010/3/2006   WN30B   0ZQNC00
> 3XM072SOA3  3XM072SOA3  9.536   29
>
> I'm a newbee so I'm doing this step by step. 1st Site A,  than  
> siteB and
> combine this with rbind to C<-rbind(A,B);
> This code works however finally I would like to break up the data  
> even more
> and split it to Site, Week, Partnumber and Lot and here I'm lost.
>
> Is there a 'grouping by' function in R which allows this operation  
> much
> easier without 'hardwiring' the parameter like I did it?
>
>
> Code siteA
> Weekmin <- min(ship$TransactionWeek);
> Weekmax <- max(ship$TransactionWeek);
> Week <-Weekmin -1;
>
> repeat{
> Week <- Week +1;
> ship1  <- subset(ship, ship$TransactionWeek == Week &ship$Testside % 
> in%
> c("A"));
> ship2 <- subset(ship1,ship1$Yield != 0 );
> ship3 <- subset(ship1,is.na(ship1$Yield));
>
> Location <- "A";
> ShippedWafer <- nrow(ship1);
> SortedWafer <- nrow(ship1)-nrow(ship3);
> UnsortedWafer <- nrow(ship3);
> WaferYield <- mean(ship2$Yieldnorm, na.rm=TRUE);
> GoodDie <- sum(ship1$Chipnorm, na.rm=TRUE);
> assign(paste("week", Week, sep="."), data.frame(Location, Week,
> ShippedWafer,
>   SortedWafer, UnsortedWafer, WaferYield,GoodDie))
> if (Week == Weekmin) next
> line <- rbind(get(paste("week", Week-1, sep=".")),get(paste("week",  
> Week,
> sep=".")))
> assign(paste("week", Week, sep="."), data.frame(line))
>
> if (Week < Weekmax)next
> if (Week == Weekmax) break
> }
> A <- data.frame(get(paste("week", Week, sep=".")));
>
> Hans
>
> Hans-J Eickelmann
> ISC Technology Procurement Center Mainz, Germany
> email : [EMAIL PROTECTED]
> phone : +49-(0)6131-84-2516
> mobile: +49-(0)170-632-5596
>
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make many barplot into one plot

2006-12-01 Thread Marc Schwartz
On Fri, 2006-12-01 at 18:02 +0100, Muhammad Subianto wrote:
> Dear all,
> ## I have 4 tables like this:
> 
> satu  <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4),
>dimnames=list(c("Negative", "Positive"), c("Black", 
> "Brown", "Red", "Blond")))
> dua   <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4),
>dimnames=list(c("Negative", "Positive"), c("Black", 
> "Brown", "Red", "Blond")))
> tiga  <- array(c(9,16,26,68,12,4,84,12), dim=c(2,4),
>dimnames=list(c("Negative", "Positive"), c("Black", 
> "Brown", "Red", "Blond")))
> empat <- array(c(25,13,50,78,19,34,84,101), dim=c(2,4),
>dimnames=list(c("Negative", "Positive"), c("Black", 
> "Brown", "Red", "Blond")))
> 
> ## with barplot I can make a plot for each table:
> 
> barplot(satu, beside=TRUE, legend.text=rownames(satu),
> ylim = c(0, max(colSums(satu)) * 1.2))
> x11()
> barplot(dua, beside=TRUE, legend.text=rownames(dua),
> ylim = c(0, max(colSums(dua)) * 1.2))
> x11()
> barplot(tiga, beside=TRUE, legend.text=rownames(tiga),
> ylim = c(0, max(colSums(tiga)) * 1.2))
> x11()
> barplot(empat, beside=TRUE, legend.text=rownames(empat),
> ylim = c(0, max(colSums(empat)) * 1.2))
> 
> ## I can make all barplot above into one plot with
> 
> x11(width=11,height=8)
> ## Make a plot with 2 rows and 2 columns
> oldpar <- par(mfrow=c(2,2),
>barplot(above)
> par(oldpar)
> 
> ## Are there any functions to make all barplot above into one plot?
> ## I would like to produce barplot like:
> 
> |   |   |   |
> |   |   |   |   |   |   |   |   |   |   |   |   |   |
> |pos|neg|pos|neg|pos|neg|pos|neg|   |pos|neg|pos|neg| ...
> |   |   |   |   |   |   |   |   |   |   |   |   |   |
> -   
>   satu dua tiga   empatsatudua ...
>   black blond
> 
> I would be grateful if anybody could help me.
> Thank you very much.

I would encourage you to look at the barchart() function in the lattice
package, which in many ways is better suited to doing multi-dimensional
plots.

That being said:

# rbind() the tables together
TAB <- rbind(satu, dua, tiga, empat)

# Do the barplot and save the bar midpoints
mp <- barplot(TAB, beside = TRUE,
  axisnames = FALSE)

# Add the individual bar labels
mtext(1, at = mp, text = c("N", "P"),
  line = 0, cex = 0.5)

# Get the midpoints of each sequential pair of bars
# within each of the four groups
at <- t(sapply(seq(1, nrow(TAB), by = 2),
   function(x) colMeans(mp[c(x, x+1), ])))

# Add the group labels for each pair
mtext(1, at = at,
  text = rep(c("satu", "dua", "tiga", "empat"), 4),
  line = 1, cex = 0.75)

# Add the color labels for each group
mtext(1, at = colMeans(mp),
  text = c("Black", "Brown", "Red", "Blond"),
  line = 2)


Take a look at ?barplot and note that the function returns the bar
midpoints, which in this case is a matrix:

> mp
 [,1] [,2] [,3] [,4]
[1,]  1.5 10.5 19.5 28.5
[2,]  2.5 11.5 20.5 29.5
[3,]  3.5 12.5 21.5 30.5
[4,]  4.5 13.5 22.5 31.5
[5,]  5.5 14.5 23.5 32.5
[6,]  6.5 15.5 24.5 33.5
[7,]  7.5 16.5 25.5 34.5
[8,]  8.5 17.5 26.5 35.5


Then look at ?mtext for the labelling.

HTH,

Marc Schwartz

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simple parallel computing on single multicore machine

2006-12-01 Thread Greg Snow
Look at the nws package, I have had success using it to parallelize
simulations using a couple of computers that were not being used at the
time.  I don't have a multicore machine, but the examples in the package
make it look like using it for multicore would be even easier.

This is on windows 2000 machines with cygwin installed.

Hope this helps, 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Millo Giovanni
Sent: Friday, December 01, 2006 5:24 AM
To: r-help@stat.math.ethz.ch
Subject: [R] simple parallel computing on single multicore machine

Dear List,

the advent of multicore machines in the consumer segment makes me wonder
whether it would, at least in principle, be possible to divide a
computational task into more slave R processes running on the different
cores of the same processor, more or less in the way package SNOW would
do on a cluster. I am thinking of simple 'embarassingly parallel'
problems, just like inverting 1000 matrices, estimating 1000 models or
the like.

I have seen some talk here on making R multi-threaded and the like, but
this is much simpler. I am just a curious useR, so don't bother if you
don't have time, but maybe you can point me at some resource, or just
say "this is nonsense"...

Cheers
Giovanni

Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34131 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160
 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni
...{{dropped}}

__
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
and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Make many barplot into one plot

2006-12-01 Thread Muhammad Subianto
Dear all,
## I have 4 tables like this:

satu  <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4),
   dimnames=list(c("Negative", "Positive"), c("Black", 
"Brown", "Red", "Blond")))
dua   <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4),
   dimnames=list(c("Negative", "Positive"), c("Black", 
"Brown", "Red", "Blond")))
tiga  <- array(c(9,16,26,68,12,4,84,12), dim=c(2,4),
   dimnames=list(c("Negative", "Positive"), c("Black", 
"Brown", "Red", "Blond")))
empat <- array(c(25,13,50,78,19,34,84,101), dim=c(2,4),
   dimnames=list(c("Negative", "Positive"), c("Black", 
"Brown", "Red", "Blond")))

## with barplot I can make a plot for each table:

barplot(satu, beside=TRUE, legend.text=rownames(satu),
ylim = c(0, max(colSums(satu)) * 1.2))
x11()
barplot(dua, beside=TRUE, legend.text=rownames(dua),
ylim = c(0, max(colSums(dua)) * 1.2))
x11()
barplot(tiga, beside=TRUE, legend.text=rownames(tiga),
ylim = c(0, max(colSums(tiga)) * 1.2))
x11()
barplot(empat, beside=TRUE, legend.text=rownames(empat),
ylim = c(0, max(colSums(empat)) * 1.2))

## I can make all barplot above into one plot with

x11(width=11,height=8)
## Make a plot with 2 rows and 2 columns
oldpar <- par(mfrow=c(2,2),
   barplot(above)
par(oldpar)

## Are there any functions to make all barplot above into one plot?
## I would like to produce barplot like:

|   |   |   |
|   |   |   |   |   |   |   |   |   |   |   |   |   |
|pos|neg|pos|neg|pos|neg|pos|neg|   |pos|neg|pos|neg| ...
|   |   |   |   |   |   |   |   |   |   |   |   |   |
-   
  satu dua tiga   empatsatudua ...
  black blond

I would be grateful if anybody could help me.
Thank you very much.

Muhammad Subianto

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lme function

2006-12-01 Thread Spencer Graves
  RSiteSearch("lme spatial correlation", "functions") produced 10 
hits for me just now.  The sixth title on that list was "spatial 
correlation structure" 
(http://finzi.psych.upenn.edu/R/library/nlme/html/corSpher.html).  This 
is the help page for the "corSpher" function.  The Examples section 
there includes references to selected pages in Pinheiro and Bates (2000) 
Mixed-Effects Models in S and S-Plus (Springer), which  for me is 
essential documentation for 'lme' and is the best book I know on 
mixed-effects models generally.  The value of that book is greatly 
enhanced by the availability of script files "ch01.R", "ch02.R", ..., 
"ch06.R", "ch08.R" (in the "~R\library\nlme\scripts" subdirectory of 
your R installation directory).  These contain R code to reproduce all 
the data analyses in the book.  There are a very few cases where the 
syntax is different between R and that documented in the book [e.g., x^2 
must be I(x^2)].  Before I found the script files, I couldn't understand 
why I got substantially different results from the book when just typing 
the commands into R. 

   Hope this helps. 
  Spencer Graves

Mark Wilson wrote:
> Hello.
>
> As advised by Mick Crawley in his book on S+, I'm trying to use the lme
> function to examine a linear relationship between two variables measured at
> 60 locations in 12 sites, while taking account of any spatial
> autocorrelation (i.e. similarity in variation between the two variables that
> is due to site). I am using the function as follows:
>
> model<-lme(yvariable~xvariable,random=~xvariable|site)
>
> If you know your way around this function, I would be very grateful if you
> could confirm that this approach is a valid one, or point out why it isn't.
> I'd also be very keen to hear any suggestions regarding alternative ways to
> address the spatial autocorrelation in my data (I'm hoping to arrive at a
> slightly more elegant solution than simply taking site averages for each of
> the two variables and running a correlation using these mean values).
>
> Thanks,
>
> Mark
>

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] group by

2006-12-01 Thread Hans-Juergen Eickelmann

Dear R-community,


I started using R  to control yield and output from different factories by
production week. A typical example is below.

LocationWeek  ShippedWafer  SortedWafer UnsortedWafer
WaferYield  GoodDie
A   479   4   5   0.476   -12
B   405   5   0   -0.3262   -9
B   482   1   1   5.092   18


This output was generated from the following sample data. The complete list
can have more than 5K rows

TransactionWeek   ShipdatePartnumber  TestsideLot Wafer1
  Wafer2Yieldnorm   Chipnorm
4711/20/2006  SWN3A   12WAC00
3LU105SOG6  3LU105SOG6  17.23160
4711/20/2006  SWN3A   12WAC00
3LU108SOE6  NA  NA  NA
4010/3/2006   WN30B   0ZQNC00
3XM063SOA1  3XM063SOA1  3.146   -12
4010/3/2006   WN30B   0ZQNC00
3XM072SOA3  3XM072SOA3  9.536   29

I'm a newbee so I'm doing this step by step. 1st Site A,  than siteB and
combine this with rbind to C<-rbind(A,B);
This code works however finally I would like to break up the data even more
and split it to Site, Week, Partnumber and Lot and here I'm lost.

Is there a 'grouping by' function in R which allows this operation much
easier without 'hardwiring' the parameter like I did it?


Code siteA
Weekmin <- min(ship$TransactionWeek);
Weekmax <- max(ship$TransactionWeek);
Week <-Weekmin -1;

repeat{
Week <- Week +1;
ship1  <- subset(ship, ship$TransactionWeek == Week &ship$Testside %in%
c("A"));
ship2 <- subset(ship1,ship1$Yield != 0 );
ship3 <- subset(ship1,is.na(ship1$Yield));

Location <- "A";
ShippedWafer <- nrow(ship1);
SortedWafer <- nrow(ship1)-nrow(ship3);
UnsortedWafer <- nrow(ship3);
WaferYield <- mean(ship2$Yieldnorm, na.rm=TRUE);
GoodDie <- sum(ship1$Chipnorm, na.rm=TRUE);
assign(paste("week", Week, sep="."), data.frame(Location, Week,
ShippedWafer,
  SortedWafer, UnsortedWafer, WaferYield,GoodDie))
if (Week == Weekmin) next
line <- rbind(get(paste("week", Week-1, sep=".")),get(paste("week", Week,
sep=".")))
assign(paste("week", Week, sep="."), data.frame(line))

if (Week < Weekmax)next
if (Week == Weekmax) break
}
A <- data.frame(get(paste("week", Week, sep=".")));

Hans

Hans-J Eickelmann
ISC Technology Procurement Center Mainz, Germany
email : [EMAIL PROTECTED]
phone : +49-(0)6131-84-2516
mobile: +49-(0)170-632-5596

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] memeory problem?!

2006-12-01 Thread massimodisasha

hi,
i'm trying to perform a clustering on a big dataframe the code is this:


print("load required R packages")

require(spgrass6)

require(cluster)

gmeta6 <- gmeta6()

print("read in our 7 raster files from GRASS")

x <- readFLOAT6sp(c 
("er","crosc","longc","slope","profc","minic","maxic"))

print("assemble a matrix of our terrain variables")

morph <- data.frame(cbind(x$er, x$crosc, x$longc, x$slope, x$profc, x 
$minic, x$maxic))

print("normailize slope by dividing my max(slope)")

morph <- data.frame(cbind(x$er, x$crosc, x$longc, x$slope/max(x 
$slope), x$profc, x$minic, x$maxic))

names(morph) <- c 
("er","crosc","longc","slope_n","profc","minic","maxic")

print("perform the clustering")

morph.clara <- clara(morph, k=5, stand=F)

x$morph_class <- morph.clara$clustering

print("send result back to GRASS")

rast.put6(x,"morph", zcol="morph_class")



during the step : perform the clustering
after a lot of time,
i've this error:




Errore in sprintf(fmt, ...) : La lunghezza della stringa eccede la  
dimensione del buffer di 8192
Inoltre: Warning messages:
1: perl = TRUE è implementato solo nei locale UTF-8
2: perl = TRUE è implementato solo nei locale UTF-8
3: perl = TRUE è implementato solo nei locale UTF-8
4: perl = TRUE è implementato solo nei locale UTF-8
5: perl = TRUE è implementato solo nei locale UTF-8
6: perl = TRUE è implementato solo nei locale UTF-8
7: perl = TRUE è implementato solo nei locale UTF-8
8: La stringa di caratteri verrà probabilmente troncata
Esecuzione interrotta



if i try the same code on a subregion of my data, it works very fine!
but for a large region i've this error :-(

obviously i think that is a memory problem, right ?
(i'm working with a notebook PPC-1.33-512ram)
my data are  : 7 raster-map on a region of about 50X40 km at a  
resolution of 20m.
is there some wolkaround about the memory problems?

an other question is:
what is this :
Warning messages:
1: perl = TRUE è implementato solo nei locale UTF-8
2: perl = TRUE è implementato solo nei locale UTF-8
3: perl = TRUE è implementato solo nei locale UTF-8
4: perl = TRUE è implementato solo nei locale UTF-8
5: perl = TRUE è implementato solo nei locale UTF-8
6: perl = TRUE è implementato solo nei locale UTF-8
7: perl = TRUE è implementato solo nei locale UTF-8

is it about this line of the code :

morph.clara <- clara(morph, k=5, stand=F)
i have an F > false


thanks for any suggestion about,

Massimo

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] C structures in R

2006-12-01 Thread Barry Rowlingson
Prof Brian Ripley wrote:

> The short answer is that quite a bit of code, e.g pwilcox and RODBC, 
> does things like this.  You don't need to pass the pointer back to R, 
> but if you do external pointers are designed for this job.  

  [reads a bit more of 'Writing R Extensions'...]

  Right yes, this does look like the tool for the job. I'll try and come 
up with a minimal example that duplicates what I'm doing with raw and 
pointers, it might be a useful illustration in the documentation.

Barry

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Box Tidwell / Error Message

2006-12-01 Thread John Fox
Dear Simon,

It's hard to tell without the data and more information about the nature of
the variables, but I suspect that the program is running into numerical
difficulties because of a flat likelihood at the maximum. Is age2 by any
chance age^2? How is year (in either form) related to age?

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Simon P. Kempf
> Sent: Friday, December 01, 2006 3:30 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Box Tidwell / Error Message
> 
> Dear R-Users,
> 
>  
> 
> I used the box.tidwell () function of the car Package. 
> 
>  
> 
> When I used the following formula:
> 
>  
> 
> semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ 
> I(age+1)+I(age2+1)+X06A
> + I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_YEAR + C_X01 + C_X14 + 
> + C_X19 +
> C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 + D_X25 + D_X27 
> + D_X30 +
> D_X32 + D_X35, data = semi.sub.in.mi1)
> 
>  
> 
> everything is fine.
> 
>  
> 
> However, when I replaced the time dummy variable:
> 
>  
> 
> semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ 
> I(age+1)+I(age2+1)+X06A
> + I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_HALF + C_X01 + C_X14 + 
> + C_X19 +
> C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 + D_X25 + D_X27 
> + D_X30 +
> D_X32 + D_X35, data = semi.sub.in.mi1)
> 
>  
> 
> I get the following error message:
> 
>  
> 
> Error in lm.fit(x, y, offset = offset, singular.ok = 
> singular.ok, ...) : 
> 
> NA/NaN/Inf in foreign function call (arg 1)
> 
>  
> 
> When I use the following formula (I deleted the I(age2+1) term):
> 
>  
> 
> semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ I(age+1)+X06A +
> I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_HALF + C_X01 + 
> C_X14 + C_X19 + C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 
> + D_X25 + D_X27 + D_X30 +
> D_X32 + D_X35, data = semi.sub.in.mi1)
> 
>  
> 
> It works.
> 
>  
> 
> Some background information:
> 
>  
> 
> -  The formula with the predictors to be transformed 
> contains only
> variables which are >0.
> 
> -  The data set does not have any missing values
> 
> -  B_YEAR is a factor with 10 levels
> 
> -  B_HALF is a factor with 20 levels
> 
> -  The data set contains more than 19000 observations.
> 
>  
> 
> Now, I am bit confused. Why does the function works when I 
> use B_YEAR respecitvely why does it work with B_HALF when I 
> delete I(age2+1)
> 
>  
> 
> Thanks in advance,
> 
>  
> 
> Simon
> 
>  
> 
>  
> 
>  
> 
>  
> 
> Simon P. Kempf 
> 
> Dipl.-Kfm. MScRE Immobilienvkonom (ebs)
> 
> Wissenschaftlicher Assistent
> 
>  
> 
> B|ro:
> 
> IREBS Immobilienakademie
> 
> c/o ebs Immobilienakademie GmbH
> 
> Berliner Str. 26a
> 
> 13507 Berlin
> 
>  
> 
> Privat:
> 
> Dunckerstra_e 60
> 
> 10439 Berlin
> 
>  
> 
> Mobil: 0176 7002 6687
> 
> Email:   [EMAIL PROTECTED]
> 
>  
> 
> 
>   [[alternative HTML version deleted]]
> 
>

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] *** caught segfault *** error

2006-12-01 Thread Prof Brian D Ripley
On Fri, 1 Dec 2006, Juanjo Abellan wrote:

[...]

> Sorry, I didn't understand the issue about the locale and the C locale that 
> Prof Ripley mentioned. Where could I learn about that?

In the R-admin manual (but Roger will understand).

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Marc Schwartz
On Thu, 2006-11-30 at 19:26 +, Gavin Simpson wrote:
> On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote:
> 
> Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline)
> for your comments and suggestions.
> 
> I noticed that two of the vectors were named and so I removed the names
> (names(vec) <- NULL) and that pushed the execution time for the function
> from c. 40 seconds to c. 115 seconds and all the time was taken within
> the data.frame(...) call. So having names *on* some of the vectors
> seemed to help things along, which was the opposite of what i had
> expected.
> 
> If I use the cbind method of Marc, then the execution time for the
> function drops to c. 1 second (most of which is in the calculation of
> one of the vectors). So I guess I can work round this now.
> 
> What I find interesting is that:
> 
> test.dat <- rnorm(4471)
> > system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
> test.dat,
> + col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
> + col8 = test.dat, col9 = test.dat, col10 = test.dat))
> [1] 0.008 0.000 0.007 0.000 0.000
> 
> Whereas doing exactly the same thing with different data in the function
> gives the following timings:
> 
> system.time(fab <- data.frame(lc.ratio, Q,
> +  fNupt,
> +  rho.n, rho.s,
> +  net.Nimm,
> +  net.Nden,
> +  CLminN,
> +  CLmaxN,
> +  CLmaxS))
> [1] 173.415   0.260 192.192   0.000   0.000
> 
> Most of that was without a change in memory, but towards the end for c.
> 5 seconds memory use by R increased by 200-300 MB.
> 
> and...
> 
> > system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
> +  fNupt = fNupt,
> +  rho.n = rho.n, rho.s = rho.s,
> +  net.Nimm = net.Nimm,
> +  net.Nden = net.Nden,
> +  CLminN = CLminN,
> +  CLmaxN = CLmaxN,
> +  CLmaxS = CLmaxS))
> [1]  99.966   0.140 114.091   0.000   0.000
> 
> Again with a slight increase in memory usage in last 5 seconds. So now,
> having stripped the names of two of the vectors (so now all are
> un-named), the un-named version of the data.frame call is almost twice
> as slow as the named data.frame call.
> 
> If I leave the names on the two vectors that had them, I get the
> following timings for those same calls
> 
> > system.time(fab <- data.frame(lc.ratio, Q,
> +  fNupt,
> +  rho.n, rho.s,
> +  net.Nimm,
> +  net.Nden,
> +  CLminN,
> +  CLmaxN,
> +  CLmaxS))
> [1]  96.234   0.244 101.706   0.000   0.000
> 
> > system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
> +  fNupt = fNupt,
> +  rho.n = rho.n, rho.s = rho.s,
> +  net.Nimm = net.Nimm,
> +  net.Nden = net.Nden,
> +  CLminN = CLminN,
> +  CLmaxN = CLmaxN,
> +  CLmaxS = CLmaxS))
> [1] 13.597  0.088 15.868  0.000  0.000
> 
> So having the 2 named vectors and using the named version of the
> data.frame call is the fastest combination.
> 
> This is all done within the debugger at the time when I would be
> generating fab, and if I do,
> 
> system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
> test.dat,
> + col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
> + col8 = test.dat, col9 = test.dat, col10 = test.dat))
> [1] 0.008 0.000 0.007 0.000 0.000
> 
> (as above) at this point in the debugger it is exceedingly quick.
> 
> I just don't understand what is going on with data.frame.
> 
> I have yet to try Prof. Ripley's suggestion of being a bit naughty with
> R - I'll see if that is any quicker.
> 
> Once again, thanks to you all for your suggestions.

Gavin,

Can you post the results of:

  str(fab)

and

  str(lc.ratio)
  str(Q)
  str(fNupt)
  str(rho.n)
  str(rho.s)
  str(net.Nimm)
  str(net.Nden)
  str(CLminN)
  str(CLmaxN)
  str(CLmaxS)

This is taking way too long. There is either something about one or more
of these objects that is more complex than just being simple vectors, or
there is something corrupt in your R session/environment.

You might want to try running a new and clean R session using:

  R --vanilla

and then re-run your code to see if that changes anything.  If so, it
suggests that my latter idea may be in play.

HTH,

Marc

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] AIC for heckit

2006-12-01 Thread Jay Emerson
> I have used the heckit function in micEcon.
> ...
> How can I then get the AIC for this model?

It appears that the heckit $probit object is of class 'glm' and so, for
example:

main.result <- heckit(whateveryouaredoing)# Do your heckit()...
probit.result <- main.result$probit # The glm object produced by
heckit()
probit.aic <- probit.result$aic # The AIC, see ?glm

should have what you need, ready to go.  I used these tedious names and
three lines of code just to be clear about what is what (I wouldn't really
do it this way).  !)

Jay

-- 
John W. Emerson (Jay)
Assistant Professor of Statistics
Director of Graduate Studies
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] generate the time series data

2006-12-01 Thread Wang Xian
I want to generate a bivariate time series data with given joint 
distribution. Let's say

Yt = A + B*Yt-1 + Vt,
where Yt = (Y1t,Y2t)'. The dependence between Y1t and Y2t is measured by a 
given copula function. I.e., C(F(Y1t), G(Y2t)) = H(Y1t,Y2t), where  C is a 
copula function, F and G are the marginal functions of Y1t and Y2t and H is 
the joint distribution of Y1t and Y2t.

How to generate Yt?
Thanks for help. 


Xian

_
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] *** caught segfault *** error

2006-12-01 Thread Juanjo Abellan
Dear all,

The shapefile was generated with ArcGIS 9.0 running on Windows XP. It  
can be can be found in www.uv.es/~abellan/districts_ok.zip.

Re running sessionInfo() before the error occurres as suggested by  
Prof. Ripley:

 > library(spdep)
Loading required package: tripack
Loading required package: maptools
Loading required package: foreign
Loading required package: sp
Loading required package: SparseM
Package SparseM (0.71) loaded.  To cite, see citation("SparseM")
Loading required package: boot
 > library(maptools)
 > sessionInfo()
R version 2.4.0 (2006-10-03)
i386-apple-darwin8.8.1

locale:
es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8

attached base packages:
[1] "methods"   "stats" "graphics"  "grDevices" "utils"  
"datasets"  "base"

other attached packages:
spdep boot  SparseM maptools   sp  foreign  tripack
"0.3-32" "1.2-26"   "0.71"  "0.6-3"  "0.9-4" "0.8-17" "1.2-10"
 > district.shp <- read.shape("~/Documents/SAHSU/MD/data/Carthography/ 
districts_ok.shp")
Shapefile type: Polygon, (5), # of Shapes: 354
 > plot(district.shp)

*** caught segfault ***
address 0xc6d5, cause 'memory not mapped'

Traceback:
1: polygon(theMap$Shapes[[ii]]$verts, col = fg[i], border = ol, ...)
2: plot.Map(district.shp)
3: plot(district.shp)
4: plot(district.shp)

Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:



Re trying maptools "example(read.shape)" as suggested by Dr Bivand:

 > example(read.shape)

rd.shp> x <- read.shape(system.file("shapes/sids.shp", package =  
"maptools")[1])
Shapefile type: Polygon, (5), # of Shapes: 100

rd.shp> length(x$Shapes)
[1] 100

rd.shp> unlist(lapply(x$att.data, class))
  AREA PERIMETER CNTY_   CNTY_ID  NAME  FIPS 
FIPSNO  CRESS_ID BIR74 SID74
"numeric" "numeric" "numeric" "numeric"  "factor"  "factor" "numeric"  
"numeric" "numeric" "numeric"
   NWBIR74 BIR79 SID79   NWBIR79
"numeric" "numeric" "numeric" "numeric"

rd.shp> str(getinfo.shape(system.file("shapes/fylk-val.shp",
 package = "maptools")[1]))
List of 5
$ : chr "/Library/Frameworks/R.framework/Versions/2.4/Resources/ 
library/maptools/shapes/fylk-val.shp"
$ : int 3
$ : int 97
$ : num [1:4]   -4868 6456207   0   0
$ : num [1:4] 1084722 7841997   0   0
- attr(*, "class")= chr "shapehead"
 > plot(x)
Warning message:
'plot.Map' is deprecated.
Use 'plot.Spatial' instead.
See help("Deprecated") and help("maptools-deprecated").

The maps is plotted.

Sorry, I didn't understand the issue about the locale and the C  
locale that Prof Ripley mentioned. Where could I learn about that?

Thanks,

Juanjo



El 30/11/2006, a las 11:41, Prof Brian Ripley escribió:

> On Thu, 30 Nov 2006, Roger Bivand wrote:
>
>> On Thu, 30 Nov 2006, Juanjo Abellan wrote:
>>
>>> Dear R users,
>>>
>>> I use R 2.4.0 on an iMac running Mac OS X 10.4.8, with a 2.16GHz
>>> Intel Core 2 Duo and 2GB 667 MHz DDR2 SDRAM.
>>>
>>
>> Please make a copy of the offending shapefile available either on a
>> website or attach it to me off-list. It would be useful to know  
>> its origin
>> (which software wrote it) and whether the copy on the iMac is  
>> identical to
>> the copy on the Windows PC (perhaps attach both?). Can other  
>> shapefiles be
>> read on the iMac?
>>
>> (This may be an R-sig-Mac issue as well as an R-sig-geo issue, so  
>> if other
>> iMac users could check whether example(read.shape) in the maptools  
>> package
>> works for them on similar hardware, I'd be grateful)
>
> And also please run sessionInfo() *after* attaching the packages,  
> since all the version information on those packages is missing in  
> the log you sent.
>
> It is possibly a locale issue (non-UTF-8 strings in the  
> shapefile?), so you might like to try this in the C locale.
>
>
>>> > sessionInfo()
>>> R version 2.4.0 (2006-10-03)
>>> i386-apple-darwin8.8.1
>>>
>>> locale:
>>> es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8
>>>
>>> attached base packages:
>>> [1] "methods"   "stats" "graphics"  "grDevices" "utils"
>>> "datasets"  "base"
>>>
>>>
>>> I get an error below whenever I try to plot a map from a shapefile
>>> imported into R; I've tried packages shapefiles and spdep, and two
>>> different shapefiles, and get the error in all 4 combinations.
>>>
>>> The shapefile is imported correctly, and I get the error only when I
>>> try to plot the map. I specifically use commands
>>>
>>> > library(spdep)
>>> Loading required package: tripack
>>> Loading required package: maptools
>>> Loading required package: foreign
>>> Loading required package: sp
>>> Loading required package: SparseM
>>> Package SparseM (0.71) loaded.  To cite, see citation("SparseM")
>>> Loading required package: boot
>>> > library(maptools)
>>> > district.shp <- read.shape("~/Documents/SAHSU/MD/data/ 
>>> Carthography/
>>> districts_ok.shp")
>>> Shapefile type: Polygon, (5), # of Shapes: 354
>>> > plot(

Re: [R] C structures in R

2006-12-01 Thread Prof Brian Ripley
Isn't this a question clearly in R-devel's domain?

  R-devel is intended for questions and discussion about code development
  in R. Questions likely to prompt discussion unintelligible to
  non-programmers should go to to R-devel.

The short answer is that quite a bit of code, e.g pwilcox and RODBC, does 
things like this.  You don't need to pass the pointer back to R, but if 
you do external pointers are designed for this job.  Nevertheless, 
graphics recording on Windows makes use of integers AFAIR to store C-level 
structures (but it predates raw and external pointers).

On Fri, 1 Dec 2006, Barry Rowlingson wrote:

> Is it safe to call C code from R that mallocs memory for a structure,
> returning a pointer to that structure via some 'raw()' parameter. Then,
> pass that pointer to another C routine, and finally free the malloced
> memory by passing the raw() data to another C routine?
>
> I've written some code that does this, I'm just not sure if anything
> could go wrong. The worst I can come up with is a memory leak if the
> structure's memory isn't freed - possibly because the R is interrupted.
>
> R isn't going to stomp on memory that's been malloced by an included C
> routine between .C calls though, is it?
>
> Barry
>
> [[
> gory details:
>
>   R code calls a C routine with .C passing a 4-byte (because 4 is
> sizeof(char*) in my architecture) 'raw' object, the C code then mallocs
> the structure and copies the address of the structure into the 4 bytes
> that the raw object (which appears as a char* in the C routine argument
> list) points to. This gets returned back to R. Another option would be
> to create a raw object of the right size to store my structure, pass
> that to C and not malloc anything in C. But that would mean altering the
> C code which I want to do as little as possible.
>
> gory code available on request.
>
> ]]
>
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simple parallel computing on single multicore machine

2006-12-01 Thread Ramon Diaz-Uriarte
On Friday 01 December 2006 13:23, Millo Giovanni wrote:
> Dear List,
>
> the advent of multicore machines in the consumer segment makes me wonder
> whether it would, at least in principle, be possible to divide a
> computational task into more slave R processes running on the different
> cores of the same processor, more or less in the way package SNOW would
> do on a cluster. I am thinking of simple 'embarassingly parallel'
> problems, just like inverting 1000 matrices, estimating 1000 models or
> the like.
>
> I have seen some talk here on making R multi-threaded and the like, but
> this is much simpler. I am just a curious useR, so don't bother if you
> don't have time, but maybe you can point me at some resource, or just
> say "this is nonsense"...



Dear Millo,

I find the usage of papply (from the library with the same name), which itself 
uses Rmpi to be easy and ideal for those cases. The papply documentation 
shows clearly what you need to do to pass the required arguments to papply. 
And once you have your MPI universe up and running (with whichever number of 
slaves you specify) it just works. As well, I find debugging very simple: 
just start an MPI universe with only one node, which forces papply to run 
serially (non-parallel) so wrong arguments, missing libraries, etc, are easy 
to spot.

Best,

R.





>
> Cheers
> Giovanni
>
> Giovanni Millo
> Research Dept.,
> Assicurazioni Generali SpA
> Via Machiavelli 4,
> 34131 Trieste (Italy)
> tel. +39 040 671184
> fax  +39 040 671160
>
> Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{dropped}}
>
> __
> 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 and provide commented, minimal,
> self-contained, reproducible code.

-- 
Ramón Díaz-Uriarte
Centro Nacional de Investigaciones Oncológicas (CNIO)
(Spanish National Cancer Center)
Melchor Fernández Almagro, 3
28029 Madrid (Spain)
Fax: +-34-91-224-6972
Phone: +-34-91-224-6900

http://ligarto.org/rdiaz
PGP KeyID: 0xE89B3462
(http://ligarto.org/rdiaz/0xE89B3462.asc)



**NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}}

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simple parallel computing on single multicore machine

2006-12-01 Thread Peter Dalgaard
Millo Giovanni wrote:
> Dear List,
>
> the advent of multicore machines in the consumer segment makes me wonder
> whether it would, at least in principle, be possible to divide a
> computational task into more slave R processes running on the different
> cores of the same processor, more or less in the way package SNOW would
> do on a cluster. I am thinking of simple 'embarassingly parallel'
> problems, just like inverting 1000 matrices, estimating 1000 models or
> the like.
>
> I have seen some talk here on making R multi-threaded and the like, but
> this is much simpler. I am just a curious useR, so don't bother if you
> don't have time, but maybe you can point me at some resource, or just
> say "this is nonsense"...
>
>
>   
I don't think snow (or rather its underlying message-passing interface)
cares whether its processes are on different physical machines. So this
is easily doable. Of course you need to be aware that the processes are
competing for resources like RAM and disc.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simple parallel computing on single multicore machine

2006-12-01 Thread Uwe Ligges


Millo Giovanni wrote:
> Dear List,
> 
> the advent of multicore machines in the consumer segment makes me wonder
> whether it would, at least in principle, be possible to divide a
> computational task into more slave R processes running on the different
> cores of the same processor, more or less in the way package SNOW would
> do on a cluster. I am thinking of simple 'embarassingly parallel'
> problems, just like inverting 1000 matrices, estimating 1000 models or
> the like.
> 
> I have seen some talk here on making R multi-threaded and the like, but
> this is much simpler. I am just a curious useR, so don't bother if you
> don't have time, but maybe you can point me at some resource, or just
> say "this is nonsense"...


Just use snow itself, for example.
Or on a completely other level a tuned BLAS for perallel computations 
such as ATLAS.

Uwe Ligges


> Cheers 
> Giovanni
> 
> Giovanni Millo
> Research Dept.,
> Assicurazioni Generali SpA
> Via Machiavelli 4, 
> 34131 Trieste (Italy)
> tel. +39 040 671184 
> fax  +39 040 671160
>  
> Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{dropped}}
> 
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] C structures in R

2006-12-01 Thread Barry Rowlingson
Is it safe to call C code from R that mallocs memory for a structure, 
returning a pointer to that structure via some 'raw()' parameter. Then, 
pass that pointer to another C routine, and finally free the malloced 
memory by passing the raw() data to another C routine?

I've written some code that does this, I'm just not sure if anything 
could go wrong. The worst I can come up with is a memory leak if the 
structure's memory isn't freed - possibly because the R is interrupted.

R isn't going to stomp on memory that's been malloced by an included C 
routine between .C calls though, is it?

Barry

[[
gory details:

   R code calls a C routine with .C passing a 4-byte (because 4 is 
sizeof(char*) in my architecture) 'raw' object, the C code then mallocs 
the structure and copies the address of the structure into the 4 bytes 
that the raw object (which appears as a char* in the C routine argument 
list) points to. This gets returned back to R. Another option would be 
to create a raw object of the right size to store my structure, pass 
that to C and not malloc anything in C. But that would mean altering the 
C code which I want to do as little as possible.

gory code available on request.

]]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] simple parallel computing on single multicore machine

2006-12-01 Thread Millo Giovanni
Dear List,

the advent of multicore machines in the consumer segment makes me wonder
whether it would, at least in principle, be possible to divide a
computational task into more slave R processes running on the different
cores of the same processor, more or less in the way package SNOW would
do on a cluster. I am thinking of simple 'embarassingly parallel'
problems, just like inverting 1000 matrices, estimating 1000 models or
the like.

I have seen some talk here on making R multi-threaded and the like, but
this is much simpler. I am just a curious useR, so don't bother if you
don't have time, but maybe you can point me at some resource, or just
say "this is nonsense"...

Cheers 
Giovanni

Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4, 
34131 Trieste (Italy)
tel. +39 040 671184 
fax  +39 040 671160
 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni ...{{dropped}}

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dummies multiplied with other variable (solved)

2006-12-01 Thread Andreas Goesele
"David Barron" <[EMAIL PROTECTED]> writes:

> I'm not sure if this will help, but it's worth a try.  Do the
> regression as I suggested before, extract the model matrix and remove
> the "offending" column.  I'm assuming you don't know in advance how
> many levels there are in the factor.  Then use this to perform the
> regression.  Something like this:
>
> m1 <- lm(x ~ fd:y + fd)
> mm <- model.matrix(m1)
> nl <- length(levels(fd))
> newdat <- mm[,-c(1,nl)]
> lm(x ~ newdat)

Thanks a lot! With a small change that solved my problem!

-- 
Andreas Gösele   Omnis enim res, quae dando non deficit,
Inst. f. Gesellschaftspolitikdum habetur et non datur,
Kaulbachstr. 31a, 80539 München  nondum habetur, quomodo habenda est.
E-mail: [EMAIL PROTECTED]  (Augustinus)

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Gavin Simpson
On Fri, 2006-12-01 at 12:13 +0100, Peter Dalgaard wrote:
> Gavin Simpson wrote:

> >
> > I just don't understand what is going on with data.frame.
> >
> >   
> I think there is something about the data you're not telling us...

Yes, that I was doing something very, very silly that I thought would
work (produce a vector CLmaxN of the required length), but was in fact
blowing out to a huge named list. It was this that was causing the
massive increase in computation time in data.frame over cbind.

After correcting my mistake, timings for data.frame are:

system.time(fab <- data.frame(lc.ratio, Q,
+  fNupt,
+  rho.n, rho.s,
+  net.Nimm,
+  net.Nden,
+  CLminN,
+  CLmaxN,
+  CLmaxS))
[1] 0.012 0.000 0.011 0.000 0.000
Browse[1]> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
+  fNupt = fNupt,
+  rho.n = rho.n, rho.s = rho.s,
+  net.Nimm = net.Nimm,
+  net.Nden = net.Nden,
+  CLminN = CLminN,
+  CLmaxN = CLmaxN,
+  CLmaxS = CLmaxS))
[1] 0.008 0.000 0.018 0.000 0.000

One vector has names for some reason, removing them brings the un-named
data.frame version down to the named version timing and makes no
difference to the named version

Browse[1]> names(CLmaxS) <- NULL
Browse[1]> system.time(fab <- data.frame(lc.ratio, Q,
+  fNupt,
+  rho.n, rho.s,
+  net.Nimm,
+  net.Nden,
+  CLminN,
+  CLmaxN,
+  CLmaxS))
[1] 0.008 0.000 0.016 0.000 0.000
Browse[1]> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
+  fNupt = fNupt,
+  rho.n = rho.n, rho.s = rho.s,
+  net.Nimm = net.Nimm,
+  net.Nden = net.Nden,
+  CLminN = CLminN,
+  CLmaxN = CLmaxN,
+  CLmaxS = CLmaxS))
[1] 0.008 0.000 0.009 0.000 0.000

Apologies to the list for bothering you all with my stupidity and thank
you again to everyone who replied - I knew it was I who was doing
something wrong, but couldn't see it and thanks to your comments,
suggestions and queries I was able to work out what that was.

All the best,

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC & ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] A different contingency table of counts by case

2006-12-01 Thread Serguei Kaniovski
Dear All,

the following code, by courtesy of Jacques VESLOT, collates the
following contingency table from DATA (read in as "df", sample listed
below)

"led" represents (court) cases,
"jid" the (justices) persons, and
"vote" is the binary state.

The command:

smat<-t(apply(combinations(nlevels(df$jid), 2), 1, function(x)
with(df[df$jid %in% levels(df$jid)[x],],
table(factor(unlist(sapply(split(vote, led), function(y)
ifelse(length(y) == 2, paste(y, collapse=""), NA))),
levels=c("00","01","10","11"))

collates a contingency table of number of cases any two persons

a. both have "1",
b. the first has "0" - the second has "1",
c. the first has "1" - the second has "0",
d. both have "0".

QUESTION: I would like to collate a table counting all possible
combinations of binary states, ie voting outcomes. Each "led" contains 9
"jid", so there will be 2^9=512 different possibilities. These are, in
the order of the decimals the vectors represent,
(1,1,1,1,1,1,1,1,1)
(1,1,1,1,1,1,1,1,0)
(1,1,1,1,1,1,1,0,1)
etc. until
(0,0,0,0,0,0,0,0,1)
(0,0,0,0,0,0,0,0,0)
What I need to know is how often each of the 512 outcomes occurs.

Thanks,
Serguei

DATA:
jid,led,vote
breyer;143/0154;0
ginsberg;143/0154;0
kennedy;143/0154;1
oconnor;143/0154;0
rehnquist;143/0154;0
scalia;143/0154;0
souter;143/0154;0
stevens;143/0154;0
thomas;143/0154;1
breyer;143/0171;1
ginsberg;143/0171;1
kennedy;143/0171;1
oconnor;143/0171;0
rehnquist;143/0171;0
scalia;143/0171;0
souter;143/0171;1
stevens;143/0171;1
thomas;143/0171;0
breyer;143/0238;1
ginsberg;143/0238;1
kennedy;143/0238;1
oconnor;143/0238;1
rehnquist;143/0238;1
scalia;143/0238;1
souter;143/0238;1
stevens;143/0238;1
thomas;143/0238;1
breyer;143/0258;1
ginsberg;143/0258;1
kennedy;143/0258;1
oconnor;143/0258;1
rehnquist;143/0258;1
scalia;143/0258;1
souter;143/0258;1
stevens;143/0258;1
thomas;143/0258;1
breyer;143/0270;0
ginsberg;143/0270;0
kennedy;143/0270;1
oconnor;143/0270;0
rehnquist;143/0270;1
scalia;143/0270;1
souter;143/0270;0
stevens;143/0270;0
thomas;143/0270;1
breyer;143/0311;0
ginsberg;143/0311;1
kennedy;143/0311;0
oconnor;143/0311;0
rehnquist;143/0311;0
scalia;143/0311;1
souter;143/0311;1
stevens;143/0311;1
thomas;143/0311;1
breyer;143/0388;1
ginsberg;143/0388;1
kennedy;143/0388;1
oconnor;143/0388;1
rehnquist;143/0388;1
scalia;143/0388;0
souter;143/0388;1
stevens;143/0388;0
thomas;143/0388;1
breyer;143/0399;1
ginsberg;143/0399;1
kennedy;143/0399;1
oconnor;143/0399;1
rehnquist;143/0399;1
scalia;143/0399;1
souter;143/0399;1
stevens;143/0399;1
thomas;143/0399;1
breyer;143/0408;1
ginsberg;143/0408;0
kennedy;143/0408;1
oconnor;143/0408;1
rehnquist;143/0408;1
scalia;143/0408;1
souter;143/0408;0
stevens;143/0408;0
thomas;143/0408;1

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Peter Dalgaard
Gavin Simpson wrote:
> [ Resending to the list as I fell foul of the too many recipients rule ]
>
> On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote:
>
> Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline)
> for your comments and suggestions.
>
> I noticed that two of the vectors were named and so I removed the names
> (names(vec) <- NULL) and that pushed the execution time for the function
> from c. 40 seconds to c. 115 seconds and all the time was taken within
> the data.frame(...) call. So having names *on* some of the vectors
> seemed to help things along, which was the opposite of what i had
> expected.
>
> If I use the cbind method of Marc, then the execution time for the
> function drops to c. 1 second (most of which is in the calculation of
> one of the vectors). So I guess I can work round this now.
>
> What I find interesting is that:
>
> test.dat <- rnorm(4471)
>   
>> system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
>> 
> test.dat,
> + col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
> + col8 = test.dat, col9 = test.dat, col10 = test.dat))
> [1] 0.008 0.000 0.007 0.000 0.000
>
> Whereas doing exactly the same thing with different data in the function
> gives the following timings:
>
> system.time(fab <- data.frame(lc.ratio, Q,
> +  fNupt,
> +  rho.n, rho.s,
> +  net.Nimm,
> +  net.Nden,
> +  CLminN,
> +  CLmaxN,
> +  CLmaxS))
> [1] 173.415   0.260 192.192   0.000   0.000
>
> Most of that was without a change in memory, but towards the end for c.
> 5 seconds memory use by R increased by 200-300 MB.
>
> and...
>
>   
>> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
>> 
> +  fNupt = fNupt,
> +  rho.n = rho.n, rho.s = rho.s,
> +  net.Nimm = net.Nimm,
> +  net.Nden = net.Nden,
> +  CLminN = CLminN,
> +  CLmaxN = CLmaxN,
> +  CLmaxS = CLmaxS))
> [1]  99.966   0.140 114.091   0.000   0.000
>
> Again with a slight increase in memory usage in last 5 seconds. So now,
> having stripped the names of two of the vectors (so now all are
> un-named), the un-named version of the data.frame call is almost twice
> as slow as the named data.frame call.
>
> If I leave the names on the two vectors that had them, I get the
> following timings for those same calls
>
>   
>> system.time(fab <- data.frame(lc.ratio, Q,
>> 
> +  fNupt,
> +  rho.n, rho.s,
> +  net.Nimm,
> +  net.Nden,
> +  CLminN,
> +  CLmaxN,
> +  CLmaxS))
> [1]  96.234   0.244 101.706   0.000   0.000
>
>   
>> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
>> 
> +  fNupt = fNupt,
> +  rho.n = rho.n, rho.s = rho.s,
> +  net.Nimm = net.Nimm,
> +  net.Nden = net.Nden,
> +  CLminN = CLminN,
> +  CLmaxN = CLmaxN,
> +  CLmaxS = CLmaxS))
> [1] 13.597  0.088 15.868  0.000  0.000
>
> So having the 2 named vectors and using the named version of the
> data.frame call is the fastest combination.
>
> This is all done within the debugger at the time when I would be
> generating fab, and if I do,
>
> system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
> test.dat,
> + col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
> + col8 = test.dat, col9 = test.dat, col10 = test.dat))
> [1] 0.008 0.000 0.007 0.000 0.000
>
> (as above) at this point in the debugger it is exceedingly quick.
>
> I just don't understand what is going on with data.frame.
>
>   
I think there is something about the data you're not telling us...

Could you e.g. do something like

str(data.frame(lc.ratio, Q,
  fNupt,
  rho.n, rho.s,
  net.Nimm,
  net.Nden,
  CLminN,
  CLmaxN,
  CLmaxS))


and

str(list(lc.ratio, Q,
  fNupt,
  rho.n, rho.s,
  net.Nimm,
  net.Nden,
  CLminN,
  CLmaxN,
  CLmaxS))





-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://

Re: [R] writing function with ,... )

2006-12-01 Thread Carmen Meier
Thanks, a lot
I was not able to find it the hole day ...
Carmen

Phil Spector schrieb:
> Carmen -
>You certainly can write functions that use ..., but you need
> to extract the arguments that the dots represent with list().
> Here's a modified version of your function that may help explain
> how this feature works.
>
> test <- function(x,...){
> print(x)
> args = list(...)
> if('y' %in% names(args))print(args$y)
> if('z' %in% names(args))print(args$z)
> }
>
>- Phil Spector
>  Statistical Computing Facility
>  Department of Statistics
>  UC Berkeley
>  [EMAIL PROTECTED]
>
>

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quicker way of combining vectors into a data.frame

2006-12-01 Thread Gavin Simpson
[ Resending to the list as I fell foul of the too many recipients rule ]

On Thu, 2006-11-30 at 11:34 -0600, Marc Schwartz wrote:

Thanks to Marc, Prof. Ripley, Sebastian and Sebastian (Luque - offline)
for your comments and suggestions.

I noticed that two of the vectors were named and so I removed the names
(names(vec) <- NULL) and that pushed the execution time for the function
from c. 40 seconds to c. 115 seconds and all the time was taken within
the data.frame(...) call. So having names *on* some of the vectors
seemed to help things along, which was the opposite of what i had
expected.

If I use the cbind method of Marc, then the execution time for the
function drops to c. 1 second (most of which is in the calculation of
one of the vectors). So I guess I can work round this now.

What I find interesting is that:

test.dat <- rnorm(4471)
> system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
test.dat,
+ col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
+ col8 = test.dat, col9 = test.dat, col10 = test.dat))
[1] 0.008 0.000 0.007 0.000 0.000

Whereas doing exactly the same thing with different data in the function
gives the following timings:

system.time(fab <- data.frame(lc.ratio, Q,
+  fNupt,
+  rho.n, rho.s,
+  net.Nimm,
+  net.Nden,
+  CLminN,
+  CLmaxN,
+  CLmaxS))
[1] 173.415   0.260 192.192   0.000   0.000

Most of that was without a change in memory, but towards the end for c.
5 seconds memory use by R increased by 200-300 MB.

and...

> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
+  fNupt = fNupt,
+  rho.n = rho.n, rho.s = rho.s,
+  net.Nimm = net.Nimm,
+  net.Nden = net.Nden,
+  CLminN = CLminN,
+  CLmaxN = CLmaxN,
+  CLmaxS = CLmaxS))
[1]  99.966   0.140 114.091   0.000   0.000

Again with a slight increase in memory usage in last 5 seconds. So now,
having stripped the names of two of the vectors (so now all are
un-named), the un-named version of the data.frame call is almost twice
as slow as the named data.frame call.

If I leave the names on the two vectors that had them, I get the
following timings for those same calls

> system.time(fab <- data.frame(lc.ratio, Q,
+  fNupt,
+  rho.n, rho.s,
+  net.Nimm,
+  net.Nden,
+  CLminN,
+  CLmaxN,
+  CLmaxS))
[1]  96.234   0.244 101.706   0.000   0.000

> system.time(fab <- data.frame(lc.ratio = lc.ratio, Q = Q,
+  fNupt = fNupt,
+  rho.n = rho.n, rho.s = rho.s,
+  net.Nimm = net.Nimm,
+  net.Nden = net.Nden,
+  CLminN = CLminN,
+  CLmaxN = CLmaxN,
+  CLmaxS = CLmaxS))
[1] 13.597  0.088 15.868  0.000  0.000

So having the 2 named vectors and using the named version of the
data.frame call is the fastest combination.

This is all done within the debugger at the time when I would be
generating fab, and if I do,

system.time(z <- data.frame(col1 = test.dat, col2 = test.dat, col3 =
test.dat,
+ col4 = test.dat, col5 = test.dat, col6 = test.dat, col7 = test.dat,
+ col8 = test.dat, col9 = test.dat, col10 = test.dat))
[1] 0.008 0.000 0.007 0.000 0.000

(as above) at this point in the debugger it is exceedingly quick.

I just don't understand what is going on with data.frame.

I have yet to try Prof. Ripley's suggestion of being a bit naughty with
R - I'll see if that is any quicker.

Once again, thanks to you all for your suggestions.

All the best,

G

> Gavin,
> 
> One more note, which is that even timing the direct data frame creation
> on my system with colnames, again using the same 10 numeric columns, I
> get:
> 
> > system.time(DF1 <- data.frame(lc.ratio = Col1, Q = Col2, fNupt = Col3,
> rho.n = Col4, rho.s = Col5, 
> net.Nimm = Col6, net.Nden = Col7, 
> CLminN = Col8, CLmaxN = Col9, 
> CLmaxS = Col10))
> [1] 0.012 0.000 0.028 0.000 0.000
> 
> 
> > str(DF1)
> 'data.frame':   4471 obs. of  10 variables:
>  $ lc.ratio: num   0.1423  0.1873 -1.8129  0.0255 -1.7650 ...
>  $ Q   : num   0.8340 -0.2387 -0.0864 -1.1184 -0.3368 ...
>  $ fNupt   : num  -0.1718 -0.0549  1.5194 -1.6127 -1.2019 ...
>  $ rho.n   : num  -0.740  0.240  0.522 -1.492  1.003 ...
>  $ rho.s   : num  -0.2363 -1.6248 -0.3045  0.0294  0.1240 ...
>  $ net.Nimm: num  -0.774  0.947 -1.098  0.809  1.216 ...
>  $ net.Nden: num  -0.198 -0.135 -0.300 -0.618 -0.784 ...
>  $ CLminN  : num   0.924 -3.265  0.211  0.813  0.262 ...
>  $ CLmaxN  : num   0.3212 -0.0502 -0.9978  

Re: [R] Aggregating data

2006-12-01 Thread Petr Pikal
Hi

On 29 Nov 2006 at 10:26, David Kaplan wrote:

Date sent:  Wed, 29 Nov 2006 10:26:32 -0600
From:   David Kaplan <[EMAIL PROTECTED]>
To: Petr Pikal <[EMAIL PROTECTED]>
Copies to:  r-help@stat.math.ethz.ch
Subject:Re: [R] Aggregating data

> The problem is that this doesn't seem to give what I want.  I did look
> at this.  Perhaps doBy will work - haven't tried it yet.  But, any

the only thing we know what you want to do is aggregating data. 
That's why I directed you to the mentioned possibilities for data 
aggregating.

Below each post you will find this 

> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.

and doing what is recommended can help others to understand your 
problem. Without telling us anything we also can do almost nothing.

HTH
Petr


> other suggestions are much appreciated.
> 
> 
> ==
> = David Kaplan, Ph.D. Professor Department of Educational
> Psychology University of Wisconsin - Madison Educational Sciences,
> Room, 1061 1025 W. Johnson Street Madison, WI 53706
> 
> email: [EMAIL PROTECTED]
> homepage:
> http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
> Phone: 608-262-0836
> ==
> =
> 
> Petr Pikal wrote:
> > Similar answer as last time
> > 
> > aggregate, tapply, by or ppackage doBy
> > 
> > HTH
> > 
> > PS. If you want to add some other text then subject in your post do
> > not use HTML posting as recommended in posting guide.
> > 
> > Petr
> > 
> > 
> > On 28 Nov 2006 at 22:04, David Kaplan wrote:
> > 
> > Date sent:  Tue, 28 Nov 2006 22:04:09 -0600
> > From:   David Kaplan <[EMAIL PROTECTED]>
> > To: r-help@stat.math.ethz.ch
> > Subject:[R] Aggregating data
> > 
> >> __
> >> 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 and provide commented,
> >> minimal, self-contained, reproducible code.
> > 
> > Petr Pikal
> > [EMAIL PROTECTED]
> >
> 
> __
> 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 and provide commented,
> minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] specify point shape for ggplot (equivalent to pch)?

2006-12-01 Thread Rainer M Krug
Hi

is it possible to specify the shape of the point to be used in ggplot 
(as with pch in plot)? I couldn't find anything in the help.

Thanks

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[EMAIL PROTECTED]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question on sub(stitute) X_1 -> X\_1

2006-12-01 Thread Prof Brian Ripley
You are confusing the printed representation with the string (a clue which 
is all over the archives, and in ?regex).

X1 <- sub("_","\\_","X_1",fixed=TRUE)
print(X1)
cat(X1, "\n")
X2 <- sub("_","_","X_1")
cat(X1, "\n")

both do as you ask.

On Fri, 1 Dec 2006, Christian Hoffmann wrote:

> Hi,
>
> Searching the archives has brought no clue:
>
> For a tex chunk in an Sweave text
>
> "Oracle query results: differences \Sexpr{varname},..."
>
> I need to change the string varname from "X_1" to "X\_1",
>
> sub("_",??,"X_+")  -> "X\_1"
>
> so that subsequent Latex will generate "X_1" (i.e. show the underscore)
> instead of "X subscript 1" (subscripting the "1")
>
> Various trials with sub("_","\\_",varname) and the like have not helped.
>
> sub("_","\\_","X_1") -> "X_1"
> sub("_","\\_","X_1",fixed=TRUE)  -> "X\\_1"
> sub("_","\_","X_1",fixed=TRUE)   -> "X_1"
>
> Latex will translate  "X\\_1" to X  (linefeed) 1  !!
>
> Thanks for help
>
> Christian
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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@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
and provide commented, minimal, self-contained, reproducible code.


[R] Box Tidwell / Error Message

2006-12-01 Thread Simon P. Kempf
Dear R-Users,

 

I used the box.tidwell () function of the car Package. 

 

When I used the following formula:

 

semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ I(age+1)+I(age2+1)+X06A
+ I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_YEAR + C_X01 + C_X14 + C_X19 +
C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 + D_X25 + D_X27 + D_X30 +
D_X32 + D_X35, data = semi.sub.in.mi1)

 

everything is fine.

 

However, when I replaced the time dummy variable:

 

semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ I(age+1)+I(age2+1)+X06A
+ I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_HALF + C_X01 + C_X14 + C_X19 +
C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 + D_X25 + D_X27 + D_X30 +
D_X32 + D_X35, data = semi.sub.in.mi1)

 

I get the following error message:

 

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 

NA/NaN/Inf in foreign function call (arg 1)

 

When I use the following formula (I deleted the I(age2+1) term):

 

semi.sub.in.mi1.boxtidwell_h<-box.tidwell(RENT_LG ~ I(age+1)+X06A +
I(X08B+1) + I(X22+1) + I(X24+1) + X31A, ~B_HALF + C_X01 + C_X14 + C_X19 +
C_X29A +C_X21 + C_X23 + D_X12 + D_X17 + D_X18 + D_X25 + D_X27 + D_X30 +
D_X32 + D_X35, data = semi.sub.in.mi1)

 

It works.

 

Some background information:

 

-  The formula with the predictors to be transformed contains only
variables which are >0.

-  The data set does not have any missing values

-  B_YEAR is a factor with 10 levels

-  B_HALF is a factor with 20 levels

-  The data set contains more than 19000 observations.

 

Now, I am bit confused. Why does the function works when I use B_YEAR
respecitvely why does it work with B_HALF when I delete I(age2+1)

 

Thanks in advance,

 

Simon

 

 

 

 

Simon P. Kempf 

Dipl.-Kfm. MScRE Immobilienökonom (ebs)

Wissenschaftlicher Assistent

 

Büro:

IREBS Immobilienakademie

c/o ebs Immobilienakademie GmbH

Berliner Str. 26a

13507 Berlin

 

Privat:

Dunckerstraße 60

10439 Berlin

 

Mobil: 0176 7002 6687

Email:   [EMAIL PROTECTED]

 


[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] RKward installation problem

2006-12-01 Thread İbrahim Mutlay
Dear R users,

Recenty i tried to install the R GUI of "RKward", but i think something is
wrong. In installation, i used the command such like:

[EMAIL PROTECTED]:/usr/lib/rkward# ./configure --enable-R-shlib

or,

[EMAIL PROTECTED]:/usr/lib/rkward# ./configure --enable-R-shlib
--prefix=/usr/lib/kde3

due to in INSTALL file, it is said that use these commands if you don't have
the libR.so file in /usr/lib/R/lib/

But, after the configuration i read:

checking for libR.so... configure: error:
   /usr/lib/R/lib/libR.so does not exist.
   Check whether you have compiled R with shared library,
   and the --with-r-home setting was detected correctly above.

When these words appear, "make" and "make install" commands cannot run
anyway.

Thanks...

Ýbrahim Mutlay

[[alternative HTML version deleted]]

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] analog to the matlab buffer function?

2006-12-01 Thread Robin Hankin
 > do.call("rbind",lapply(0:4,function(i){i+(1:5)}))
  [,1] [,2] [,3] [,4] [,5]
[1,]12345
[2,]23456
[3,]34567
[4,]45678
[5,]56789
 >



On 1 Dec 2006, at 00:32, Charles C. Berry wrote:

>
> See
>
>   ?embed
>
> It is not quite the same, but this seems to be what you want - at  
> least
> for the example you give:
>
>> t( embed(1:5,3) )[3:1,]
>   [,1] [,2] [,3]
> [1,]123
> [2,]234
> [3,]345
>>
>
> On Fri, 1 Dec 2006, Martin Ivanov wrote:
>
>> Hello! I am new to R. I could not find a function analogous to  
>> matlab's
>> function buffer, which is used in signal processing. Is there such a
>> function in R? What I need to do is as follows. If I apply the  
>> function
>> to the vector c(1:5) for example with a window length 3 and  
>> overlapping
>> 2, I need to get a matrix like this:
>> 1 2 3
>> 2 3 4
>> 3 4 5
>> In matlab this is achieved with the function buffer. Is there  
>> ananalogous R function?
>>
>> Thank you very much in advance.
>> Regards,
>> Martin
>>
>> __
>> 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
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> Charles C. Berry(858) 534-2098
>   Dept of Family/Preventive  
> Medicine
> E mailto:[EMAIL PROTECTED] UC San Diego
> http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego  
> 92093-0717
>
> __
> 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
> and provide commented, minimal, self-contained, reproducible code.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Vertical line in densityplot?

2006-12-01 Thread Gustaf Rydevik
On 12/1/06, Thomas Petzoldt <[EMAIL PROTECTED]> wrote:
> Hi,
>
> lattice graphics work by utilizing so called panel functions. Here is a
> working version of your example:
>
> library(lattice)
> x<-rnorm(100)
> plot.new()
> densityplot(x,
>   panel=function(x, ...){
> panel.densityplot(x, ...)
> panel.abline(v=0)
>   }
> )
>
>
> For mor information, please look into the examples of densityplot and
> the help file of panel.abline
>
>
> Hope it helps
>
> Thomas
>

Thank you very much! Lattice works somewhat different from "regular"
graphics step-by-step addition then.

With standard axis, I just meant a set of axis where the x and y axis
are represented by lines going through origo, or (0,0). Right now some
sort of box is used instead.

Thanks again!

/Gustaf

-- 
email:[EMAIL PROTECTED]
tel: +46(0)703051451
address: Kantorsgatan 50:190 75424 Uppsala Sweden

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Question on sub(stitute) X_1 -> X\_1

2006-12-01 Thread Christian Hoffmann
Hi,

Searching the archives has brought no clue:

For a tex chunk in an Sweave text

"Oracle query results: differences \Sexpr{varname},..."

I need to change the string varname from "X_1" to "X\_1",

sub("_",??,"X_+")  -> "X\_1"

so that subsequent Latex will generate "X_1" (i.e. show the underscore) 
instead of "X subscript 1" (subscripting the "1")

Various trials with sub("_","\\_",varname) and the like have not helped.

sub("_","\\_","X_1") -> "X_1"
sub("_","\\_","X_1",fixed=TRUE)  -> "X\\_1"
sub("_","\_","X_1",fixed=TRUE)   -> "X_1"

Latex will translate  "X\\_1" to X  (linefeed) 1  !!

Thanks for help

Christian
-- 
Dr. Christian W. Hoffmann,
Swiss Federal Research Institute WSL
Zuercherstrasse 111, CH-8903 Birmensdorf, Switzerland
Tel +41-44-7392-277 (office), -111(exchange), -215  (fax)
[EMAIL PROTECTED],  www.wsl.ch/staff/christian.hoffmann

__
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
and provide commented, minimal, self-contained, reproducible code.