Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: mkspline and reg


From   "stata_user stata_user" <[email protected]>
To   [email protected]
Subject   RE: st: RE: mkspline and reg
Date   Wed, 01 Nov 2006 21:37:05 +0000

Thanks Maarten,
Your comments are useful, and graphics allow to visualize nicely the results

I think for the example that you propose it will be better to consider
gen mpg1b = mpg1 - 20

This will allow to interpret the intercept as the average value of price for mpg=20 and foreign, this important because we include an interaction term

Regards

Sami



From: "Maarten Buis" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: st: RE: mkspline and reg
Date: Wed, 1 Nov 2006 10:21:58 +0100h

Sami:
One way to see if your approach makes sense is to create predicted values, graph tem and
see if they make sense, like in the example below. I think it follows your procedure and the
graphs look fine.

HTH,
Maarten

*-------------- begin example ------------
sysuse auto, clear
mkspline mpg1 20 mpg2=mpg

gen forXmpg1 = foreign*mpg1
gen forXmpg2 = foreign*mpg2
reg price mpg1 mpg2 forXmpg1 forXmpg2 foreigngen mpg1b = mpg1 - 12

predict pricehat1
twoway line pricehat1 mpg if foreign==0, sort || /*
*/ line pricehat1 mpg if foreign==1, sort /*
*/ ytitle("predicted price") name(a) /*
*/ legend(label(1 "domestic") label(2 "foreign"))


gen forXmpg1b = foreign*mpg1b
reg price mpg1b mpg2 forXmpg1b forXmpg2 foreign

predict pricehat2
twoway line pricehat2 mpg if foreign==0, sort || /*
*/ line pricehat2 mpg if foreign==1, sort /*
*/ ytitle("predicted price") name(b) /*
*/ legend(label(1 "domestic") label(2 "foreign"))
*--------------- end example ---------------


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of stata_user stata_user
Sent: dinsdag 31 oktober 2006 23:28
To: [email protected]
Subject: st: mkspline and reg


I 've a variable age which takes values from 20 to 60,
I have an outcome y and a dummy variable represnting gender

I would like to fit a regresion model using linear splines, including an
interraction effect

I want to test if there are two different slopes before 40 and after 40, and
I am also interested on the intercept , I consider the following approach

1/ First create linear splines

mkspline age1 40 age2 = age

2/Second in order to have intercept at age=40

generate age1a = age1 -40

3/
I fit a regression model

xi: regress y i.sex*age1a i.sex*age2

Could you please comment on this approach?



*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
Windows Live� Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gb

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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