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/