Date: Tue, 20 Jun 2006 09:17:03 +0200
Reply-To: alte@uni-greifswald.de
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dietrich Alte <alte@UNI-GREIFSWALD.DE>
Organization: Institut für Epidemiologie & Sozia
lmedizin, EMA Uni Greifswald
Subject: Re: Change Point Analysis
In-Reply-To: <200606191643.k5JFTDPf028670@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Try this:
* Simulate
data---------------------------------------------------------------------------------;
data sim;
a1 = 0; b1 = 0.02;
x0 = 250; * oder: x0 = (a1-a2)/(b2-b1);
b2 = -0.02;
a2 = a1 - x0*(b2-b1);
put x0= a2=;
do x = 1 to 500 by 0.5;
error = normal(0) * 10 + 2;
if x < x0 then y = a1 + b1 * x + error;
else y = a2 + b2 * x + error;
output;
end;
keep y x x0;
run;
proc sort data=sim; by x; run;
goptions reset=all;
proc gplot data=sim; plot y * x; run; quit;
* cut time var into before/after break;;
data sim;
set sim;
x1 = (x-x0) * (x LE x0);
x2 = (x-x0) * (x GT x0);
run;
* estimation;
proc glm data=sim;
model y = x1 x2;
output out = pred predicted=y_hat LCL=LCL UCL=UCL LCLM=LCLM UCLM=UCLM;
contrast 'beta x1 = beta x2' x1 1 x2 -1; * tests equality of estimates;
run;quit;
* picture it;
goptions reset=all;
symbol1 v=dot h=0.2 c=black ;
symbol2 i=join w=1 v=none c=red;
symbol3 i=join w=1 v=none c=black l=2;
symbol4 i=join w=1 v=none c=black l=2;
proc gplot data=pred; plot (y y_hat LCLM UCLM) * x
/overlay haxis=axis1 href=250; run; quit;
Tom Hulsey schrieb:
>Greetings:
>Does anyone have code for change point analysis? I have two continuous
>variables: vitamin D and calcium. They correlate positively, with
>increases in D, calcium increases -- up to a point. Then even though D
>continues to increase, calcium plateaus. I need to determine the change
>point. Suggestions? Thanks. Tom Hulsey
>
>
>
--
----------------------------------------------------------------
DIETRICH ALTE, Dipl.-Statistiker, Dr. rer. med.
Projektmanager "Study of Health in Pomerania (SHIP)"
Institut für Epidemiologie & Sozialmedizin
EMA-Universität Greifswald - Medizinische Fakultät
Walther-Rathenau-Str. 48, D-17487 Greifswald, Germany
URL www.medizin.uni-greifswald.de/epidem/
Phone ++49(0)3834-867713, Fax ++49(0)3834-866684
----------------------------------------------------------------