Michael
2006-Feb-27 10:32 UTC
[R] how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
Hi all, Could anybody recommend some easy-to-understand and example based notes/tutorials on how to use cubic splines to do filtering on multi-dimension data? I am confused by the 1-dimensional case, and more confused by multi-dimensional case. I found all the books suddenly become very abstract when it comes to this subject. They don't provide examples in R or Splus at all. Specifically, I don't know how to provide data "x" to the "ns" function in R, and I don't understand what should be the output matrix, and how to use the output matrix to "filter" data? Books mention about basis matrix, design matrix, model matrix, data matrix, etc. I got lost. I presume the output of the "ns" function in R is "basis matrix", but then how do I use it? How to form tensor-product? I don't understand it at all. Please help me! Thank you very much! [[alternative HTML version deleted]]
vito muggeo
2006-Feb-27 12:17 UTC
[R] how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
Dear Micheal, > the output of the "ns" function in R is "basis matrix", but then Yes you are right, the output of the ns(x, df) is the basis matrix of a natural cubic spline with df degrees of freedom. See ?ns (in package splines) on how to specify df or knots or .. Fitting y~ns(x,df) yields a smooth curve given by a linear combination of the basis functions (the single colums of the basis matrix) by the estimated coefficients (returned by the fitted model). As far as I know, a tensor product is usually employed to multidimensional smoothing and the multidimensional basis is formed via the kronecker product of the marginal bases. Finally, last but not least: Probably you need some statistical backaground on spline fitting.. Please, read some statistical papers/books on such topic (for instance see references in packages splines, mgcv) best, vito Michael wrote:> Hi all, > > Could anybody recommend some easy-to-understand and example based > notes/tutorials on how to use cubic splines to do filtering on > multi-dimension data? > > I am confused by the 1-dimensional case, and more confused by > multi-dimensional case. > > I found all the books suddenly become very abstract when it comes to this > subject. > > They don't provide examples in R or Splus at all. > > Specifically, I don't know how to provide data "x" to the "ns" function in > R, > > and I don't understand what should be the output matrix, and how to use the > output matrix to "filter" data? > > Books mention about basis matrix, design matrix, model matrix, data matrix, > etc. I got lost. > > I presume the output of the "ns" function in R is "basis matrix", but then > how do I use it? How to form tensor-product? > > I don't understand it at all. > > Please help me! > > Thank you very much! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- ===================================Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Universit?? di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612
Liaw, Andy
2006-Feb-27 21:47 UTC
[R] how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
If you do not understand what ns() outputs, nor descriptions of splines in books, perhaps it's not an appropriate tool for you. Look for something that you understand (or can understand after some reading). No one is pointing a gun to your head and tell you to use splines, I hope. If you have a hard time understanding what you read in books, it's unrealistic to expect a mailing list about a software to teach you. Andy From: Michael> > Have you seen an example on how to do it in R? I found no practical > examples... > > On 2/27/06, vito muggeo <vmuggeo at dssm.unipa.it> wrote: > > > > Dear Micheal, > > > > > the output of the "ns" function in R is "basis matrix", but then > > Yes you are right, the output of the ns(x, df) is the basis > matrix of a > > natural cubic spline with df degrees of freedom. See ?ns (in package > > splines) on how to specify df or knots or .. > > > > Fitting y~ns(x,df) yields a smooth curve given by a linear > combination > > of the basis functions (the single colums of the basis > matrix) by the > > estimated coefficients (returned by the fitted model). > > > > As far as I know, a tensor product is usually employed to > > multidimensional smoothing and the multidimensional basis > is formed via > > the kronecker product of the marginal bases. > > > > Finally, last but not least: Probably you need some statistical > > backaground on spline fitting.. > > Please, read some statistical papers/books on such topic > (for instance > > see references in packages splines, mgcv) > > > > best, > > vito > > > > Michael wrote: > > > Hi all, > > > > > > Could anybody recommend some easy-to-understand and example based > > > notes/tutorials on how to use cubic splines to do filtering on > > > multi-dimension data? > > > > > > I am confused by the 1-dimensional case, and more confused by > > > multi-dimensional case. > > > > > > I found all the books suddenly become very abstract when > it comes to > > this > > > subject. > > > > > > They don't provide examples in R or Splus at all. > > > > > > Specifically, I don't know how to provide data "x" to the > "ns" function > > in > > > R, > > > > > > and I don't understand what should be the output matrix, > and how to use > > the > > > output matrix to "filter" data? > > > > > > Books mention about basis matrix, design matrix, model > matrix, data > > matrix, > > > etc. I got lost. > > > > > > I presume the output of the "ns" function in R is "basis > matrix", but > > then > > > how do I use it? How to form tensor-product? > > > > > > I don't understand it at all. > > > > > > Please help me! > > > > > > Thank you very much! > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > R-help at stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > > > > -- > > ===================================> > Vito M.R. Muggeo > > Dip.to Sc Statist e Matem `Vianelli' > > Universit?? di Palermo > > viale delle Scienze, edificio 13 > > 90128 Palermo - ITALY > > tel: 091 6626240 > > fax: 091 485726/485612 > > ===================================> > > > [[alternative HTML version deleted]] > >
Liaw, Andy
2006-Feb-28 03:46 UTC
[R] how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?
You want something more useful, here are a couple: Prof. David Ruppert has some slides from his talks that contain quite simple explanations of how regression splines work. I'll also say one thing that I've said on this list before: Get a copy of Prof. Harrell's Regression Modeling Strategies, and read it over and over until you can memorize it backward. Andy -----Original Message----- From: Michael [mailto:comtech.usa@gmail.com] Sent: Monday, February 27, 2006 5:31 PM To: Liaw, Andy Cc: vito muggeo; R-help@stat.math.ethz.ch Subject: Re: [R] how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering? I think you mis-understood. And perhaps you read in a haste, or you were just in a bad mood today. I think on this mailing-list, many people come for help on a R related issue, they know something theoretically, but since they are new to R, they want to use R, they want to use R to help do applied things. For me, there is a missing link between my understanding of splines from the books(which are abstract) and a usage example in R. That's something I am looking for. I believe it is very appropriate. If you don't know, or don't want to say anything helpful, please just don't say anything. It is not about a gun pointing, it is about a learning process which is very specific to R. Please kindly try not to say negative things, and try to discourage people from learning new things. On 2/27/06, Liaw, Andy < andy_liaw@merck.com <mailto:andy_liaw@merck.com> > wrote: If you do not understand what ns() outputs, nor descriptions of splines in books, perhaps it's not an appropriate tool for you. Look for something that you understand (or can understand after some reading). No one is pointing a gun to your head and tell you to use splines, I hope. If you have a hard time understanding what you read in books, it's unrealistic to expect a mailing list about a software to teach you. Andy From: Michael> > Have you seen an example on how to do it in R? I found no practical > examples... > > On 2/27/06, vito muggeo <vmuggeo@dssm.unipa.it<mailto:vmuggeo@dssm.unipa.it> > wrote:> > > > Dear Micheal, > > > > > the output of the "ns" function in R is "basis matrix", but then > > Yes you are right, the output of the ns(x, df) is the basis > matrix of a > > natural cubic spline with df degrees of freedom. See ?ns (in package > > splines) on how to specify df or knots or .. > > > > Fitting y~ns(x,df) yields a smooth curve given by a linear > combination > > of the basis functions (the single colums of the basis > matrix) by the > > estimated coefficients (returned by the fitted model). > > > > As far as I know, a tensor product is usually employed to > > multidimensional smoothing and the multidimensional basis > is formed via > > the kronecker product of the marginal bases. > > > > Finally, last but not least: Probably you need some statistical > > backaground on spline fitting.. > > Please, read some statistical papers/books on such topic > (for instance > > see references in packages splines, mgcv) > > > > best, > > vito > > > > Michael wrote: > > > Hi all, > > > > > > Could anybody recommend some easy-to-understand and example based > > > notes/tutorials on how to use cubic splines to do filtering on > > > multi-dimension data? > > > > > > I am confused by the 1-dimensional case, and more confused by > > > multi-dimensional case. > > > > > > I found all the books suddenly become very abstract when > it comes to > > this > > > subject. > > > > > > They don't provide examples in R or Splus at all. > > > > > > Specifically, I don't know how to provide data "x" to the > "ns" function > > in > > > R, > > > > > > and I don't understand what should be the output matrix, > and how to use > > the > > > output matrix to "filter" data? > > > > > > Books mention about basis matrix, design matrix, model > matrix, data > > matrix, > > > etc. I got lost. > > > > > > I presume the output of the "ns" function in R is "basis > matrix", but > > then > > > how do I use it? How to form tensor-product? > > > > > > I don't understand it at all. > > > > > > Please help me! > > > > > > Thank you very much! > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > R-help@stat.math.ethz.ch <mailto:R-help@stat.math.ethz.ch> mailinglist> > > https://stat.ethz.ch/mailman/listinfo/r-help<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>> > > > > > > -- > > ===================================> > Vito M.R. Muggeo > > Dip.to <http://Dip.to> Sc Statist e Matem `Vianelli' > > Universitä½® di Palermo > > viale delle Scienze, edificio 13 > > 90128 Palermo - ITALY > > tel: 091 6626240 > > fax: 091 485726/485612 > > ===================================> > > > [[alternative HTML version deleted]] > >---------------------------------------------------------------------------- -- Notice: This e-mail message, together with any attachments,...{{dropped}}