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: Calculating first differenced correlations


From   "White, Nicole (UMSL-Student)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Calculating first differenced correlations
Date   Wed, 8 Dec 2010 18:17:47 +0000

Steve, 

Thank you for your help! These commands were very helpful!

________________________________________
From: [email protected] [[email protected]] on behalf of Steven Samuels [[email protected]]
Sent: Tuesday, December 07, 2010 7:30 PM
To: [email protected]
Subject: Re: st: ST: Calculating first differenced correlations

Nicole White wrote: "I am trying to figure out how to calculate the
correlation of first differences for two variables, poverty and
violence rates, for the years 1993 to 2004. "

--
You can do this by hand or by using time series commands; see the
example below.  I'm not expert in this area, but analyzing log crime
and log poverty might be worthwhile.

Steve


**************************CODE BEGINS**************************
clear
set obs 12
gen year = _n + 1992
list
set seed 4568
gen crime = uniform()*2500
gen poverty = crime[_n-1] +uniform()

// First by hand
gen d1crime= crime-crime[_n-1]
gen d1pov = poverty-poverty[_n-1]
corr d1pov d1crime

// With Time series operators d. (= d1.)
tsset year

list d1pov d.poverty d1crime d.crime d1.crime
corr d.poverty d.crime
scatter d.poverty d.crime
***************************CODE ENDS***************************


On Dec 7, 2010, at 5:59 PM, White, Nicole (UMSL-Student) wrote:

Hello--
I am trying to figure out how to calculate the correlation of first
differences for two variables, poverty and violence rates, for the
years 1993 to 2004.  I assume that I need to identify my dataset as a
time series, so I entered the tsset command and identified the time
variable as years, 1993 to 2004.  However, I do not know what command
or formula to use to generate the first difference for these rates.
Can anyone offer some guidance?  Thanks
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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