[R] data.frame handling

2007-03-19 Thread Michela Cameletti
Dear R-users,
I have a little problem that I can't solve by myself.
I have a data frame with 2 factors and 8 observations (see the following
code):

 y - c(1,1,1,2,2,3,3,3)
 y - factor(y)
 levels(y) - c(a,b,c)
 x - c(1,2,3,1,2,1,2,3)
 x - factor(x)
 levels(x) - c(x,y,z)
 X  - data.frame(factor1=x,factor2=y)

and the final result is

  factor1 factor2
1   x   a
2   y   a
3   z   a
4   x   b
5   y   b
6   x   c
7   y   c
8   z   c

From the above data I'd like to obtain the following matrix:
a   b   c
x   1   1   1
y   1   1   1
z   1   0   1

Do you have any advice? Can you help me please?
Thank you in advance,
Michela

__
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] spatio temporal plot

2007-01-08 Thread Michela Cameletti
Dear R-users,
I have a matrix of data (air pollution) with n rows and T columns, where n
is the number of spatial locations and T is the number of time points
(days of the year).
I would like to use a 3d plot for plotting the n time series I have: so
x-axis and y-axis are for the spatial coordinates and the z-axis is for
the T air pollution data. But the final result should be like this: see
the attached figure. It's like doing n vertical plots of the n time series
and put them nearby using the spatial coordinates.
Can you help me please?
Thanks in advance,
best regards
Michela

timeseriesplot.PNG
Description: PNG image
__
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] double boostrap with clusterApplyLB

2006-12-11 Thread Michela Cameletti
Dear R-Users,
we are using a linux-cluster with RMPI and the snow package.
We would like to do a double boostrap.
We have a general function that implements the first boostrap (the outer) and
we are wondering if we can include another bootstrap (the inner) in the
same general function including another clusterApplyLB.

For example:

general function = function(...) {
  clusterApplyLB(cl, fun,...) }
where fun is the function for the inner boostrap

outer bootstrap = clusterApplyLB(cl,general function,...)

Does R accept this kind of expression?
Thank you very much in advance,
Michela and Marco

__
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] loading libraries on MPI cluster

2006-11-23 Thread Michela Cameletti
Dear R-users,
we are using library(snow) for computation on a linux cluster with RMPI.
We have a problem with clusterEvalQ: after launching clusterEvalQ it seems
loading the required library on each node but if we type a function
belonging to the loaded package R doesn't find it.

 library(snow)

# making cluster with 3 nodes
 cl - makeCluster(3, type = MPI)
Loading required package: Rmpi
3 slaves are spawned successfully. 0 failed.

#loading library abind on each node
 clusterEvalQ(cl,library(abind))
[[1]]
 [1] abind EMsspir   mvtnorm   MASS  snow  Rmpi
 [7] methods   stats graphics  grDevices utils datasets
[13] base

[[2]]
 [1] abind EMsspir   mvtnorm   MASS  snow  Rmpi
 [7] methods   stats graphics  grDevices utils datasets
[13] base

[[3]]
 [1] abind EMsspir   mvtnorm   MASS  snow  Rmpi
 [7] methods   stats graphics  grDevices utils datasets
[13] base

#searching for function abind belonging to library abind
 abind
Error: object abind not found

Is it possible to know which libraries each node has loaded?
Thank you very much
best regards
Michela and Marco

__
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] Rmpi performance

2006-10-13 Thread Michela Cameletti
Dear R users,
we are trying to do some parallel computing using library(snow).
In particular we have a cluster with 3 nodes

cl - makeCluster(3, type = MPI)
3 slaves are spawned successfully. 0 failed.


and we want to compute the function op_mat (see below) first with the 
master and then with the cluster using system.time for checking the 
computational performance.

op_mat = function(mat) {

+   inv = solve(mat)
+   det_inv = det(inversa)
+   tr_inv  = sum(diag(inversa))
+   return(list(c(det=det_inv,tr=tr_inv)))
+ }

nn = 3000
XX = matrix(rnorm(nn*nn),nn,nn)
# with the master
 system.time(op_matrici(XX))
[1] 42.283  1.883 44.168  0.000  0.000
# with the cluster
 system.time(clusterCall(cl,op_matrici,XX))
[1] 11.523 12.612 71.562  0.000  0.000

You can see that using the master it takes 44.168 seconds for computing 
the function on matrix XX while it takes 71.562 seconds (more time!!!) 
with the cluster. Can you give us some advice in order to understand why 
the cluster is slower than the master?
Thank you very much in advance,
bye
Michela  and Marco
Ps: we have a gigabit ethernet between the master and the nodes

__
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] SSPIR problem

2006-06-15 Thread michela . cameletti
Dear R-Users,
I'm using SSPIR package for a spatio-temporal application.
Is it possible to modify the structure of the involved matrixes (Fmat,
Gmat, Vmat,Wmat)?
I want to create a model like this

#y(t)=k*theta(t)+epsilon(t)
#theta(t)=h*theta(t-1)+eta(t)
#epsilon(t) N(0,V) V=sigma2*I
#eta(t) N(0,W)W=sigma2_eta

where the state variable theta has dimension 1(p=1) and at each time time
the observed variable y has dimension equal to d=3. Moreover I want to use
white noise errors.
But with the command
SS(y) where y is my nXd data matrix (d=observations at each time,
n=numbers of time points)
I obtain a different model.

Can you help me please?
Thanks in advance
Michela

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


[R] SSPIR problem

2006-06-15 Thread michela . cameletti
Dear R-Users,
I'm using SSPIR package for a spatio-temporal application.
Is it possible to modify the structure of the involved matrixes (Fmat,
Gmat, Vmat,Wmat)?
I want to create a model like this

#y(t)=k*theta(t)+epsilon(t)
#theta(t)=h*theta(t-1)+eta(t)
#epsilon(t) N(0,V) V=sigma2*I
#eta(t) N(0,W)W=sigma2_eta

where the state variable theta has dimension 1(p=1) and at each time time
the observed variable y has dimension equal to d=3. Moreover I want to use
white noise errors.
But with the command
SS(y) where y is my nXd data matrix (d=observations at each time,
n=numbers of time points)
I obtain a different model.

Can you help me please?
Thanks in advance
Michela

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


[R] EM algorithm

2006-04-04 Thread michela . cameletti
Dear R-Users,
I have a model with a latent variable for a spatio-temporal process.
I would like to use EM algorithm to estimate the parameters.
Does anybody know how to implement the algorithm in R?
Thank you very much in advance,
Michela

__
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