[R] extract positions from matrix

2011-11-17 Thread .Jpg
Hi everyone, I tried to solve this problem but I could not find the 
solution. I have about 105 matrices of equal size in the memory of**R, I 
need to do is extract from these matrices some known positions and 
create a new matrix with these columns. Show you an example with only 
three matrices (but in my case I have hundreds of them).

A=matrix(1:15,5)

[,1] [,2] [,3]

[1,] 1 6 11

[2,] 2 7 12

[3,] 3 8 13

[4,] 4 9 14

[5,] 5 10 15

B=matrix(15:29,5)

[,1] [,2] [,3]

[1,] 15 20 25

[2,] 16 21 26

[3,] 17 22 27

[4,] 18 23 28

[5,] 19 24 29

C=matrix(30:44,5)

[,1] [,2] [,3]

[1,] 30 35 40

[2,] 31 36 41

[3,] 32 37 42

[4,] 33 38 43

[5,] 34 39 44

The positions I wish to extract are 1 and 5 of the first row of each 
matrix (in my case are 25positions) and with this generate a new matrix 
with the form

d=

[,1] [,2] [,3]

[1,] 1 15 30

[2,] 5 19 34

The ideais to builda loop toextract thisinformation from 
hundredsmatrices, butI failed todo so.

Any helpwould be greatthank you very muchin advance

regards
.jpg


[[alternative HTML version deleted]]

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


[R] tuning random forest. An unexpected result

2011-11-17 Thread gianni lavaredo
Dear Researches,

I am using RF (in regression way) for analize several metrics extract from
image. I am tuning RF setting a loop using different range of mtry, tree
and nodesize using the lower value of MSE-OOB

mtry from 1 to 5
nodesize from1 to 10
tree from 1 to 500

using this paper as refery

Palmer, D. S., O'Boyle, N. M., Glen, R. C.,  Mitchell, J. B. O. (2007).
Random Forest Models To Predict Aqueous Solubility. Journal of Chemical
Information and Modeling, 47, 150-158.

my problem is the following using data(airquality) :

the tunning parameters with the lower value is:

 print(result.mtry.df[result.mtry.df$RMSE == min(result.mtry.df$RMSE),])
*RMSE  = 15.44751
MSE = 238.6257
mtry = 3
nodesize = 5
tree = 35*

the numer of tree is very low, different respect how i can read in several
pubblications

And the second value lower is a tunning parameters with *tree = 1*

print(head(result.mtry.df[
with(result.mtry.df, order(MSE)), ]))
  RMSE  MSE mtry nodesize tree
12035 15.44751 238.625735   35
*18001 15.44861 238.6595471
*7018  16.02354 256.753925   18
20031 16.02536 256.812151   31
11037 16.02862 256.916533   37
11612 16.05162 257.654434  112

i am wondering if i wrong in the setting or there are some aspects i don't
conseder.
thanks for attention and thanks in advance for suggestions and help

Gianni

[[alternative HTML version deleted]]

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


[R] Predicting response from new curves using fda package

2011-11-17 Thread rubbish
Basically all I want to do is predict a scalar response using some 
curves. I've got as far as doing a regression (using fRegress from the 
fda package) but have no idea how to apply the results to a NEW set of 
curves (for prediction).

I have N=536 curves, and 536 scalar responses. Here's what I've done so far:

  * I've created a basis for the curves.
  * I've created a fdPar object to introduce a penalty
  * I've created the fd object using smooth.basis to smooth the curves
with the chosen penalty on the specified basis.
  * I've ran a regression using fRegress(), regressing the curves on the
scalar response.

Now, all I'd like to do, is use that regression to produce predictions 
for a new set of data that I have. I can't seem to find an easy way to 
do this.

Cheers


[[alternative HTML version deleted]]

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


[R] help

2011-11-17 Thread Somaye Node
hello mr martin
i need the program of lower incomplet Gamma function, and i dont know any thing 
about mathematica, my gamma function is Y(1/2,r^2/4*teta), r is variable. 
pleasr help me, its emmidiate for me.
all the best
somaye node

[[alternative HTML version deleted]]

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


Re: [R] Spatial Statistics using R

2011-11-17 Thread vioravis
Thanks a lot for the guidance. I will take a look at these options.

Ravi

--
View this message in context: 
http://r.789695.n4.nabble.com/Spatial-Statistics-using-R-tp4079092p4082354.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] building biOps on macports, and configure--vars

2011-11-17 Thread Prof Brian Ripley

Please don't ask non-R programming questions on R-help.

This is best asked on R-sig-mac, including details of how you built 
your R.  But the short answer is not to mix macports with the CRAN 
build of R.  And there are matching libs for CRAN's build at

http://r.research.att.com/libs/

On Thu, 17 Nov 2011, Timothy Teravainen wrote:



All,

the MacOSX binary build of the biOps package is broken on cran, so I am trying 
to compile from source. I am very close; the trick is apparently that this 
package depends on fftw3, libjpeg and libtiff. My fftw3 is in /usr/local/, but 
my libjpeg and libtiff are in /opt/local/ since i got them through macports. In 
general, I'd like to keep as many of my third-party libraries as I can in the 
macports system, which means that I need to point R CMD INSTALL to /opt/local. 
Here is the problem I am running into:

This is my current command-line:
sudo R CMD INSTALL --configure-vars='LIBS=-L/opt/local/lib 
CPPFLAGS=-I/opt/local/include/' 
--configure-args='--includedir=/opt/local/include --libdir=/opt/local/include' 
biOps_0.2.1.1.tar.gz

I found that by using the configure--vars argument i can get the 'configure' 
script to finish (without the configure--vars argument, the 'configure' script 
of course fails to find libjpeg and libtiff, and exits).

However, after 'configure' runs, when the installer actually tries to build the 
biOps package, it fails as follows:

gcc-4.2 -arch x86_64 -std=gnu99 
-I/Library/Frameworks/R.framework/Resources/include 
-I/Library/Frameworks/R.framework/Resources/include/x86_64  
-I/usr/local/include-fPIC  -g -O2 -c jpegio.c -o jpegio.o
jpegio.c:36:21: error: jpeglib.h: No such file or directory
pegio.c: In function ‘read_jpg_img_info’:
jpegio.c:52: error: storage size of ‘cinfo’ isn’t known
jpegio.c:53: error: storage size of ‘jerr’ isn’t known
[[... about 30 lines of this follow...]]
make: *** [jpegio.o] Error 1
ERROR: compilation failed for package ‘biOps’

The problem is, obviously, that the gcc call is missing -I/opt/local/include, 
even though I put that in both --configure-vars and --configure-args! I also note, that 
the '--configure-args' seems to have no effect at all. It's '--configure-vars' that 
allows the 'configure' script to finish successfully.

I've searched and read various docs, but I don't know what else I can do at 
this point (i'd like to avoid copying my libraries into /usr/local if at all 
possible, and it does seem that the point of the configure--foo arguments is to 
let me do that). Am I missing a necessary argument? Is it a bug in the biOps 
package? Is there any solution/workaround that doesn't involve copying stuff 
into /usr/local? Thanks for any help.


Yours,

Timothy Teravainen

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fisher Exact Test

2011-11-17 Thread Abraham Mathew
This mean
First, I am no expert but I am analyzing some marketing data.
I have information on two versions of the same site, and I have data
on the number of times people filled out a form on each version
of the site.

Sample data:

   Site 1  Site 2
Filled out form1035

Did not fill out form  5040


dat2 = matrix(c(10,50,35,40), ncol=2)
dat2
fisher.test(dat2)

 fisher.test(dat2)
Fisher's Exact Test for Count Data

data:  dat2
p-value = 0.0002381
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.09056509 0.54780215
sample estimates:
odds ratio
 0.2311144


I'm really not sure if I set up the test properly, but I can
obviously reject the null hypothesis given the low p-value.
Site 2 converts better than site 2 at a statistically significant
threshold.

Am I running my code wrong?
Can anyone help?

[[alternative HTML version deleted]]

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


Re: [R] Adding a year to existing date

2011-11-17 Thread Petr PIKAL
Hi

 
 On 17/11/11 17:33, arunkumar wrote:
  Hi
 
I need to add an year to and date field in the dataframe.
 
  Please help me
 
  X Date
  1 2008-01-01
  2 2008-02-01
  3 2003-03-01
 
 I can't find anything built in.  This is probably because year is an 
 ill-defined
 unit; years vary in length in a somewhat peculiar fashion.  So doing 
 arithmetic
 with respect to years is frowned on.
 
 However you might try this:
 
 `%+%` - function(x,y){
 if(!isTRUE(all.equal(y,round(y stop(Argument \y\ must be an 
 integer.\n)
   x - as.POSIXlt(x)
   x$year - x$year+y
 as.Date(x)
 }
 
 Then:
 
 xxx - as.Date(c(2008-01-01,2008-02-01,2003-03-01))
 xxx %+% 1
 [1] 2009-01-01 2009-02-01 2004-03-01

another option is

paste((as.numeric(format(xxx, %Y))+1), format(xxx,%m-%d), sep=-)

Regards
Petr


 
 Dunno what dangers lurk; caveat utilitor.
 
  cheers,
 
  Rolf Turner
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


<    1   2