Re: [R] Fisher's Test 5x4 table

2015-08-28 Thread Gerrit Eichner

Dear Paul,

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


So, what exactly did you try and what was the actual problem/error 
message?


Besides that, have you noted that two of you data rows have the same name?


Have you read the online help page of fisher.test():

 ?fisher.test


Have you tried anything like the following?

W - as.matrix( read.table( w.txt, head = T)[-1])

fisher.test( W, workspace = 1e8)
   # For workspace look at the help page, but it presumably
   # won't work because of your sample size.


set.seed( 20150828) # for reproducibility
fisher.test( W, simulate.p.value = TRUE, B = 1e5)
   # For B look at the help page.


Finally: Did Minitab really report p  0.001? ;-)

 Hth  --  Gerrit


Dear all,
   I am trying to do a fishers test on a 5x4 table on R
statistics. I have already done a chi squared test using Minitab on this
data set, getting a result of (1, N = 165.953, DF 12, p0.001), yet using
these results (even though they are excellent) may not be suitable for
publication. I have tried numerous other statistical packages in the hope
of doing this test, yet each one has just the 2x2 table.
   I am struggling to edit the template fishers test on R to fit
my table (as according to the R book it is possible, yet i cannot get it to
work). The template given on the R documentation and R book is for a 2x2
fisher test. What do i need to change to get this to work? I have attached
the data with the email so one can see what i am on about. Or do i have to
write my own new code to compute this.

Yours Sincerely,
Paul Brett



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] attribute color to a list

2015-08-28 Thread Karim Mezhoud
Hi,
attriColorValue works with one value. I would like to get the color of a
list with lappy but in input I have two variables (the value and the list).


attriColorValue - function(Value, list, colors=c(a,b,c, d,e),feet){

 list - round(list, digits = 0)
Max - max(list, na.rm=TRUE)
Min - min(list, na.rm=TRUE)

  my.colors - colorRampPalette(colors)
  #generates Max-Min colors from the color ramp
  color.df-data.frame(COLOR_VALUE=seq(Min,Max,feet),
color.name=my.colors(length(seq(Min,Max,feet

  colorRef - color.df[which(color.df[,1]==Value),2]
  return(colorRef)
}

list -
c(7607.2149,36.0673,26.5613,-21.094,535.1462,8460.8617,3112.3839,1810.5521,-2783.7832,-1283.5496,879.4978,-307.8481,133.6729,51.6518,-212.3436,-118.6624,912.8616,16.7501,465.6139,486.3803,1051.6673,-1529.426,198.9787,-265.013,74.0492,-52.0192,-97.655,-5963.4183,-2118.4033,5701.5644,1987.7252,1638.274,1576.775,1520.7626,1039.4264,905.7974,-966.3739,365.2626,364.8378,258.3969,-323.999,-394.7463)

works
as.character(attriColorValue(123,list, colors=c(blue,white,red) ,
feet=1))

not working??
lapply(list, function(x) attriColorValue(x,df$exprsMeanDiff ,colors, feet))

Thanks
Karim

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread S Ellison
I perhaps should have added a stronger warning here; note that the model 
fitting in my previous post (below) uses explicit initial breakpoints for 
segmented (specifically, c(30,60) at line 1 of the get.segments() ). if you 
know where yours are, substitute them there.  Otherwise, you'd need to use the 
automated breakpoint routines documented in ?segmented, typically adjusting the 
control list. To be general,  you'd need a way to get a choice of at least 
number of breakpoints into the model. xyplot doesn't (I think) pass extra 
parameters to its panel function, but it will pick up environment parameters so 
you _could_ just rely on that, or perhaps on setting something in options(), as 
a quick and dirty work-round. 
 
S Ellisaon

--
There isn't an abline method for segmented, and even if there were you'd need 
segments() for a segmented line plot. You're going to have to roll your own.  
That will need a function to extract the break locations and predicted values 
at those points

I don't have your data, so I can't do one specifically for you. But here's a 
version that works on the data in the first example in ?segmented. I've 
deliberately separated segmented model fitting and line segment extraction 
(get.segments) from the panel function that plots them, as that would then work 
with the base graphics segments function

#Construct the data set (from ?segmented, though the z covariate is not used 
here)
  set.seed(12)
  xx-1:100
  zz-runif(100)
  yy-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2)
  dati-data.frame(x=xx,y=yy,z=zz)
  


# Function to fit a simple model using segmented
# and then get line segment data from the model
# For the latter, I've used code from plot. segmented to locate extremes 
# and break points (in psi) and then just used 
# predict() rather crudely to get the corresponding ordinate values
# you would have to do something more clever
# if your model is not just y~x

get.segments - function(x, y, term, ...) {
   #Returns a data frame of line segment coordinates
   #from a simple segmented() model
   
S - segmented(lm(y~x), seg.Z=~x,psi=list(x=c(30,60)),
   control=seg.control(display=FALSE))
   if(missing(term)) term - S$nameUV$Z[1]
   x-with(S, sort(c(psi[,'Est.'], rangeZ[,term])))
   #Then cheat a bit
   new - data.frame(x=unname(x))
   names(new) - term
   y - predict(S, new=new)
   L - length(x) -1
  #return the line segment data in an easy-to-use format
  data.frame(x0=x[1:L], y0=y[1:L], x1=x[1:L + 1], y1=y[1:L + 1])
}

#Write a panel function using that...
panel.segmented - function(x, y, ...) {
## Fit the simple model
m - get.segments( x, y )
#Plot the segments
with(m, panel.segments(x0, y0, x1, y1, ... ))
}

library(lattice)
xyplot(y~x, data=dati,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.segmented(x, y, ...)
}
)

#And just to see if it works for panel-grouped data:
set.seed(1023)
dati$parts - sample(gl(2, 50))
xyplot(y~x|parts, data=dati,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.segmented(x, y, ...)
}
)

S Ellison



***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Problem loading mvabund package

2015-08-28 Thread Suparna Mitra
Hello,
  Can anybody please help me with mvabund  package installation?
I downloaded and installed it. It seems installed, but I can't load the
package.
Here is what I tried:


 install.packages(/Users/smitra/Documents/Soft/mvabund_3.10.4.tgz, repos
= NULL, type=source)
* installing *binary* package ‘mvabund’ ...
* DONE (mvabund)

 library(mvabund)
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
:
  there is no package called ‘tweedie’
Error: package or namespace load failed for ‘mvabund’


Any help will be great.
Thanks.
Suparna

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread S Ellison
There isn't an abline method for segmented, and even if there were you'd need 
segments() for a segmented line plot. You're going to have to roll your own.  
That will need a function to extract the break locations and predicted values 
at those points

I don't have your data, so I can't do one specifically for you. But here's a 
version that works on the data in the first example in ?segmented. I've 
deliberately separated segmented model fitting and line segment extraction 
(get.segments) from the panel function that plots them, as that would then work 
with the base graphics segments function

#Construct the data set (from ?segmented, though the z covariate is not used 
here)
  set.seed(12)
  xx-1:100
  zz-runif(100)
  yy-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2)
  dati-data.frame(x=xx,y=yy,z=zz)
  


# Function to fit a simple model using segmented
# and then get line segment data from the model
# For the latter, I've used code from plot. segmented to locate extremes 
# and break points (in psi) and then just used 
# predict() rather crudely to get the corresponding ordinate values
# you would have to do something more clever
# if your model is not just y~x

get.segments - function(x, y, term, ...) {
   #Returns a data frame of line segment coordinates
   #from a simple segmented() model
   
S - segmented(lm(y~x), seg.Z=~x,psi=list(x=c(30,60)),
   control=seg.control(display=FALSE))
   if(missing(term)) term - S$nameUV$Z[1]
   x-with(S, sort(c(psi[,'Est.'], rangeZ[,term])))
   #Then cheat a bit
   new - data.frame(x=unname(x))
   names(new) - term
   y - predict(S, new=new)
   L - length(x) -1
  #return the line segment data in an easy-to-use format
  data.frame(x0=x[1:L], y0=y[1:L], x1=x[1:L + 1], y1=y[1:L + 1])
}

#Write a panel function using that...
panel.segmented - function(x, y, ...) {
## Fit the simple model
m - get.segments( x, y )
#Plot the segments
with(m, panel.segments(x0, y0, x1, y1, ... ))
}

library(lattice)
xyplot(y~x, data=dati,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.segmented(x, y, ...)
}
)

#And just to see if it works for panel-grouped data:
set.seed(1023)
dati$parts - sample(gl(2, 50))
xyplot(y~x|parts, data=dati,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.segmented(x, y, ...)
}
)

S Ellison



***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] attribute color to a list

2015-08-28 Thread Jim Lemon
Hi Karim,
I'm not sure that this is what is causing the error, but your list is
actually a vector. The following runs, but the function is obviously not
working:

sapply(list,
 function(x)
as.character(attriColorValue(x,list,colors=c(blue,white,red),feet=1)))

There is probably a better name for your vector than list.

Jim


On Fri, Aug 28, 2015 at 8:16 PM, Karim Mezhoud kmezh...@gmail.com wrote:

 Hi,
 attriColorValue works with one value. I would like to get the color of a
 list with lappy but in input I have two variables (the value and the list).


 attriColorValue - function(Value, list, colors=c(a,b,c, d,e),feet){

  list - round(list, digits = 0)
 Max - max(list, na.rm=TRUE)
 Min - min(list, na.rm=TRUE)

   my.colors - colorRampPalette(colors)
   #generates Max-Min colors from the color ramp
   color.df-data.frame(COLOR_VALUE=seq(Min,Max,feet),
 color.name=my.colors(length(seq(Min,Max,feet

   colorRef - color.df[which(color.df[,1]==Value),2]
   return(colorRef)
 }

 list -

 c(7607.2149,36.0673,26.5613,-21.094,535.1462,8460.8617,3112.3839,1810.5521,-2783.7832,-1283.5496,879.4978,-307.8481,133.6729,51.6518,-212.3436,-118.6624,912.8616,16.7501,465.6139,486.3803,1051.6673,-1529.426,198.9787,-265.013,74.0492,-52.0192,-97.655,-5963.4183,-2118.4033,5701.5644,1987.7252,1638.274,1576.775,1520.7626,1039.4264,905.7974,-966.3739,365.2626,364.8378,258.3969,-323.999,-394.7463)

 works
 as.character(attriColorValue(123,list, colors=c(blue,white,red) ,
 feet=1))

 not working??
 lapply(list, function(x) attriColorValue(x,df$exprsMeanDiff ,colors, feet))

 Thanks
 Karim

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


[[alternative HTML version deleted]]

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


Re: [R] Problem loading mvabund package

2015-08-28 Thread Michael Dewey

Dear Suparna,

See below

On 28/08/2015 10:22, Suparna Mitra wrote:

Hello,
   Can anybody please help me with mvabund  package installation?
I downloaded and installed it. It seems installed, but I can't load the
package.
Here is what I tried:



install.packages(/Users/smitra/Documents/Soft/mvabund_3.10.4.tgz, repos

= NULL, type=source)
* installing *binary* package ‘mvabund’ ...
* DONE (mvabund)


library(mvabund)

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
:
   there is no package called ‘tweedie’


There are two possibilities here
1 - you have not installed tweedie
2 - you have and R cannot find it


Error: package or namespace load failed for ‘mvabund’


Any help will be great.
Thanks.
Suparna

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] attribute color to a list

2015-08-28 Thread Karim Mezhoud
Hi,
Thank you for comments.
Yes it is a vector an not a list ;).
I need to round also the input Value (Value - round(Value, digits=0). If
not Matching is not possible. The vector is a real number and the color.df
are Integer.
Thanks for sapply is better than lapply in my case.
Karim

On Fri, Aug 28, 2015 at 11:35 AM, Jim Lemon drjimle...@gmail.com wrote:

 Hi Karim,
 I'm not sure that this is what is causing the error, but your list is
 actually a vector. The following runs, but the function is obviously not
 working:

 sapply(list,
  function(x)
 as.character(attriColorValue(x,list,colors=c(blue,white,red),feet=1)))

 There is probably a better name for your vector than list.

 Jim


 On Fri, Aug 28, 2015 at 8:16 PM, Karim Mezhoud kmezh...@gmail.com wrote:

 Hi,
 attriColorValue works with one value. I would like to get the color of a
 list with lappy but in input I have two variables (the value and the
 list).


 attriColorValue - function(Value, list, colors=c(a,b,c, d,e),feet){

  list - round(list, digits = 0)
 Max - max(list, na.rm=TRUE)
 Min - min(list, na.rm=TRUE)

   my.colors - colorRampPalette(colors)
   #generates Max-Min colors from the color ramp
   color.df-data.frame(COLOR_VALUE=seq(Min,Max,feet),
 color.name=my.colors(length(seq(Min,Max,feet

   colorRef - color.df[which(color.df[,1]==Value),2]
   return(colorRef)
 }

 list -

 c(7607.2149,36.0673,26.5613,-21.094,535.1462,8460.8617,3112.3839,1810.5521,-2783.7832,-1283.5496,879.4978,-307.8481,133.6729,51.6518,-212.3436,-118.6624,912.8616,16.7501,465.6139,486.3803,1051.6673,-1529.426,198.9787,-265.013,74.0492,-52.0192,-97.655,-5963.4183,-2118.4033,5701.5644,1987.7252,1638.274,1576.775,1520.7626,1039.4264,905.7974,-966.3739,365.2626,364.8378,258.3969,-323.999,-394.7463)

 works
 as.character(attriColorValue(123,list, colors=c(blue,white,red) ,
 feet=1))

 not working??
 lapply(list, function(x) attriColorValue(x,df$exprsMeanDiff ,colors,
 feet))

 Thanks
 Karim

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] heat map labeling

2015-08-28 Thread Jim Lemon
Hi Angela,
Assuming the above data frame is named angela.df:

angela.mat-as.matrix(angela.df[,2:3])
angela.mat-angela.mat[apply(angela.mat,1,function(x) all(x)  0),]

will remove all of the rows that have contain at least one zero.

Jim


On Fri, Aug 28, 2015 at 9:00 AM, Angela via R-help r-help@r-project.org
wrote:

 Hello,

 I have a dataset of 985 genes, looks something like the ones below. I want
 to label only those with the high intensities, since labeling all doesn't
 show up. Is there a way to do that? If not, is there a way to pull out the
 highest ones (say, highest 50, or those above X amount) and only show those
 in a heat map? Thanks!

 -Angela

 Z transforming gives all cells the same value, just + or - (for example,
 all have 0.5 and -0.5). The researchers want the actual values used.

 Gene   var1   var2
 A   800 0
 B   25  30
 C   75  200
 D   0   0
 E   400 600
 E   500 70
 E   100 100
 F   600 600
 F   70  827460
 G   420930  40
 H   0   0
 H   100 100
 I   70  60
 J   0   70
 K   0   0
 L   20  50
 L   100 300

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] lsqlin in R package pracma

2015-08-28 Thread Hans W Borchers
I got interested in enabling the full funcionality that MATLAB's
lsqlin() has, that is with equality and bound constraints. To replace
an equality constraint with two inequality constraints will not work
with solve.QP() because it requires positive definite matrices. I will
use kernlab::ipop() instead.

To handle the full MATLAB example, add the following simple linear
equality constraint  3x1 + 5x2 + 7x3 + 9x4 = 4 to the example above,
plus lower and upper bounds -0.1 and 2.0 for all x_i.

C - matrix(c(
0.9501,   0.7620,   0.6153,   0.4057,
0.2311,   0.4564,   0.7919,   0.9354,
0.6068,   0.0185,   0.9218,   0.9169,
0.4859,   0.8214,   0.7382,   0.4102,
0.8912,   0.4447,   0.1762,   0.8936), 5, 4, byrow=TRUE)
d - c(0.0578, 0.3528, 0.8131, 0.0098, 0.1388)
A - matrix(c(
0.2027,   0.2721,   0.7467,   0.4659,
0.1987,   0.1988,   0.4450,   0.4186,
0.6037,   0.0152,   0.9318,   0.8462), 3, 4, byrow=TRUE)
b - c(0.5251, 0.2026, 0.6721)

# Add the equality constraint to matrix A
Aeq - c(3, 5, 7, 9)
beq - 4
A1 - rbind(A ,  c(3, 5, 7, 9))
b1 - c(b, 4)
lb - rep(-0.1, 4)   # lower and upper bounds
ub - rep( 2.0, 4)
r1 - c(1, 1, 1, 0)  # 0 to force an equality constraint

# Prepare for a quadratic solver
Dmat - t(C) %*% C
dvec - (t(C) %*% d)
Amat - -1 * A1
bvec - -1 * b1

library(kernlab)
s - ipop(-dvec, Dmat, Amat, bvec, lb, ub, r1)
s
# An object of class ipop
# Slot primal:
# [1] -0.0885 -0.0997  0.15990817  0.40895991
# ...

x - s@primal   # [1] -0.1000  -0.1000  0.1599  0.4090
A1 %*% x - b1 = 0  # i.e., A x = b and 3x[1] + ... + 9x[4] = 4
sum((C %*% x - d)^2)# minimum: 0.1695

And this is exactly the solution that lsqlin() in MATLAB computes.


On Thu, Aug 27, 2015 at 6:06 PM, Raubertas, Richard
richard_rauber...@merck.com wrote:
 Is it really that complicated?  This looks like an ordinary quadratic 
 programming problem, and 'solve.QP' from the 'quadprog' package seems to 
 solve it without user-specified starting values:

 library(quadprog)
 Dmat - t(C) %*% C
 dvec - (t(C) %*% d)
 Amat - -1 * t(A)
 bvec - -1 * b

 rslt - solve.QP(Dmat, dvec, Amat, bvec)
 sum((C %*% rslt$solution - d)^2)

 [1] 0.01758538

 Richard Raubertas
 Merck  Co.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Fisher's Test 5x4 table

2015-08-28 Thread Gerrit Eichner

Paul,

as the error messages of your first three attempts (see below) tell you - 
in an admittedly rather cryptic way - your table or its sample size, 
respectively, are too large, so that either the largest (hash table) key 
is too large, or your (i.e., R's) workspace is too small, or your 
hardware/os cannot allocate enough memory to calculate the p-value of 
Fisher Exact Test exactly by means of the implemented algorithm.


One way out of this is to approximate the exact p-value through 
simulation, but apparently there occurred a typo in your (last) attempt to 
do that (Error: unexpected '' in ).



So, for me the following works (and it should also for you) and gives the 
shown output (after a very short while):



Trapz - as.matrix( read.table( w.txt, head = T, row.names = Traps))



set.seed( 20150828)   # For the sake of reproducibility.
fisher.test( Trapz, simulate.p.value = TRUE,

+ B = 1e5)

   Fisher's Exact Test for Count Data with simulated p-value (based on
   1e+05 replicates)

data:  Trapz
p-value = 1e-05
alternative hypothesis: two.sided



Or for a higher value for B if you are patient enough (with a computing 
time of several seconds) :



set.seed( 20150828)
fisher.test( Trapz, simulate.p.value=TRUE, B = 1e7)


   Fisher's Exact Test for Count Data with simulated p-value (based on
   1e+07 replicates)

data:  Trapz
p-value = 1e-07
alternative hypothesis: two.sided


 Hth  --  Gerrit

(BTW, you don't have to specify arguments (in function calls) whose 
default values you don't want to change.)




On Fri, 28 Aug 2015, paul brett wrote:


Hi Gerrit,
I spotted that, it was a mistake on my own part, it should
read 1.trap.2.barrier. I have corrected it on the file attached.

So I have done these so far:
 fisher.test(Trapz, workspace = 20, hybrid = FALSE, control = list(),
or = 1, alternative = two.sided, conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 2e+05, hybrid = FALSE, control =
list(),  :
 FEXACT error 501.
The hash table key cannot be computed because the largest key
is larger than the largest representable int.
The algorithm cannot proceed.
Reduce the workspace size or use another algorithm.


fisher.test(Trapz, workspace = 2000, hybrid = FALSE, control = list(), or

= 1, alternative = two.sided, conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 2000, hybrid = FALSE, control =
list(),  :
 FEXACT error 40.
Out of workspace.

fisher.test(Trapz, workspace = 1e8, hybrid = FALSE, control = list(), or

= 1, alternative = two.sided, conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error in fisher.test(Trapz, workspace = 1e+08, hybrid = FALSE, control =
list(),  :
 FEXACT error 501.
The hash table key cannot be computed because the largest key
is larger than the largest representable int.
The algorithm cannot proceed.
Reduce the workspace size or use another algorithm.

fisher.test(Trapz, workspace = 20, hybrid = FALSE, control =

list(), or = 1, alternative = two.sided, conf.int = TRUE, conf.level =
0.95,simulate.p.value = FALSE, B = 2000)
Error: cannot allocate vector of size 7.5 Gb
In addition: Warning messages:
1: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
 Reached total allocation of 6027Mb: see help(memory.size)
2: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
 Reached total allocation of 6027Mb: see help(memory.size)
3: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
 Reached total allocation of 6027Mb: see help(memory.size)
4: In fisher.test(Trapz, workspace = 2e+09, hybrid = FALSE, control =
list(),  :
 Reached total allocation of 6027Mb: see help(memory.size)

fisher.test(Trapz, workspace = 1e8, hybrid = FALSE, control = list(), or =
1, alternative = two.sided, conf.int = TRUE, conf.level =
0.95,simulate.p.value = TRUE, B = 1e5)
Error: unexpected '' in 

So the issue could be perhaps that R cannot compute my sample as the
workspace needed is too big? Is there a way around this? I think I have
everything set out correctly.
Is my only other alternative is to do a 2x2 fisher test for each of the
variables?

I attach on the pdf the Minitab result for the Chi squared test as proof (I
know that getting very low p values are highly unlikely but sometimes it
happens). Seeing is believing i suppose!

Regards,
Paul



On Fri, Aug 28, 2015 at 8:56 AM, Gerrit Eichner 
gerrit.eich...@math.uni-giessen.de wrote:


Dear Paul,

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

So, what exactly did you try and what was the actual problem/error message?

Besides that, have you noted that two of you data rows have the same name?


Have you read the online help page of fisher.test

[R-es] Un asunto al margen

2015-08-28 Thread heber sarmiento via R-help-es
Cordial Saludo
He conversado con algunos amigos y me han comentado que existe una plataforma 
de trabajo colaborativo, algo parecido a schoology o edmode  la cual entre 
otras herramientas trae implementado a R y LaTeX, el problema es que no 
recuerdo el nombre y si bien entiendo que esta lista no es el espacio más 
apropiado para la consulta, quedaría muy agradecido por cualquier orientación 
al respecto, de antemano me excuso con todos si soy impertinente con mi 
pregunta y desde ya muchas gracias. 
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Rcpp, function signature

2015-08-28 Thread peter dalgaard

On 27 Aug 2015, at 17:40 , Dirk Eddelbuettel e...@debian.org wrote:

 Michael Meyer via R-help r-help at r-project.org writes:
 
 I am an  (very) grateful user of Rcpp.
 
 Glad to hear that!
 
 But you are on the wrong mailing list. Please ask on rcpp-devel.

But for the benefit of the rest of us: A NumericVector is a pointer, right?

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread Duncan Mackay
Hi

Without a reproducible example I am only guessing 

Try this 

xyplot(threshold ~ age |frequency.a, data=subset(rage !is.na(threshold} 
!is.na(age)),
   groups = HL,
   cex=0.5,
   layout=c(7,4),
   par.strip.tex=list(cex=0.8),
   xlab=Age (years),
   ylab=Threshold (dB SPL),
   # na.rm=TRUE, # see above
   type = c(p,l),  # re-read ?xyplot: from the panel section:
panel.abline(lm(threshold~age))
   panel = panel.superpose,
   panel.groups =function(x,y,groups,...) {

panel.xyplot(x,y,...)
# panel.abline(segmented(lm(threshold~age),seg.Z =
~age, psi = NA, control = seg.control(K=1)))

  },
)

I do not know what the commented line means-- you may need to look at the
subscripts section as well as panel.groups of ?xyplot
and ?panel.xyplot

Regards

Duncan

Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sumitrajit
Dhar
Sent: Friday, 28 August 2015 14:12
To: r-help@r-project.org
Subject: [R] Piecewise regression using segmented package plotted in xyplot

Hi,

xyplot(threshold ~ age |frequency.a, data=rage,
groups=HL,
  cex=0.5,
  layout=c(7,4),
par.strip.tex=list(cex=0.8),
  xlab=Age (years),
  ylab=Threshold (dB SPL),
  na.rm=TRUE,
  panel=function(x,y,groups,...) {
panel.superpose(x,y,groups=HL,...)
# panel.abline(segmented(lm(threshold~age),seg.Z = ~age, psi = NA, control =
seg.control(K=1)))
panel.abline(lm(threshold~age))
  },
  )

Is there anyway to make the commented line work in lattice? I need to fit my
data in each panel using piecewise regression. Being able to use segmented
would make it easy.

The code above works to give me a linear fit.

Thanks for your help in advance.

Regards,
Sumit



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] lsqlin in R package pracma

2015-08-28 Thread Berend Hasselman


Nice and interesting! Something to remember.

Lesson (for me):

Always first look in Task Views on CRAN.
Choose Optimization and look at Mathematical Programming Solvers.

Berend

 On 28 Aug 2015, at 12:56, Hans W Borchers hwborch...@gmail.com wrote:
 
 I got interested in enabling the full funcionality that MATLAB's
 lsqlin() has, that is with equality and bound constraints. To replace
 an equality constraint with two inequality constraints will not work
 with solve.QP() because it requires positive definite matrices. I will
 use kernlab::ipop() instead.
 
 To handle the full MATLAB example, add the following simple linear
 equality constraint  3x1 + 5x2 + 7x3 + 9x4 = 4 to the example above,
 plus lower and upper bounds -0.1 and 2.0 for all x_i.
 
C - matrix(c(
0.9501,   0.7620,   0.6153,   0.4057,
0.2311,   0.4564,   0.7919,   0.9354,
0.6068,   0.0185,   0.9218,   0.9169,
0.4859,   0.8214,   0.7382,   0.4102,
0.8912,   0.4447,   0.1762,   0.8936), 5, 4, byrow=TRUE)
d - c(0.0578, 0.3528, 0.8131, 0.0098, 0.1388)
A - matrix(c(
0.2027,   0.2721,   0.7467,   0.4659,
0.1987,   0.1988,   0.4450,   0.4186,
0.6037,   0.0152,   0.9318,   0.8462), 3, 4, byrow=TRUE)
b - c(0.5251, 0.2026, 0.6721)
 
# Add the equality constraint to matrix A
Aeq - c(3, 5, 7, 9)
beq - 4
A1 - rbind(A ,  c(3, 5, 7, 9))
b1 - c(b, 4)
lb - rep(-0.1, 4)   # lower and upper bounds
ub - rep( 2.0, 4)
r1 - c(1, 1, 1, 0)  # 0 to force an equality constraint
 
# Prepare for a quadratic solver
Dmat - t(C) %*% C
dvec - (t(C) %*% d)
Amat - -1 * A1
bvec - -1 * b1
 
library(kernlab)
s - ipop(-dvec, Dmat, Amat, bvec, lb, ub, r1)
s
# An object of class ipop
# Slot primal:
# [1] -0.0885 -0.0997  0.15990817  0.40895991
# ...
 
x - s@primal   # [1] -0.1000  -0.1000  0.1599  0.4090
A1 %*% x - b1 = 0  # i.e., A x = b and 3x[1] + ... + 9x[4] = 4
sum((C %*% x - d)^2)# minimum: 0.1695
 
 And this is exactly the solution that lsqlin() in MATLAB computes.
 
 
 On Thu, Aug 27, 2015 at 6:06 PM, Raubertas, Richard
 richard_rauber...@merck.com wrote:
 Is it really that complicated?  This looks like an ordinary quadratic 
 programming problem, and 'solve.QP' from the 'quadprog' package seems to 
 solve it without user-specified starting values:
 
 library(quadprog)
 Dmat - t(C) %*% C
 dvec - (t(C) %*% d)
 Amat - -1 * t(A)
 bvec - -1 * b
 
 rslt - solve.QP(Dmat, dvec, Amat, bvec)
 sum((C %*% rslt$solution - d)^2)
 
 [1] 0.01758538
 
 Richard Raubertas
 Merck  Co.
 
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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 -- To UNSUBSCRIBE and more, see
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] Frequency count of terms only in a given column in R

2015-08-28 Thread Michael Dewey

Dear Agrima

As well as Sarah's seven possibilities an eighth occurs to me: you have 
not yet read it into R in the first place. If that is the case you may 
be able to use read.table to get it into a data frame with columns 
corresponding to your words.

?read.table may be your friend here.

On 28/08/2015 15:42, Sarah Goslee wrote:

Hi,

On Fri, Aug 28, 2015 at 7:49 AM, agrima seth sethagr...@gmail.com wrote:

i have a text file with data of the given format:

white snow
lived snow
in snow
lived place
in place
a place
called place
as place


That doesn't specify the format. I can think of at least seven things
that could be:
a character vector
a two-column matrix
a one-column matrix
a two-column data frame, with or without values correctly specified as character
a one-column data frame, with or without values correctly specified as character

The correct answer depends on what the format actually is; you need to
use dput() or some other unambiguous way of providing sample data.

Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Some combination of strsplit() and table(), possibly with apply(),
will be the answer, though.

Sarah


here i have to find the frequency of the terms only in the first column
(i.e.)
white - 1
lived- 2
in -2
a-1
called - 1
as -1

Could you please guide me how to do the above in R.

 [[alternative HTML version deleted]]

and please don't post in HTML, as it makes figuring out what you meant
even more difficult.

Sarah




--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Frequency count of terms only in a given column in R

2015-08-28 Thread agrima seth
i have a text file with data of the given format:

white snow
lived snow
in snow
lived place
in place
a place
called place
as place

here i have to find the frequency of the terms only in the first column
(i.e.)
white - 1
lived- 2
in -2
a-1
called - 1
as -1

Could you please guide me how to do the above in R.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Frequency count of terms only in a given column in R

2015-08-28 Thread Sarah Goslee
Hi,

On Fri, Aug 28, 2015 at 7:49 AM, agrima seth sethagr...@gmail.com wrote:
 i have a text file with data of the given format:

 white snow
 lived snow
 in snow
 lived place
 in place
 a place
 called place
 as place

That doesn't specify the format. I can think of at least seven things
that could be:
a character vector
a two-column matrix
a one-column matrix
a two-column data frame, with or without values correctly specified as character
a one-column data frame, with or without values correctly specified as character

The correct answer depends on what the format actually is; you need to
use dput() or some other unambiguous way of providing sample data.

Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Some combination of strsplit() and table(), possibly with apply(),
will be the answer, though.

Sarah

 here i have to find the frequency of the terms only in the first column
 (i.e.)
 white - 1
 lived- 2
 in -2
 a-1
 called - 1
 as -1

 Could you please guide me how to do the above in R.

 [[alternative HTML version deleted]]
and please don't post in HTML, as it makes figuring out what you meant
even more difficult.

Sarah


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Rcpp, function signature

2015-08-28 Thread Dirk Eddelbuettel
peter dalgaard pdalgd at gmail.com writes:
 But for the benefit of the rest of us: A NumericVector is a pointer, right?

Effectively even though it is not treated as one by the users.  But you 
know what P in SEXP stands for, and Rcpp objects really are what we call
proxy objects for the respective underlying SEXP objects.

Searching the rcpp-devel list archives for the clone() function will bring
a number of preceding discussions.  As I said in the previous email, this
list is not the best place to discuss Rcpp matters --- rcpp-devel is. 
Please feel free to bring follow-up questions there.

Dirk

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Referencing a component of a large object (Error: slot NULL)

2015-08-28 Thread William Dunlap
   s - paste('chain:,j,' ,sep=)

You don't want the single quotes around the string you are constructing.
Try
   s - paste0(chain:, j)
which will give you, e.g.,
   chain:1
instead of
   'chain:1'

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Aug 28, 2015 at 6:08 PM, Andrea Lamont alamont...@gmail.com wrote:

 Hm.

 It still doesn't seem to be working and has me completely stumped.

 This works:
 mi.control.i@data[['chain:1']]@variables$y.obs.tx@parameters[30,]

 But this doesn't:
  mi.control.i@data[[s]]@variables$y.obs.tx@parameters[30,]
 Error: trying to get slot variables from an object of a basic class
 (NULL) with no slots
  s
 [1] 'chain:1'

 On Fri, Aug 28, 2015 at 5:52 PM, William Dunlap wdun...@tibco.com wrote:


   tf - vector(list, numberofchains)
   for (j in 1:numberofchains){
   s - paste('chain:,j,' ,sep=)
   tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]
   }


 If you want the component whose name is the value of the variable 's'
 use data[[s]].

 The syntax 'data$s' means to get the component of 'data' called s,
 usually the same as 'data[[s]]'.


 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 On Fri, Aug 28, 2015 at 12:08 PM, Andrea Lamont alamont...@gmail.com
 wrote:

 I am running a simulation and need to refer to a matrix of parameters
 from
 a large object. Here is a snippet of the object structure itself:

 Formal class 'mi' [package mi] with 3 slots
   ..@ call   : language .local(y = y, n.chains = ..2, max.minutes =
 2)
   ..@ data   :List of 100
   .. ..$ chain:1  :'data.frame':1 obs. of  76 variables:
 Formal class 'missing_data.frame' [package mi] with 17 slots
   .. .. .. ..@ .Data   : list()
   .. .. .. ..@ variables   :List of 76
   .. .. .. .. ..$ y.obs.tx:Formal class 'binary' [package mi] with 27
 slots...

 The parameter list I need can be referenced by:

 mi.control.i@data$'chain:1'@variables$y.obs.tx@parameters[30,]

 Since this is a simulation, I would like to grab the parameters from each
 chain and join them together in a matrix. I have this:

 tf - vector(list, numberofchains)for (j in 1:numberofchains){
   s - paste('chain:,j,' ,sep=)
   tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]}

 Within the loop, however, the reference to the object (tf[[j]]) does not
 work. I get an error that reads

 Error: trying to get slot variables from an object of a basic class
 (NULL) with no slots


 I am happy to send reproducible code, however, I obtain this object
 through
 the package 'mi' and is computationally intensive. I'm not sure if it
 makes
 it easier for folks. Let me know.

 Any ideas?

 --
 Andrea Lamont, PhD
 Post-Doctoral Fellow
 University of South Carolina
 Columbia, SC 29208

 *Please consider the environment before printing this email.*

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.





 --
 Andrea Lamont, PhD
 Post-Doctoral Fellow
 University of South Carolina
 Columbia, SC 29208

 *Please consider the environment before printing this email.*


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Change the maximum likelihood of multinomial logic model in R

2015-08-28 Thread Alaa Sindi
Dear all,

Can anyone help me to change the maximum likelihood of multinomial logic model 
in R?

Thanks
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Change the maximum likelihood of multinomial logic model in R

2015-08-28 Thread Alaa Sindi
Dear All,
 can anybody help me with an example on how to use mlogit.optim?

Regards


 On Aug 28, 2015, at 9:00 PM, Alaa Sindi alaasi...@gmail.com wrote:
 
 Dear all,
 
 Can anyone help me to change the maximum likelihood of multinomial logic 
 model in R?
 
 Thanks

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] heat map labeling

2015-08-28 Thread Jim Lemon
Hi Angela,
It depends upon what you want to illustrate. If you are just interested in
the relative values, you can suppress the labels. One solution is to create
a very high PDF to look at the colors, which you could then expand and
scroll around to see the labels.

Jim

On Sat, Aug 29, 2015 at 6:06 AM, Angela via R-help r-help@r-project.org
wrote:

 Hi Jim,

 Thank you, that definitely reduced it but there are still about 600 genes,
 so too many to label. It does make the heat map itself look cleaner. Maybe
 labeling isn't necessary for the heat map?

 -Angela



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Multiple Integrals

2015-08-28 Thread Shant Ch via R-help
Hello all,
For a study I want to find E|X1/3+X2/3+X3/3-X4| for variables following 
lognormal distribution. To get the value we need to use four integrals. This is 
the code which I is used

  fx-function(x){
    dlnorm(x,meanlog=2.185,sdlog=0.562)
  }
U31-integrate(function(y1) { sapply(y1, function(y1) { 
+  integrate(function(y2){  sapply(y2, function(y2) {
+  integrate(function(x1){  sapply(x1, function(x1) { 
+  integrate(function(x2)
+   abs(y1/3+y2/3+x1/3-x2)*fx(y1)*fx(y2)*fx(x1)*fx(x2),0, Inf)$value
+  })},0, Inf)$value })},0, Inf)$value})},0,Inf)$value
The error I received is the following:
Error in integrate(function(y2) { : 
  maximum number of subdivisions reached

I can understand the problem, but I am unable to figure out what can be done.. 
It would be great if you can let me know a solution to the problem so as to 
find a value for the integral.

Shant

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] kknn::predict and kknn$fitted.values

2015-08-28 Thread Jonathan Henkelman
I am noticing that there is a difference between the fitted.values returned
by train.kknn, and the values returned using predict with the same model and
dataset. For example:

 data (glass)
 tmp - train.kknn(Type ~ ., glass, kmax=1, kernel=rectangular,
 distance=1)
 tmp$fitted.values
[[1]]
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1
 [62] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 1 2 1 2 2 1 2 2 5 2 2 2 6 2 2 2 2 2 2 2 2 2 2 2 2
[123] 2 2 2 2 3 2 2 2 5 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 2 3 3
3 3 3 3 2 3 7 5 5 5 5 5 5 5 5 5 5 2 5 6 6 6 6 6 6 6
[184] 2 6 7 7 2 6 7 7 7 7 7 7 7 7 7 7 7 7 5 7 7 7 7 7 7 7 7 7 7 7 7
attr(,kernel)
[1] rectangular
attr(,k)
[1] 1
Levels: 1 2 3 5 6 7

 predict (tmp,glass)
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [62] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
[123] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6
[184] 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Levels: 1 2 3 5 6 7

When I check the confusion matricies for these I see that fitted.values is
giving some confusion, that is, like it is a true fit, whereas predict is
returning the exact answers.

 table (tmp$fitted.values[[1]],glass$Type)
 1  2  3  5  6  7
  1 69  4  0  0  0  0
  2  1 67  2  1  1  1
  3  0  1 15  0  0  0
  5  0  3  0 11  0  1
  6  0  1  0  0  8  1
  7  0  0  0  1  0 26

 table (predict(tmp,glass),glass$Type)   
 1  2  3  5  6  7
  1 70  0  0  0  0  0
  2  0 76  0  0  0  0
  3  0  0 17  0  0  0
  5  0  0  0 13  0  0
  6  0  0  0  0  9  0
  7  0  0  0  0  0 29

Can anyone clarify what fitted.values and predict actually do? I would have
expected they would give the same output.

Thanks... Jonathan



--
View this message in context: 
http://r.789695.n4.nabble.com/kknn-predict-and-kknn-fitted-values-tp4711625.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Referencing a component of a large object (Error: slot NULL)

2015-08-28 Thread Andrea Lamont
I am running a simulation and need to refer to a matrix of parameters from
a large object. Here is a snippet of the object structure itself:

Formal class 'mi' [package mi] with 3 slots
  ..@ call   : language .local(y = y, n.chains = ..2, max.minutes = 2)
  ..@ data   :List of 100
  .. ..$ chain:1  :'data.frame':1 obs. of  76 variables:
Formal class 'missing_data.frame' [package mi] with 17 slots
  .. .. .. ..@ .Data   : list()
  .. .. .. ..@ variables   :List of 76
  .. .. .. .. ..$ y.obs.tx:Formal class 'binary' [package mi] with 27 slots...

The parameter list I need can be referenced by:

mi.control.i@data$'chain:1'@variables$y.obs.tx@parameters[30,]

Since this is a simulation, I would like to grab the parameters from each
chain and join them together in a matrix. I have this:

tf - vector(list, numberofchains)for (j in 1:numberofchains){
  s - paste('chain:,j,' ,sep=)
  tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]}

Within the loop, however, the reference to the object (tf[[j]]) does not
work. I get an error that reads

Error: trying to get slot variables from an object of a basic class
(NULL) with no slots


I am happy to send reproducible code, however, I obtain this object through
the package 'mi' and is computationally intensive. I'm not sure if it makes
it easier for folks. Let me know.

Any ideas?

-- 
Andrea Lamont, PhD
Post-Doctoral Fellow
University of South Carolina
Columbia, SC 29208

*Please consider the environment before printing this email.*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Change the maximum likelihood of multinomial logic model in R

2015-08-28 Thread Don McKenzie
Have you looked at the help for mlogit.optim?  At the minimum you need a 
likelihood function and starting value(s).  If you don’t understand the 
function syntax you may have difficulty interpreting any output that you do get.

 On Aug 28, 2015, at 11:26 AM, Alaa Sindi alaasi...@gmail.com wrote:
 
 Dear All,
 can anybody help me with an example on how to use mlogit.optim?
 
 Regards
 
 
 On Aug 28, 2015, at 9:00 PM, Alaa Sindi alaasi...@gmail.com wrote:
 
 Dear all,
 
 Can anyone help me to change the maximum likelihood of multinomial logic 
 model in R?
 
 Thanks
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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 -- To UNSUBSCRIBE and more, see
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] Separate point sizes in rgl.points()?

2015-08-28 Thread Atte Tenkanen

Hi,

DrawDensity3D-function in package VecStatGraphs3D utilizes 
rgl.points-function {rgl}:


function (vectors, Div = 40, Layers = 3, DrawAxes = FALSE)
{
open3d(windowRect = c(100, 100, 800, 800))
bg3d(white)
Cx = vectors[, 1]
Cy = vectors[, 2]
Cz = vectors[, 3]
Cr - kde3d(x = Cx, y = Cy, z = Cz, n = Div)
th - seq(min(Cr$d), max(Cr$d), len = Layers + 2)
ramp - colorRamp(c(white, yellow, red))
colo - rgb(ramp(seq(0, 1, length = Layers)), maxColorValue = 255)
al - seq(0.1, 0.6, len = Layers)
module = sqrt(Cx * Cx + Cy * Cy + Cz * Cz)
spheres3d(0, 0, 0, radius = max(module), color = black,
front = line, back = line, lwd = 1, smooth = TRUE,
lit = TRUE, line_antialias = FALSE, alpha = 0.2)
x - c(0, max(module), 0, 0)
y - c(0, 0, max(module), 0)
z - c(0, 0, 0, max(module))
labels - c(, X, Y, Z)
i - c(1, 2, 1, 3, 1, 4)
text3d(x, y, z, labels, adj = 0.8, cex = 1.5, font = 2, color = 
black)

segments3d(x[i], y[i], z[i], lwd = 3)
rgl.points(x = Cx, y = Cy, z = Cz, size = 3, color = black)
contour3d(Cr$d, level = th[c(-1, -(Layers + 2))], x = Cr$x,
y = Cr$y, z = Cr$z, alpha = al, color = colo, add = TRUE,
engine = rgl, fill = TRUE, smooth = 2, material = shiny)
if (DrawAxes == TRUE) {
axes3d()
}
}

Is it somehow possible to define the sizes of the points all separately?

I tried by adding ”Psize” to function arguments and changing

rgl.points(x = Cx, y = Cy, z = Cz, size = Psize, color = black”),

then giving individual point size to each point but this does not work.

This does’t work either:

for(i in 1:length(Cx))
{
rgl.points(x=Cx[i], y=Cz[i], z=Cz[i], size=PSize[i], col= Colors[i])
}

Atte Tenkanen

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] heat map labeling

2015-08-28 Thread Angela via R-help
Hi Jim,

Thank you, that definitely reduced it but there are still about 600 genes, so 
too many to label. It does make the heat map itself look cleaner. Maybe 
labeling isn't necessary for the heat map?

-Angela

On Fri, 8/28/15, Jim Lemon drjimle...@gmail.com wrote:

 Subject: Re: [R] heat map labeling

 Cc: r-help mailing list r-help@r-project.org
 Date: Friday, August 28, 2015, 6:16 AM

 Hi
 Angela,Assuming the above data frame is named
 angela.df:
 
angela.mat-as.matrix(angela.df[,2:3])angela.mat-angela.mat[apply(angela.mat,1,function(x)
 all(x)  0),]
 will remove all of the rows
 that have contain at least one zero.
 Jim

 On Fri, Aug 28, 2015 at
 9:00 AM, Angela via R-help r-help@r-project.org
 wrote:
 Hello,



 I have a dataset of 985 genes, looks something like the ones
 below. I want to label only those with the high intensities,
 since labeling all doesn't show up. Is there a way to do
 that? If not, is there a way to pull out the highest ones
 (say, highest 50, or those above X amount) and only show
[[elided Yahoo spam]]



 -Angela



 Z transforming gives all cells the same value, just + or -
 (for example, all have 0.5 and -0.5). The researchers want
 the actual values used.



 Gene   var1       var2

 A       800 0

 B       25  30

 C       75  200

 D       0               0

 E       400 600

 E       500 70

 E       100 100

 F       600 600

 F       70  827460

 G       420930  40

 H       0               0

 H       100 100

 I       70  60

 J       0               70

 K       0               0

 L       20  50

 L       100 300



 __

 R-help@r-project.org
 mailing list -- To UNSUBSCRIBE and more, see

 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 -- To UNSUBSCRIBE and more, see
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] Referencing a component of a large object (Error: slot NULL)

2015-08-28 Thread William Dunlap
  tf - vector(list, numberofchains)
  for (j in 1:numberofchains){
  s - paste('chain:,j,' ,sep=)
  tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]
  }


If you want the component whose name is the value of the variable 's'
use data[[s]].

The syntax 'data$s' means to get the component of 'data' called s,
usually the same as 'data[[s]]'.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Aug 28, 2015 at 12:08 PM, Andrea Lamont alamont...@gmail.com
wrote:

 I am running a simulation and need to refer to a matrix of parameters from
 a large object. Here is a snippet of the object structure itself:

 Formal class 'mi' [package mi] with 3 slots
   ..@ call   : language .local(y = y, n.chains = ..2, max.minutes =
 2)
   ..@ data   :List of 100
   .. ..$ chain:1  :'data.frame':1 obs. of  76 variables:
 Formal class 'missing_data.frame' [package mi] with 17 slots
   .. .. .. ..@ .Data   : list()
   .. .. .. ..@ variables   :List of 76
   .. .. .. .. ..$ y.obs.tx:Formal class 'binary' [package mi] with 27
 slots...

 The parameter list I need can be referenced by:

 mi.control.i@data$'chain:1'@variables$y.obs.tx@parameters[30,]

 Since this is a simulation, I would like to grab the parameters from each
 chain and join them together in a matrix. I have this:

 tf - vector(list, numberofchains)for (j in 1:numberofchains){
   s - paste('chain:,j,' ,sep=)
   tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]}

 Within the loop, however, the reference to the object (tf[[j]]) does not
 work. I get an error that reads

 Error: trying to get slot variables from an object of a basic class
 (NULL) with no slots


 I am happy to send reproducible code, however, I obtain this object through
 the package 'mi' and is computationally intensive. I'm not sure if it makes
 it easier for folks. Let me know.

 Any ideas?

 --
 Andrea Lamont, PhD
 Post-Doctoral Fellow
 University of South Carolina
 Columbia, SC 29208

 *Please consider the environment before printing this email.*

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


[[alternative HTML version deleted]]

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


Re: [R] Problem loading mvabund package

2015-08-28 Thread Suparna Mitra
Thank you Michael :)
S

On 28 August 2015 at 12:09, Michael Dewey li...@dewey.myzen.co.uk wrote:

 Dear Suparna,

 See below

 On 28/08/2015 10:22, Suparna Mitra wrote:

 Hello,
Can anybody please help me with mvabund  package installation?
 I downloaded and installed it. It seems installed, but I can't load the
 package.
 Here is what I tried:


 install.packages(/Users/smitra/Documents/Soft/mvabund_3.10.4.tgz, repos

 = NULL, type=source)
 * installing *binary* package ‘mvabund’ ...
 * DONE (mvabund)

 library(mvabund)

 Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
 :
there is no package called ‘tweedie’


 There are two possibilities here
 1 - you have not installed tweedie
 2 - you have and R cannot find it

 Error: package or namespace load failed for ‘mvabund’


 Any help will be great.
 Thanks.
 Suparna

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


 --
 Michael
 http://www.dewey.myzen.co.uk/home.html


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Change the maximum likelihood of multinomial logic model in R

2015-08-28 Thread David Winsemius

On Aug 28, 2015, at 11:26 AM, Alaa Sindi wrote:

 Dear All,
 can anybody help me with an example on how to use mlogit.optim?

That is just a helper function. The examples are all on the  mogit help page.

 
 On Aug 28, 2015, at 9:00 PM, Alaa Sindi alaasi...@gmail.com wrote:
 
 Dear all,
 
 Can anyone help me to change the maximum likelihood of multinomial logic 
 model in R?
 
 Thanks
 
 __
 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Referencing a component of a large object (Error: slot NULL)

2015-08-28 Thread Andrea Lamont
I am running a simulation and need to refer to a matrix of parameters from
a large object. Here is a snippet of the object structure itself:

Formal class 'mi' [package mi] with 3 slots
  ..@ call   : language .local(y = y, n.chains = ..2, max.minutes = 2)
  ..@ data   :List of 100
  .. ..$ chain:1  :'data.frame':1 obs. of  76 variables:
Formal class 'missing_data.frame' [package mi] with 17 slots
  .. .. .. ..@ .Data   : list()
  .. .. .. ..@ variables   :List of 76
  .. .. .. .. ..$ y.obs.tx:Formal class 'binary' [package mi] with 27 slots...

The parameter list I need can be referenced by:

mi.control.i@data$'chain:1'@variables$y.obs.tx@parameters[30,]

Since this is a simulation, I would like to grab the parameters from each
chain and join them together in a matrix. I have this:

tf - vector(list, numberofchains)for (j in 1:numberofchains){
  s - paste('chain:,j,' ,sep=)
  tf[[j]] =  mi.control.i@data$s@variables$y.obs.tx@parameters[30,]}

Within the loop, however, the reference to the object (tf[[j]]) does not
work. I get an error that reads

Error: trying to get slot variables from an object of a basic class
(NULL) with no slots


I am happy to send reproducible code, however, I obtain this object through
the package 'mi' and is computationally intensive. I'm not sure if it makes
it easier for folks. Let me know.

Any ideas?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-es] Una inquietud

2015-08-28 Thread heber sarmiento via R-help-es
Estoy elaborando un pequeño script en el que pido a los usuarios introducir un 
conjunto de valores, esto lo estoy haciendo con la función cat() el asunto es 
que no se como hacer para que luego de leídos, ellos sean asignados a un vector 
x-c(???...??)   agradezco cualquier orientación y desde ya gracias.  

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] una ayudita

2015-08-28 Thread heber sarmiento via R-help-es
Estoy elaborando un pequeño script en el que pido a los usuarios introducir un 
conjunto de valores, esto lo estoy haciendo con la función cat() el asunto es 
que no se como hacer para que luego de leídos, ellos sean asignados a un vector 
x-c(???...??)   agradezco cualquier orientación y desde ya gracias. 
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es