Post e(b) vector from a custom program in Stata

Robert Aue

I wrote a program that computes a weighted regression and now I want my estimation results to be stored as an e(b) vector so that the bootstrap command can easily access the results, but I keep getting an error. My program looks like:

capture program drop mytest
program mytest, eclass
version 13
syntax varlist [if]
marksample touse
// mata subroutine creates matrix `b', such as mata: bla("`varlist'", "`touse'")
tempname b
matrix `b' = (1\2\3)
ereturn post `b'
end 

mytest town_id
ereturn list

But I keep getting a conformability error r(503); upon running the script. When I instead post an ordinary matrix such as ereturn matrix x = b, everything works fine but I would like to have my coefficients stored 'properly' in an e(b) vector.

I checked Stata's documentation but was unable to find out why this is not working. Their advice is to code

tempname b V
// produce coefficient vector `b' and variance–covariance matrix `V'
ereturn post `b' `V', obs(`nobs') depname(`depn') esample(`touse')

The options of ereturn post are all optional. Could anyone tell me what I am missing here? Thanks!

Roberto Ferrer

Use a "row" vector instead of a "column" vector. If you check, for example, the stored results of regress, you'll see that this is what is expected.

capture program drop mytest
program mytest, eclass
version 13
syntax varlist [if]
marksample touse
// mata subroutine creates matrix `b', such as mata: bla("`varlist'", "`touse'")
tempname b
matrix `b' = (1,2,3)
ereturn post `b'
end 

*----- tests -----

clear
sysuse auto

// mytest test
mytest mpg weight
ereturn list
matrix list e(b)

// regress example
regress price weight mpg
ereturn list
matrix list e(b)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Creating a vector with unique observations from a variable in Stata

From Dev

Arrays / Vector equivalent in Stata

From Dev

Vector of object from a custom class

From Dev

Stata: using local variables to build a program in Stata

From Dev

shortcode from Custom post in wordpress

From Dev

Displaying a custom post from a custom taxonomy

From Dev

Stata: Custom format for stats() in esttab

From Dev

Custom headers when using AWS EB Worker

From Dev

Custom headers when using AWS EB Worker

From Dev

Is there a program to create icon resources or all resolutions from vector image for android?

From Dev

Display contents from custom post type in Wordpress

From Dev

Get an ACF custom field from an adjacent post

From Dev

Unregister custom post type from Wordpress

From Dev

Display contents from custom post type in Wordpress

From Dev

Get title from wordpress custom post type

From Dev

Fetch category from custom post type

From Dev

ACF - Getting a gallery from a Custom Post Type

From Dev

Exclude Posts of a Term From a Custom Post Type

From Dev

Exclude children of custom post type from search

From Dev

Vector of Vector with custom class

From Dev

How to hide Permalink section from a Custom Post Type's post?

From Dev

Wordpress: Display content from a Custom Post Type within a regular Post

From Dev

How to get the all post from two custom post types?

From Dev

WordPress > Get custom taxonomy from a custom post type

From Dev

How to get the custom category slug and id from custom post type?

From Dev

Wordpress - custom post types with custom fields, gone from admin menu

From Dev

Show Custom Field From Custom Post Type In Template

From Dev

How can I remove duplicates from a vector of custom structs?

From Dev

How to make custom plot symbols from vector graphics in R

Related Related

  1. 1

    Creating a vector with unique observations from a variable in Stata

  2. 2

    Arrays / Vector equivalent in Stata

  3. 3

    Vector of object from a custom class

  4. 4

    Stata: using local variables to build a program in Stata

  5. 5

    shortcode from Custom post in wordpress

  6. 6

    Displaying a custom post from a custom taxonomy

  7. 7

    Stata: Custom format for stats() in esttab

  8. 8

    Custom headers when using AWS EB Worker

  9. 9

    Custom headers when using AWS EB Worker

  10. 10

    Is there a program to create icon resources or all resolutions from vector image for android?

  11. 11

    Display contents from custom post type in Wordpress

  12. 12

    Get an ACF custom field from an adjacent post

  13. 13

    Unregister custom post type from Wordpress

  14. 14

    Display contents from custom post type in Wordpress

  15. 15

    Get title from wordpress custom post type

  16. 16

    Fetch category from custom post type

  17. 17

    ACF - Getting a gallery from a Custom Post Type

  18. 18

    Exclude Posts of a Term From a Custom Post Type

  19. 19

    Exclude children of custom post type from search

  20. 20

    Vector of Vector with custom class

  21. 21

    How to hide Permalink section from a Custom Post Type's post?

  22. 22

    Wordpress: Display content from a Custom Post Type within a regular Post

  23. 23

    How to get the all post from two custom post types?

  24. 24

    WordPress > Get custom taxonomy from a custom post type

  25. 25

    How to get the custom category slug and id from custom post type?

  26. 26

    Wordpress - custom post types with custom fields, gone from admin menu

  27. 27

    Show Custom Field From Custom Post Type In Template

  28. 28

    How can I remove duplicates from a vector of custom structs?

  29. 29

    How to make custom plot symbols from vector graphics in R

HotTag

Archive