Re: [R] Help please

2021-03-10 Thread Jim Lemon
Hi Areti,
Maybe this will help:

scrounging<-data.frame(
 behav=sample(c("inactive","active","foraging","snoozing"),50,TRUE),
 substr=sample(c("tree","ground","vine","air"),50,TRUE))
scrounge.tab<-table(scrounging)
barplot(scrounge.tab)
legend(3.8,14,c("inactive","active","foraging","snoozing"),
 fill=c("gray80","gray60","gray40","gray20"))

Jim

On Thu, Mar 11, 2021 at 9:54 AM Areti Panopoulou
 wrote:
>
> Hello,
>
> I am trying to make a stacked barplot with different behaviours
> ("inactive", "active", "foraging" etc) on different substrates ("tree",
> "ground" etc). I have found this function:
>
> # Stacked Bar Plot with Colors and Legend
> counts <- table(mtcars$vs, mtcars$gear)
> barplot(counts, main="Car Distribution by Gears and VS",
>   xlab="Number of Gears", col=c("darkblue","red"),
>   legend = rownames(counts))
>
> But don't know how to apply it. Can anybody help me apply the function to
> work with my variables ( I can send more information if necessary, or make
> any clarifications).
>
> This is a great help, thanks a lot.
>
> [[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] Help please

2021-03-10 Thread Rui Barradas

Hello,

Please read the posting guide at the end of this and every R-Help mail.
You should post the output of

dput(data)

or, if the data set 'data' is too big, the output of

dput(head(data, 20))

for us to be able to help you.

Rui Barradas

Às 18:29 de 10/03/21, Areti Panopoulou escreveu:

Hello,

I am trying to make a stacked barplot with different behaviours
("inactive", "active", "foraging" etc) on different substrates ("tree",
"ground" etc). I have found this function:

# Stacked Bar Plot with Colors and Legend
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts, main="Car Distribution by Gears and VS",
   xlab="Number of Gears", col=c("darkblue","red"),
   legend = rownames(counts))

But don't know how to apply it. Can anybody help me apply the function to
work with my variables ( I can send more information if necessary, or make
any clarifications).

This is a great help, thanks a lot.

[[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.


[R] Help please

2021-03-10 Thread Areti Panopoulou
Hello,

I am trying to make a stacked barplot with different behaviours
("inactive", "active", "foraging" etc) on different substrates ("tree",
"ground" etc). I have found this function:

# Stacked Bar Plot with Colors and Legend
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts, main="Car Distribution by Gears and VS",
  xlab="Number of Gears", col=c("darkblue","red"),
  legend = rownames(counts))

But don't know how to apply it. Can anybody help me apply the function to
work with my variables ( I can send more information if necessary, or make
any clarifications).

This is a great help, thanks a lot.

[[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] Help please

2017-06-25 Thread Bert Gunter
On Sun, Jun 25, 2017 at 5:29 PM, Jim Lemon  wrote:
> Hi Rabby,
> Before you run your regression, try this:
>
> is.factor(Final$Cor)
>
> If this returns TRUE, then this variable is a factor and it will be
> treated as a number of levels rather than a set of numeric values.
> This usually happens when a text file is read in and there is at least
> one value that cannot be converted to numeric. So if you are doing
> something like this:
>
> Final<-read.csv("Final.csv")
>
> Try this:
>
> Final<-read.csv("Final.csv",stringsAsFactors=FALSE)
> Final$Cor<-as.numeric(Final$Cor)
>
> If there is at least one NA value in Final$Cor, that is probably what
> is causing your problem.

I don't think so. If Final$Cor is numeric to begin with, there should
be no problem with NA's. Commas or other stray characters might be the
problem, however. As always, consulting ?read.csv should be the first
stop.

The OP would probably benefit by spending some time with an R tutorial
or two(there are many good ones on teh web), I think, where such
issues are often discussed.

Cheers,
Bert


>
> Jim
>
> On Mon, Jun 26, 2017 at 9:38 AM, Sarpong, Rabby  wrote:
>> Hello Jim,
>>
>> Thanks for the response I really appreciate it. I have edited the data over
>> and over to correct that. But I am still getting the same results. Is that
>> the only way to resolve it please?
>>
>> -Rabby Sarpong
>>
>> ____
>> From: Jim Lemon 
>> Sent: Sunday, June 25, 2017 3:22:54 AM
>> To: Sarpong, Rabby
>> Cc: r-help@R-project.org
>> Subject: Re: [R] Help please
>>
>> Hi Rabby,
>> It looks to me as though your variable Final$Cor is being treated as a
>> factor rather than a numeric value. This may be due to one or more
>> non-numeric values occurring in the data that is read in. Also you do
>> not have to use the Final$* notation in the formula as you have
>> specified the data frame "Final".
>>
>> Jim
>>
>>
>> On Sun, Jun 25, 2017 at 2:17 AM, Sarpong, Rabby  wrote:
>>> Hello,
>>>
>>>
>>> I need some help on a regression I am running please. I am running a
>>> multiple regression in R and I am getting weird outputs and would like your
>>> help in resolving it.
>>>
>>> This is the code I run:
>>>
>>>
>>> Reg = lm (Final$Y.t.-Final$Y.t.1.  ~ Final$ Y.t.1. + Final$Cor +
>>> Final$Gov+ Final$Inv+ Final$TrOp + Final$Pop+ Final$Sch  , data = Final)
>>> summary(Reg)
>>>
>>>
>>> And the output I get is pasted below. As shown, highlighted variable is
>>> regressed more than once which should not be the case and I am not sure why
>>> that is the case. I have checked my data and nothing seems out of the
>>> ordinary. What could be wrong please?
>>>
>>>
>>> PS. I am still learning to use R.
>>>
>>>
>>> Thank you,
>>>
>>> Rabby
>>>
>>>
>>>
>>> Residuals:
>>>  Min   1Q   Median   3Q  Max
>>> -1.04279 -0.06739  0.00124  0.06376  1.59115
>>>
>>> Coefficients:
>>>Estimate Std. Error t value Pr(>|t|)
>>> (Intercept)   0.1045711  0.0867584   1.205 0.228308
>>> Final$Y.t.1. -0.0313686  0.0058536  -5.359 9.95e-08 ***
>>> Final$Cor10   0.0009784  0.1622916   0.006 0.995191
>>> Final$Cor11   0.1230775  0.1165864   1.056 0.291318
>>> Final$Cor12   0.1615939  0.1086529   1.487 0.137199
>>> Final$Cor13   0.1934974  0.1160577   1.667 0.095713 .
>>> Final$Cor14   0.2341660  0.1286909   1.820 0.069057 .
>>> Final$Cor15   0.0744373  0.1036776   0.718 0.472909
>>> Final$Cor16   0.1964904  0.0932540   2.107 0.035311 *
>>> Final$Cor17   0.1989502  0.0908614   2.190 0.028736 *
>>> Final$Cor18   0.1993614  0.0886491   2.249 0.024692 *
>>> Final$Cor19   0.2062234  0.0878018   2.349 0.018991 *
>>> Final$Cor20   0.1889846  0.0868192   2.177 0.029683 *
>>> Final$Cor21   0.1717589  0.0855883   2.007 0.044984 *
>>> Final$Cor22   0.1453460  0.0856982   1.696 0.090129 .
>>> Final$Cor23   0.1976086  0.0871142   2.268 0.023474 *
>>> Final$Cor24   0.1471384  0.0859318   1.712 0.087093 .
>>> Final$Cor25   0.1447194  0.0851309   1.700 0.089384 .
>>> Final$Cor26   0.1553640  0.0855425   1.816 0.069574 .
>>> Final$Cor27   0.1220044  0.0854661   1.428 0.153678
>>> Final$Cor28   0.1406044  0.0854213   1.646 0.100011
>>> Final$Cor29   0.1594371  0.0860525   1.853 0.

Re: [R] Help please

2017-06-25 Thread Jim Lemon
Hi Rabby,
Before you run your regression, try this:

is.factor(Final$Cor)

If this returns TRUE, then this variable is a factor and it will be
treated as a number of levels rather than a set of numeric values.
This usually happens when a text file is read in and there is at least
one value that cannot be converted to numeric. So if you are doing
something like this:

Final<-read.csv("Final.csv")

Try this:

Final<-read.csv("Final.csv",stringsAsFactors=FALSE)
Final$Cor<-as.numeric(Final$Cor)

If there is at least one NA value in Final$Cor, that is probably what
is causing your problem.

Jim

On Mon, Jun 26, 2017 at 9:38 AM, Sarpong, Rabby  wrote:
> Hello Jim,
>
> Thanks for the response I really appreciate it. I have edited the data over
> and over to correct that. But I am still getting the same results. Is that
> the only way to resolve it please?
>
> -Rabby Sarpong
>
> 
> From: Jim Lemon 
> Sent: Sunday, June 25, 2017 3:22:54 AM
> To: Sarpong, Rabby
> Cc: r-help@R-project.org
> Subject: Re: [R] Help please
>
> Hi Rabby,
> It looks to me as though your variable Final$Cor is being treated as a
> factor rather than a numeric value. This may be due to one or more
> non-numeric values occurring in the data that is read in. Also you do
> not have to use the Final$* notation in the formula as you have
> specified the data frame "Final".
>
> Jim
>
>
> On Sun, Jun 25, 2017 at 2:17 AM, Sarpong, Rabby  wrote:
>> Hello,
>>
>>
>> I need some help on a regression I am running please. I am running a
>> multiple regression in R and I am getting weird outputs and would like your
>> help in resolving it.
>>
>> This is the code I run:
>>
>>
>> Reg = lm (Final$Y.t.-Final$Y.t.1.  ~ Final$ Y.t.1. + Final$Cor +
>> Final$Gov+ Final$Inv+ Final$TrOp + Final$Pop+ Final$Sch  , data = Final)
>> summary(Reg)
>>
>>
>> And the output I get is pasted below. As shown, highlighted variable is
>> regressed more than once which should not be the case and I am not sure why
>> that is the case. I have checked my data and nothing seems out of the
>> ordinary. What could be wrong please?
>>
>>
>> PS. I am still learning to use R.
>>
>>
>> Thank you,
>>
>> Rabby
>>
>>
>>
>> Residuals:
>>  Min   1Q   Median   3Q  Max
>> -1.04279 -0.06739  0.00124  0.06376  1.59115
>>
>> Coefficients:
>>Estimate Std. Error t value Pr(>|t|)
>> (Intercept)   0.1045711  0.0867584   1.205 0.228308
>> Final$Y.t.1. -0.0313686  0.0058536  -5.359 9.95e-08 ***
>> Final$Cor10   0.0009784  0.1622916   0.006 0.995191
>> Final$Cor11   0.1230775  0.1165864   1.056 0.291318
>> Final$Cor12   0.1615939  0.1086529   1.487 0.137199
>> Final$Cor13   0.1934974  0.1160577   1.667 0.095713 .
>> Final$Cor14   0.2341660  0.1286909   1.820 0.069057 .
>> Final$Cor15   0.0744373  0.1036776   0.718 0.472909
>> Final$Cor16   0.1964904  0.0932540   2.107 0.035311 *
>> Final$Cor17   0.1989502  0.0908614   2.190 0.028736 *
>> Final$Cor18   0.1993614  0.0886491   2.249 0.024692 *
>> Final$Cor19   0.2062234  0.0878018   2.349 0.018991 *
>> Final$Cor20   0.1889846  0.0868192   2.177 0.029683 *
>> Final$Cor21   0.1717589  0.0855883   2.007 0.044984 *
>> Final$Cor22   0.1453460  0.0856982   1.696 0.090129 .
>> Final$Cor23   0.1976086  0.0871142   2.268 0.023474 *
>> Final$Cor24   0.1471384  0.0859318   1.712 0.087093 .
>> Final$Cor25   0.1447194  0.0851309   1.700 0.089384 .
>> Final$Cor26   0.1553640  0.0855425   1.816 0.069574 .
>> Final$Cor27   0.1220044  0.0854661   1.428 0.153678
>> Final$Cor28   0.1406044  0.0854213   1.646 0.100011
>> Final$Cor29   0.1594371  0.0860525   1.853 0.064146 .
>> Final$Cor30   0.1792005  0.0863734   2.075 0.038215 *
>> Final$Cor31   0.1376306  0.0871176   1.580 0.114398
>> Final$Cor32   0.1521694  0.0865125   1.759 0.078832 .
>> Final$Cor33   0.1535856  0.0863890   1.778 0.075671 .
>> Final$Cor34   0.1327356  0.0865482   1.534 0.125364
>> Final$Cor35   0.1501163  0.0864312   1.737 0.082661 .
>> Final$Cor36   0.1114404  0.0866389   1.286 0.198587
>> Final$Cor37   0.1326494  0.0873405   1.519 0.129073
>> Final$Cor38   0.0993100  0.0869474   1.142 0.253594
>> Final$Cor39   0.1346916  0.0885424   1.521 0.128458
>> Final$Cor40.0306186  0.1625561   0.188 0.850627
>> Final$Cor40   0.1596858  0.0906725   1.761 0.078459 .
>> Final$Cor41   0.1330054  0.0881280   1.509 0.131491
>> Final$Cor42   0.1355948  0.0911754   1.487 0.137216
>> Final$Cor43   0.1106947

Re: [R] Help please

2017-06-25 Thread Jim Lemon
Final$Cor69   0.2166677  0.1021570   2.121 0.034123 *
> Final$Cor70   0.1143033  0.1054570   1.084 0.278623
> Final$Cor71   0.1469311  0.1637571   0.897 0.369757
> Final$Cor72   0.2268878  0.1103408   2.056 0.039964 *
> Final$Cor73   0.1925218  0.1055544   1.824 0.068402 .
> Final$Cor74   0.1574432  0.1020634   1.543 0.123178
> Final$Cor75   0.0571227  0.1166594   0.490 0.624464
> Final$Cor76   0.1096049  0.1634571   0.671 0.502635
> Final$Cor78   0.0949307  0.1305748   0.727 0.467347
> Final$Cor80.1082102  0.1289245   0.839 0.401443
> Final$Gov-0.0016397  0.0008084  -2.028 0.042736 *
> Final$Inv 0.0016819  0.0004667   3.604 0.000326 ***
> Final$TrOp0.0002904  0.0001209   2.402 0.016445 *
> Final$Pop-0.0130554  0.0038839  -3.361 0.000799 ***
> Final$Sch 0.0005785  0.0002696   2.146 0.032064 *
> ---
>
>
>
> [[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.


[R] Help please

2017-06-24 Thread Sarpong, Rabby
ted]]

__
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] Help please with error from nnet::multinom

2016-06-26 Thread David Winsemius
, 2016 at 3:14 PM, David Winsemius  
> > wrote:
> >
> > > On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
> > >
> > > Thanks Bert.
> > >
> > > But I it doesn't complain when predict is used on X instead of X_new
> > > (using nnet_7.3-12), which is even more puzzling to me:
> > >
> > > pred <- predict(fit, X, type = "probs")
> >
> > Indeed: There is a predict.multinom function and it does have 'probs' as an 
> > acceptable argument to type:
> >
> > I got success (or at least an absence of an error message) with:
> >
> > #--
> >  X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
> >  X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3))
> >  str(X)
> >
> > 'data.frame':   300 obs. of  3 variables:
> >  $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
> >  $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
> >  $ X3: num  0.797 1.116 1.719 2.725 0.605 ...
> >
> >  fit <- multinom(y ~ ., data=X, trace = FALSE)
> >  pred <- predict(fit, setNames(X_new, names(X)), type = "probs")
> >
> > > head(pred)
> >   ysim1 ysim2 ysim3
> > 1 0.3519378 0.3517418 0.2963204
> > 2 0.3135513 0.3138573 0.3725915
> > 3 0.3603779 0.3600461 0.2795759
> > 4 0.3572297 0.3569498 0.2858206
> > 5 0.3481512 0.3480128 0.3038360
> > 6 0.3813310 0.3806118 0.2380572
> >
> > #
> >
> >
> > > head(pred)
> > > ysim1 ysim2 ysim3
> > > 1 0.3059421 0.3063284 0.3877295
> > > 2 0.3200219 0.3202551 0.3597230
> > > 3 0.3452414 0.3451460 0.3096125
> > > 4 0.3827077 0.3819603 0.2353320
> > > 5 0.2973288 0.2977994 0.4048718
> > > 6 0.3817027 0.3809759 0.2373214
> > >
> > > Thanks again,
> > > Lars.
> > >
> > >
> > > On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter  
> > > wrote:
> > >
> > >> Well, for one thing, there is no "probs" method for predict.nnet, at
> > >> least in my version: nnet_7.3-12
> > >>
> > >> Cheers,
> > >> Bert
> > >>
> > >>
> > >> Bert Gunter
> > >>
> > >> "The trouble with having an open mind is that people keep coming along
> > >> and sticking things into it."
> > >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> > >>
> > >>
> > >> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
> > >>> Hello,
> > >>>
> > >>> I'd appreciate your help in spotting the reason for the error and 
> > >>> warning
> > >>> messages below.
> > >>>
> > >>> library(nnet)
> > >>> set.seed(1)
> > >>> ysim <- gl(3, 100)
> > >>> y <- model.matrix(~ysim -1)
> > >>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> > >>> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
> > >>>
> > >>> fit <- multinom(y ~ X, trace = FALSE)
> > >>> pred <- predict(fit, X_new, type = "probs")
> > >>>
> > >>> Error in predict.multinom(fit, X_new, type = "probs") :
> > >>>  NAs are not allowed in subscripted assignments
> > >>> In addition: Warning message:
> > >>>  'newdata' had 200 rows but variables found have 300 rows
> > >>>
> > >>> Thanks,
> > >>> Lars.
> > >>>
> > >>>[[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.
> >
> > David Winsemius
> > Alameda, CA, USA
> >
> >
> 
> David Winsemius
> Alameda, CA, USA
> 
> 

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.


Re: [R] Help please with error from nnet::multinom

2016-06-26 Thread Lars Bishop
Thanks, David. Sorry, do you mean this?

library(nnet)
set.seed(1)
ysim <- gl(3, 100)
y <- model.matrix(~ysim -1)
X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
fit <- multinom(y ~ X, trace = FALSE)
pred <- predict(fit, setNames(data.frame(X_new),c("X1","X2","X3") ), type =
"probs")

Error in predict.multinom(fit, setNames(data.frame(X_new), c("X1", "X2",  :
   NAs are not
allowed in subscripted assignments
 In addition:
Warning message:
   'newdata'
had 200 rows but variables found have 300 rows

On Sun, Jun 26, 2016 at 3:46 PM, David Winsemius 
wrote:

>
> > On Jun 26, 2016, at 12:39 PM, Lars Bishop  wrote:
> >
> > Many thanks David. That works. Looks then this error will always occur
> in predict.multinom whenever the data argument is missing in the mutlinom
> fit, but the data argument is optional as per documentation.
>
> I don't agree with that analysis. The problem occurs because of a mismatch
> of names in the new data argument. With your original code this runs
> without error:
>
> pred <- predict(fit, setNames(data.frame(X_new),c("X1","X2","X3") ), type
> = "probs")
>
> --
> David.
> >
> > Best,
> > Lars.
> >
> > On Sun, Jun 26, 2016 at 3:14 PM, David Winsemius 
> wrote:
> >
> > > On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
> > >
> > > Thanks Bert.
> > >
> > > But I it doesn't complain when predict is used on X instead of X_new
> > > (using nnet_7.3-12), which is even more puzzling to me:
> > >
> > > pred <- predict(fit, X, type = "probs")
> >
> > Indeed: There is a predict.multinom function and it does have 'probs' as
> an acceptable argument to type:
> >
> > I got success (or at least an absence of an error message) with:
> >
> > #--
> >  X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
> >  X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol =
> 3))
> >  str(X)
> >
> > 'data.frame':   300 obs. of  3 variables:
> >  $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
> >  $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
> >  $ X3: num  0.797 1.116 1.719 2.725 0.605 ...
> >
> >  fit <- multinom(y ~ ., data=X, trace = FALSE)
> >  pred <- predict(fit, setNames(X_new, names(X)), type = "probs")
> >
> > > head(pred)
> >   ysim1 ysim2 ysim3
> > 1 0.3519378 0.3517418 0.2963204
> > 2 0.3135513 0.3138573 0.3725915
> > 3 0.3603779 0.3600461 0.2795759
> > 4 0.3572297 0.3569498 0.2858206
> > 5 0.3481512 0.3480128 0.3038360
> > 6 0.3813310 0.3806118 0.2380572
> >
> > #
> >
> >
> > > head(pred)
> > > ysim1 ysim2 ysim3
> > > 1 0.3059421 0.3063284 0.3877295
> > > 2 0.3200219 0.3202551 0.3597230
> > > 3 0.3452414 0.3451460 0.3096125
> > > 4 0.3827077 0.3819603 0.2353320
> > > 5 0.2973288 0.2977994 0.4048718
> > > 6 0.3817027 0.3809759 0.2373214
> > >
> > > Thanks again,
> > > Lars.
> > >
> > >
> > > On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter 
> wrote:
> > >
> > >> Well, for one thing, there is no "probs" method for predict.nnet, at
> > >> least in my version: nnet_7.3-12
> > >>
> > >> Cheers,
> > >> Bert
> > >>
> > >>
> > >> Bert Gunter
> > >>
> > >> "The trouble with having an open mind is that people keep coming along
> > >> and sticking things into it."
> > >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> > >>
> > >>
> > >> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop 
> wrote:
> > >>> Hello,
> > >>>
> > >>> I'd appreciate your help in spotting the reason for the error and
> warning
> > >>> messages below.
> > >>>
> > >>> library(nnet)
> > >>> set.seed(1)
> > >>> ysim <- gl(3, 100)
> > >>> y <- model.matrix(~ysim -1)
> > >>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> > >>>

Re: [R] Help please with error from nnet::multinom

2016-06-26 Thread David Winsemius

> On Jun 26, 2016, at 12:39 PM, Lars Bishop  wrote:
> 
> Many thanks David. That works. Looks then this error will always occur in 
> predict.multinom whenever the data argument is missing in the mutlinom fit, 
> but the data argument is optional as per documentation. 

I don't agree with that analysis. The problem occurs because of a mismatch of 
names in the new data argument. With your original code this runs without error:

pred <- predict(fit, setNames(data.frame(X_new),c("X1","X2","X3") ), type = 
"probs")

-- 
David.
> 
> Best,
> Lars.
> 
> On Sun, Jun 26, 2016 at 3:14 PM, David Winsemius  
> wrote:
> 
> > On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
> >
> > Thanks Bert.
> >
> > But I it doesn't complain when predict is used on X instead of X_new
> > (using nnet_7.3-12), which is even more puzzling to me:
> >
> > pred <- predict(fit, X, type = "probs")
> 
> Indeed: There is a predict.multinom function and it does have 'probs' as an 
> acceptable argument to type:
> 
> I got success (or at least an absence of an error message) with:
> 
> #--
>  X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
>  X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3))
>  str(X)
> 
> 'data.frame':   300 obs. of  3 variables:
>  $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X3: num  0.797 1.116 1.719 2.725 0.605 ...
> 
>  fit <- multinom(y ~ ., data=X, trace = FALSE)
>  pred <- predict(fit, setNames(X_new, names(X)), type = "probs")
> 
> > head(pred)
>   ysim1 ysim2 ysim3
> 1 0.3519378 0.3517418 0.2963204
> 2 0.3135513 0.3138573 0.3725915
> 3 0.3603779 0.3600461 0.2795759
> 4 0.3572297 0.3569498 0.2858206
> 5 0.3481512 0.3480128 0.3038360
> 6 0.3813310 0.3806118 0.2380572
> 
> #
> 
> 
> > head(pred)
> > ysim1 ysim2 ysim3
> > 1 0.3059421 0.3063284 0.3877295
> > 2 0.3200219 0.3202551 0.3597230
> > 3 0.3452414 0.3451460 0.3096125
> > 4 0.3827077 0.3819603 0.2353320
> > 5 0.2973288 0.2977994 0.4048718
> > 6 0.3817027 0.3809759 0.2373214
> >
> > Thanks again,
> > Lars.
> >
> >
> > On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter  wrote:
> >
> >> Well, for one thing, there is no "probs" method for predict.nnet, at
> >> least in my version: nnet_7.3-12
> >>
> >> Cheers,
> >> Bert
> >>
> >>
> >> Bert Gunter
> >>
> >> "The trouble with having an open mind is that people keep coming along
> >> and sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >>
> >>
> >> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
> >>> Hello,
> >>>
> >>> I'd appreciate your help in spotting the reason for the error and warning
> >>> messages below.
> >>>
> >>> library(nnet)
> >>> set.seed(1)
> >>> ysim <- gl(3, 100)
> >>> y <- model.matrix(~ysim -1)
> >>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> >>> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
> >>>
> >>> fit <- multinom(y ~ X, trace = FALSE)
> >>> pred <- predict(fit, X_new, type = "probs")
> >>>
> >>> Error in predict.multinom(fit, X_new, type = "probs") :
> >>>  NAs are not allowed in subscripted assignments
> >>> In addition: Warning message:
> >>>  'newdata' had 200 rows but variables found have 300 rows
> >>>
> >>> Thanks,
> >>> Lars.
> >>>
> >>>[[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.
> 
> David Winsemius
> Alameda, CA, USA
> 
> 

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.


Re: [R] Help please with error from nnet::multinom

2016-06-26 Thread Lars Bishop
Many thanks David. That works. Looks then this error will always occur in
predict.multinom whenever the data argument is missing in the mutlinom fit,
but the data argument is optional as per documentation.

Best,
Lars.

On Sun, Jun 26, 2016 at 3:14 PM, David Winsemius 
wrote:

>
> > On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
> >
> > Thanks Bert.
> >
> > But I it doesn't complain when predict is used on X instead of X_new
> > (using nnet_7.3-12), which is even more puzzling to me:
> >
> > pred <- predict(fit, X, type = "probs")
>
> Indeed: There is a predict.multinom function and it does have 'probs' as
> an acceptable argument to type:
>
> I got success (or at least an absence of an error message) with:
>
> #--
>  X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
>  X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol =
> 3))
>  str(X)
>
> 'data.frame':   300 obs. of  3 variables:
>  $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X3: num  0.797 1.116 1.719 2.725 0.605 ...
>
>  fit <- multinom(y ~ ., data=X, trace = FALSE)
>  pred <- predict(fit, setNames(X_new, names(X)), type = "probs")
>
> > head(pred)
>   ysim1 ysim2 ysim3
> 1 0.3519378 0.3517418 0.2963204
> 2 0.3135513 0.3138573 0.3725915
> 3 0.3603779 0.3600461 0.2795759
> 4 0.3572297 0.3569498 0.2858206
> 5 0.3481512 0.3480128 0.3038360
> 6 0.3813310 0.3806118 0.2380572
>
> #
>
>
> > head(pred)
> > ysim1 ysim2 ysim3
> > 1 0.3059421 0.3063284 0.3877295
> > 2 0.3200219 0.3202551 0.3597230
> > 3 0.3452414 0.3451460 0.3096125
> > 4 0.3827077 0.3819603 0.2353320
> > 5 0.2973288 0.2977994 0.4048718
> > 6 0.3817027 0.3809759 0.2373214
> >
> > Thanks again,
> > Lars.
> >
> >
> > On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter 
> wrote:
> >
> >> Well, for one thing, there is no "probs" method for predict.nnet, at
> >> least in my version: nnet_7.3-12
> >>
> >> Cheers,
> >> Bert
> >>
> >>
> >> Bert Gunter
> >>
> >> "The trouble with having an open mind is that people keep coming along
> >> and sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >>
> >>
> >> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
> >>> Hello,
> >>>
> >>> I'd appreciate your help in spotting the reason for the error and
> warning
> >>> messages below.
> >>>
> >>> library(nnet)
> >>> set.seed(1)
> >>> ysim <- gl(3, 100)
> >>> y <- model.matrix(~ysim -1)
> >>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> >>> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
> >>>
> >>> fit <- multinom(y ~ X, trace = FALSE)
> >>> pred <- predict(fit, X_new, type = "probs")
> >>>
> >>> Error in predict.multinom(fit, X_new, type = "probs") :
> >>>  NAs are not allowed in subscripted assignments
> >>> In addition: Warning message:
> >>>  'newdata' had 200 rows but variables found have 300 rows
> >>>
> >>> Thanks,
> >>> Lars.
> >>>
> >>>[[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.
>
> David Winsemius
> Alameda, CA, USA
>
>

[[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] Help please with error from nnet::multinom

2016-06-26 Thread Bert Gunter
Thanks, David.

That is very interesting, because ?multinom says that the value is:

"A nnet object with additional components: ..."

Of course I could have checked methods(predict), but I just took the
Help file at its word. Should it not be revised to say explicitly:

"An object of class 'multinom', which is a nnet object ... "

??

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 12:14 PM, David Winsemius
 wrote:
>
>> On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
>>
>> Thanks Bert.
>>
>> But I it doesn't complain when predict is used on X instead of X_new
>> (using nnet_7.3-12), which is even more puzzling to me:
>>
>> pred <- predict(fit, X, type = "probs")
>
> Indeed: There is a predict.multinom function and it does have 'probs' as an 
> acceptable argument to type:
>
> I got success (or at least an absence of an error message) with:
>
> #--
>  X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
>  X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3))
>  str(X)
>
> 'data.frame':   300 obs. of  3 variables:
>  $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
>  $ X3: num  0.797 1.116 1.719 2.725 0.605 ...
>
>  fit <- multinom(y ~ ., data=X, trace = FALSE)
>  pred <- predict(fit, setNames(X_new, names(X)), type = "probs")
>
>> head(pred)
>   ysim1 ysim2 ysim3
> 1 0.3519378 0.3517418 0.2963204
> 2 0.3135513 0.3138573 0.3725915
> 3 0.3603779 0.3600461 0.2795759
> 4 0.3572297 0.3569498 0.2858206
> 5 0.3481512 0.3480128 0.3038360
> 6 0.3813310 0.3806118 0.2380572
>
> #
>
>
>> head(pred)
>> ysim1 ysim2 ysim3
>> 1 0.3059421 0.3063284 0.3877295
>> 2 0.3200219 0.3202551 0.3597230
>> 3 0.3452414 0.3451460 0.3096125
>> 4 0.3827077 0.3819603 0.2353320
>> 5 0.2973288 0.2977994 0.4048718
>> 6 0.3817027 0.3809759 0.2373214
>>
>> Thanks again,
>> Lars.
>>
>>
>> On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter  wrote:
>>
>>> Well, for one thing, there is no "probs" method for predict.nnet, at
>>> least in my version: nnet_7.3-12
>>>
>>> Cheers,
>>> Bert
>>>
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
>>>> Hello,
>>>>
>>>> I'd appreciate your help in spotting the reason for the error and warning
>>>> messages below.
>>>>
>>>> library(nnet)
>>>> set.seed(1)
>>>> ysim <- gl(3, 100)
>>>> y <- model.matrix(~ysim -1)
>>>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
>>>> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
>>>>
>>>> fit <- multinom(y ~ X, trace = FALSE)
>>>> pred <- predict(fit, X_new, type = "probs")
>>>>
>>>> Error in predict.multinom(fit, X_new, type = "probs") :
>>>>  NAs are not allowed in subscripted assignments
>>>> In addition: Warning message:
>>>>  'newdata' had 200 rows but variables found have 300 rows
>>>>
>>>> Thanks,
>>>> Lars.
>>>>
>>>>[[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.
>
> 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.


Re: [R] Help please with error from nnet::multinom

2016-06-26 Thread David Winsemius

> On Jun 26, 2016, at 11:32 AM, Lars Bishop  wrote:
> 
> Thanks Bert.
> 
> But I it doesn't complain when predict is used on X instead of X_new
> (using nnet_7.3-12), which is even more puzzling to me:
> 
> pred <- predict(fit, X, type = "probs")

Indeed: There is a predict.multinom function and it does have 'probs' as an 
acceptable argument to type:

I got success (or at least an absence of an error message) with:

#--
 X <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3))
 X_new <- data.frame(matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3))
 str(X)

'data.frame':   300 obs. of  3 variables:
 $ X1: num  0.797 1.116 1.719 2.725 0.605 ...
 $ X2: num  0.797 1.116 1.719 2.725 0.605 ...
 $ X3: num  0.797 1.116 1.719 2.725 0.605 ...

 fit <- multinom(y ~ ., data=X, trace = FALSE)
 pred <- predict(fit, setNames(X_new, names(X)), type = "probs")

> head(pred)
  ysim1 ysim2 ysim3
1 0.3519378 0.3517418 0.2963204
2 0.3135513 0.3138573 0.3725915
3 0.3603779 0.3600461 0.2795759
4 0.3572297 0.3569498 0.2858206
5 0.3481512 0.3480128 0.3038360
6 0.3813310 0.3806118 0.2380572

#


> head(pred)
> ysim1 ysim2 ysim3
> 1 0.3059421 0.3063284 0.3877295
> 2 0.3200219 0.3202551 0.3597230
> 3 0.3452414 0.3451460 0.3096125
> 4 0.3827077 0.3819603 0.2353320
> 5 0.2973288 0.2977994 0.4048718
> 6 0.3817027 0.3809759 0.2373214
> 
> Thanks again,
> Lars.
> 
> 
> On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter  wrote:
> 
>> Well, for one thing, there is no "probs" method for predict.nnet, at
>> least in my version: nnet_7.3-12
>> 
>> Cheers,
>> Bert
>> 
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> 
>> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
>>> Hello,
>>> 
>>> I'd appreciate your help in spotting the reason for the error and warning
>>> messages below.
>>> 
>>> library(nnet)
>>> set.seed(1)
>>> ysim <- gl(3, 100)
>>> y <- model.matrix(~ysim -1)
>>> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
>>> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
>>> 
>>> fit <- multinom(y ~ X, trace = FALSE)
>>> pred <- predict(fit, X_new, type = "probs")
>>> 
>>> Error in predict.multinom(fit, X_new, type = "probs") :
>>>  NAs are not allowed in subscripted assignments
>>> In addition: Warning message:
>>>  'newdata' had 200 rows but variables found have 300 rows
>>> 
>>> Thanks,
>>> Lars.
>>> 
>>>[[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.

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.


Re: [R] Help please with error from nnet::multinom

2016-06-26 Thread Lars Bishop
Thanks Bert.

But I it doesn't complain when predict is used on X instead of X_new
(using nnet_7.3-12), which is even more puzzling to me:

pred <- predict(fit, X, type = "probs")
head(pred)
ysim1 ysim2 ysim3
1 0.3059421 0.3063284 0.3877295
2 0.3200219 0.3202551 0.3597230
3 0.3452414 0.3451460 0.3096125
4 0.3827077 0.3819603 0.2353320
5 0.2973288 0.2977994 0.4048718
6 0.3817027 0.3809759 0.2373214

Thanks again,
Lars.


On Sun, Jun 26, 2016 at 1:05 PM, Bert Gunter  wrote:

> Well, for one thing, there is no "probs" method for predict.nnet, at
> least in my version: nnet_7.3-12
>
> Cheers,
> Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
> > Hello,
> >
> > I'd appreciate your help in spotting the reason for the error and warning
> > messages below.
> >
> > library(nnet)
> > set.seed(1)
> > ysim <- gl(3, 100)
> > y <- model.matrix(~ysim -1)
> > X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> > X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
> >
> > fit <- multinom(y ~ X, trace = FALSE)
> > pred <- predict(fit, X_new, type = "probs")
> >
> > Error in predict.multinom(fit, X_new, type = "probs") :
> >   NAs are not allowed in subscripted assignments
> > In addition: Warning message:
> >   'newdata' had 200 rows but variables found have 300 rows
> >
> > Thanks,
> > Lars.
> >
> > [[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] Help please with error from nnet::multinom

2016-06-26 Thread Bert Gunter
Well, for one thing, there is no "probs" method for predict.nnet, at
least in my version: nnet_7.3-12

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 9:27 AM, Lars Bishop  wrote:
> Hello,
>
> I'd appreciate your help in spotting the reason for the error and warning
> messages below.
>
> library(nnet)
> set.seed(1)
> ysim <- gl(3, 100)
> y <- model.matrix(~ysim -1)
> X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
> X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)
>
> fit <- multinom(y ~ X, trace = FALSE)
> pred <- predict(fit, X_new, type = "probs")
>
> Error in predict.multinom(fit, X_new, type = "probs") :
>   NAs are not allowed in subscripted assignments
> In addition: Warning message:
>   'newdata' had 200 rows but variables found have 300 rows
>
> Thanks,
> Lars.
>
> [[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.


[R] Help please with error from nnet::multinom

2016-06-26 Thread Lars Bishop
Hello,

I'd appreciate your help in spotting the reason for the error and warning
messages below.

library(nnet)
set.seed(1)
ysim <- gl(3, 100)
y <- model.matrix(~ysim -1)
X <- matrix( 3 * runif(length(ysim)), nrow = 300, ncol = 3)
X_new <- matrix( 3 * runif(length(ysim)), nrow = 200, ncol = 3)

fit <- multinom(y ~ X, trace = FALSE)
pred <- predict(fit, X_new, type = "probs")

Error in predict.multinom(fit, X_new, type = "probs") :
  NAs are not allowed in subscripted assignments
In addition: Warning message:
  'newdata' had 200 rows but variables found have 300 rows

Thanks,
Lars.

[[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] What URL do I go to manage my subscription to the r-help? Please respond directly to me, not to this list!!!!

2015-12-01 Thread David Winsemius

> On Dec 1, 2015, at 6:24 PM, John Sorkin  wrote:
> 
> Please respond directly to me jsor...@grecc.umaryland.edu.

I generally respond to both the poster and the list.

> If you respond to the list I will not get your response. There is a problem 
> with my subscription. It has been changed to digest. I need to set it back to 
> no digest (i.e. get messages as soon as they are posted)
> John

The link is found at the bottom of the listinfo page linked at the bottom of 
every posting from Rhelp.


> 
> 
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
> 
> 
> 
> 
> Call
> 
> Call from mobile
> 
> Send SMS
> 
> Add to Skype
> 
> You'll need Skype CreditFree via Skype
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and 
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
> 
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:15}}

______
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] What URL do I go to manage my subscription to the r-help? Please respond directly to me, not to this list!!!!

2015-12-01 Thread John Sorkin
Please respond directly to me jsor...@grecc.umaryland.edu. If you respond to 
the list I will not get your response. There is a problem with my subscription. 
It has been changed to digest. I need to set it back to no digest (i.e. get 
messages as soon as they are posted)
John


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




Call

Call from mobile

Send SMS

Add to Skype

You'll need Skype CreditFree via Skype
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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] R-help, please

2015-09-21 Thread MCGUIRE, Rhydwyn
Hi Kim, this sounds like a homework question which is not meant for this list, 
I don't believe you need a package for this, but you may find the ifelse 
function along with the sum()function useful. You can get more information by 
typing ?ifelse and ?sum into R.

Regards,
Rhydwyn


Rhydwyn McGuire
Senior Biostatistician | Health Statistics NSW
Level 7, 73 Miller St, North Sydney 2060
Tel 02 9391 9781 | rm...@doh.health.nsw.gov.au
www.health.nsw.gov.au




-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of 
le4...@mweb.co.za
Sent: Tuesday, 22 September 2015 12:15 AM
To: r-help@R-project.org
Subject: Re: [R] R-help, please

Good day,
My name is Kim Nguyen and please I need your help with: How to calculate the 
PASS rate of the data in the table below, with PASS in a single subject if 
value>=50 and PASS will be given if PASS 3 out of 4 subjectsWhich package will 
I need to use in this analysis




ID

Literacy

Maths

Physics

Chemistry


A

65

70

79

80


B

65

45

38

50


C

50

62

48

49


D

70

85

82

84


E

45

69

65

62

I appreciate your consultant very much
With kind regardsKim Nguyen
Sent from MWEB Message Centre - CONNECT AND YOU CAN

[[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.
__
This email has been scanned for the NSW Ministry of Health by the Websense 
Hosted Email Security System.
Emails and attachments are monitored to ensure compliance with the NSW Ministry 
of health's Electronic Messaging Policy.
__
___
Disclaimer: This message is intended for the addressee named and may contain 
confidential information.
If you are not the intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the individual sender, and are not 
necessarily the views of the NSW Ministry of Health.
___
This email has been scanned for the NSW Ministry of Health by the Websense 
Hosted Email Security System.
Emails and attachments are monitored to ensure compliance with the NSW Ministry 
of Health's Electronic Messaging Policy.

__
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] R-help, please

2015-09-21 Thread John Kane
It looks like you sent the e-mail in HTML. 

It is unreadable.

You must sent e-mail to R-help in plain text not HTML

John Kane
Kingston ON Canada


> -Original Message-
> From: le4...@mweb.co.za
> Sent: Mon, 21 Sep 2015 16:14:41 +0200
> To: r-help@r-project.org
> Subject: Re: [R] R-help, please
> 
> Good day,
> My name is Kim Nguyen and please I need your help with: How to calculate
> the PASS rate of the data in the table below, with PASS in a single
> subject if value>=50 and PASS will be given if PASS 3 out of 4
> subjectsWhich package will I need to use in this analysis
> 
> 
> 
> 
> ID
> 
> Literacy
> 
> Maths
> 
> Physics
> 
> Chemistry
> 
> 
> A
> 
> 65
> 
> 70
> 
> 79
> 
> 80
> 
> 
> B
> 
> 65
> 
> 45
> 
> 38
> 
> 50
> 
> 
> C
> 
> 50
> 
> 62
> 
> 48
> 
> 49
> 
> 
> D
> 
> 70
> 
> 85
> 
> 82
> 
> 84
> 
> 
> E
> 
> 45
> 
> 69
> 
> 65
> 
> 62
> 
> I appreciate your consultant very much
> With kind regardsKim Nguyen
> Sent from MWEB Message Centre - CONNECT AND YOU CAN
> 
>   [[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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
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] R-help, please

2015-09-21 Thread Rolf Turner



Your question looks very much like homework and this list does not do 
homework for people.  Talk to your instructor.


cheers,

Rolf Turner

On 22/09/15 02:14, le4...@mweb.co.za wrote:

Good day,
My name is Kim Nguyen and please I need your help with: How to calculate the PASS 
rate of the data in the table below, with PASS in a single subject if value>=50 
and PASS will be given if PASS 3 out of 4 subjectsWhich package will I need to use 
in this analysis




ID

Literacy

Maths

Physics

Chemistry


A

65

70

79

80


B

65

45

38

50


C

50

62

48

49


D

70

85

82

84


E

45

69

65

62

I appreciate your consultant very much
With kind regardsKim Nguyen


__
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] R-help, please

2015-09-21 Thread le4...@mweb.co.za
Good day,
My name is Kim Nguyen and please I need your help with: How to calculate the 
PASS rate of the data in the table below, with PASS in a single subject if 
value>=50 and PASS will be given if PASS 3 out of 4 subjectsWhich package will 
I need to use in this analysis




ID

Literacy

Maths

Physics

Chemistry


A

65

70

79

80


B

65

45

38

50


C

50

62

48

49


D

70

85

82

84


E

45

69

65

62

I appreciate your consultant very much
With kind regardsKim Nguyen
Sent from MWEB Message Centre - CONNECT AND YOU CAN

[[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] help please >>metro_hastings function

2015-02-15 Thread ARNAB KR MAITY via R-help
Hi,
I have used this function before successfully. I could help you if you could 
provide your code.
Thanks & Regards,Arnab 
  From: hms Dreams 
 To: "r-help@r-project.org"  
 Sent: Saturday, February 14, 2015 6:27 AM
 Subject: [R] help please >>metro_hastings function
   



Hi :)anybody can help me please I'm trying to use Metro_Hastings (

MHadaptive package)the proplem is:  How can I know the covariance matrix( 
prop_sigma ) to enter it in Metro_Hastings: 
 mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1), prop_sigma 
=NULL,par_names=c('alpha','gamma','delta'),data=x ) its gave me an error , I 
must enter the cov matrix but I don't know how to calculate it, somebody told 
me to wrote the function without prop_sigma but its also gave me an error what 
can I do?? Thank you,Sara
                         
    [[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] help please >>metro_hastings function

2015-02-14 Thread John Kane
It looks like you posted in HTML and the result are garbbled. ONly post in 
plain text. Also it might help to read one or both of these
https://github.com/hadley/devtools/wiki/Reproducibility
 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

John Kane
Kingston ON Canada


> -Original Message-
> From: cute_loo...@hotmail.com
> Sent: Sat, 14 Feb 2015 15:27:58 +0300
> To: r-help@r-project.org
> Subject: [R] help please >>metro_hastings function
> 
> 
> 
> 
> Hi :)anybody can help me please I'm trying to use Metro_Hastings (
> 
> MHadaptive package)the proplem is:  How can I know the covariance matrix(
> prop_sigma ) to enter it in Metro_Hastings:
>  mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1), prop_sigma
> =NULL,par_names=c('alpha','gamma','delta'),data=x ) its gave me an error
> , I must enter the cov matrix but I don't know how to calculate it,
> somebody told me to wrote the function without prop_sigma but its also
> gave me an error what can I do?? Thank you,Sara
> 
>   [[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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

______
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 please >>metro_hastings function

2015-02-14 Thread hms Dreams



Hi :)anybody can help me please I'm trying to use Metro_Hastings (

MHadaptive package)the proplem is:  How can I know the covariance matrix( 
prop_sigma ) to enter it in Metro_Hastings: 
 mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1), prop_sigma 
=NULL,par_names=c('alpha','gamma','delta'),data=x ) its gave me an error , I 
must enter the cov matrix but I don't know how to calculate it, somebody told 
me to wrote the function without prop_sigma but its also gave me an error what 
can I do?? Thank you,Sara
  
[[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] Help Please, ggplot2

2013-04-01 Thread Jeff Newmiller
Your example is not reproducible [1]. We don't know what device you are writing 
to, and we don't have your data or even a subset of it.

However, facet_wrap is not used for generating separate graphs. You will need 
to make some kind of loop construct (for or lapply) that opens the device, 
prints the plot of a subset of the data (without faceting), and closes the 
device, for each group in your data. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

David Lyon  wrote:

>library(ggplot2)
>a<- read.table("data", header=T)
>b = na.omit(a)
>ggplot(data=b) + geom_line(aes(x=timepoint, y=value,group=sample,
>colour= factor(sample))) +  geom_point(aes(x=timepoint, y=value,
>group=s
>ample)) + facet_wrap(~bio, scales = "free",ncol = 5) +theme_bw() +
>opts(legend.direction = "horizontal",    legend.position = "top",
>legend.background = theme_blank()) +  labs(fill="")
>dev.off()
>
>
>This generates one nice plot with many many plots in 1 file.
>How do I modify the code to split up the plots into single file instead
>of merging them in 1 file I want each plot to be in a separate file ?
>
>Thanks in advance
>
>
>______
>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.


[R] Help Please, ggplot2

2013-04-01 Thread David Lyon
library(ggplot2)
a<- read.table("data", header=T)
b = na.omit(a)
ggplot(data=b) + geom_line(aes(x=timepoint, y=value,group=sample, colour= 
factor(sample))) +  geom_point(aes(x=timepoint, y=value, group=s
ample)) + facet_wrap(~bio, scales = "free",ncol = 5) +theme_bw() + 
opts(legend.direction = "horizontal",    legend.position = "top", 
legend.background = theme_blank()) +  labs(fill="")
dev.off()


This generates one nice plot with many many plots in 1 file.
How do I modify the code to split up the plots into single file instead of 
merging them in 1 file I want each plot to be in a separate file ?

Thanks in advance


__
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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Petr PIKAL
Hi

> all problems solved. thank you for your help!
> for the sake of completeness, here my solution:
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, 
sep="\t")
> daten<-as.data.frame(daten)

not needed, daten is already data frame

> 
> #2) create empty matrix:
> indxind<-matrix(0,nrow=617, ncol=617) 
> #indxind[1:20,1:19]
> 
> #3) compare cells to each other, score:
> #for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
> z1<-1 #running variable for rows in daten
> z2<-1 #running variable for rows in daten
> l1<-1 #running variable for rows in indxind
> l2<-1 #running variable for rows in indxind
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
> while (z1<11) {  #for each current colum, take one row
> (z1)...
> while (z2<11) {  #...and compare it to
> another row (z2) of the current colum
>   if (z1!=z2) {
>   l1
> 
> topf<-indxind[l1,l2]
>   if
> (daten[z1,s]==daten[z2,s]) topf<-topf+1   #actually, 2 rows make up 1
> individual,
>   if
> (daten[z1,s]==daten[z2+1,s]) topf<-topf+1  #therefore i compare 2 
rows
>   if
> (daten[z1+1,s]==daten[z2,s]) topf<-topf+1  #with another 2 rows
>   if
> (daten[z1+1,s]==daten[z2+1,s]) topf<-topf+1
> 
> indxind[l1,l2]<-topf
>   }
>   z2<-z2+2
>   l2<-l2+1
>   }
> z2<-1
> l2<-1
> z1<-z1+2
> l1<-l1+1
>   }
> z1<-1
> l1<-1
>}
> 
> #4) check:
> indxind[1:5,1:5]

I believe that above cycles can be simplified, maybe by changing your 
daten to three dimensional array or some clever **ply construction but if 
your loops works it is not probably worth en effort.

Regards
Petr

> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/help-please-
> matrix-operations-inside-3-nested-loops-tp4639592p4639744.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.

__
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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Petr PIKAL
Hi

> thank you for your help.
> 
> my input data looks like this (tab separated):
> 
> Ind.nr.   Pop.nr.   scm266   rms1280   scm247   rms1107
> 1   101   305   318   222   135
> 1   101   305   318   231   135
> 2   101   305   313   999   96
> 2   101   305   321   999   130
> 3   101   305   324   231   135
> 3   101   305   324   231   135
> 4   101   305   313   230   126
> 4   101   305   313   230   135
> 6   101   305   313   231   135
> 6   101   305   321   231   135

Better to use dput(your.data) for sharing data. Anyway I am still confused 
but you probably are able to clarify things further.

> 
> it is a dataset with genetic marker alleles for single individuals. 
> the first row is the header, all following rows are individuals. 2 rows
> count for 1 individual.
> first colum is the individual's number, second colum is the number for 
the
> population the individual comes from, and all following colums are 
different
> genetic markers.
> 
> what i want to do with this data in R, is to compare one individual with

In those 2 rows for one individual sometimes the genetic marker differs

> test[1:2, "scm247"]
[1] 222 231

What do you want to do with them?

> each of the other individuals, allele-wise. there are five 
possibilities:
> the two compared individuals share 4,3,2,1,0 alleles of the currently
> examined marker (=colum). for each shared allele this pair of 
individuals
> shall get 1 scoring point. for each pair of individuals, all scoring 
points
> shall be summarized over all markers.

Based on your example, 

> dput(test)
structure(list(Ind.nr. = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 6L, 
6L), Pop.nr. = c(101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 
101L, 101L), scm266 = c(305L, 305L, 305L, 305L, 305L, 305L, 305L, 
305L, 305L, 305L), rms1280 = c(318L, 318L, 313L, 321L, 324L, 
324L, 313L, 313L, 313L, 321L), scm247 = c(222L, 231L, 999L, 999L, 
231L, 231L, 230L, 230L, 231L, 231L), rms1107 = c(135L, 135L, 
96L, 130L, 135L, 135L, 126L, 135L, 135L, 135L)), .Names = c("Ind.nr.", 
"Pop.nr.", "scm266", "rms1280", "scm247", "rms1107"), class = 
"data.frame", row.names = c(NA, 
-10L))

what is your desired result?

Regards
Petr


> 
> 
> my code again, modified according to your suggestions:
> 
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, 
sep="\t")
> daten<-as.data.frame(daten)
> 
> #2) create empty matrix:
> indxind<-matrix(0,nrow=617, ncol=617) 
> indxind[1:20,1:19]
> 
> #3) compare cells to each other, score:
> #for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
>   for (z1 in 1:6) {  #for each current colum, take one row (z1)...
> for (z2 in 1:6) {  #...and compare it to another row (z2) of the 
current
> colum
>   if (z1!=z2) {topf<-indxind[z1,z2]
>if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1 
> #actually, 2 rows make up 1 individual,
>if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1 
> #therefore i compare 2 rows
>if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1 
> #with another 2 rows
>if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
>indxind[z1,z2]<-topf
>indxind[z2,z1]<-topf
>   }
>   #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, 
but
> gives always 8 for indxind[1,2]
> }
> #indxind[1:5,1:5] #empty matrix
>   }
>   #indxind[1:5,1:5] #empty matrix
> }
> 
> #4) check:
> indxind[1:5,1:5]
> 
> 
> 
> @ Michael Weylandt: i've done my best with regard to the "big picture" 
of my
> algorithm and the small reproducible example. i hope both is sufficient.
> @ Petr Pikal-3: in this case, there are only numerical values, but it's 
a
> useful hint for my other codes.
> @ Petr Pikal-3 and Berend Hasselman: initializing indxind with 0's 
instead
> of NAs helps, it fills something in indxind now. but it does the 
calculation
> only for the first marker (colum 3), afterwards i get an error: 
> Fehler in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf 
+ 
> : 
>   Fehlender Wert, wo TRUE/FALSE nötig ist
> Error in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf 
+  :
>   Missing value, where TRUE/FAlse is required
> Has this something to do with the changing to 
daten<-as.data.frame(daten) in
> line 3 (instead of as.matrix before)?
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/help-please-
> matrix-oper

Re: [R] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
all problems solved. thank you for your help!
for the sake of completeness, here my solution:
#1) read in data:
daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, sep="\t")
daten<-as.data.frame(daten)

#2) create empty matrix:
indxind<-matrix(0,nrow=617, ncol=617) 
#indxind[1:20,1:19]

#3) compare cells to each other, score:
#for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
z1<-1 #running variable for rows in daten
z2<-1 #running variable for rows in daten
l1<-1 #running variable for rows in indxind
l2<-1 #running variable for rows in indxind
for (s in 3:6) {   #walks though the matrix colum by colum, starting at
colum 3
while (z1<11) {  #for each current colum, take one row
(z1)...
while (z2<11) {  #...and compare it to
another row (z2) of the current colum
  if (z1!=z2) {
  l1
 
topf<-indxind[l1,l2]
  if
(daten[z1,s]==daten[z2,s]) topf<-topf+1   #actually, 2 rows make up 1
individual,
  if
(daten[z1,s]==daten[z2+1,s]) topf<-topf+1  #therefore i compare 2 rows
  if
(daten[z1+1,s]==daten[z2,s]) topf<-topf+1  #with another 2 rows
  if
(daten[z1+1,s]==daten[z2+1,s]) topf<-topf+1
 
indxind[l1,l2]<-topf
  }
  z2<-z2+2
  l2<-l2+1
  }
z2<-1
l2<-1
z1<-z1+2
l1<-l1+1
  }
z1<-1
l1<-1
   }

#4) check:
indxind[1:5,1:5]



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639744.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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
SORRY it should be:


Fridolin wrote
> 
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
>   for (z1 in 1:5) {  #for each current colum, take one row (z1)...
> for (z2 in 1:5) {  #...and compare it to another row (z2) of the
> current colum
> 

error is gone now SORRY!!!



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639735.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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
thank you for your help.

my input data looks like this (tab separated):

Ind.nr. Pop.nr. scm266  rms1280 scm247  rms1107
1   101 305 318 222 135
1   101 305 318 231 135
2   101 305 313 999 96
2   101 305 321 999 130
3   101 305 324 231 135
3   101 305 324 231 135
4   101 305 313 230 126
4   101 305 313 230 135
6   101 305 313 231 135
6   101 305 321 231 135

it is a dataset with genetic marker alleles for single individuals. 
the first row is the header, all following rows are individuals. 2 rows
count for 1 individual.
first colum is the individual's number, second colum is the number for the
population the individual comes from, and all following colums are different
genetic markers.

what i want to do with this data in R, is to compare one individual with
each of the other individuals, allele-wise. there are five possibilities:
the two compared individuals share 4,3,2,1,0 alleles of the currently
examined marker (=colum). for each shared allele this pair of individuals
shall get 1 scoring point. for each pair of individuals, all scoring points
shall be summarized over all markers.


my code again, modified according to your suggestions:

#1) read in data:
daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, sep="\t")
daten<-as.data.frame(daten)

#2) create empty matrix:
indxind<-matrix(0,nrow=617, ncol=617) 
indxind[1:20,1:19]

#3) compare cells to each other, score:
#for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
for (s in 3:6) {   #walks though the matrix colum by colum, starting at
colum 3
  for (z1 in 1:6) {  #for each current colum, take one row (z1)...
for (z2 in 1:6) {  #...and compare it to another row (z2) of the current
colum
  if (z1!=z2) {topf<-indxind[z1,z2]
   if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1  
#actually, 2 rows make up 1 individual,
   if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1 
#therefore i compare 2 rows
   if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1 
#with another 2 rows
   if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
   indxind[z1,z2]<-topf
   indxind[z2,z1]<-topf
  }
  #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, but
gives always 8 for indxind[1,2]
}
#indxind[1:5,1:5] #empty matrix
  }
  #indxind[1:5,1:5] #empty matrix
}

#4) check:
indxind[1:5,1:5]



@ Michael Weylandt: i've done my best with regard to the "big picture" of my
algorithm and the small reproducible example. i hope both is sufficient.
@ Petr Pikal-3: in this case, there are only numerical values, but it's a
useful hint for my other codes.
@ Petr Pikal-3 and Berend Hasselman: initializing indxind with 0's instead
of NAs helps, it fills something in indxind now. but it does the calculation
only for the first marker (colum 3), afterwards i get an error: 
Fehler in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf + 
: 
  Fehlender Wert, wo TRUE/FALSE nötig ist
Error in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf +  :
  Missing value, where TRUE/FAlse is required
Has this something to do with the changing to daten<-as.data.frame(daten) in
line 3 (instead of as.matrix before)?



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639730.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] help, please! matrix operations inside 3 nested loops

2012-08-08 Thread Berend Hasselman

Fridolin wrote
> 
> hello, this is my script:
> 
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/input_STRUCTURE_tab_excl_5_282_559.txt',
> header=TRUE, sep="\t")
> daten<-as.matrix(daten)
> 
> #2) create empty matrix:
> indxind<-matrix(nrow=617, ncol=617) 
> indxind[1:20,1:19]
> 

You should at least initialize indxind to 0 with

indxind<-matrix(0,nrow=617, ncol=617) 

because the default for matrix is to use NA for data.

Berend




--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639621.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] help, please! matrix operations inside 3 nested loops

2012-08-08 Thread R. Michael Weylandt
On Wed, Aug 8, 2012 at 9:06 AM, Fridolin  wrote:
> hello, this is my script:
>
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/input_STRUCTURE_tab_excl_5_282_559.txt',
> header=TRUE, sep="\t")
> daten<-as.matrix(daten)
>
> #2) create empty matrix:
> indxind<-matrix(nrow=617, ncol=617)
> indxind[1:20,1:19]
>
> #3) compare cells to each other, score:
> for (s in 3:34) {   #walks though the matrix colum by colum, starting at
> colum 3
>   for (z1 in 1:617) {  #for each current colum, take one row (z1)...
> for (z2 in 1:617) {  #...and compare it to another row (z2) of the
> current colum
>   if (z1!=z2) {topf<-indxind[z1,z2]
>if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1
> #actually, 2 rows make up 1 individual,
>if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1
> #therefore i compare 2 rows
>if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1
> #with another 2 rows
>if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
>indxind[z1,z2]<-topf
>indxind[z2,z1]<-topf
>   }
>   #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, but
> gives NA for indxind[1,2]
>   }
> #indxind[1:5,1:5] #empty matrix
>   }
>   #indxind[1:5,1:5] #empty matrix
>   }
>
> #4) check:
> indxind[1:5,1:5]
>
> this results no errors, but my matrix indxind remains empty (only NAs).
> though all columns and rows are counted properly. R needs quite a while to
> get through all this (there are probably smarter and faster ways to
> calculate this but i am not too deep into R and bioinformatics, and i need
> to calculate this only once). could the 3 for-loops already be too
> computationally intense for adding matrix operations?
>
> any help would be much appreciated!
>
> thx, frido
>
>

Hi Frido,

I'm afraid I get a little lost in your code, but I'd be willing to bet
we can cut the loops out entirely and speed things up.

Can you give us a "big picture" description of the algorithm you're
implementing as well as (if it's not too hard) a small reproducible
example [1]?

Note also that most of us don't use Nabble so you'll need to
explicitly quote any relevant context.

Thanks,
Michael

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

__
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, please! matrix operations inside 3 nested loops

2012-08-08 Thread Fridolin
hello, this is my script:

#1) read in data:
daten<-read.table('K:/Analysen/STRUCTURE/input_STRUCTURE_tab_excl_5_282_559.txt',
header=TRUE, sep="\t")
daten<-as.matrix(daten)

#2) create empty matrix:
indxind<-matrix(nrow=617, ncol=617) 
indxind[1:20,1:19]

#3) compare cells to each other, score:
for (s in 3:34) {   #walks though the matrix colum by colum, starting at
colum 3
  for (z1 in 1:617) {  #for each current colum, take one row (z1)...
for (z2 in 1:617) {  #...and compare it to another row (z2) of the
current colum
  if (z1!=z2) {topf<-indxind[z1,z2]
   if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1  
#actually, 2 rows make up 1 individual,
   if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1 
#therefore i compare 2 rows
   if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1 
#with another 2 rows
   if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
   indxind[z1,z2]<-topf
   indxind[z2,z1]<-topf
  }
  #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, but
gives NA for indxind[1,2]
  }
#indxind[1:5,1:5] #empty matrix
  }
  #indxind[1:5,1:5] #empty matrix
  }

#4) check:
indxind[1:5,1:5]

this results no errors, but my matrix indxind remains empty (only NAs).
though all columns and rows are counted properly. R needs quite a while to
get through all this (there are probably smarter and faster ways to
calculate this but i am not too deep into R and bioinformatics, and i need
to calculate this only once). could the 3 for-loops already be too
computationally intense for adding matrix operations?

any help would be much appreciated!

thx, frido



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592.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] Help! Please recommend good books/resources on visualizing data and understanding multivariate relations...

2012-07-05 Thread Oxenstierna
I'm a fan of Ggobi--which works well with or without R--but I'm not sure how
it handles enormous data sets. I second the Tufte recommendation, and add: 
Interactive and Dynamic Graphics for Data Analysis. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-Please-recommend-good-books-resources-on-visualizing-data-and-understanding-multivariate-relati-tp4635344p4635456.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] Help! Please recommend good books/resources on visualizing data and understanding multivariate relations...

2012-07-04 Thread John Kane
One basic and very good one is 
Cleveland, W. S. (1985). The Elements of Graphing Data. Wadsworth, Inc.

John Kane
Kingston ON Canada


> -Original Message-
> From: comtech@gmail.com
> Sent: Tue, 3 Jul 2012 18:12:00 -0500
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Help! Please recommend good books/resources on visualizing
> data and understanding multivariate relations...
> 
> Hi all,
> 
> Could you please help me?
> 
> I am looking for books/pointers/resources/tutorials on visualizing
> complex/big data and on understanding multivariate relations in
> complicated
> data.
> 
> More specifically, we have categorical variables and are interested in
> how
> to visualize the categorical data and visualize data conditioned upon
> categorical values.
> 
> Could anybody please give me some pointers?
> 
> Thanks a lot!
> 
>   [[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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

______
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] Help! Please recommend good books/resources on visualizing data and understanding multivariate relations...

2012-07-03 Thread massimo di stefano
I found this [1] book interesting. About "big data" It  really depends from
a number of things...  if can help, I know hdf5 work pretty Well with huge
dataset .

[1] http://www.ggobi.org/book/index.html
On Jul 3, 2012 7:14 PM, "Michael"  wrote:

> Hi all,
>
> Could you please help me?
>
> I am looking for books/pointers/resources/tutorials on visualizing
> complex/big data and on understanding multivariate relations in complicated
> data.
>
> More specifically, we have categorical variables and are interested in how
> to visualize the categorical data and visualize data conditioned upon
> categorical values.
>
> Could anybody please give me some pointers?
>
> Thanks a lot!
>
> [[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.
>

[[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] Help! Please recommend good books/resources on visualizing data and understanding multivariate relations...

2012-07-03 Thread Rich Shepard

On Tue, 3 Jul 2012, Michael wrote:


I am looking for books/pointers/resources/tutorials on visualizing
complex/big data and on understanding multivariate relations in
complicated data.


Michael,

  You need to become familiar with the works of Edward Tufte, the dean of
complex data visualization .

  "Edward Rolf Tufte is an American statistician and professor emeritus of
political science, statistics, and computer science at Yale University. He
is noted for his writings on information design and as a pioneer in the
field of data visualization." -- Wikipedia

  Happy reading!

Rich

--
Richard B. Shepard, Ph.D.  |   Integrity - Credibility - Innovation
Applied Ecosystem Services, Inc.   |Helping Ensure Our Clients' Futures
<http://www.appl-ecosys.com> Voice: 503-667-4517  Fax: 503-667-8863

__
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! Please recommend good books/resources on visualizing data and understanding multivariate relations...

2012-07-03 Thread Michael
Hi all,

Could you please help me?

I am looking for books/pointers/resources/tutorials on visualizing
complex/big data and on understanding multivariate relations in complicated
data.

More specifically, we have categorical variables and are interested in how
to visualize the categorical data and visualize data conditioned upon
categorical values.

Could anybody please give me some pointers?

Thanks a lot!

[[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] help please. 2 tables, which test?

2012-03-13 Thread Greg Snow
For this case I would use a permutation test.  Start by choosing some
statistic that represents your 4 students across the different grades,
some possibilities would be the sum of scores across grades and
students, or mean, or median, or ...

Compute the selected statistic for your 4 students and save that
value.  Now select 4 students at random and compute the same
statistic, repeat this a bunch of times (thousands) and compute the
statistic each time.  All those stats on the random selections
represent the distribution of the statistic under the null hypothesis
that your 4 students were randomly chosen (vs. chosen based on
something that is related to the grade).  Now you just compare the
stat on the original 4 students to the distribution (if you need a
specific p-value it is just the proportion of the random stats that
are as or more extreme as your original 4).

On Sat, Mar 10, 2012 at 4:04 AM, aoife doherty  wrote:
> Thank you for the replies.
> So what my test wants to do is this:
>
> I have a big matrix, 30 rows (students in a class) X 50 columns (students
> grades for the year).
> An example of the matrix is as such:
>
>
>                     grade1       grade2        grade3     .  grade 50
> student 1
> student 2***
> student 3
> student 4***
> student 5***
> student 6
> .
> .
> .
> .
> .
> student 30***
>
> As you can see, four students (students 2,4,5 and 30) have stars beside
> their name. I have chosen these students based on a particular
> characteristic that they all share.I then pulled these students out to make
> a new table:
>
>                     grade1          grade2         grade3 ... grade 50
>
> student 2
> student 4
> student 5
> student 30
>
>
> and what i want to see is basically is there any difference between the
> grades this particular set of students(i.e. student 2,4,5 and 30) got, and
> the class as a whole?
>
> So my null hypothesis is that there is no difference between this set of
> students grades, and what you would expect from the class as a whole.
>
> Aaral
>
>
>
>
>
>
> On Sat, Mar 10, 2012 at 12:18 AM, Greg Snow <538...@gmail.com> wrote:
>>
>> Just what null hypothesis are you trying to test or what question are
>> you trying to answer by comparing 2 matrices of different size?
>>
>> I think you need to figure out what your real question is before
>> worrying about which test might work on it.
>>
>> Trying to get your data to fit a given test rather than finding the
>> appropriate test or other procedure to answer your question is like
>> buying a new suit then having plastic surgery to make you fit the suit
>> rather than having the tailor modify the suit to fit you.
>>
>> If you can give us more information about what your question is we
>> have a better chance of actually helping you.
>>
>> On Fri, Mar 9, 2012 at 9:46 AM, aoife doherty 
>> wrote:
>> >
>> > Thank you. Can the chi-squared test compare two matrices that are not
>> > the
>> > same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5
>> > matrix?
>> >
>> >
>> >
>> > On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <538...@gmail.com> wrote:
>> >>
>> >> The chi-squared test is one option (and seems reasonable to me if it
>> >> the the proportions/patterns that you want to test).  One way to do
>> >> the test is to combine your 2 matrices into a 3 dimensional array (the
>> >> abind package may help here) and test using the loglin function.
>> >>
>> >> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh 
>> >> wrote:
>> >> > Hi.Please help if someone can.
>> >> >
>> >> > Problem:
>> >> > I have 2 matrices
>> >> >
>> >> > Eg
>> >> >
>> >> > matrix 1:
>> >> >                Freq  None  Some
>> >> >  Heavy    3        2          5
>> >> >  Never    8       13         8
>> >> >  Occas    1        4          4
>> >> >  Regul     9        5         7
>> >> >
>> >> > matrix 2:
>> >> >                  Freq     None     Some
>> >> >  Heavy        7          1             3
>> >> >  Never      87         18          84
>> >> >  Occas      12           3            4
>> >> >  Regul        9            1            7
>> >> >
>> >> >
>> >> > I want to see if matrix 1 is significantly different f

Re: [R] help please. 2 tables, which test?

2012-03-10 Thread aoife doherty
Thank you for the replies.
So what my test wants to do is this:

I have a big matrix, 30 rows (students in a class) X 50 columns (students
grades for the year).
An example of the matrix is as such:


grade1   grade2grade3 .  grade 50
student 1
student 2***
student 3
student 4***
student 5***
student 6
.
.
.
.
.
student 30***

As you can see, four students (students 2,4,5 and 30) have stars beside
their name. I have chosen these students based on a particular
characteristic that they all share.I then pulled these students out to make
a new table:

grade1  grade2 grade3 ... grade 50

student 2
student 4
student 5
student 30


and what i want to see is basically is there any difference between the
grades this particular set of students(i.e. student 2,4,5 and 30) got, and
the class as a whole?

So my null hypothesis is that there is no difference between this set of
students grades, and what you would expect from the class as a whole.

Aaral






On Sat, Mar 10, 2012 at 12:18 AM, Greg Snow <538...@gmail.com> wrote:

> Just what null hypothesis are you trying to test or what question are
> you trying to answer by comparing 2 matrices of different size?
>
> I think you need to figure out what your real question is before
> worrying about which test might work on it.
>
> Trying to get your data to fit a given test rather than finding the
> appropriate test or other procedure to answer your question is like
> buying a new suit then having plastic surgery to make you fit the suit
> rather than having the tailor modify the suit to fit you.
>
> If you can give us more information about what your question is we
> have a better chance of actually helping you.
>
> On Fri, Mar 9, 2012 at 9:46 AM, aoife doherty 
> wrote:
> >
> > Thank you. Can the chi-squared test compare two matrices that are not the
> > same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5
> matrix?
> >
> >
> >
> > On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <538...@gmail.com> wrote:
> >>
> >> The chi-squared test is one option (and seems reasonable to me if it
> >> the the proportions/patterns that you want to test).  One way to do
> >> the test is to combine your 2 matrices into a 3 dimensional array (the
> >> abind package may help here) and test using the loglin function.
> >>
> >> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh 
> wrote:
> >> > Hi.Please help if someone can.
> >> >
> >> > Problem:
> >> > I have 2 matrices
> >> >
> >> > Eg
> >> >
> >> > matrix 1:
> >> >Freq  None  Some
> >> >  Heavy32  5
> >> >  Never8   13 8
> >> >  Occas14  4
> >> >  Regul 95 7
> >> >
> >> > matrix 2:
> >> >  Freq None Some
> >> >  Heavy7  1 3
> >> >  Never  87 18  84
> >> >  Occas  12   34
> >> >  Regul917
> >> >
> >> >
> >> > I want to see if matrix 1 is significantly different from matrix 2. I
> >> > consider using a chi-squared test. Is this appropriate?
> >> > Could anyone advise?
> >> > Many thank you.
> >> > Aaral Singh
> >> >
> >> > --
> >> > View this message in context:
> >> >
> http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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.
> >>
> >>
> >>
> >> --
> >> Gregory (Greg) L. Snow Ph.D.
> >> 538...@gmail.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.
> >
> >
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.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.
>

[[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] help please. 2 tables, which test?

2012-03-09 Thread Greg Snow
Just what null hypothesis are you trying to test or what question are
you trying to answer by comparing 2 matrices of different size?

I think you need to figure out what your real question is before
worrying about which test might work on it.

Trying to get your data to fit a given test rather than finding the
appropriate test or other procedure to answer your question is like
buying a new suit then having plastic surgery to make you fit the suit
rather than having the tailor modify the suit to fit you.

If you can give us more information about what your question is we
have a better chance of actually helping you.

On Fri, Mar 9, 2012 at 9:46 AM, aoife doherty  wrote:
>
> Thank you. Can the chi-squared test compare two matrices that are not the
> same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5 matrix?
>
>
>
> On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <538...@gmail.com> wrote:
>>
>> The chi-squared test is one option (and seems reasonable to me if it
>> the the proportions/patterns that you want to test).  One way to do
>> the test is to combine your 2 matrices into a 3 dimensional array (the
>> abind package may help here) and test using the loglin function.
>>
>> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh  wrote:
>> > Hi.Please help if someone can.
>> >
>> > Problem:
>> > I have 2 matrices
>> >
>> > Eg
>> >
>> > matrix 1:
>> >                Freq  None  Some
>> >  Heavy    3        2          5
>> >  Never    8       13         8
>> >  Occas    1        4          4
>> >  Regul     9        5         7
>> >
>> > matrix 2:
>> >                  Freq     None     Some
>> >  Heavy        7          1             3
>> >  Never      87         18          84
>> >  Occas      12           3            4
>> >  Regul        9            1            7
>> >
>> >
>> > I want to see if matrix 1 is significantly different from matrix 2. I
>> > consider using a chi-squared test. Is this appropriate?
>> > Could anyone advise?
>> > Many thank you.
>> > Aaral Singh
>> >
>> > --
>> > View this message in context:
>> > http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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.
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> 538...@gmail.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.
>
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] help please. 2 tables, which test?

2012-03-09 Thread S Ellison
 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of aoife doherty
>
> Thank you. Can the chi-squared test compare two matrices that 
> are not the same size, eg if matrix 1 is a 2 X 4 table, and 
> matrix 2 is a 3 X 5 matrix?

No.

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

__
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] help please. 2 tables, which test?

2012-03-09 Thread R. Michael Weylandt
You should probably read up on what the chi-squared test actually
tests: in one form, it asks whether some set of observations could
have come from a given multinomial distribution. Concretely, it asks
whether it is "reasonable" to get 3 blues, 4 reds, and 2 whites from a
uniform distribution over read white and blue. (Real statisticians
will have all sorts of problems with that over-simplification) What
you seem to be asking is whether it is "reasonable" to get 3 blues 4
reds, 2 whites, and 6 greens from a uniform distribution over red
white and blue -- obviously something doesn't fit here. Caveat: if
matrix1 matches matrix2 but there were null observations that got
dropped, then this can be done.

https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test

The website http://stats.stackexchange.com/ can (and will) provide
more statistically oriented help.

Michael

On Fri, Mar 9, 2012 at 11:46 AM, aoife doherty  wrote:
> Thank you. Can the chi-squared test compare two matrices that are not the
> same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5 matrix?
>
>
> On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <538...@gmail.com> wrote:
>
>> The chi-squared test is one option (and seems reasonable to me if it
>> the the proportions/patterns that you want to test).  One way to do
>> the test is to combine your 2 matrices into a 3 dimensional array (the
>> abind package may help here) and test using the loglin function.
>>
>> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh  wrote:
>> > Hi.Please help if someone can.
>> >
>> > Problem:
>> > I have 2 matrices
>> >
>> > Eg
>> >
>> > matrix 1:
>> >                Freq  None  Some
>> >  Heavy    3        2          5
>> >  Never    8       13         8
>> >  Occas    1        4          4
>> >  Regul     9        5         7
>> >
>> > matrix 2:
>> >                  Freq     None     Some
>> >  Heavy        7          1             3
>> >  Never      87         18          84
>> >  Occas      12           3            4
>> >  Regul        9            1            7
>> >
>> >
>> > I want to see if matrix 1 is significantly different from matrix 2. I
>> > consider using a chi-squared test. Is this appropriate?
>> > Could anyone advise?
>> > Many thank you.
>> > Aaral Singh
>> >
>> > --
>> > View this message in context:
>> http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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.
>>
>>
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> 538...@gmail.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.
>>
>
>        [[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@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] help please. 2 tables, which test?

2012-03-09 Thread aoife doherty
Thank you. Can the chi-squared test compare two matrices that are not the
same size, eg if matrix 1 is a 2 X 4 table, and matrix 2 is a 3 X 5 matrix?


On Fri, Mar 9, 2012 at 4:37 PM, Greg Snow <538...@gmail.com> wrote:

> The chi-squared test is one option (and seems reasonable to me if it
> the the proportions/patterns that you want to test).  One way to do
> the test is to combine your 2 matrices into a 3 dimensional array (the
> abind package may help here) and test using the loglin function.
>
> On Thu, Mar 8, 2012 at 5:46 AM, aaral singh  wrote:
> > Hi.Please help if someone can.
> >
> > Problem:
> > I have 2 matrices
> >
> > Eg
> >
> > matrix 1:
> >Freq  None  Some
> >  Heavy32  5
> >  Never8   13 8
> >  Occas14  4
> >  Regul 95 7
> >
> > matrix 2:
> >  Freq None Some
> >  Heavy7  1 3
> >  Never  87 18  84
> >  Occas  12   34
> >  Regul917
> >
> >
> > I want to see if matrix 1 is significantly different from matrix 2. I
> > consider using a chi-squared test. Is this appropriate?
> > Could anyone advise?
> > Many thank you.
> > Aaral Singh
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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.
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.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.
>

[[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] help please. 2 tables, which test?

2012-03-09 Thread Greg Snow
The chi-squared test is one option (and seems reasonable to me if it
the the proportions/patterns that you want to test).  One way to do
the test is to combine your 2 matrices into a 3 dimensional array (the
abind package may help here) and test using the loglin function.

On Thu, Mar 8, 2012 at 5:46 AM, aaral singh  wrote:
> Hi.Please help if someone can.
>
> Problem:
> I have 2 matrices
>
> Eg
>
> matrix 1:
>                Freq  None  Some
>  Heavy    3        2          5
>  Never    8       13         8
>  Occas    1        4          4
>  Regul     9        5         7
>
> matrix 2:
>                  Freq     None     Some
>  Heavy        7          1             3
>  Never      87         18          84
>  Occas      12           3            4
>  Regul        9            1            7
>
>
> I want to see if matrix 1 is significantly different from matrix 2. I
> consider using a chi-squared test. Is this appropriate?
> Could anyone advise?
> Many thank you.
> Aaral Singh
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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.


[R] help please. 2 tables, which test?

2012-03-08 Thread aaral singh
Hi.Please help if someone can.

Problem:
I have 2 matrices

Eg

matrix 1:
Freq  None  Some 
  Heavy32  5 
  Never8   13 8 
  Occas14  4 
  Regul 95 7 

matrix 2:
  Freq None Some 
  Heavy7  1 3 
  Never  87 18  84 
  Occas  12   34 
  Regul917 


I want to see if matrix 1 is significantly different from matrix 2. I
consider using a chi-squared test. Is this appropriate?
Could anyone advise?
Many thank you.
Aaral Singh

--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-2-tables-which-test-tp4456312p4456312.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] Help please

2012-02-29 Thread Uwe Ligges



On 29.02.2012 17:36, Raúl Fernández Naranjo wrote:










Hi everyone, I was using rattle. I used a database with 4 individuals and 
50 variables. Reading the database was OK and that was made by rattle but when 
y was trying to draw the tree, rattle shows the image attached.



And have you followed the advice and contacted the e-mail address given 
there?


Uwe Ligges




Please help me.

Raúl Fernández



graf.png




__
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.


[R] Help please

2012-02-29 Thread Raúl Fernández Naranjo









Hi everyone, I was using rattle. I used a database with 4 individuals and 
50 variables. Reading the database was OK and that was made by rattle but when 
y was trying to draw the tree, rattle shows the image attached.

Please help me.

Raúl Fernández

  <>__
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] Help, please

2011-05-19 Thread Mike Marchywka








> From: dwinsem...@comcast.net
> To: julio.flo...@spss.com.mx
> Date: Thu, 19 May 2011 10:40:08 -0400
> CC: r-help@r-project.org
> Subject: Re: [R] Help, please
>
>
> On May 18, 2011, at 6:29 PM, Julio César Flores Castro wrote:
>
> > Hi,
> >
> > I am using R 2.10.1 and I have a doubt. Do you know how many cases
> > can R
> > handle?
>
> I was able to handle (meaning do Cox proportional hazards work with
> the 'rms' package which adds extra memory overhead with a datadist
> object) a 5.5 million rows by 100 columns dataframe without
> difficulty using 24 GB on a Mac (BSD UNIX kernel). I was running into
> performance slow downs related to paging out to virtual memory at 150
> columns, but after expanding to 32 GB can now handle 5.5 MM records
> with 200 columns without paging.
>
> >
> > I want to use the library npmc but if I have more than 4,500 cases I
> > get an
> > error message. If I use less than 4500 cases I don´t have problems
> > with this
> > library.
> >
> > Is there any way to increase the number of cases in order to use this
> > library.
>
> 64 bit OS, 64 bit R, and more memory.
>
The longer term solution is implementation and algorithm designed to
increase coherence
of memory accesses ( firefox is doing this to me now dropping every few chars 
and
 getting 
many behind as it thrashes with memory leak, LOL).




      
__
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] Help, please

2011-05-19 Thread David Winsemius


On May 18, 2011, at 6:29 PM, Julio César Flores Castro wrote:


Hi,

I am using R 2.10.1 and I have a doubt. Do you know how many cases  
can R

handle?


I was able to handle (meaning do Cox proportional hazards work with  
the 'rms' package which adds extra memory overhead with a datadist  
object)  a 5.5 million rows by 100 columns dataframe without  
difficulty using 24 GB on a Mac (BSD UNIX kernel). I was running into  
performance slow downs related to paging out to virtual memory at 150  
columns, but after expanding to 32 GB can now handle 5.5 MM records  
with 200 columns without paging.




I want to use the library npmc but if I have more than 4,500 cases I  
get an
error message. If I use less than 4500 cases I don´t have problems  
with this

library.

Is there any way to increase the number of cases in order to use this
library.


64 bit OS, 64 bit R,  and more memory.

--
David Winsemius, MD
West Hartford, CT

__
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] Help, please

2011-05-18 Thread Prof Brian Ripley

On Wed, 18 May 2011, Julio César Flores Castro wrote:


Hi,



I am using R 2.10.1 and I have a doubt. Do you know how many cases can R
handle?


At least millions.


I want to use the library npmc but if I have more than 4,500 cases I get an
error message. If I use less than 4500 cases I don?t have problems with this
library.


So you are not asking about R but about a contributed package. 
Clearly you have not read the posting guide (you sent HTML), so please 
do so and follow its advice.  That amounts to preparing a documented 
and reproducible example and sending it to the package maintainer in a 
properly signed email which makes clear your affiliation (which 
appears to be a company).



Is there any way to increase the number of cases in order to use this
library.



Thanks in advance



Julio Flores


[[alternative HTML version deleted]]




--
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.


Re: [R] Help, please

2011-05-18 Thread Steve Lianoglou
Hi,

On Wed, May 18, 2011 at 6:29 PM, Julio César Flores Castro
 wrote:
> Hi,
>
> I am using R 2.10.1 and I have a doubt.

As a general rule of thumb, it's usually best to be using the latest
version of R (which is no R 2.13.0) -- 2.10.1 came out in December,
2009, so ... try to upgrade if you can.

> Do you know how many cases can R
> handle?

What do you mean "cases"?

I reckon the answer to this question is related to the amount of RAM
you have, and whether or not you are running R in 32 vs. 64 mode.

> I want to use the library npmc but if I have more than 4,500 cases I get an
> error message.

To get better help, you should paste in the code you used that
produced the error, as well as the error message itself.

> Is there any way to increase the number of cases in order to use this
> library.

You haven't provided enough information to help just yet -- the error
message you get will be *particularly* helpful, but please provide the
code you used as well.

If I had to guess, though, I'm going to go with my original "RAM +
64bit thing" as being one way to increase the number of "cases" you
can use.

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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, please

2011-05-18 Thread Julio César Flores Castro
Hi,

 

I am using R 2.10.1 and I have a doubt. Do you know how many cases can R
handle?

I want to use the library npmc but if I have more than 4,500 cases I get an
error message. If I use less than 4500 cases I don´t have problems with this
library.

Is there any way to increase the number of cases in order to use this
library.

 

Thanks in advance

 

Julio Flores


[[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] help please: put output into dataframe

2011-03-18 Thread Ram H. Sharma
how(madx <- mad(getdata[,i], na.rm = TRUE))
> >>>  MD1 <- c(medianx + 2*madx)
> >>>  MD2 <- c(medianx - 2*madx)
> >>>  out1[i] <- which(getdata[,i] > MD1) # store data that are
> >>> greater than median + 2 mad
> >>>  out2[i] <- which (getdata[,1] < MD2) # store data that are
> >>> greater than median - 2 mad
> >>> resultdf <- data.frame(out1, out2)
> >>>     write.table (resultdf, "out.csv", sep=",")
> >>>  }
> >>>
> >>>
> >>> My idea here is to store those value which are either greater than
> median
> >>> +
> >>> 2 *MAD or less than median - 2*MAD. Each variable have different length
> of
> >>> output.
> >>>
> >>> The following last error message:
> >>> Error in data.frame(out1, out2) :
> >>>  arguments imply differing number of rows: 2, 0
> >>> In addition: Warning messages:
> >>> 1: In out1[i] <- which(getdata[, i] > MD1) :
> >>>  number of items to replace is not a multiple of replacement length
> >>> 2: In out2[i] <- which(getdata[, 1] < MD2) :
> >>>  number of items to replace is not a multiple of replacement length
> >>> 3: In out1[i] <- which(getdata[, i] > MD1) :
> >>>  number of items to replace is not a multiple of replacement length
> >>>
> >>> Thank you in advance for helping me.
> >>>
> >>> Best regards;
> >>> RHS
> >>>
> >>>[[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<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
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>

[[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] help please: put output into dataframe

2011-03-18 Thread jim holtman
t;
>> >>
>> >> On Thu, Mar 17, 2011 at 7:04 PM, Ram H. Sharma
>> >> wrote:
>> >>
>> >>> Dear R community members
>> >>>
>> >>> I have been struggling on this simple question, but never get
>> >>> appropriate
>> >>> solution. So please help.
>> >>>
>> >>>  # my data, though I have a large number of variables
>> >>> var1 <- rnorm(500, 10,4)
>> >>> var2 <- rnorm(500, 20, 8)
>> >>> var3 <- rnorm(500, 30, 18)
>> >>> var4 <- rnorm(500, 40, 20)
>> >>> datafr1 <- data.frame(var1, var2, var3, var4)
>> >>>
>> >>> # my unsuccessful codes
>> >>>  nvar <- ncol(datafr1)
>> >>> for (i in 1:nvar) {
>> >>>              out1 <- NULL
>> >>>              out2 <- NULL
>> >>>              medianx <- median(getdata[,i], na.rm = TRUE)
>> >>>              show(madx <- mad(getdata[,i], na.rm = TRUE))
>> >>>              MD1 <- c(medianx + 2*madx)
>> >>>              MD2 <- c(medianx - 2*madx)
>> >>>              out1[i] <- which(getdata[,i] > MD1) # store data that are
>> >>> greater than median + 2 mad
>> >>>              out2[i] <- which (getdata[,1] < MD2) # store data that
>> >>> are
>> >>> greater than median - 2 mad
>> >>>             resultdf <- data.frame(out1, out2)
>> >>>             write.table (resultdf, "out.csv", sep=",")
>> >>>              }
>> >>>
>> >>>
>> >>> My idea here is to store those value which are either greater than
>> >>> median
>> >>> +
>> >>> 2 *MAD or less than median - 2*MAD. Each variable have different
>> >>> length of
>> >>> output.
>> >>>
>> >>> The following last error message:
>> >>> Error in data.frame(out1, out2) :
>> >>>  arguments imply differing number of rows: 2, 0
>> >>> In addition: Warning messages:
>> >>> 1: In out1[i] <- which(getdata[, i] > MD1) :
>> >>>  number of items to replace is not a multiple of replacement length
>> >>> 2: In out2[i] <- which(getdata[, 1] < MD2) :
>> >>>  number of items to replace is not a multiple of replacement length
>> >>> 3: In out1[i] <- which(getdata[, i] > MD1) :
>> >>>  number of items to replace is not a multiple of replacement length
>> >>>
>> >>> Thank you in advance for helping me.
>> >>>
>> >>> Best regards;
>> >>> RHS
>> >>>
>> >>>        [[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.
>> >>>
>> >>
>> >>
>> >
>> >        [[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.
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Data Munger Guru
>>
>> What is the problem that you are trying to solve?
>
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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] help please: put output into dataframe

2011-03-18 Thread David Winsemius
er of rows: 2, 0
In addition: Warning messages:
1: In out1[i] <- which(getdata[, i] > MD1) :
number of items to replace is not a multiple of replacement length
2: In out2[i] <- which(getdata[, 1] < MD2) :
number of items to replace is not a multiple of replacement length
3: In out1[i] <- which(getdata[, i] > MD1) :
number of items to replace is not a multiple of replacement length

Thank you in advance for helping me.

Best regards;
RHS

  [[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<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
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html 
>

and provide commented, minimal, self-contained, reproducible code.





--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



    [[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.


David Winsemius, MD
West Hartford, CT

__
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] help please: put output into dataframe

2011-03-18 Thread Ram H. Sharma
ful codes
> >>>  nvar <- ncol(datafr1)
> >>> for (i in 1:nvar) {
> >>>  out1 <- NULL
> >>>  out2 <- NULL
> >>>  medianx <- median(getdata[,i], na.rm = TRUE)
> >>>  show(madx <- mad(getdata[,i], na.rm = TRUE))
> >>>  MD1 <- c(medianx + 2*madx)
> >>>  MD2 <- c(medianx - 2*madx)
> >>>  out1[i] <- which(getdata[,i] > MD1) # store data that are
> >>> greater than median + 2 mad
> >>>  out2[i] <- which (getdata[,1] < MD2) # store data that are
> >>> greater than median - 2 mad
> >>> resultdf <- data.frame(out1, out2)
> >>> write.table (resultdf, "out.csv", sep=",")
> >>>  }
> >>>
> >>>
> >>> My idea here is to store those value which are either greater than
> median
> >>> +
> >>> 2 *MAD or less than median - 2*MAD. Each variable have different length
> of
> >>> output.
> >>>
> >>> The following last error message:
> >>> Error in data.frame(out1, out2) :
> >>>  arguments imply differing number of rows: 2, 0
> >>> In addition: Warning messages:
> >>> 1: In out1[i] <- which(getdata[, i] > MD1) :
> >>>  number of items to replace is not a multiple of replacement length
> >>> 2: In out2[i] <- which(getdata[, 1] < MD2) :
> >>>  number of items to replace is not a multiple of replacement length
> >>> 3: In out1[i] <- which(getdata[, i] > MD1) :
> >>>  number of items to replace is not a multiple of replacement length
> >>>
> >>> Thank you in advance for helping me.
> >>>
> >>> Best regards;
> >>> RHS
> >>>
> >>>[[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<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
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>

[[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] help please: put output into dataframe

2011-03-18 Thread jim holtman
store those value which are either greater than median
>>> +
>>> 2 *MAD or less than median - 2*MAD. Each variable have different length of
>>> output.
>>>
>>> The following last error message:
>>> Error in data.frame(out1, out2) :
>>>  arguments imply differing number of rows: 2, 0
>>> In addition: Warning messages:
>>> 1: In out1[i] <- which(getdata[, i] > MD1) :
>>>  number of items to replace is not a multiple of replacement length
>>> 2: In out2[i] <- which(getdata[, 1] < MD2) :
>>>  number of items to replace is not a multiple of replacement length
>>> 3: In out1[i] <- which(getdata[, i] > MD1) :
>>>  number of items to replace is not a multiple of replacement length
>>>
>>> Thank you in advance for helping me.
>>>
>>> Best regards;
>>> RHS
>>>
>>>        [[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.
>>>
>>
>>
>
>        [[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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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] help please: put output into dataframe

2011-03-18 Thread Ram H. Sharma
Hi Dennis and R-users

Thank you for more help. I am pretty close, but challenge still remain is
forcing the output with different length to output dataframe.

> x <- data.frame(apply(datafr1, 2, fout))
Error in data.frame(var1 = c(-0.70777998321315, 0.418602152926712,
2.08356737154810,  :
  arguments imply differing number of rows: 28, 12, 20, 19

As I need to work with >2000 variables, my intension here is to save this
output to such way that it would be further manipulated. Topline is to save
in dataframe that have extreme values for the variable concerned and
bottomline is automate to save the output printed in the screen to a
textfile.

Thank you for help once again.

Ram


On Fri, Mar 18, 2011 at 3:16 AM, Dennis Murphy  wrote:

> Hi:
>
> Is this what you're after?
>
> fout <- function(x) {
>  lim <- median(x) + c(-2, 2) * mad(x)
>  x[x < lim[1] | x > lim[2]]
>}
> > apply(datafr1, 2, fout)
> $var1
>  [1] 17.5462078 18.4548214  0.7083442  1.9207578 -1.2296787 17.4948240
>  [7] 19.5702558  1.6181150 20.9791652 -1.3542099  1.8215087 -1.0296303
> [13] 20.5237930 17.5366497 18.5657566  0.9335419 19.7519983 17.8607968
> [19] 19.1307524 19.6145711 21.8037136 19.1532175 -2.6688409 19.6949309
> [25]  1.9712347
>
> $var2
>  [1]  37.3822087  35.6490641  35.6000785  38.5981086  -1.6504275
> 37.1419290
>  [7]  37.7605230  40.3508689   0.6639900   2.4695841  38.8209491
> 39.9087921
> [13]  38.9907585  35.8279437   2.7870799  37.0941113   0.6308583
> 36.4556638
> [19] -10.2384849   2.8480199  -7.7680457  35.7076539  -0.5467739
> 3.4702765
> [25]  40.4818580   3.2864273   1.4917174
>
> $var3
>  [1]  74.252563  68.396391  68.845461  -5.006545  66.083402  76.036577
>  [7]  75.112586  -6.374241  63.883549  64.041216 -19.764360 -15.051017
> [13]  -9.782767  64.696013  70.970648  -4.562031 -22.135003  70.549310
> [19]  69.495915  -4.095587  86.612375  87.029526  70.072126  -6.421695
> [25]  65.737536
>
> $var4
>  [1]  81.476483  87.098767 -10.451616  91.927329  86.588952  85.080950
>  [7]  84.958645  -9.456368  86.270876 -22.936779  83.314032
>
> Double checks:
> > apply(datafr1, 2, function(x) median(x) + c(-2, 2) * mad(x))
>  var1  var2  var3  var4
> [1,]  2.12167  3.779415 -3.736066 -3.471752
> [2,] 17.37176 34.929800 62.969733 80.224799
> > apply(datafr1, 2, range)
>   var1  var2  var3  var4
> [1,] -2.668841 -10.23848 -22.13500 -22.93678
> [2,] 21.803714  40.48186  87.02953  91.92733
>
> Assuming you wanted to do this columnwise (by variable), it appears to be
> doing the right thing.
>
> HTH,
> Dennis
>
>
> On Thu, Mar 17, 2011 at 7:04 PM, Ram H. Sharma wrote:
>
>> Dear R community members
>>
>> I have been struggling on this simple question, but never get appropriate
>> solution. So please help.
>>
>>  # my data, though I have a large number of variables
>> var1 <- rnorm(500, 10,4)
>> var2 <- rnorm(500, 20, 8)
>> var3 <- rnorm(500, 30, 18)
>> var4 <- rnorm(500, 40, 20)
>> datafr1 <- data.frame(var1, var2, var3, var4)
>>
>> # my unsuccessful codes
>>  nvar <- ncol(datafr1)
>> for (i in 1:nvar) {
>>  out1 <- NULL
>>  out2 <- NULL
>>  medianx <- median(getdata[,i], na.rm = TRUE)
>>  show(madx <- mad(getdata[,i], na.rm = TRUE))
>>  MD1 <- c(medianx + 2*madx)
>>  MD2 <- c(medianx - 2*madx)
>>  out1[i] <- which(getdata[,i] > MD1) # store data that are
>> greater than median + 2 mad
>>  out2[i] <- which (getdata[,1] < MD2) # store data that are
>> greater than median - 2 mad
>> resultdf <- data.frame(out1, out2)
>> write.table (resultdf, "out.csv", sep=",")
>>  }
>>
>>
>> My idea here is to store those value which are either greater than median
>> +
>> 2 *MAD or less than median - 2*MAD. Each variable have different length of
>> output.
>>
>> The following last error message:
>> Error in data.frame(out1, out2) :
>>  arguments imply differing number of rows: 2, 0
>> In addition: Warning messages:
>> 1: In out1[i] <- which(getdata[, i] > MD1) :
>>  number of items to replace is not a multiple of replacement length
>> 2: In out2[i] <- which(getdata[, 1] < MD2) :
>>  number of items to replace is not a multiple of replacement length
>> 3: In out1[i] <- which(getdata[, i] > MD1) :
>>  number of items to replace is not a multiple of replacement length
>>
>> Thank you in advance f

Re: [R] help please: put output into dataframe

2011-03-18 Thread Dennis Murphy
Hi:

Is this what you're after?

fout <- function(x) {
 lim <- median(x) + c(-2, 2) * mad(x)
 x[x < lim[1] | x > lim[2]]
   }
> apply(datafr1, 2, fout)
$var1
 [1] 17.5462078 18.4548214  0.7083442  1.9207578 -1.2296787 17.4948240
 [7] 19.5702558  1.6181150 20.9791652 -1.3542099  1.8215087 -1.0296303
[13] 20.5237930 17.5366497 18.5657566  0.9335419 19.7519983 17.8607968
[19] 19.1307524 19.6145711 21.8037136 19.1532175 -2.6688409 19.6949309
[25]  1.9712347

$var2
 [1]  37.3822087  35.6490641  35.6000785  38.5981086  -1.6504275  37.1419290
 [7]  37.7605230  40.3508689   0.6639900   2.4695841  38.8209491  39.9087921
[13]  38.9907585  35.8279437   2.7870799  37.0941113   0.6308583  36.4556638
[19] -10.2384849   2.8480199  -7.7680457  35.7076539  -0.5467739   3.4702765
[25]  40.4818580   3.2864273   1.4917174

$var3
 [1]  74.252563  68.396391  68.845461  -5.006545  66.083402  76.036577
 [7]  75.112586  -6.374241  63.883549  64.041216 -19.764360 -15.051017
[13]  -9.782767  64.696013  70.970648  -4.562031 -22.135003  70.549310
[19]  69.495915  -4.095587  86.612375  87.029526  70.072126  -6.421695
[25]  65.737536

$var4
 [1]  81.476483  87.098767 -10.451616  91.927329  86.588952  85.080950
 [7]  84.958645  -9.456368  86.270876 -22.936779  83.314032

Double checks:
> apply(datafr1, 2, function(x) median(x) + c(-2, 2) * mad(x))
 var1  var2  var3  var4
[1,]  2.12167  3.779415 -3.736066 -3.471752
[2,] 17.37176 34.929800 62.969733 80.224799
> apply(datafr1, 2, range)
  var1  var2  var3  var4
[1,] -2.668841 -10.23848 -22.13500 -22.93678
[2,] 21.803714  40.48186  87.02953  91.92733

Assuming you wanted to do this columnwise (by variable), it appears to be
doing the right thing.

HTH,
Dennis


On Thu, Mar 17, 2011 at 7:04 PM, Ram H. Sharma wrote:

> Dear R community members
>
> I have been struggling on this simple question, but never get appropriate
> solution. So please help.
>
>  # my data, though I have a large number of variables
> var1 <- rnorm(500, 10,4)
> var2 <- rnorm(500, 20, 8)
> var3 <- rnorm(500, 30, 18)
> var4 <- rnorm(500, 40, 20)
> datafr1 <- data.frame(var1, var2, var3, var4)
>
> # my unsuccessful codes
>  nvar <- ncol(datafr1)
> for (i in 1:nvar) {
>  out1 <- NULL
>  out2 <- NULL
>  medianx <- median(getdata[,i], na.rm = TRUE)
>  show(madx <- mad(getdata[,i], na.rm = TRUE))
>  MD1 <- c(medianx + 2*madx)
>  MD2 <- c(medianx - 2*madx)
>  out1[i] <- which(getdata[,i] > MD1) # store data that are
> greater than median + 2 mad
>  out2[i] <- which (getdata[,1] < MD2) # store data that are
> greater than median - 2 mad
> resultdf <- data.frame(out1, out2)
> write.table (resultdf, "out.csv", sep=",")
>  }
>
>
> My idea here is to store those value which are either greater than median +
> 2 *MAD or less than median - 2*MAD. Each variable have different length of
> output.
>
> The following last error message:
> Error in data.frame(out1, out2) :
>  arguments imply differing number of rows: 2, 0
> In addition: Warning messages:
> 1: In out1[i] <- which(getdata[, i] > MD1) :
>  number of items to replace is not a multiple of replacement length
> 2: In out2[i] <- which(getdata[, 1] < MD2) :
>  number of items to replace is not a multiple of replacement length
> 3: In out1[i] <- which(getdata[, i] > MD1) :
>  number of items to replace is not a multiple of replacement length
>
> Thank you in advance for helping me.
>
> Best regards;
> RHS
>
>[[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.
>

[[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 please: put output into dataframe

2011-03-17 Thread Ram H. Sharma
Dear R community members

I have been struggling on this simple question, but never get appropriate
solution. So please help.

 # my data, though I have a large number of variables
var1 <- rnorm(500, 10,4)
var2 <- rnorm(500, 20, 8)
var3 <- rnorm(500, 30, 18)
var4 <- rnorm(500, 40, 20)
datafr1 <- data.frame(var1, var2, var3, var4)

# my unsuccessful codes
 nvar <- ncol(datafr1)
for (i in 1:nvar) {
  out1 <- NULL
  out2 <- NULL
  medianx <- median(getdata[,i], na.rm = TRUE)
  show(madx <- mad(getdata[,i], na.rm = TRUE))
  MD1 <- c(medianx + 2*madx)
  MD2 <- c(medianx - 2*madx)
  out1[i] <- which(getdata[,i] > MD1) # store data that are
greater than median + 2 mad
  out2[i] <- which (getdata[,1] < MD2) # store data that are
greater than median - 2 mad
 resultdf <- data.frame(out1, out2)
 write.table (resultdf, "out.csv", sep=",")
  }


My idea here is to store those value which are either greater than median +
2 *MAD or less than median - 2*MAD. Each variable have different length of
output.

The following last error message:
Error in data.frame(out1, out2) :
  arguments imply differing number of rows: 2, 0
In addition: Warning messages:
1: In out1[i] <- which(getdata[, i] > MD1) :
  number of items to replace is not a multiple of replacement length
2: In out2[i] <- which(getdata[, 1] < MD2) :
  number of items to replace is not a multiple of replacement length
3: In out1[i] <- which(getdata[, i] > MD1) :
  number of items to replace is not a multiple of replacement length

Thank you in advance for helping me.

Best regards;
RHS

[[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] help please ..simple question regarding output the p-value inside a function and lm

2011-02-27 Thread Dennis Murphy
Hi:

There has to be a better way to do this, but one option is to use pmin() and
pmax().

# Function to apply to pairs of columns:
ordPair <- function(x, y) data.frame(pmin(x, y), pmax(x,y))
u <- with(odataframe, cbind(ordPair(X1, X2), ordPair(X3, X4), ordPair(X5,
X6))
u
  pmin.x..y. pmax.x..y. pmin.x..y. pmax.x..y. pmin.x..y. pmax.x..y.
1  1  2  1  4  1  3
2  1  3  1  3  1  2
3  3  4  1  2  1  2
4  1  2  1  2  1  2
5  2  2  1  3  2  3

The first column is the row names - don't let it confuse you :) Clearly, you
need to rename the columns.

If you need to apply this to a large number of column pairs, I would suggest
doing something like the following:

# Partition columns into odds and evens:
cols1 <- names(odataframe)[(1:ncol(odataframe)) %% 2 == 1]
> cols1
[1] "X1" "X3" "X5"
cols2 <- names(odataframe)[(1:ncol(odataframe)) %% 2 == 0]
> cols2
[1] "X2" "X4" "X6"
# Multiply apply the ordPair() function to successive pairs of columns:
> as.data.frame(do.call(cbind, mapply(ordPair, odataframe[cols1],
odataframe[cols2])))
  V1 V2 V3 V4 V5 V6
1  1  2  1  4  1  3
2  1  3  1  3  1  2
3  3  4  1  2  1  2
4  1  2  1  2  1  2
5  2  2  1  3  2  3

HTH,
Dennis


On Sat, Feb 26, 2011 at 9:07 AM, Umesh Rosyara  wrote:

> Hi Jorge and R users
>
> Thank you so much for the responses. You input helped me alot and
> potentially can help me to solve one more problem, but I got error message.
> I am sorry to ask you again but if you can find my problem in quick look
> that will be great. I hope this will not cost alot of your time as this is
> based on your idea.
>
> # Just data
> X1 <- c(1,3,4,2,2)
> X2 <- c(2,1,3,1,2)
> X3 <- c(4,3,2,1,1)
> X4<- c(1,1,1,2,3)
> X5 <- c(3,2,1,1,2)
> X6 <- c(1,1,2,2,3)
> odataframe <- data.frame(X1,X2,X3,X4,X5,X6)
>
> My objective here is sort the value of the pair of variables (X1 and X2, X3
> and X4, X5 and X6 and so on.)  in such way that the second column
> in
> pair is always higher than the first one (X2 > X1, X4 > X3, X6> X5 and so
> on...).
>
> Here is my attempt:
> nmrk <- 3
> nvar <- 2*nmrk
> lapply(1:nvar, function(ind){
> # indices for the variables we need
>  a <- seq(1, nvar, by = 2)
>  b <- seq(2, nvar, by = 2)
> # shorting column
> tx[, a[ind]] = ifelse(odataframe[, a[ind]] < odataframe[,b[ind]],
> odataframe[, a[ind]], odataframe[, b[ind]])
> tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
> odataframe[,b[ind]], odataframe[,a[ind]])
> df1 <- transform( odataframe, odataframe[, a[ind]]= tx[, a[ind]],
> odataframe[, b[ind]]= tx[, b[ind]]))
> }
>
> I got the following error:
> Error:
> Error: unexpected '=' in:
> "tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
> odataframe[,b[ind]], odataframe[,a[ind]])
> df1 <- transform( odataframe, odataframe[, a[ind]]="
>
> Thanks;
> Umesh R
>
>
>[[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.
>

[[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] help please ..simple question regarding output the p-value inside a function and lm

2011-02-26 Thread Umesh Rosyara
Hi Jorge and R users 
 
Thank you so much for the responses. You input helped me alot and
potentially can help me to solve one more problem, but I got error message.
I am sorry to ask you again but if you can find my problem in quick look
that will be great. I hope this will not cost alot of your time as this is
based on your idea. 
 
# Just data 
X1 <- c(1,3,4,2,2)
X2 <- c(2,1,3,1,2)
X3 <- c(4,3,2,1,1)
X4<- c(1,1,1,2,3)
X5 <- c(3,2,1,1,2)
X6 <- c(1,1,2,2,3)
odataframe <- data.frame(X1,X2,X3,X4,X5,X6)
 
My objective here is sort the value of the pair of variables (X1 and X2, X3
and X4, X5 and X6 and so on.)  in such way that the second column in
pair is always higher than the first one (X2 > X1, X4 > X3, X6> X5 and so
on...). 
 
Here is my attempt: 
nmrk <- 3
nvar <- 2*nmrk 
lapply(1:nvar, function(ind){
# indices for the variables we need
 a <- seq(1, nvar, by = 2)
 b <- seq(2, nvar, by = 2)
# shorting column
tx[, a[ind]] = ifelse(odataframe[, a[ind]] < odataframe[,b[ind]],
odataframe[, a[ind]], odataframe[, b[ind]])
tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
odataframe[,b[ind]], odataframe[,a[ind]])
df1 <- transform( odataframe, odataframe[, a[ind]]= tx[, a[ind]],
odataframe[, b[ind]]= tx[, b[ind]]))
}
 
I got the following error: 
Error:
Error: unexpected '=' in:
"tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
odataframe[,b[ind]], odataframe[,a[ind]])
df1 <- transform( odataframe, odataframe[, a[ind]]="
 
Thanks;
Umesh R 


[[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 please ..simple question regarding output the p-value inside a function and lm

2011-02-25 Thread Umesh Rosyara
Dear R community members and R experts 

 

I am stuck at a point and I tried with my colleagues and did not get it out.
Sorry, I need your help. 

 

Here my data (just created to show the example):

 

# generating a dataset just to show how my dataset look like, here I have x
variables

# x1 .to X1000 plus ind and y 

ind <- c(1:100)

y <- rnorm(100, 10,2)

set.seed(201)

P <- vector()

dataf1 <- as.data.frame(matrix(rep(NA, 10), nrow=100))

dataf <- data.frame (dataf1, ind,y)

names(dataf) <- (c(paste("x",1:1000, sep=""),"ind", "y"))

for(i in 1:1000) {

dataf[,i] <- rnorm(100)

}

 

# my intension was to fit a model that would fit the following fashion:

y ~ x1 +x2, y ~ x3+x4, y ~ x5+ x6y ~ x999+x1000 (to end of the
dataframe)

 

# please not that I want to avoid to fit  y ~ x2 + x3 or  y ~ x4 + x5 (means
that I am selecting two x variables at time to end)

# question: how can I do this and put inside a user function as I worked out
the following??? 

 

 

# defining function for lm model 

mylm <- function (mydata,nvar) {

y <- NULL

P1 <- vector (mode="numeric", length = nvar)

P2 <- vector (mode="numeric", length = nvar)

for(i in 1: nvar) {

print(P1[i] <- summary(lm(mydata$y ~   mydata[,i]) +
mydata[,i+1]$coefficients[2,4]))

print(P2[i] <- summary(lm(mydata$y ~   mydata[,i]) +
mydata[,i+1]$coefficients[2,5]))

print(plot(nvar, P1))

print(plot(nvar, P2))

}

} 

 

# applying the function to mydata 

mylm (dataf, 1000)

 

Does not work?? The following is the error message: 

Error in model.frame.default(formula = mydata$y ~ mydata[, i],
drop.unused.levels = TRUE) : 

  invalid type (NULL) for variable 'mydata$y'

 

Please help !

 

Thanks;

 

Umesh R


[[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] Help Please!!!!!!!!!

2010-11-30 Thread Adaikalavan Ramasamy

Dear Melissa,

If Jim's solution doesn't work then for some reason your function is 
converting numerical values into either character or factor and I would 
suggest you use the colClasses argument to force the right class.


For example,

 mat <- read.table( file="lala.txt", sep="\t", row.names=1, header=T,
colClasses=rep("numeric", 4) )

Then do a str(mat) and see what you get.

Regards, Adai



On 29/11/2010 13:02, jim holtman wrote:

Your data seems to read in just fine, so what is the problem you are
trying to solve?


x<- read.table('clipboard', sep='\t', header=TRUE)
str(x)

'data.frame':   5 obs. of  5 variables:
  $ X : Factor w/ 5 levels "JE","JM","S",..: 5 2 4 1 3
  $ None  : int  4 4 25 18 10
  $ Light : int  2 3 10 24 6
  $ Medium: int  3 7 12 33 7
  $ Heavy : int  2 4 4 13 2

summary(x)

   X  None  LightMedium Heavy
  JE:1   Min.   : 4.0   Min.   : 2   Min.   : 3.0   Min.   : 2
  JM:1   1st Qu.: 4.0   1st Qu.: 3   1st Qu.: 7.0   1st Qu.: 2
  S :1   Median :10.0   Median : 6   Median : 7.0   Median : 4
  SE:1   Mean   :12.2   Mean   : 9   Mean   :12.4   Mean   : 5
  SM:1   3rd Qu.:18.0   3rd Qu.:10   3rd Qu.:12.0   3rd Qu.: 4
 Max.   :25.0   Max.   :24   Max.   :33.0   Max.   :13


On Mon, Nov 29, 2010 at 12:29 AM, Melissa Waldman
  wrote:

Hi,

I have been working with Program R for my stats class and I keep coming upon
the same error, I have read so many sites about inputting data from a text
file into R and I'm using the data to do a correspondence analysis.  I feel
like I have read everything and it is still not explaining why the error
message keeps coming up, I have used the exact examples I have seen in
articles and the same error keeps popping up: Error in sum(N) : invalid
'type' (character) of argument

I have spent so long trying to figure this out without success,
I am sure it has to do with the fact that my rows have names in them.  I
have attached the text file I have been using and if you have any ideas as
to how I can get R to plot the data using correspondence analysis with the
column and row names that would be really helpful!  Or if you could pass
this email to someone who may know how to help me, that would be much
appreciated.

Thank you,
Melissa Waldman

my email: melissawald...@gmail.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.








______
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] Help Please!!!!!!!!!

2010-11-29 Thread jim holtman
Your data seems to read in just fine, so what is the problem you are
trying to solve?

> x <- read.table('clipboard', sep='\t', header=TRUE)
> str(x)
'data.frame':   5 obs. of  5 variables:
 $ X : Factor w/ 5 levels "JE","JM","S",..: 5 2 4 1 3
 $ None  : int  4 4 25 18 10
 $ Light : int  2 3 10 24 6
 $ Medium: int  3 7 12 33 7
 $ Heavy : int  2 4 4 13 2
> summary(x)
  X  None  LightMedium Heavy
 JE:1   Min.   : 4.0   Min.   : 2   Min.   : 3.0   Min.   : 2
 JM:1   1st Qu.: 4.0   1st Qu.: 3   1st Qu.: 7.0   1st Qu.: 2
 S :1   Median :10.0   Median : 6   Median : 7.0   Median : 4
 SE:1   Mean   :12.2   Mean   : 9   Mean   :12.4   Mean   : 5
 SM:1   3rd Qu.:18.0   3rd Qu.:10   3rd Qu.:12.0   3rd Qu.: 4
Max.   :25.0   Max.   :24   Max.   :33.0   Max.   :13


On Mon, Nov 29, 2010 at 12:29 AM, Melissa Waldman
 wrote:
> Hi,
>
> I have been working with Program R for my stats class and I keep coming upon
> the same error, I have read so many sites about inputting data from a text
> file into R and I'm using the data to do a correspondence analysis.  I feel
> like I have read everything and it is still not explaining why the error
> message keeps coming up, I have used the exact examples I have seen in
> articles and the same error keeps popping up: Error in sum(N) : invalid
> 'type' (character) of argument
>
> I have spent so long trying to figure this out without success,
> I am sure it has to do with the fact that my rows have names in them.  I
> have attached the text file I have been using and if you have any ideas as
> to how I can get R to plot the data using correspondence analysis with the
> column and row names that would be really helpful!  Or if you could pass
> this email to someone who may know how to help me, that would be much
> appreciated.
>
> Thank you,
> Melissa Waldman
>
> my email: melissawald...@gmail.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.
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] Help Please!!!!!!!!!

2010-11-29 Thread Paul

On 29/11/10 05:29, Melissa Waldman wrote:

Hi,

I have been working with Program R for my stats class and I keep coming upon
the same error, I have read so many sites about inputting data from a text
file into R and I'm using the data to do a correspondence analysis.  I feel
like I have read everything and it is still not explaining why the error
message keeps coming up, I have used the exact examples I have seen in
articles and the same error keeps popping up: Error in sum(N) : invalid
'type' (character) of argument

I have spent so long trying to figure this out without success,
I am sure it has to do with the fact that my rows have names in them.  I
have attached the text file I have been using and if you have any ideas as
to how I can get R to plot the data using correspondence analysis with the
column and row names that would be really helpful!  Or if you could pass
this email to someone who may know how to help me, that would be much
appreciated.

Thank you,
Melissa Waldman

   

Hi Melissa,

Welcome to the world of R.  You didn't tell us which commands you were 
running that gave an error, but the error 'invalid 'type'' suggests to 
me you were trying to sum a variable that R thought was a character, and 
not a number.


I would recomend you (re) read the introduction to R 
(http://cran.r-project.org/doc/manuals/R-intro.pdf), especially chapter 
2, which deals with this.


As a quick example, if you've read your file into a dataframe called 
foo, with columns none, light etc then doing


class(foo$none)

will tell you what R thinks this field is.  If it is character then you 
can do


foo$none <- as.numeric(foo$none)

to tell R to treat it as numbers.

Regards,

Paul.

__
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] Help Please!!!!!!!!!

2010-11-29 Thread Edwin Groot
On Sun, 28 Nov 2010 21:29:08 -0800
 Melissa Waldman  wrote:
> Hi,
> 
> I have been working with Program R for my stats class and I keep
> coming upon
> the same error, I have read so many sites about inputting data from a
> text
> file into R and I'm using the data to do a correspondence analysis.
>  I feel
> like I have read everything and it is still not explaining why the
> error
> message keeps coming up, I have used the exact examples I have seen
> in
> articles and the same error keeps popping up: Error in sum(N) :
> invalid
> 'type' (character) of argument
> 
> I have spent so long trying to figure this out without
> success,
> I am sure it has to do with the fact that my rows have names in them.
>  I
> have attached the text file I have been using and if you have any
> ideas as
> to how I can get R to plot the data using correspondence analysis
> with the
> column and row names that would be really helpful!  Or if you could
> pass
> this email to someone who may know how to help me, that would be much
> appreciated.
> 
> Thank you,
> Melissa Waldman
> 
> my email: melissawald...@gmail.com

Hello Melissa,
First of all, you need a descriptive subject, such as, "Cannot read
tabular data in R". R-help is a high-volume (100 to 200 messages per
day) and each person that can help you is a specialist in one or
another area.
Secondly, please include in your mail an excerpt of the relevant code
you used that read the data in and produced the error.

>From looking at your text file, I would delete the white space before
None, save the file, and use the following function to read your data
into a data.frame:

read.delim("smokedata.txt")

This assumes you used a tab character between each field.

HTH, Edwin
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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 Please!!!!!!!!!

2010-11-29 Thread Melissa Waldman
Hi,

I have been working with Program R for my stats class and I keep coming upon
the same error, I have read so many sites about inputting data from a text
file into R and I'm using the data to do a correspondence analysis.  I feel
like I have read everything and it is still not explaining why the error
message keeps coming up, I have used the exact examples I have seen in
articles and the same error keeps popping up: Error in sum(N) : invalid
'type' (character) of argument

I have spent so long trying to figure this out without success,
I am sure it has to do with the fact that my rows have names in them.  I
have attached the text file I have been using and if you have any ideas as
to how I can get R to plot the data using correspondence analysis with the
column and row names that would be really helpful!  Or if you could pass
this email to someone who may know how to help me, that would be much
appreciated.

Thank you,
Melissa Waldman

my email: melissawald...@gmail.com
NoneLight   Medium  Heavy
SM  4   2   3   2
JM  4   3   7   4
SE  25  10  12  4
JE  18  24  33  13
S   10  6   7   2
__
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] help please: predict error code

2010-04-24 Thread Peter Ehlers

I'm sure there are people willing to help you, but you
will have to be a little more forthcoming with information.
I don't know how many predict functions there are in the
2000-plus packages on CRAN, but there surely are quite a
few. Perhaps you could let us know what you're using
before you get to your predict call. Reproducible code
would be best.

 -Peter Ehlers

On 2010-04-24 12:45, Brittany Hall wrote:










Hello,

I am trying to calculate predicted values derived from one dataset into a 
hypothetical dataset. I tried this line of code:

graphdata$fmgpredvalues<- predict(Acs250.3.4, graphdata)

and received the following error message:

ERROR: ZXend[1], drop = FALSE] %*%lmeFit$beta

I have made sure all variable names are the same between the two datasets and 
all factors are appropriately labeled.

I appreciate any insight.

Thanks,

Brittany





[[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.


--
Peter Ehlers
University of Calgary

__
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 please: predict error code

2010-04-24 Thread Brittany Hall









Hello,
 
I am trying to calculate predicted values derived from one dataset into a 
hypothetical dataset. I tried this line of code:
 
graphdata$fmgpredvalues <- predict(Acs250.3.4, graphdata)
 
and received the following error message:
 
ERROR: ZXend[1], drop = FALSE] %*%lmeFit$beta
 
I have made sure all variable names are the same between the two datasets and 
all factors are appropriately labeled.
 
I appreciate any insight.
 
Thanks,
 
Brittany
 



  
[[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] Help Please!

2010-02-10 Thread Phil Spector
Please don't reply to this request.  This is a student in one of 
my classes.


- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Tue, 9 Feb 2010, Nick Manginelli wrote:


So I have to use this table of min, max, and mean temps for certain 
years?http://www.stat.berkeley.edu/classes/s133/data/january.tab. I am supposed 
to figure out which year had the hottest January and which had the coldest. But 
I dont know how to!

Nick Manginelli



[[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] Help Please!

2010-02-10 Thread Mike Williams
On Wed, Feb 10, 2010 at 2:47 AM, Nick Manginelli  wrote:
> So I have to use this table of min, max, and mean temps for certain 
> years http://www.stat.berkeley.edu/classes/s133/data/january.tab. I am 
> supposed to figure out which year had the hottest January and which had the 
> coldest. But I dont know how to!
>
> Nick Manginelli

For starters I'd suggest pruning the data with grep, then you can
pretty much eyeball the result.

[m...@localhost lab1]$ grep " 1$" january.txt
45.550.67   62.120051
50.755.02   59.520061
43.953.23   65.720071
42.252.16   64.720081
46.651.93   59.920091
53  57.75   63.420101

Although you have to decide if you want to use the min, max, or mean
temp to rank the years.  If you use min for coldest its 2008, using
mean it would be 2009.

Also, if you are going to play with this data with R you probably want
to change the headings because it will be confusing, (to you if not to
R) to have column names that match R builtin commands. Maybe use minT
meanTmaxT yearday
I'm sure someone else here can help you with using R.  I'm just
learning R myself and also just about to go to sleep.

Mike

__
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 Please!

2010-02-09 Thread Nick Manginelli
So I have to use this table of min, max, and mean temps for certain 
years http://www.stat.berkeley.edu/classes/s133/data/january.tab. I am supposed 
to figure out which year had the hottest January and which had the coldest. But 
I dont know how to!

Nick Manginelli


  
[[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] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-15 Thread Mark Difford

Hi Roberto,

The other thing you can do --- if you don't wish to step across to lmer(),
where you will be able to exactly replicate the crossed-factor error
structure --- is stay with aov(... + Error()), but fit the factor you are
interested in last. Assume it is Sex. Then fit your model as

aov.model <- aov(Volume ~ Lobe * Tissue * Sex + Error(Subject/(Lobe *
Tissue))

This should give you a so-called "Type-II" test for Sex. You may verify this
by fitting the model without the Error term and using Anova() from the car
package (which does Type-II/III tests) to look at the SS and F values.

I say should, because the only concern I have is whether this procedure is
affected by the presence of an Error term in the model. Establishing this is
beyond my capabilities.

Regards, Mark.


roberto toro wrote:
> 
> Thanks for answering Mark!
> 
> I tried with the coding of the interaction you suggested:
> 
>> tfac<-with(vlt,interaction(Lobe,Tissue,drop=T))
>> mod<-lme(Volume~Sex*Lobe*Tissue,random=~1|Subject/tfac,data=vlt)
> 
> But is it normal that the DF are 2303? DF is 2303 even for the estimate of
> LobeO that has only 662 values (331 for Tissue=white and 331 for
> Tissue=grey).
> I'm not sure either that Sex, Lobe and Tissue are correctly handled
> why are
> there different estimates called Sex:LobeO, Sex:LobeP, etc, and not just
> Sex:Lobe as with aov()?. Why there's Tissuew, but not Sex1, for example?
> 
> Thanks again!
> roberto
> 
> ps1. How would you code this with lmer()?
> ps2. this is part of the output of mod<-lme:
>> summary(mod)
> Linear mixed-effects model fit by REML
>  Data: vlt
>AIC  BIClogLik
>   57528.35 57639.98 -28745.17
> 
> Random effects:
>  Formula: ~1 | Subject
> (Intercept)
> StdDev:11294.65
> 
>  Formula: ~1 | tfac %in% Subject
> (Intercept) Residual
> StdDev:10569.03 4587.472
> 
> Fixed effects: Volume ~ Sex * Lobe * Tissue
>Value Std.Error   DFt-value p-value
> (Intercept)245224.61  1511.124 2303  162.27963  0.
> Sex  2800.01  1866.312  3291.50029  0.1345
> LobeO -180794.83  1526.084 2303 -118.46975  0.
> LobeP -131609.27  1526.084 2303  -86.23984  0.
> LobeT  -73189.97  1526.084 2303  -47.95932  0.
> Tissuew-72461.05  1526.084 2303  -47.48168  0.
> Sex:LobeO-663.27  1884.789 2303   -0.35191  0.7249
> Sex:LobeP   -2146.08  1884.789 2303   -1.13863  0.2550
> Sex:LobeT1379.49  1884.789 23030.73191  0.4643
> Sex:Tissuew  5387.65  1884.789 23032.85849  0.0043
> LobeO:Tissuew   43296.99  2158.209 2303   20.06154  0.
> LobeP:Tissuew   50952.21  2158.209 2303   23.60856  0.
> LobeT:Tissuew  -15959.31  2158.209 2303   -7.39470  0.
> Sex:LobeO:Tissuew   -5228.66  2665.494 2303   -1.96161  0.0499
> Sex:LobeP:Tissuew   -1482.83  2665.494 2303   -0.55631  0.5781
> Sex:LobeT:Tissuew   -6037.49  2665.494 2303   -2.26506  0.0236
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Help-please%21-How-to-code-a-mixed-model-with-2-within-subject-factors-using-lme-or-lmer--tp19480815p19489323.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] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-14 Thread Adam D. I. Kramer


On Sun, 14 Sep 2008, roberto toro wrote:


Thanks for answering Mark!

I tried with the coding of the interaction you suggested:


tfac<-with(vlt,interaction(Lobe,Tissue,drop=T))
mod<-lme(Volume~Sex*Lobe*Tissue,random=~1|Subject/tfac,data=vlt)


But is it normal that the DF are 2303? DF is 2303 even for the estimate of
LobeO that has only 662 values (331 for Tissue=white and 331 for
Tissue=grey). I'm not sure either that Sex, Lobe and Tissue are correctly
handled why are there different estimates called Sex:LobeO, Sex:LobeP,
etc, and not just Sex:Lobe as with aov()?. Why there's Tissuew, but not
Sex1, for example?


lme is basically doing a regression, not an ANOVA as you're used to it. You
may want anova(mod) instead of summary(mod) to see aggregated effects. Or,
you could define contrasts among your levels by assigning to
contrasts(vlt$Lobe), for example.

Also, in the above model, you're only looking at modeling a separate average
volume for each subject-within-tfac; if I read you correctly, you actually
want to model a lobe and tissue effect for each subject for each tfac, in
which case you would want something like what was in my last post.

--Adam



Thanks again!
roberto

ps1. How would you code this with lmer()?
ps2. this is part of the output of mod<-lme:

summary(mod)

Linear mixed-effects model fit by REML
Data: vlt
  AIC  BIClogLik
 57528.35 57639.98 -28745.17

Random effects:
Formula: ~1 | Subject
   (Intercept)
StdDev:11294.65

Formula: ~1 | tfac %in% Subject
   (Intercept) Residual
StdDev:10569.03 4587.472

Fixed effects: Volume ~ Sex * Lobe * Tissue
  Value Std.Error   DFt-value p-value
(Intercept)245224.61  1511.124 2303  162.27963  0.
Sex  2800.01  1866.312  3291.50029  0.1345
LobeO -180794.83  1526.084 2303 -118.46975  0.
LobeP -131609.27  1526.084 2303  -86.23984  0.
LobeT  -73189.97  1526.084 2303  -47.95932  0.
Tissuew-72461.05  1526.084 2303  -47.48168  0.
Sex:LobeO-663.27  1884.789 2303   -0.35191  0.7249
Sex:LobeP   -2146.08  1884.789 2303   -1.13863  0.2550
Sex:LobeT1379.49  1884.789 23030.73191  0.4643
Sex:Tissuew  5387.65  1884.789 23032.85849  0.0043
LobeO:Tissuew   43296.99  2158.209 2303   20.06154  0.
LobeP:Tissuew   50952.21  2158.209 2303   23.60856  0.
LobeT:Tissuew  -15959.31  2158.209 2303   -7.39470  0.
Sex:LobeO:Tissuew   -5228.66  2665.494 2303   -1.96161  0.0499
Sex:LobeP:Tissuew   -1482.83  2665.494 2303   -0.55631  0.5781
Sex:LobeT:Tissuew   -6037.49  2665.494 2303   -2.26506  0.0236

__
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.


Re: [R] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-14 Thread Mark Difford

Hi Roberto,

It's difficult to comment further on specifics without access to your data
set. A general point is that the output from summary(aov.object) is not
directly comparable with summary(lme.object). The latter gives you a summary
of a fitted linear regression model, not an analysis of variance model, and
what you "see" will depend on what contrasts were in place when the model
was fitted.

If you haven't changed these then they will be so-called treatment
contrasts. What you are seeing for Lobe (which plainly is coded as a factor)
in the output from summary(lme.object) are the regression coefficients for
each level of Lobe relative to its reference/treatment/baseline level, which
is your (Intercept). If you fitted your model with, say, Helmert or
sum-to-zero contrasts then these values would change.

To see what your current reference level is do levels(dataset$Lobe). See
?levels.

What you want to look at to begin with is: anova(lme.object).

HTH, Mark.


roberto toro wrote:
> 
> Thanks for answering Mark!
> 
> I tried with the coding of the interaction you suggested:
> 
>> tfac<-with(vlt,interaction(Lobe,Tissue,drop=T))
>> mod<-lme(Volume~Sex*Lobe*Tissue,random=~1|Subject/tfac,data=vlt)
> 
> But is it normal that the DF are 2303? DF is 2303 even for the estimate of
> LobeO that has only 662 values (331 for Tissue=white and 331 for
> Tissue=grey).
> I'm not sure either that Sex, Lobe and Tissue are correctly handled
> why are
> there different estimates called Sex:LobeO, Sex:LobeP, etc, and not just
> Sex:Lobe as with aov()?. Why there's Tissuew, but not Sex1, for example?
> 
> Thanks again!
> roberto
> 
> ps1. How would you code this with lmer()?
> ps2. this is part of the output of mod<-lme:
>> summary(mod)
> Linear mixed-effects model fit by REML
>  Data: vlt
>AIC  BIClogLik
>   57528.35 57639.98 -28745.17
> 
> Random effects:
>  Formula: ~1 | Subject
> (Intercept)
> StdDev:11294.65
> 
>  Formula: ~1 | tfac %in% Subject
> (Intercept) Residual
> StdDev:10569.03 4587.472
> 
> Fixed effects: Volume ~ Sex * Lobe * Tissue
>Value Std.Error   DFt-value p-value
> (Intercept)245224.61  1511.124 2303  162.27963  0.
> Sex  2800.01  1866.312  3291.50029  0.1345
> LobeO -180794.83  1526.084 2303 -118.46975  0.
> LobeP -131609.27  1526.084 2303  -86.23984  0.
> LobeT  -73189.97  1526.084 2303  -47.95932  0.
> Tissuew-72461.05  1526.084 2303  -47.48168  0.
> Sex:LobeO-663.27  1884.789 2303   -0.35191  0.7249
> Sex:LobeP   -2146.08  1884.789 2303   -1.13863  0.2550
> Sex:LobeT1379.49  1884.789 23030.73191  0.4643
> Sex:Tissuew  5387.65  1884.789 23032.85849  0.0043
> LobeO:Tissuew   43296.99  2158.209 2303   20.06154  0.
> LobeP:Tissuew   50952.21  2158.209 2303   23.60856  0.
> LobeT:Tissuew  -15959.31  2158.209 2303   -7.39470  0.
> Sex:LobeO:Tissuew   -5228.66  2665.494 2303   -1.96161  0.0499
> Sex:LobeP:Tissuew   -1482.83  2665.494 2303   -0.55631  0.5781
> Sex:LobeT:Tissuew   -6037.49  2665.494 2303   -2.26506  0.0236
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Help-please%21-How-to-code-a-mixed-model-with-2-within-subject-factors-using-lme-or-lmer--tp19480815p19481027.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.


[R] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-14 Thread roberto toro
Thanks for answering Mark!

I tried with the coding of the interaction you suggested:

> tfac<-with(vlt,interaction(Lobe,Tissue,drop=T))
> mod<-lme(Volume~Sex*Lobe*Tissue,random=~1|Subject/tfac,data=vlt)

But is it normal that the DF are 2303? DF is 2303 even for the estimate of
LobeO that has only 662 values (331 for Tissue=white and 331 for Tissue=grey).
I'm not sure either that Sex, Lobe and Tissue are correctly handled why are
there different estimates called Sex:LobeO, Sex:LobeP, etc, and not just
Sex:Lobe as with aov()?. Why there's Tissuew, but not Sex1, for example?

Thanks again!
roberto

ps1. How would you code this with lmer()?
ps2. this is part of the output of mod<-lme:
> summary(mod)
Linear mixed-effects model fit by REML
 Data: vlt
   AIC  BIClogLik
  57528.35 57639.98 -28745.17

Random effects:
 Formula: ~1 | Subject
(Intercept)
StdDev:11294.65

 Formula: ~1 | tfac %in% Subject
(Intercept) Residual
StdDev:10569.03 4587.472

Fixed effects: Volume ~ Sex * Lobe * Tissue
   Value Std.Error   DFt-value p-value
(Intercept)245224.61  1511.124 2303  162.27963  0.
Sex  2800.01  1866.312  3291.50029  0.1345
LobeO -180794.83  1526.084 2303 -118.46975  0.
LobeP -131609.27  1526.084 2303  -86.23984  0.
LobeT  -73189.97  1526.084 2303  -47.95932  0.
Tissuew-72461.05  1526.084 2303  -47.48168  0.
Sex:LobeO-663.27  1884.789 2303   -0.35191  0.7249
Sex:LobeP   -2146.08  1884.789 2303   -1.13863  0.2550
Sex:LobeT1379.49  1884.789 23030.73191  0.4643
Sex:Tissuew  5387.65  1884.789 23032.85849  0.0043
LobeO:Tissuew   43296.99  2158.209 2303   20.06154  0.
LobeP:Tissuew   50952.21  2158.209 2303   23.60856  0.
LobeT:Tissuew  -15959.31  2158.209 2303   -7.39470  0.
Sex:LobeO:Tissuew   -5228.66  2665.494 2303   -1.96161  0.0499
Sex:LobeP:Tissuew   -1482.83  2665.494 2303   -0.55631  0.5781
Sex:LobeT:Tissuew   -6037.49  2665.494 2303   -2.26506  0.0236

__
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] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-14 Thread Mark Difford

Hi Roberto,

>> but I can't figure out the /(Lobe*Tissue) part...

This type of nesting is easier to do using lmer(). To do it using lme() you
have to generate the crossed factor yourself. Do something like this:

##
tfac <- with(vslt, interaction(Lobe, Tissue, drop=T))
str(tfac); head(tfac)
mod2<-lme(Volume ~ Val*Lobe*Tissue, random = ~1|Subject/tfac, data = vslt)

Pre-Scriptum: You can also use ?":" but ?interaction is more flexible and
powerful.

Regards, Mark.


roberto toro wrote:
> 
> Hello,
> 
> I'm using aov() to analyse changes in brain volume between males and
> females. For every subject (there are 331 in total) I have 8 volume
> measurements (4 different brain lobes and 2 different tissues
> (grey/white matter)). The data looks like this:
> 
> Subject   Sex LobeTissue  Volume
> subect1   1   F   g   262374
> subect1   1   F   w   173758
> subect1   1   O   g   67155
> subect1   1   O   w   30067
> subect1   1   P   g   117981
> subect1   1   P   w   85441
> subect1   1   T   g   185241
> subect1   1   T   w   83183
> subect2   1   F   g   255309
> subect2   1   F   w   164335
> subect2   1   O   g   71769
> subect2   1   O   w   31879
> subect2   1   P   g   120518
> subect2   1   P   w   90334
> subect2   1   T   g   168413
> subect2   1   T   w   75790
> subect3   0   F   g   243621
> subect3   0   F   w   167025
> subect3   0   O   g   65998
> subect3   0   O   w   29758
> subect3   0   P   g   118026
> subect3   0   P   w   91903
> subect3   0   T   g   156279
> subect3   0   T   w   82349
> 
> 
> I'm trying to see if there is an interaction Sex*Lobe*Tissue. This is
> the command I use with aov():
>   
> mod1<-aov(Volume~Sex*Lobe*Tissue+Error(Subject/(Lobe*Tissue)),data.vslt)
> 
> Subject is a random effect, Sex, Lobe and Tissue are fixed effects;
> Sex is an outer factor (between subjects), and Lobe and Tissue are
> inner factors (within-subjects); and there is indeed a significant
> 3-way interaction.
> 
> I was told, however, that the results reported by aov() may depend on
> the order of the factors
> (type I anova), and that is better to use lme() or lmer() with type
> II, but I'm struggling to find the right syntaxis...
> 
> To begin, how should I write the model using lme() or lmer()??
> 
> I tried this with lme():
>
> gvslt<-groupedData(Volume~1|Subject,outer=~Val,inner=list(~Lobe,~Tissue),data=vslt)
> mod2<-lme(Volume~Val*Lobe*Tissue,random=~1|Subject,data=gvslt)
> 
> but I have interaction terms for every level of Lobe and Tissue, and 8
> times the number of DF I should have... (around 331*8 instead of
> ~331).
> 
> Using lmer(), the specification of Subject as a random effect is
> straightforward:
> 
> mod2<-lmer(Volume~Sex*Lobe*Tissue+(1|Subject),data.vslt)
> 
> but I can't figure out the /(Lobe*Tissue) part...
> 
> Thank you very much in advance!
> roberto
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Help-please%21-How-to-code-a-mixed-model-with-2-within-subject-factors-using-lme-or-lmer--tp19479860p19480387.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.


[R] Help please! How to code a mixed-model with 2 within-subject factors using lme or lmer?

2008-09-14 Thread roberto toro
Hello,

I'm using aov() to analyse changes in brain volume between males and
females. For every subject (there are 331 in total) I have 8 volume
measurements (4 different brain lobes and 2 different tissues
(grey/white matter)). The data looks like this:

Subject Sex LobeTissue  Volume
subect1 1   F   g   262374
subect1 1   F   w   173758
subect1 1   O   g   67155
subect1 1   O   w   30067
subect1 1   P   g   117981
subect1 1   P   w   85441
subect1 1   T   g   185241
subect1 1   T   w   83183
subect2 1   F   g   255309
subect2 1   F   w   164335
subect2 1   O   g   71769
subect2 1   O   w   31879
subect2 1   P   g   120518
subect2 1   P   w   90334
subect2 1   T   g   168413
subect2 1   T   w   75790
subect3 0   F   g   243621
subect3 0   F   w   167025
subect3 0   O   g   65998
subect3 0   O   w   29758
subect3 0   P   g   118026
subect3 0   P   w   91903
subect3 0   T   g   156279
subect3 0   T   w   82349


I'm trying to see if there is an interaction Sex*Lobe*Tissue. This is
the command I use with aov():
   mod1<-aov(Volume~Sex*Lobe*Tissue+Error(Subject/(Lobe*Tissue)),data.vslt)

Subject is a random effect, Sex, Lobe and Tissue are fixed effects;
Sex is an outer factor (between subjects), and Lobe and Tissue are
inner factors (within-subjects); and there is indeed a significant
3-way interaction.

I was told, however, that the results reported by aov() may depend on
the order of the factors
(type I anova), and that is better to use lme() or lmer() with type
II, but I'm struggling to find the right syntaxis...

To begin, how should I write the model using lme() or lmer()??

I tried this with lme():

gvslt<-groupedData(Volume~1|Subject,outer=~Val,inner=list(~Lobe,~Tissue),data=vslt)
mod2<-lme(Volume~Val*Lobe*Tissue,random=~1|Subject,data=gvslt)

but I have interaction terms for every level of Lobe and Tissue, and 8
times the number of DF I should have... (around 331*8 instead of
~331).

Using lmer(), the specification of Subject as a random effect is
straightforward:

mod2<-lmer(Volume~Sex*Lobe*Tissue+(1|Subject),data.vslt)

but I can't figure out the /(Lobe*Tissue) part...

Thank you very much in advance!
roberto

__
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 please with predict.lme from nlme with nested random effects

2007-11-07 Thread Tom Cameron
 2 3 1 20 0.904 6  
48 P 1 2 3 1 17 0.923 7  
48 P 1 2 3 1 17 0.885 7  
48 P 1 2 3 1 17 0.873 7  
48 P 1 2 3 1 17 0.886 7  
48 P 1 2 3 1 17 0.899 7  
48 P 1 2 3 1 17 0.861 7  
48 P 1 2 3 1 17 0.857 7  
48 P 1 2 3 1 17 0.821 7  
48 P 1 2 3 1 17 0.872 7  
48 P 1 2 3 1 2 0.935 8  
48 P 1 2 4 1 19 0.914 5  
48 P 1 2 4 1 19 1.035 5  
48 P 1 2 4 1 19 0.830 5  
48 P 1 2 4 1 13 0.961 6  
48 P 1 2 4 1 13 1.100 6  
48 P 1 2 4 1 13 0.921 6  
48 P 1 2 4 1 13 0.941 6  
48 P 1 2 4 1 13 0.929 6  
48 P 1 2 4 1 2 0.779 7  
48 P 1 2 5 1 18 0.826 6  
48 P 1 2 5 1 18 0.979 6  
48 P 1 2 5 1 18 0.922 6  
48 P 1 2 5 1 18 0.888 6  
48 P 1 2 5 1 18 0.975 6  
48 P 1 2 5 1 18 0.859 6  
48 P 1 2 5 1 18 0.991 6  
48 P 1 2 5 1 18 0.858 6  
48 P 1 2 5 1 18 0.853 6  
48 P 1 2 5 1 18 1.098 6  
48 P 1 2 5 1 18 0.904 6  
48 P 1 2 6 1 17 0.670 6  
48 P 1 2 6 1 17 0.749 6  
48 P 1 2 6 1 17 0.720 6  
48 P 1 2 6 1 17 0.798 6  
48 P 1 2 6 1 17 0.776 6  
48 P 1 2 6 1 10 0.837 7  
48 P 1 2 6 1 10 0.842 7  
48 P 1 2 6 1 10 0.801 7  
48 P 1 2 6 1 1 0.948 8  
48 P 1 2 7 1 17 0.914 7  
48 P 1 2 7 1 17 0.838 7  
48 P 1 2 7 1 17 0.974 7  
48 P 1 2 7 1 17 0.835 7  
48 P 1 2 7 1 17 0.807 7  
48 P 1 2 7 1 17 0.852 7  
48 P 1 2 7 1 17 0.888 7  
48 P 1 2 7 1 17 0.874 7  
48 P 1 2 7 1 17 0.834 7  
48 P 1 2 7 1 17 0.756 7  
48 P 1 1 1 1 13 0.634 10  
48 P 1 1 1 1 12 0.791 11  
48 P 1 1 1 1 11 0.767 13  
48 P 1 1 1 1 8 0.617 14  
48 P 1 1 1 1 6 0.889 15  
48 P 1 1 1 1 6 0.763 15  
48 P 1 1 1 1 2 0.738 18  
48 P 1 1 1 1 2 0.744 18  
48 P 1 1 2 1 18 0.637 12  
48 P 1 1 2 1 18 0.611 13  
48 P 1 1 2 1 10 0.614 14  
48 P 1 1 2 1 9 0.639 15  
48 P 1 1 2 1 9 0.808 15  
48 P 1 1 2 1 9 0.686 15  
48 P 1 1 3 1 12 0.799 8  
48 P 1 1 3 1 7 0.749 9  
48 P 1 1 3 1 7 0.882 9  
48 P 1 1 3 1 1 0.739 12  
48 P 1 1 4 1 18 0.626 9  
48 P 1 1 4 1 17 0.643 10  
48 P 1 1 4 1 12 0.626 11  
48 P 1 1 4 1 10 0.706 13  
48 P 1 1 4 1 8 0.689 14  
48 P 1 1 4 1 7 0.641 15  
48 P 1 1 4 1 7 0.751 15  
48 P 1 1 4 1 7 0.769 15  
48 P 1 1 5 1 18 0.718 9  
48 P 1 1 5 1 18 0.745 9  
48 P 1 1 5 1 15 0.608 11  
48 P 1 1 5 1 14 0.667 12  
48 P 1 1 5 1 11 0.652 14  
48 P 1 1 5 1 10 0.611 15  
48 P 1 1 5 1 4 0.676 18  
48 P 1 1 6 1 9 0.814 9  
48 P 1 1 6 1 9 0.666 9  
48 P 1 1 6 1 7 0.642 11  
48 P 1 1 7 1 19 0.659 9  
48 P 1 1 7 1 18 0.765 11  
48 P 1 1 7 1 6 0.699 18  

______
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] help please

2007-10-29 Thread Ben Bolker



osita k ezeh wrote:
> 
> hello,
> 
> please can anyone help me out. Am a new user of R
> program. Am having problem
> with this code below, not getting the expected
> results.
> 
> 

  Did you not get my and Uwe's previous responses to your question?

  Ben Bolker

-- 
View this message in context: 
http://www.nabble.com/help-please-tf4709336.html#a13466355
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] help please

2007-10-29 Thread Uwe Ligges
You got at least two answers on this yesterday. If you want more precise 
answers, please tell us what your expected result is.

Uwe Ligges


osita k ezeh wrote:
> hello,
> 
> please can anyone help me out. Am a new user of R
> program. Am having problem
> with this code below, not getting the expected
> results.
> 
>  Each m, the cumulative sum should be 1.000 but the
> 2nd and 3rd m returned 2.000 and 3.000
> instead of 1.000.
> 
> 
> 
> thanks
> Aruike
> 
> 
> 
> pp=function(x,n,M){z=1.0;a=2.3071430;b=7.266064;H=3
> 
>  out.h=c()   
> 
>  out.y=c()
> 
>  out.m=c()
> 
>  out.prob=c()
> 
>  
> 
>for(h in 1:H){
> 
>for(m in 1:M){
> 
>for(y in 0:m){  
> 
> 
> 
> 
> g=lgamma(m+z)+lgamma(n[h]+a+b)+lgamma(x[h]+y+a)+lgamma(n[h]+m+b-x[h]-y)
> 
> 
>  
> g=g-lgamma(y+z)-lgamma(m-y+z)-lgamma(x[h]+a)-lgamma(n[h]+b-x[h])-
> lgamma(n[h]+m+a+b)
> 
>   
> 
>  out.h=c(out.h,h)
> 
>  out.y=c(out.y,y)
> 
>  out.m=c(out.m,m)
> 
>  out.prob=c(out.prob, exp(g))   
> 
>out.cum=c(cumsum(out.prob))
> 
> 
> 
>  Result=data.frame(out.h,out.y,out.m,out.prob,out.cum)
> 
>  
> 
>  Kings=pp(x=c(19,20), n=c(52,60),3)
> 
>  Kings
> 
>out.h out.y out.m   out.prob   out.cum
> 
> 1  1 0 1 0.65395431 0.6539543
> 
> 2  1 1 1 0.34604569 1.000
> 
> 3  1 0 2 0.43127277 1.4312728
> 
> 4  1 1 2 0.44536308 1.8766358
> 
> 5  1 2 2 0.12336415 2.000
> 
> 6  1 0 3 0.28672775 2.2867277
> 
> 7  1 1     3 0.43363507 2.7203628
> 
> 8  1 2 3 0.23440955 2.9547724
> 
> 9  1 3 3 0.04522764 3.000
> 
> __
> 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.


[R] help please

2007-10-28 Thread osita k ezeh
hello,

please can anyone help me out. Am a new user of R
program. Am having problem
with this code below, not getting the expected
results.

 Each m, the cumulative sum should be 1.000 but the
2nd and 3rd m returned 2.000 and 3.000
instead of 1.000.



thanks
Aruike



pp=function(x,n,M){z=1.0;a=2.3071430;b=7.266064;H=3

 out.h=c()   

 out.y=c()

 out.m=c()

 out.prob=c()

 

   for(h in 1:H){

   for(m in 1:M){

   for(y in 0:m){  




g=lgamma(m+z)+lgamma(n[h]+a+b)+lgamma(x[h]+y+a)+lgamma(n[h]+m+b-x[h]-y)


 
g=g-lgamma(y+z)-lgamma(m-y+z)-lgamma(x[h]+a)-lgamma(n[h]+b-x[h])-
lgamma(n[h]+m+a+b)

  

 out.h=c(out.h,h)

 out.y=c(out.y,y)

 out.m=c(out.m,m)

 out.prob=c(out.prob, exp(g))   

   out.cum=c(cumsum(out.prob))



 Result=data.frame(out.h,out.y,out.m,out.prob,out.cum)

 

 Kings=pp(x=c(19,20), n=c(52,60),3)

 Kings

   out.h out.y out.m   out.prob   out.cum

1  1 0 1 0.65395431 0.6539543

2  1 1 1 0.34604569 1.000

3  1 0 2 0.43127277 1.4312728

4  1 1 2 0.44536308 1.8766358

5  1 2 2 0.12336415 2.000

6  1 0 3 0.28672775 2.2867277

7  1 1 3 0.43363507 2.7203628

8  1 2 3 0.23440955 2.9547724

9  1 3 3 0.04522764 3.000

__
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.