Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Display spline knots with xline?


From   Ben Jann <[email protected]>
To   [email protected]
Subject   Re: st: Display spline knots with xline?
Date   Wed, 28 Jan 2009 12:49:04 +0100

How about:

sysuse auto
mkspline smpg=mpg, nknots(7) displayknots cubic
matrix list r(knots)
mata: st_local("knots", mm_invtokens(strofreal(st_matrix("r(knots)"))))
scatter price mpg, xline(`knots')

-moremata- is required. Type -ssc install moremata-.
ben

On Wed, Jan 28, 2009 at 12:13 PM, Claus Dethlefsen
<[email protected]> wrote:
> Dear list
>
> Using cubic splines, I would like to display the knots used. In Stata
> 10, I can use mkspline to create the spline variables and it returns
> the values of the knots in a matrix. I would like to transfer this
> matrix in a nice way to my scatter plot command as the xline argument.
> Example:
>
>
> sysuse auto
> mkspline smpg=mpg, nknots(7) displayknots cubic
> matrix list r(knots)
>
>
> scatter price mpg, xline(14         16         18         20
> 23         26         31)
>                                   ^ here I would like to write
> r(knots) instead of copy-pasting the values
>
> Best regards,
> Claus
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index