[R] pls package

2016-03-15 Thread cindy Guo
Hi All,

I am using the cppls function in the pls package, and I want to use cross
validation to determine the best number of components. Since Hastie et al
recommended a "one standard error rule", i.e., choose the most parsimonious
model whose error is no more than one standard error above
the error of the best model, I am wondering how I can get the standard
error of misclassification rate from pls package?

Thank you,
Cindy

[[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 plsr function

2014-06-24 Thread cindy Guo
Ok, yes, I can match them now. Thank you very much!



On Tue, Jun 24, 2014 at 3:58 AM, Bjørn-Helge Mevik 
wrote:

> annie Zhang  writes:
>
> > ## the predicted scores from the model
> > (pred <- predict(data.cpls,n.comp=1:2,newdata=x.new,type="score"))
> > ## the predicted scores using x%*%projection
> >
> cbind(x.new.centered%*%data.cpls$projection[,1],x.new.centered%*%data.cpls$projection[,2])
> >
> > Can someone please tell me why the two predicted scores don't match?
>
> If you look at the code that does the prediction:
>
> > pls:::predict.mvr
> function (object, newdata, ncomp = 1:object$ncomp, comps, type =
> c("response",
> "scores"), na.action = na.pass, ...)
> {
> [...]
>TT <- (newX - rep(object$Xmeans, each = nobs)) %*%
> object$projection[, comps]
>
> you will see that it subtracts the _old X_ coloumn means from the new X
> matrix, not the _new X_ coloumn means.  So
>
> sweep(x.new, 2, data.cpls$Xmeans, "-") %*% data.cpls$projection[,1:2]
>
> will reproduce the values from predict().
>
> --
> Regards,
> Bjørn-Helge Mevik
>
> __
> 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] calculate probability circles

2011-04-26 Thread cindy Guo
Hi, All,

I want to have the 1%, 2%, 3%, ... contours for Dirichlet distribution. I
need the exact contour circles  (mathematically) instead of contour plots.
Can anyone help me with this?

Many thanks,
Cindy

[[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] integration

2011-04-09 Thread cindy Guo
'integrate' does not allow parameter limits. For example, the limits of x is
(z/y, Inf) while z and y are unkonwn.

On Fri, Apr 8, 2011 at 9:46 PM, Ravi Varadhan  wrote:

> ?integrate
>
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
> Behalf Of cindy Guo [cindy.g...@gmail.com]
> Sent: Friday, April 08, 2011 9:21 PM
> To: r-help@r-project.org
> Subject: [R]  integration
>
> Hi, All,
>
> I have a density function with 3 variables which is defined on some
> irregular domain, and I want to get the marginal distribution of each
> variable. Is there any function doing this?
>
> A simple example is p(x,y,z)=x*y*z*I(xy>z). So each marginal distribution
> is
> a function of the other two variables. My density form is very complicated,
> so I cannot do it by hand. I was just wondering if there is any function in
> R for this?
>
> Thanks,
>
> Cindy
>
> [[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
and provide commented, minimal, self-contained, reproducible code.


[R] integration

2011-04-08 Thread cindy Guo
Hi, All,

I have a density function with 3 variables which is defined on some
irregular domain, and I want to get the marginal distribution of each
variable. Is there any function doing this?

A simple example is p(x,y,z)=x*y*z*I(xy>z). So each marginal distribution is
a function of the other two variables. My density form is very complicated,
so I cannot do it by hand. I was just wondering if there is any function in
R for this?

Thanks,

Cindy

[[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] pairs

2009-11-16 Thread cindy Guo
Thank you. I will check that.
Cindy

On Mon, Nov 16, 2009 at 1:45 PM, cls59  wrote:

>
>
> David Winsemius wrote:
> >
> > ?order
> >
>
> cindy Guo wrote:
> >
> > Do you mean if the numbers in each row are ordered? They are not, but if
> > it's needed, we can order them. The matrix only has 5000 rows.
> >
>
> No, he's suggesting you check out the order() function by calling it's help
> page:
>
>  ?order
>
> order() will sort your results into ascending or descending order.  You
> could then pick off the top 50 by using head().
>
> Hope that helps!
>
> -Charlie
>
>
> -
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University
> --
> View this message in context:
> http://old.nabble.com/pairs-tp26364801p26378236.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<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] pairs

2009-11-16 Thread cindy Guo
Do you mean if the numbers in each row are ordered? They are not, but if
it's needed, we can order them. The matrix only has 5000 rows.

On Mon, Nov 16, 2009 at 1:34 PM, David Winsemius wrote:

>
>  On Nov 16, 2009, at 2:32 PM, cindy Guo wrote:
>
>  I forgot to say that there are no ties in each row. So any number can
> occur only once in each row. Also as I mentioned earlier, actually I only
> need the top 50 most frequent pairs, is there a more efficient way to do it?
> Because I have 15000 numbers, output of all the pairs would be too long.
>
>
> ?order
>
>
>
> Thank you,
>
> Cindy
>
> On Mon, Nov 16, 2009 at 7:02 AM, David Winsemius 
> wrote:
>
>> I stuck in another "7" in one of the lines with a 2 and reasoned that we
>> could deal with the desire for non-ordered "pair counting" by pasting
>> min(x,y) to max(x,y);
>>
>> > dput(prmtx)
>> structure(c(2, 1, 3, 9, 5, 7, 7, 8, 1, 7, 6, 5, 6, 2, 2, 7), .Dim = c(4L,
>> 4L))
>> > prmtx
>> [,1] [,2] [,3] [,4]
>> [1,]2516
>> [2,]1772
>> [3,]3762
>> [4,]9857
>>
>> > pair.str <- sapply(1:nrow(prmtx), function(z)  apply(combn(prmtx[z,],
>> 2), 2,function(x) paste(min(x[2],x[1]), max(x[2],x[1]), sep=".")))
>>
>> The logic:
>> sapply(1:nrow(prmtx), ... just loops over the rows of the matrix.
>> combn(prmtx[z,], 2)  ... returns a two row matrix of combination in a
>> single row.
>> apply(combn(prmtx[z,], 2), 2 ... since combn( , 2)  returns a matrix that
>> has two _rows_ I needed to loop over the columns.
>> paste(min(x[2],x[1]), max(x[2],x[1]), sep=".") ... stick the minimum of a
>> pair in front of the max and separates them with a period to prevent two+
>> digits from being non-unique
>>
>> Then using table() and logical tests in an index for the desired multiple
>> pairs:
>>
>>
>> > tpair <-table(pair.str)
>> > tpair
>> pair.str
>> 1.2 1.5 1.6 1.7 2.3 2.5 2.6 2.7 3.6 3.7 5.6 5.7 5.8 5.9 6.7 7.7 7.8 7.9
>> 8.9
>>  2   1   1   2   1   1   2   3   1   1   1   1   1   1   1   1   1   1   1
>>
>>
>> > tpair[tpair>1]
>> pair.str
>> 1.2 1.7 2.6 2.7
>>  2   2   2   3
>>
>> --
>> David.
>>
>>
>> On Nov 16, 2009, at 7:02 AM, David Winsemius wrote:
>>
>> I'm not convinced it's right. In fact, I'm pretty sure the last step
>>> taking only the first half of the list is wrong. I also do not know if you
>>> have considered how you want to count situations like:
>>>
>>> 3 2 7 4 5 7 ...
>>> 7 3 8 6 1 2 9 2 ..
>>>
>>> How many "pairs" of 2-7/7-2 would that represent?
>>>
>>> --
>>> David
>>> On Nov 15, 2009, at 11:06 PM, cindy Guo wrote:
>>>
>>> Hi, David,
>>>>
>>>> The matrix has 20 columns.
>>>> Thank you very much for your help. I think it's right, but it seems I
>>>> need some time to figure it out. I am a green hand. There are so many
>>>> functions here I never used before. :)
>>>>
>>>> Cindy
>>>>
>>>> On Sun, Nov 15, 2009 at 5:19 PM, David Winsemius <
>>>> dwinsem...@comcast.net> wrote:
>>>> Assuming that the number of columns is 4, then consider this approach:
>>>>
>>>> > prs <-scan()
>>>> 1: 2 5 1 6
>>>> 5: 1 7 8 2
>>>> 9: 3 7 6 2
>>>> 13: 9 8 5 7
>>>> 17:
>>>> Read 16 items
>>>> prmtx <- matrix(prs, 4,4, byrow=T)
>>>>
>>>> #Now make copus of x.y and y.x
>>>>
>>>> pair.str <- sapply(1:nrow(prmtx), function(z) c(apply(combn(prmtx[z,],
>>>> 2), 2,function(x) paste(x[1],x[2], sep=".")) , apply(combn(prmtx[z,], 2),
>>>> 2,function(x) paste(x[2],x[1], sep="."))) )
>>>> tpair <-table(pair.str)
>>>>
>>>> # This then gives you a duplicated list
>>>> > tpair[tpair>1]
>>>> pair.str
>>>> 1.2 2.1 2.6 2.7 6.2 7.2 7.8 8.7
>>>> 2   2   2   2   2   2   2   2
>>>>
>>>> # So only take the first half of the pairs:
>>>> > head(tpair[tpair>1], sum(tpair>1)/2)
>>>>
>>>> pair.str
>>>> 1.2 2.1 2.6 2.7
>>>> 2   2   2   2
>>>>
>>>> --
>>>> David.
>>>>
>>>>
>&

Re: [R] pairs

2009-11-16 Thread cindy Guo
I forgot to say that there are no ties in each row. So any number can occur
only once in each row. Also as I mentioned earlier, actually I only need the
top 50 most frequent pairs, is there a more efficient way to do it? Because
I have 15000 numbers, output of all the pairs would be too long.

Thank you,

Cindy

On Mon, Nov 16, 2009 at 7:02 AM, David Winsemius wrote:

> I stuck in another "7" in one of the lines with a 2 and reasoned that we
> could deal with the desire for non-ordered "pair counting" by pasting
> min(x,y) to max(x,y);
>
> > dput(prmtx)
> structure(c(2, 1, 3, 9, 5, 7, 7, 8, 1, 7, 6, 5, 6, 2, 2, 7), .Dim = c(4L,
> 4L))
> > prmtx
> [,1] [,2] [,3] [,4]
> [1,]2516
> [2,]1772
> [3,]3762
> [4,]9857
>
> > pair.str <- sapply(1:nrow(prmtx), function(z)  apply(combn(prmtx[z,], 2),
> 2,function(x) paste(min(x[2],x[1]), max(x[2],x[1]), sep=".")))
>
> The logic:
> sapply(1:nrow(prmtx), ... just loops over the rows of the matrix.
> combn(prmtx[z,], 2)  ... returns a two row matrix of combination in a
> single row.
> apply(combn(prmtx[z,], 2), 2 ... since combn( , 2)  returns a matrix that
> has two _rows_ I needed to loop over the columns.
> paste(min(x[2],x[1]), max(x[2],x[1]), sep=".") ... stick the minimum of a
> pair in front of the max and separates them with a period to prevent two+
> digits from being non-unique
>
> Then using table() and logical tests in an index for the desired multiple
> pairs:
>
>
> > tpair <-table(pair.str)
> > tpair
> pair.str
> 1.2 1.5 1.6 1.7 2.3 2.5 2.6 2.7 3.6 3.7 5.6 5.7 5.8 5.9 6.7 7.7 7.8 7.9 8.9
>  2   1   1   2   1   1   2   3   1   1   1   1   1   1   1   1   1   1   1
>
> > tpair[tpair>1]
> pair.str
> 1.2 1.7 2.6 2.7
>  2   2   2   3
>
> --
> David.
>
>
> On Nov 16, 2009, at 7:02 AM, David Winsemius wrote:
>
> I'm not convinced it's right. In fact, I'm pretty sure the last step taking
>> only the first half of the list is wrong. I also do not know if you have
>> considered how you want to count situations like:
>>
>> 3 2 7 4 5 7 ...
>> 7 3 8 6 1 2 9 2 ..
>>
>> How many "pairs" of 2-7/7-2 would that represent?
>>
>> --
>> David
>> On Nov 15, 2009, at 11:06 PM, cindy Guo wrote:
>>
>> Hi, David,
>>>
>>> The matrix has 20 columns.
>>> Thank you very much for your help. I think it's right, but it seems I
>>> need some time to figure it out. I am a green hand. There are so many
>>> functions here I never used before. :)
>>>
>>> Cindy
>>>
>>> On Sun, Nov 15, 2009 at 5:19 PM, David Winsemius 
>>> wrote:
>>> Assuming that the number of columns is 4, then consider this approach:
>>>
>>> > prs <-scan()
>>> 1: 2 5 1 6
>>> 5: 1 7 8 2
>>> 9: 3 7 6 2
>>> 13: 9 8 5 7
>>> 17:
>>> Read 16 items
>>> prmtx <- matrix(prs, 4,4, byrow=T)
>>>
>>> #Now make copus of x.y and y.x
>>>
>>> pair.str <- sapply(1:nrow(prmtx), function(z) c(apply(combn(prmtx[z,],
>>> 2), 2,function(x) paste(x[1],x[2], sep=".")) , apply(combn(prmtx[z,], 2),
>>> 2,function(x) paste(x[2],x[1], sep="."))) )
>>> tpair <-table(pair.str)
>>>
>>> # This then gives you a duplicated list
>>> > tpair[tpair>1]
>>> pair.str
>>> 1.2 2.1 2.6 2.7 6.2 7.2 7.8 8.7
>>> 2   2   2   2   2   2   2   2
>>>
>>> # So only take the first half of the pairs:
>>> > head(tpair[tpair>1], sum(tpair>1)/2)
>>>
>>> pair.str
>>> 1.2 2.1 2.6 2.7
>>> 2   2   2   2
>>>
>>> --
>>> David.
>>>
>>>
>>>
>>> On Nov 15, 2009, at 8:06 PM, David Winsemius wrote:
>>>
>>> I could of course be wrong but have you yet specified the number of
>>> columns for this pairing exercise?
>>>
>>> On Nov 15, 2009, at 5:26 PM, cindy Guo wrote:
>>>
>>> Hi, All,
>>>
>>> I have an n by m matrix with each entry between 1 and 15000. I want to
>>> know
>>> the frequency of each pair in 1:15000 that occur together in rows. So for
>>> example, if the matrix is
>>> 2 5 1 6
>>> 1 7 8 2
>>> 3 7 6 2
>>> 9 8 5 7
>>> Pair (2,6) (un-ordered) occurs together in rows 1 and 3. I want to return
>>> the value 2 for this pair as well as that for all pairs. Is there a fast
>>> 

Re: [R] pairs

2009-11-15 Thread cindy Guo
Hi, David,

The matrix has 20 columns.
Thank you very much for your help. I think it's right, but it seems I need
some time to figure it out. I am a green hand. There are so many functions
here I never used before. :)

Cindy

On Sun, Nov 15, 2009 at 5:19 PM, David Winsemius wrote:

> Assuming that the number of columns is 4, then consider this approach:
>
> > prs <-scan()
> 1: 2 5 1 6
> 5: 1 7 8 2
> 9: 3 7 6 2
> 13: 9 8 5 7
> 17:
> Read 16 items
> prmtx <- matrix(prs, 4,4, byrow=T)
>
> #Now make copus of x.y and y.x
>
> pair.str <- sapply(1:nrow(prmtx), function(z) c(apply(combn(prmtx[z,], 2),
> 2,function(x) paste(x[1],x[2], sep=".")) , apply(combn(prmtx[z,], 2),
> 2,function(x) paste(x[2],x[1], sep="."))) )
> tpair <-table(pair.str)
>
> # This then gives you a duplicated list
> > tpair[tpair>1]
> pair.str
> 1.2 2.1 2.6 2.7 6.2 7.2 7.8 8.7
>  2   2   2   2   2   2   2   2
>
> # So only take the first half of the pairs:
> > head(tpair[tpair>1], sum(tpair>1)/2)
>
> pair.str
> 1.2 2.1 2.6 2.7
>  2   2   2   2
>
> --
> David.
>
>
>
> On Nov 15, 2009, at 8:06 PM, David Winsemius wrote:
>
>   I could of course be wrong but have you yet specified the number of
>> columns for this pairing exercise?
>>
>> On Nov 15, 2009, at 5:26 PM, cindy Guo wrote:
>>
>> Hi, All,
>>>
>>> I have an n by m matrix with each entry between 1 and 15000. I want to
>>> know
>>> the frequency of each pair in 1:15000 that occur together in rows. So for
>>> example, if the matrix is
>>> 2 5 1 6
>>> 1 7 8 2
>>> 3 7 6 2
>>> 9 8 5 7
>>> Pair (2,6) (un-ordered) occurs together in rows 1 and 3. I want to return
>>> the value 2 for this pair as well as that for all pairs. Is there a fast
>>> way
>>> to do this avoiding loops? Loops take too long.
>>>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>  ^^
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

[[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] pairs

2009-11-15 Thread cindy Guo
Hi, Charlie,

Thank you for the reply. Maybe I don't need the frequency of each pair. I
only need the top, say 50, pairs with the highest frequency. Is there anyway
which can avoid calculating for all the pairs?

Thanks,

Cindy
On Sun, Nov 15, 2009 at 4:18 PM, cls59  wrote:

>
>
>
> cindy Guo wrote:
> >
> > Hi, All,
> >
> > I have an n by m matrix with each entry between 1 and 15000. I want to
> > know
> > the frequency of each pair in 1:15000 that occur together in rows. So for
> > example, if the matrix is
> > 2 5 1 6
> > 1 7 8 2
> > 3 7 6 2
> > 9 8 5 7
> > Pair (2,6) (un-ordered) occurs together in rows 1 and 3. I want to return
> > the value 2 for this pair as well as that for all pairs. Is there a fast
> > way
> > to do this avoiding loops? Loops take too long.
> >
> > Thank you,
> >
> > Cindy
> >
>
> Use %in% to check for the presence of the numbers in a row and apply() to
> efficiently execute the test for each row:
>
>  tstMatrix <- matrix( c(2,5,1,6,
>1,7,8,2,
>3,7,6,2,
>9,8,5,7), nrow=4, byrow=T )
>
>  matches <- apply( tstMatrix, 1, function( row ){
>
>if( 2 %in% row & 6 %in% row ){
>
>  return( 2 )
>
>} else {
>
>  return( 0 )
>
>}
>
>  })
>
>  matches
>  [1] 2 0 2 0
>
> If you have more than one pair, it gets a little tricky.  Say you are also
> looking for the pair (7,8).  Store them as a list:
>
>  pairList <- list( c(2,6), c(7,8) )
>
> Then use sapply() to efficiently iterate over the pair list and execute the
> apply() test:
>
>  matchMatrix <- sapply( pairList, function( pair ){
>
>matches <- apply( tstMatrix, 1, function( row ){
>
>  if( pair[1] %in% row & pair[2] %in% row ){
>
>return( pair[1] )
>
>  } else {
>
>return( 0 )
>
>  }
>
>})
>
>return( matches )
>
>  })
>
>  matchMatrix
>
>   [,1] [,2]
>  [1,]20
>  [2,]07
>  [3,]20
>  [4,]07
>
>
>
> If you're looking to apply the above method to every possible permutation
> of
> 2 numbers that may be generated from the range of numbers 1:15000... that's
> 225,000,000 pairs. expand.grid() can generate the required pair list-- but
> that step alone causes a memory allocation of ~6 GB on my machine.
>
> If you don't have a pile of CPU cores and RAM at your disposal, you can
> probably:
>
>  1. Restrict the upper end of your range to the maximal entry present in
> your matrix since all other combinations have zero occurrences.
>
>  2. Break the list of pairs up into several sublists, run the tests, and
> aggregate the results.
>
> Either way, the analysis will take some time despite the efficiencies of
> the
> apply family of functions due to the shear size of the problem.  If you
> have
> more than one CPU, I would recommend taking a look at parallelized apply
> functions, perhaps using a package like snowfall,  as the testing of the
> pairs is an "embarrassingly parallel" problem.
>
> Hopefully I'm misunderstanding the scope of your problem.
>
>
> Good luck!
>
> -Charlie
>
> -
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University
> --
> View this message in context:
> http://old.nabble.com/pairs-tp26364801p26365206.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<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] pairs

2009-11-15 Thread cindy Guo
Hi, All,

I have an n by m matrix with each entry between 1 and 15000. I want to know
the frequency of each pair in 1:15000 that occur together in rows. So for
example, if the matrix is
2 5 1 6
1 7 8 2
3 7 6 2
9 8 5 7
Pair (2,6) (un-ordered) occurs together in rows 1 and 3. I want to return
the value 2 for this pair as well as that for all pairs. Is there a fast way
to do this avoiding loops? Loops take too long.

Thank you,

Cindy

[[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] SSVS

2009-09-14 Thread cindy Guo
Hi, ALL,

Is there any R/bioconductor package to do SSVS (stochastic search variable
selection) for glm?

Thanks,

Cindy

[[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] matrix power

2009-08-10 Thread cindy Guo
I think it may be important, but I am not sure. Actually I am trying to
program the adaptive nearest neighbor method proposed by Hastie and
Tibshirani. I am following the steps in the book 'The elements of
statistical learning' by Hastie, Tibshirani and Friedman, in which the local
metric is defined as W^(-1/2)[B*+I]W^(-1/2), where W is the pooled
within-class covariance matrix.
Cindy

On Mon, Aug 10, 2009 at 4:28 PM, Gabor Grothendieck  wrote:

> If its not important which of many solutions you use then
> the generalized inverse can be used, say.  Just use 0
> for each small eigenvalue and 1/sqrt(x) for the others.
>
> On Mon, Aug 10, 2009 at 6:36 PM, cindy Guo wrote:
> > Hi, Ted,
> >
> > Thanks for the sample code. It is exactly what I want. But can I ask
> another
> > question? The matrix for which I want the negative square root is a
> > covariance matrix. I suppose it should be positive definite, so I can do
> > 1/sqrt(V) as you wrote. But the covariance matrix I got in R using the
> > function cov has a lot of negative eigenvalues, like -5.338634e-17, so
> > 1/sqrt(V) generates NA's. Can you tell what's the problem here.
> >
> > Thanks,
> > Cindy
> >
> > On Mon, Aug 10, 2009 at 2:53 PM, Ted Harding
> > wrote:
> >
> >>  On 10-Aug-09 21:31:30, cindy Guo wrote:
> >> > Hi, All,
> >> > If I  have a symmetric matrix, how can I get the negative square root
> >> > of the matrx, ie. X^(-1/2) ?
> >> >
> >> > Thanks,
> >> >
> >> > Cindy
> >>
> >>  X <- matrix(c(2,1,1,2),nrow=2)
> >>  X
> >> #  [,1] [,2]
> >> # [1,]21
> >> # [2,]12
> >>
> >>  E <- eigen(X)
> >>  V <- E$values
> >>  Q <- E$vectors
> >>  Y <- Q%*%diag(1/sqrt(V))%*%t(Q)
> >>  Y
> >> #[,1]   [,2]
> >> # [1,]  0.7886751 -0.2113249
> >> # [2,] -0.2113249  0.7886751
> >>
> >>  solve(Y%*%Y)## i.e. find its inverse
> >> #  [,1] [,2]
> >> # [1,]21
> >> # [2,]12
> >>
> >> Hence (Y%*%Y)^(-1) = X, or Y = X^(-1/2)
> >>
> >> Hopingb this helps,
> >> Ted.
> >>
> >> 
> >> E-Mail: (Ted Harding) 
> >> Fax-to-email: +44 (0)870 094 0861
> >> Date: 10-Aug-09   Time: 22:53:25
> >> -- XFMail --
> >>
> >
> >[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] matrix power

2009-08-10 Thread cindy Guo
Hi, Dan,

Yes, this is what I want. Is there better way to solve this?

Cindy

On Mon, Aug 10, 2009 at 2:52 PM, Nordlund, Dan (DSHS/RDA) <
nord...@dshs.wa.gov> wrote:

>  > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
> > Behalf Of cindy Guo
> > Sent: Monday, August 10, 2009 2:32 PM
> > To: r-help@r-project.org
> > Subject: [R] matrix power
> >
> > Hi, All,
> >
> > If I  have a symmetric matrix, how can I get the negative square root of
> the
> > matrx, ie. X^(-1/2) ?
> >
> > Thanks,
> >
> > Cindy
> >
>
> Cindy,
>
> Just to be sure we are all on the same page.  Are saying you have a matrix
> X, and you want to find the a matrix A such that
>
> X = A %*% A
>
> And you want to then find the matrix inverse of A ?
>
> Dan
>
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA  98504-5204
>
>
> __
> 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] matrix power

2009-08-10 Thread cindy Guo
Hi, Ted,

Now I understand the problem. Thank you for the explanation. It's very
helpful. I appreciate it.

Cindy

On Mon, Aug 10, 2009 at 3:58 PM, Ted Harding
wrote:

> On 10-Aug-09 22:36:03, cindy Guo wrote:
> > Hi, Ted,
> > Thanks for the sample code. It is exactly what I want. But can
> > I ask another question? The matrix for which I want the negative
> > square root is a covariance matrix. I suppose it should be positive
> > definite, so I can do 1/sqrt(V) as you wrote. But the covariance
> > matrix I got in R using the function cov has a lot of negative
> > eigenvalues, like -5.338634e-17, so 1/sqrt(V) generates NA's. Can
> > you tell what's the problem here.
> >
> > Thanks,
> > Cindy
>
> Cindy,
> If that -5.338634e-17 is typical of the "lot of negative eigenvalues",
> then what you are seeing is the result of R's attempt to calculate
> zero eigenvalues, but defeated by the inevitable rounding errors.
> In other words, your covariance matrix is singular, and the variables
> involved are not linearly independent.
>
> The only thing that is guaranteed about a covariance matrix is that
> it is positive semi-definite (not positive definite); in other words
> all eigenvalues are positive or zero (mathematically).
>
> For example, if Y=X, var(X) = var(Y) = 1, then
>  cov(X,Y) =  1  1
>  1  1
> which is singular (eigenvalues = 2, 0).
>
> The result of attempting to compute them is subject to rounding errors,
> which (for zero eigenvalues) can be slightly negative.
>
> So the covariance matrix in your case would not have an inverse,
> still less a negative square root!
>
> The basic problem is that you have luinear dependence between the
> variables. To make progress, you would need to find a maximal linearly
> independent set (or possibly find the principal components with
> nozero weights).
>
> Ted.
>
> 
> E-Mail: (Ted Harding) 
> Fax-to-email: +44 (0)870 094 0861
> Date: 10-Aug-09   Time: 23:58:00
> -- XFMail --
>

[[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] matrix power

2009-08-10 Thread cindy Guo
Hi, Ted,

Thanks for the sample code. It is exactly what I want. But can I ask another
question? The matrix for which I want the negative square root is a
covariance matrix. I suppose it should be positive definite, so I can do
1/sqrt(V) as you wrote. But the covariance matrix I got in R using the
function cov has a lot of negative eigenvalues, like -5.338634e-17, so
1/sqrt(V) generates NA's. Can you tell what's the problem here.

Thanks,
Cindy

On Mon, Aug 10, 2009 at 2:53 PM, Ted Harding
wrote:

>  On 10-Aug-09 21:31:30, cindy Guo wrote:
> > Hi, All,
> > If I  have a symmetric matrix, how can I get the negative square root
> > of the matrx, ie. X^(-1/2) ?
> >
> > Thanks,
> >
> > Cindy
>
>  X <- matrix(c(2,1,1,2),nrow=2)
>  X
> #  [,1] [,2]
> # [1,]21
> # [2,]12
>
>  E <- eigen(X)
>  V <- E$values
>  Q <- E$vectors
>  Y <- Q%*%diag(1/sqrt(V))%*%t(Q)
>  Y
> #[,1]   [,2]
> # [1,]  0.7886751 -0.2113249
> # [2,] -0.2113249  0.7886751
>
>  solve(Y%*%Y)## i.e. find its inverse
> #  [,1] [,2]
> # [1,]21
> # [2,]12
>
> Hence (Y%*%Y)^(-1) = X, or Y = X^(-1/2)
>
> Hopingb this helps,
> Ted.
>
> 
> E-Mail: (Ted Harding) 
> Fax-to-email: +44 (0)870 094 0861
> Date: 10-Aug-09   Time: 22:53:25
> -- XFMail --
>

[[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] matrix power

2009-08-10 Thread cindy Guo
Hi, All,

If I  have a symmetric matrix, how can I get the negative square root of the
matrx, ie. X^(-1/2) ?

Thanks,

Cindy

[[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] nearest neighbors

2009-08-09 Thread cindy Guo
Hi, All,

I am wondering if there is any package which can give the index of the k
nearest neighbors.

Thank you,

Cindy

[[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] diagonal LDA and QDA

2009-08-01 Thread cindy Guo
Hi, all,

I am wondering if there is any package doing lda and qda which allows
assuming diagonal covariance matrices. I checked the lda function in MASS,
and it seems it does not support this.

Thanks,

Cindy

[[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] diagonal LDA and QDA

2009-08-01 Thread cindy Guo
Hi, all,

I am wondering if there is any package doing lda and qda which allows
assuming diagonal covariance matrices. I checked the lda function in MASS,
and it seems it does not support this.

Thanks,

Cindy

[[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] diagonal lda and qda

2009-08-01 Thread cindy Guo
Hi, all,

I am wondering if there is any package doing lda and qda which allows
assuming diagonal covariance matrices. I checked the lda function in MASS,
and it seems it does not support this.

Thanks,

Cindy

[[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] install package from CRAN

2009-07-28 Thread cindy Guo
Hi,

Thank you for asking. Actually I downloaded the tar.gz file as Mark said and
used R CMD INSTALL -l  .  package.tar.gz to install. I didn't know I can
download CRAN packages from the internet.

I am not a unix person, so I struggled a lot with the commands on unix and
directories especially. I don't know how to deal with it when I don't have
enough privilege.
Cindy



On Tue, Jul 28, 2009 at 7:33 PM, stephen sefick  wrote:

> What was the problem- out of curiosity?
>
> Stephen Sefick
>
> On Tue, Jul 28, 2009 at 9:23 PM, cindy Guo wrote:
> > Hi,
> >
> > Thank you for all your replies. I got it work now.
> >
> > Cindy
> >
> > On Tue, Jul 28, 2009 at 6:09 PM, Dirk Eddelbuettel 
> wrote:
> >
> >>
> >> Cindy,
> >>
> >> On 28 July 2009 at 17:15, cindy Guo wrote:
> >> | I have a very basic question about install packages from CRAN on unix.
> I
> >> | only installed on Windows before. Should I use the command
> >> install.package?
> >> | The error message I got is
> >> | syntax error near unexpected token `"mvtnorm"'
> >> | Is it because I didn't set the path? Which path should I specify?
> >>
> >> a)  You use install.packages() only from __inside R__. As you got an
> error
> >>from bash, you must have done this from the command prompt.
> >>
> >> b)  At the command prompt, use 'R CMD INSTALL mvtnorm' instead.
> >>
> >> In either case, you need proper permissions to install in global
> >> directories,
> >> so if you can run this, try either 'sudo R' to start R so that
> >> 'install.packages("mvtnorm")' will succeed, or use 'sudo R CMD INSTALL
> >> mvtnorm.
> >>
> >> Also, if you are on Debian / Ubuntu, you can do
> >>  sudo apt-get install r-cran-mvtnorm
> >> as we provide a prebuild version.
> >>
> >> Dirk
> >>
> >> --
> >> Three out of two people have difficulties with fractions.
> >>
> >
> >[[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.
> >
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>-K. Mullis
>

[[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] install package from CRAN

2009-07-28 Thread cindy Guo
Hi,

Thank you for all your replies. I got it work now.

Cindy

On Tue, Jul 28, 2009 at 6:09 PM, Dirk Eddelbuettel  wrote:

>
> Cindy,
>
> On 28 July 2009 at 17:15, cindy Guo wrote:
> | I have a very basic question about install packages from CRAN on unix. I
> | only installed on Windows before. Should I use the command
> install.package?
> | The error message I got is
> | syntax error near unexpected token `"mvtnorm"'
> | Is it because I didn't set the path? Which path should I specify?
>
> a)  You use install.packages() only from __inside R__. As you got an error
>from bash, you must have done this from the command prompt.
>
> b)  At the command prompt, use 'R CMD INSTALL mvtnorm' instead.
>
> In either case, you need proper permissions to install in global
> directories,
> so if you can run this, try either 'sudo R' to start R so that
> 'install.packages("mvtnorm")' will succeed, or use 'sudo R CMD INSTALL
> mvtnorm.
>
> Also, if you are on Debian / Ubuntu, you can do
>  sudo apt-get install r-cran-mvtnorm
> as we provide a prebuild version.
>
> Dirk
>
> --
> Three out of two people have difficulties with fractions.
>

[[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] install package from CRAN

2009-07-28 Thread cindy Guo
Hi, Steve,

Thanks for the response.

I did the same thing:
 install.packages('mvtnorm')
-bash: syntax error near unexpected token `'mvtnorm''

I think what may cause difference is that I am using a unix cluster of my
university, so I am not the administrator. Do I need to set the path?

Cindy


On Tue, Jul 28, 2009 at 5:31 PM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 28, 2009, at 8:15 PM, cindy Guo wrote:
>
> Hi,
>>
>> I have a very basic question about install packages from CRAN on unix. I
>> only installed on Windows before. Should I use the command
>> install.package?
>> The error message I got is
>> syntax error near unexpected token `"mvtnorm"'
>> Is it because I didn't set the path? Which path should I specify?
>>
>
>
> You should use install.packages (note the last "s")... how did you call
> that function to get that error you are showing us?
>
> It looks like you're trying to install the 'mvtnorm' package, and you'd do
> so like this:
>
> install.packages('mvtnorm')
>
> Is that what you did?
>  -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
>
>

[[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] install package from CRAN

2009-07-28 Thread cindy Guo
Hi,

I have a very basic question about install packages from CRAN on unix. I
only installed on Windows before. Should I use the command install.package?
The error message I got is
syntax error near unexpected token `"mvtnorm"'
Is it because I didn't set the path? Which path should I specify?

Thanks,

Cindy

[[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] local regression using loess

2009-07-28 Thread cindy Guo
Bert, Ryan, Alain,

You suggestions are very helpful. Thank you. I learned a lot from the
discussion.

Cindy

On Tue, Jul 28, 2009 at 8:53 AM, Ryan  wrote:

> Bert Gunter  gene.com> writes:
>
> >
> >
> > Actually, loess is much more than an "interpolant".  I wouldn't
> > even call it that.  It is a local regression  technique that comes
> > with all the equipment you get in classical regression.  But it
> > is meant for normal-like errors, which is not what you have.
> >
>
>
> Bert - when I hear "interpolate", I think of connecting the
> data points, like using something like divided differences
> or hermite interpolation, so I thought that's what you
> meant.  Sorry for the misunderstanding.
>
> True that loess was designed to be robust, but when I
> said it is meant for normal-like errors, I was referring
> to loess with statistical procedures analagous to the
> classical regression setting, such as confidence intervals,
> anova, etc. (see "Locally Weighted Regression: An
> Approach to Regression Analysis by Local Fitting", 1988).
>
> __
> 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] local regression using loess

2009-07-27 Thread cindy Guo
Hi, Ryan,

Thank you for the information. I tried it. But there are some error
messages.

When I use fit <- locfit(Y~X1*X2,family='binomial'), the error message is
error lfproc(x, y, weights = weights, cens = cens, base = base, geth =
geth,  :
  compparcomp: parameters out of bounds

And when I use fit <- locfit(Y~X1*X2), the error message is
error lfproc(x, y, weights = weights, cens = cens, base = base, geth =
geth,  :
  newsplit: out of vertex space

This happens sometimes, not every time for different data. Do you know
what's the reason?

Thank you,

Cindy

On Mon, Jul 27, 2009 at 5:25 PM, Ryan  wrote:

> > >
> > > Hi, All,
> > >
> > > I have a dataset with binary response ( 0 and 1) and some numerical
> > > covariates. I know I can use logistic regression to fit the data. But I
> > > want
> > > to consider more locally. So I am wondering how can I fit the data with
> > > 'loess' function in R? And what will be the response: 0/1 or the
> > > probability
> > > in either group like in logistic regression?
> > >
> > > -- Neither. Loess is an algorithm that smoothly "interpolates" the
> data. It
> > > makes no claim of modeling the probability for a binary response
> variable.
> > >
> > > -- Bert Gunter
> > > Genentech Nonclinical Statistics
> > >
> > > Thank you,
> > > Cindy
> > >
> > >[[alternative HTML version deleted]]
> > >
>
> Actually, loess is much more than an "interpolant".  I wouldn't
> even call it that.  It is a local regression  technique that comes
> with all the equipment you get in classical regression.  But it
> is meant for normal-like errors, which is not what you have.
>
> I would recommend that you take a look at the locfit package.
> It fits local likelihood models.  I've never tried it with binary data,
> but if y is your 0/1 response and x is a covariate, you might try
> something like:
>
> locfit(y ~ x, ..., family="binomial")
>
> If you have a good library at your disposal, try picking up Loader's
> book "Local Regression and Likelihood".
>
> __
> 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] local regression using loess

2009-07-27 Thread cindy Guo
Hi, Bert,

Thanks for the response. But then in this case, can I use loess to fit the
data? If yes, then how to interpret the results?

Cindy

On Mon, Jul 27, 2009 at 4:32 PM, Bert Gunter  wrote:

>  -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
> Behalf Of cindy Guo
> Sent: Monday, July 27, 2009 4:06 PM
> To: r-help@r-project.org
> Subject: [R] local regression using loess
>
> Hi, All,
>
> I have a dataset with binary response ( 0 and 1) and some numerical
> covariates. I know I can use logistic regression to fit the data. But I
> want
> to consider more locally. So I am wondering how can I fit the data with
> 'loess' function in R? And what will be the response: 0/1 or the
> probability
> in either group like in logistic regression?
>
> -- Neither. Loess is an algorithm that smoothly "interpolates" the data. It
> makes no claim of modeling the probability for a binary response variable.
>
> -- Bert Gunter
> Genentech Nonclinical Statistics
>
> Thank you,
> Cindy
>
>[[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
and provide commented, minimal, self-contained, reproducible code.


[R] local regression using loess

2009-07-27 Thread cindy Guo
Hi, All,

I have a dataset with binary response ( 0 and 1) and some numerical
covariates. I know I can use logistic regression to fit the data. But I want
to consider more locally. So I am wondering how can I fit the data with
'loess' function in R? And what will be the response: 0/1 or the probability
in either group like in logistic regression?

Thank you,
Cindy

[[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] normal mixture model

2009-07-27 Thread cindy Guo
Hi, Christian,

Yes, it works. Thank you very much. It's really helpful.

Cindy

On Mon, Jul 27, 2009 at 5:39 AM, Christian Hennig wrote:

> Hi Cindy,
>
> you need the summary function
>
>> mclustsummary <- summary(mclustBICoutputobject,data)
>>
> to get all the information. Some (like best model) is given if you just
> print out the summary object. Some other information (like estimated
> parameter values) are accessible as components of the summary object, like
> mclustsummary$parameters$...
> Try
>
>> str(mclustsummary)
>>
> to see what's there (unfortunately this is not fully documented).
>
> For more detail see the help pages.
>
> Hope this helps,
>
> Christian
>
> On Sun, 26 Jul 2009, cindy Guo wrote:
>
>   Hi, Christian,
>>
>> Thank you for the reply. I just tried. Does the function mclustBIC only
>> give
>> the best model, or does it also do EM to get the cluster means and
>> variances
>> according to the best model it picks? I didn't find it.  Is there a way to
>> automatically select the best number of components and do EM? Because I
>> need
>> to do the normal mixture model in a loop (one EM at an iteration), so I
>> want
>> it to do everything automatically.
>> Thanks,
>>
>> Cindy
>>
>> On Sun, Jul 26, 2009 at 3:46 PM, Christian Hennig > >wrote:
>>
>>   You can use mclustBIC in package mclust (uses the BIC for deciding
>>> about
>>> the number of components and hierarchical clustering for initialisation).
>>>
>>> Christian
>>>
>>>
>>> On Sun, 26 Jul 2009, cindy Guo wrote:
>>>
>>>  Hi, All,
>>>
>>>>
>>>> I want to fit a normal mixture model. Which package in R is best for
>>>> this?
>>>> I
>>>> was using the package 'mixdist', but I need to group the data into
>>>> groups
>>>> before fitting model, and different groupings seem to lead to different
>>>> results. What other package can I use which is stable? And are there
>>>> packages that can automatically determine the number of components?
>>>>
>>>> Thank you,
>>>>
>>>> Cindy
>>>>
>>>>   [[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>
>>>> <http://www.r-project.org/posting-guide.html>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>>
>>>> *** --- ***
>>> Christian Hennig
>>> University College London, Department of Statistical Science
>>> Gower St., London WC1E 6BT, phone +44 207 679 1698
>>> chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche
>>>
>>>
>>
> *** --- ***
> Christian Hennig
> University College London, Department of Statistical Science
> Gower St., London WC1E 6BT, phone +44 207 679 1698
> chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche
>

[[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] normal mixture model

2009-07-26 Thread cindy Guo
Hi, Christian,

Thank you for the reply. I just tried. Does the function mclustBIC only give
the best model, or does it also do EM to get the cluster means and variances
according to the best model it picks? I didn't find it.  Is there a way to
automatically select the best number of components and do EM? Because I need
to do the normal mixture model in a loop (one EM at an iteration), so I want
it to do everything automatically.
Thanks,

Cindy

On Sun, Jul 26, 2009 at 3:46 PM, Christian Hennig wrote:

> You can use mclustBIC in package mclust (uses the BIC for deciding about
> the number of components and hierarchical clustering for initialisation).
>
> Christian
>
>
> On Sun, 26 Jul 2009, cindy Guo wrote:
>
>   Hi, All,
>>
>> I want to fit a normal mixture model. Which package in R is best for this?
>> I
>> was using the package 'mixdist', but I need to group the data into groups
>> before fitting model, and different groupings seem to lead to different
>> results. What other package can I use which is stable? And are there
>> packages that can automatically determine the number of components?
>>
>> Thank you,
>>
>> Cindy
>>
>>[[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.
>>
>>
> *** --- ***
> Christian Hennig
> University College London, Department of Statistical Science
> Gower St., London WC1E 6BT, phone +44 207 679 1698
> chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche
>

[[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] normal mixture model

2009-07-26 Thread cindy Guo
Hi, All,

I want to fit a normal mixture model. Which package in R is best for this? I
was using the package 'mixdist', but I need to group the data into groups
before fitting model, and different groupings seem to lead to different
results. What other package can I use which is stable? And are there
packages that can automatically determine the number of components?

Thank you,

Cindy

[[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] mixdist package in R

2009-07-26 Thread cindy Guo
Hi, All,

I fitted a 3-component normal mixture model with the mixdist package in R.
How can I get the density of a new data after I fit the model? Is there any
function to do it?

Thanks,

Cindy

[[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] question about mean

2009-02-08 Thread cindy Guo
Hello, everyone,

I have a matrix like following:

school  value
A  .1
A  .2
A  .15
A  .2
B  .3
B  .5
C  .3
C  .3
C  .4
C  .5
C  .6
C  .9
C  1

I want to get the mean 'value' for each 'school', but each school has
different length. Is there any way to do this fast? Because my data has
hundreds of thousands of rows.

Thank you,

Cindy

[[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] how to call a C-library in R

2008-08-23 Thread cindy Guo
Hi, everyone,

I need to use a C library. But since I have little experience in C, I want
to call this C library in R and program the rest in R. Does anyone know how
to do this?

Thanks,

Cindy

[[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] R-package install

2008-07-25 Thread cindy Guo
Thank you, Brian and Mark,

I tried the win-builder on http://win-builder.r-project.org/. Is this what
you mean? I uploaded the source code, and I didn't get any email after
couple of hours. It should arrive after half an hour, as it is said on the
webpage. Do you know what can happen?

Cindy


On 7/25/08, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>
> We write manuals so that you can know how to do things in R.  Package
> installation is covered in the 'R Installation and Administration' manual.
>
> We don't have the attachment, but assuming this was a source package I
> sugest you look into Uwe Ligges' win-builder service mentioned in that
> manual (and in 'Writing R Extensions').
>
> On Thu, 24 Jul 2008, cindy Guo wrote:
>
> Hi, Mark,
>> Thank you for your response.
>> No, I don't know how to compile it. Do I need to use unix to compile?
>> After
>> compiling, can I use it in Windows R?
>> Attached is the package.
>> Cindy
>>
>>
>> On 7/24/08, Mark Difford <[EMAIL PROTECTED]> wrote:
>>
>>>
>>>
>>> Hi Cindy,
>>>
>>>  Hi, I have a R package, which is a .tar.tar file. And it is said to be
>>>>> source code for all
>>>>> platforms. ... I am wondering if I can use this package in Windows R.
>>>>>
>>>>
>>> If it is source code you would first need to compile it to binary format
>>> before you can use it. Can you do that?
>>>
>>> Which package is it?
>>>
>>> Regards, Mark.
>>>
>>>
>>> cindy Guo wrote:
>>>
>>>>
>>>> Hi, I have a R package, which is a .tar.tar file. And it is said to be
>>>> source code for all platforms. And the author said it should install on
>>>> any
>>>> system (but he didn't know about Windows). I am wondering if I can use
>>>> this
>>>> package in Windows R.
>>>> Thank you,
>>>> Cindy
>>>>
>>>>  [[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.
>>>>
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/R-package-install-tp18636993p18639516.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<http://www.r-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
> --
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>

[[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] R-package install

2008-07-24 Thread cindy Guo
Hi, Mark,
Thank you for your response.
No, I don't know how to compile it. Do I need to use unix to compile? After
compiling, can I use it in Windows R?
Attached is the package.
Cindy


On 7/24/08, Mark Difford <[EMAIL PROTECTED]> wrote:
>
>
> Hi Cindy,
>
> >> Hi, I have a R package, which is a .tar.tar file. And it is said to be
> >> source code for all
> >> platforms. ... I am wondering if I can use this package in Windows R.
>
> If it is source code you would first need to compile it to binary format
> before you can use it. Can you do that?
>
> Which package is it?
>
> Regards, Mark.
>
>
> cindy Guo wrote:
> >
> > Hi, I have a R package, which is a .tar.tar file. And it is said to be
> > source code for all platforms. And the author said it should install on
> > any
> > system (but he didn't know about Windows). I am wondering if I can use
> > this
> > package in Windows R.
> > Thank you,
> > Cindy
> >
> >   [[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.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/R-package-install-tp18636993p18639516.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.


[R] R-package install

2008-07-24 Thread cindy Guo
Hi, I have a R package, which is a .tar.tar file. And it is said to be
source code for all platforms. And the author said it should install on any
system (but he didn't know about Windows). I am wondering if I can use this
package in Windows R.
Thank you,
Cindy

[[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] truncated normal

2008-07-23 Thread cindy Guo
Hi, I want to generate random samples from truncated normal say
Normal(0,1)Indicator((0,1),(2,4)). It has more than one intervals. In the
library msm, it seems to me that the 'lower' and 'upper' arguments can only
be a number. I tried rtnorm(1,mean=0,sd=1, lower=c(0,2),upper=c(1,4)) and it
didn't work. Can you tell me  how I can do truncated normal at more than one
intervals?
Thank you.

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