Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: nonfactorial combinations with -margins-
From
Richard Williams <[email protected]>
To
[email protected], "[email protected]" <[email protected]>
Subject
Re: st: nonfactorial combinations with -margins-
Date
Thu, 01 Aug 2013 15:01:53 -0500
What is with the numbers on at1 and at2? Is this what you want?
margins, at(headroom = 2.4 weight = 2000 length = 150 ) at(headroom =
3.6 weight = 3000 length = 200 )
At 01:29 PM 8/1/2013, Feiveson, Alan H. (JSC-SK311) wrote:
Hi - In Stata 13, I've been struggling with getting -margins- to
produce arbitrary combinations of several predictors without
creating a huge list of all possible combinations.
Example:
. sysuse auto,clear
(1978 Automobile Data)
. reg price headroom weight length
Source | SS df MS Number of
obs = 74
-------------+------------------------------ F( 3, 70) = 13.23
Model | 229789847 3 76596615.8 Prob >
F = 0.0000
Residual
| 405275549 70 5789650.7 R-squared = 0.3618
-------------+------------------------------ Adj R-squared = 0.3345
Total | 635065396 73 8699525.97 Root
MSE = 2406.2
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95%
Conf. Interval]
-------------+----------------------------------------------------------------
headroom
| -486.4429 388.7626 -1.25 0.215 -1261.806 288.9197
weight
| 4.674047 1.118074 4.18 0.000 2.444119 6.903975
length
| -87.59202 39.88962 -2.20 0.031 -167.1494 -8.034676
_cons
| 9969.584 4304.018 2.32 0.023 1385.49 18553.68
------------------------------------------------------------------------------
Suppose I want to get predictions at only two combinations of these
three predictors:(headroom = 2.4, weight = 2000, length = 150) and
(headroom = 3.6, weight = 3000, length = 200). But if I specify
. margins,at(headroom = (2.4 3.6) weight = (2000 3000) length = (150 200) )
Adjusted predictions Number of obs = 74
Model VCE : OLS
Expression : Linear prediction, predict()
1._at : headroom = 2.4
weight = 2000
length = 150
2._at : headroom = 2.4
weight = 2000
length = 200
3._at : headroom = 2.4
weight = 3000
length = 150
4._at : headroom = 2.4
weight = 3000
length = 200
5._at : headroom = 3.6
weight = 2000
length = 150
6._at : headroom = 3.6
weight = 2000
length = 200
7._at : headroom = 3.6
weight = 3000
length = 150
8._at : headroom = 3.6
weight = 3000
length = 200
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. t P>|t| [95%
Conf. Interval]
-------------+----------------------------------------------------------------
_at |
1 | 5011.412 616.6852 8.13 0.000 3781.473
6241.352
2 | 631.8115 1654.47 0.38 0.704 -2667.925
3931.548
3 | 9685.46 1488.435 6.51 0.000 6716.87
12654.05
4 | 5305.859 655.2722 8.10 0.000 3998.959
6612.758
5 | 4427.681 810.5569 5.46 0.000 2811.076
6044.286
6 | 48.0801 1620.927 0.03 0.976 -3184.757
3280.917
7 | 9101.728 1584.549 5.74 0.000 5941.445
12262.01
8 | 4722.127 581.5246 8.12 0.000 3562.313
5881.941
------------------------------------------------------------------------------
I get all 8 combinations of these three variables at two values
each, yet I only care about two of them. Clearly this can get out of
hand if there are lots of predictors or values in these lists.
What I would like is something like
. margins,at1(headroom = 2.4 weight = 2000 length = 150 )
at2(headroom = 3.6 weight = 3000 length = 200 )
but this is not allowed.
Is there a syntax for doing what I want that I have overlooked?
Thanks
Al Feiveson
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
WWW: http://www.nd.edu/~rwilliam
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/