Bookmark and Share

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: Producing e a two phase single-case graph


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Producing e a two phase single-case graph
Date   Mon, 25 Mar 2013 15:47:48 +0000

To get what you want, try

twoway connected out time if prepost == 0 || ///
connected out time if prepost || ///
line fitpre time  || ///
line fitpost time , ///
xline(10.5) ///
ylabel(1(1)4) ///
xlabel(1(1)20, labsize(small)) ///
legend(order(1 "Observed pre" 2 "Observed post" ///
3 "Fitted pre" 4 "Fitted post"))

You show no code, so it is difficult to explain why it didn't work. At
a guess, you added a -connect()- option at the end, but that wouldn't
retrospectively alter a graph that has already gone to press, so to
speak. You have to specify connecting at the time.

Nick

On Mon, Mar 25, 2013 at 3:39 PM, Dan Brossart <[email protected]> wrote:
> Joerg,
>
> Yes, that is exactly what I had in mind! Is there a way to add symbols to
> each time point? I think the option connect does this but I can't get it to
> work in your example. In any case, thanks for giving me a way forward!
>
> Dan
>
>
>
> On 3/24/2013 6:05 PM, Joerg Luedicke wrote:
>>
>> Do you have something like this in mind?
>>
>> *------------------------------
>> // Pre/post toy data
>> clear
>> set obs 20
>> gen prepost = 0 in 1/10
>> replace prepost = 1 in 11/20
>> gen time = _n
>> gen out = 2+runiform() if prepost == 0
>> replace out = 3+runiform() if prepost
>>
>> // Fitted values
>> reg out time if prepost == 0
>> predict fitpre if e(sample)
>> reg out time if prepost
>> predict fitpost if e(sample)
>>
>> // Plot
>> line out time if prepost == 0 || ///
>> line out time if prepost || ///
>> line fitpre time  || ///
>> line fitpost time , ///
>> xline(10.5) ///
>> ylabel(1(1)4) ///
>> xlabel(1(1)20, labsize(small)) ///
>> legend(order(1 "Observed pre" 2 "Observed post" ///
>> 3 "Fitted pre" 4 "Fitted post"))
>> *------------------------------
>>
>> Joerg
>>
>>
>> On Sun, Mar 24, 2013 at 4:34 PM, Dan Brossart <[email protected]> wrote:
>>>
>>> Dear All,
>>>
>>> I am trying to generate a graph for single-case data (20 time points
>>> total)
>>> where the baseline has 10 occasions of measurement and the treatment
>>> phase
>>> has 10 occasions of measurement. I need to be able to graph the baseline
>>> and
>>> treatment as a single graph with a vertical line separating the two
>>> phases.
>>> In each phase I need to have a line connecting each data point (but not
>>> from
>>> phase 1 to phase 2). I also need the ability to add a regression line to
>>> each phase - each phase gets its own line, independent of the other phase
>>> regression line.
>>>
>>> I've looked through Mitchell's "A Visual Guide to Stata Graphics" 3rd
>>> Ed.,
>>> but there isn't an example like this and so far I haven't found anything
>>> like this in the archives. My efforts to use twoway have so far failed to
>>> produce anything close. Using twoway with xrescale and a by statement
>>> gives
>>> me two separate graphs and I really want to do this in a single graph.
>>> Ideas?
>>>
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index