My dataset contains some variables for which the response option is "don_t_know" and "refuse_to_answer".

I would like to count the number of variables for which one, the other, or both options, and then, for each observation count the number of don't know, refuse to answer, or both, use it to then have a rate of don't know and refuse to answer per observation, which I would later use to compute the number of and rate of don't know and refuse to answer per enumerator.

I am struggling to create a variable that counts the number of don't knows and refuse to answer per observation. I think that from there on, I can finish the work.

In the questionnaire, don't know is either don_t_know or -88 (for numerical variables). refuse to answer is either refuse_to_answer or -99.

Thank you

Best,

Nicolas

]]>

Is there any way to conduct a cross-lagged fixed effects model with two-wave data using Stata?

Best,

Joonmo Son]]>

I am playing around with FX-Rates a little bit and try to model them with simple ARIMA models.

I got some DATA from the FED-Homepage for exchange rate on Dollar/Yen.

The Data is (seen from Graph and AugDickeyFullerTest) non-stationary.

So I take 1. Differences of the FX-Rate and now it is stationary. BUT as a consequence

The regression coefficient of the FX-Rate is now practically 0 and the p-value is 0.997 for an arima (0,1,0) model

The same is true for other models like (1,1,1) and (1,1,5) etc.

What is the problem? If I take the original FX-Rates or the log of the rates the regression gives me highly significant coefficients with p-values 0,0000.. What am I doing wrong?

Thank you for your help guys.

Karl

]]>

i want to run a loop over the 11 variables.

and i have tried to first generate a local macro using * but this does not seem to work

Code:

gen mark=0 local dx dx_* foreach n in `dx' { gsort id -`n' date by id: replace mark=1 if _n==1 {

I think it the way i define my local macro.

how can i create a local macro of different variables all starting with the same dx_NAME that can be included in a loop as described above.

Lars]]>

I'm building some scatter graphs using gr combine. After building the graph, I'd like to rotate the whole graph 90 degrees (instead of rotating the graph in Word or Powerpoint) afterwards. Is it possible?

I could build a rotated graph from scratch, but that's more time consuming.

]]>

I'm working on a dataset that contains information on spending with democracy worldwide. It has 508,264 rows of obs. Each row contains data about the donor of aid, the recipient (country), year, and a variable that presents a code for each type of spending (e.g., economic development, Human rights, etc) and a country "id" variable. An example of part of the dataset follows below.

What I need: to get each spending code (i.e., coalesced_purpose_code) and its corresponding spending (i.e., commitment_usd) transformed into variables.

My ultimate goal: to calculate commitment_usd, for each spending code category in coalesced_purpose_code, for each country/year - and then collapse the information and get a panel data. For instance, to get total spending with Human rights given to Angola in 2000, 2001 etc, and total spending with Environment given to Angola in 2000, 2001, etc, and the same for all other countries and years.

Problem: the reshape command does not work because the values of variable year are not unique within my country id variable.

Therefore, would someone know how I to obtain each value of coalesced_purpose_code transformed into variables?

Thank you.

donor | donor_iso3 | recipient | recipient_iso3 | year | coalesced_purpose_code | coalesced_purpose_code | commitment_usd |

United States | USA | Angola | AGO | 2008 | 15140 | Government adm | 1489745 |

United States | USA | Benin | BEN | 2007 | 15140 | Government adm | 3569874 |

United States | USA | Botswana | BWA | 2006 | 15110 | Economic and dev | 3286247 |

Belgium | BEL | Burkina Faso | BFA | 2005 | 15110 | Economic and dev | 32417951 |

Belgium | BEL | Burkina Faso | BFA | 2006 | 15140 | Government adm | 32578412.3 |

France | FRA | Burkina Faso | BFA | 2008 | 42010 | Environment | 32569787 |

France | FRA | Burundi | BDI | 2006 | 15110 | Economic and dev | 3282489 |

France | FRA | Burundi | BDI | 2006 | 51010 | Women and dev | 65714982 |

France | FRA | Burundi | BDI | 2008 | 43082 | Research | 1543624 |

Canada | CAN | Cameroon | CMR | 2001 | 15110 | Economic and dev | 457528912.3 |

Canada | CAN | Cameroon | CMR | 2003 | 42010 | Environment | 14564145.2 |

Italy | ITA | Cameroon | CMR | 2004 | 15120 | Human rights | 754525.9 |

United Kingdom | GBR | Cameroon | CMR | 2008 | 15120 | Human rights | 24675455.4 |

United Kingdom | GBR | Cape Verde | CPV | 2005 | 15100 | Govt and civil soc. | 235278524 |

United Kingdom | GBR | Cape Verde | CPV | 2005 | 15140 | Government adm | 786225 |

United Kingdom | GBR | Central African Rep. | CAF | 2006 | 16010 | Social welfare | 862884 |

United Kingdom | GBR | Chad | TCD | 2003 | 15150 | Strenghtening civil soc. | 589645 |

Sweden | SWE | Congo, Dem. Rep. | COD | 2001 | 15110 | Economic and dev | 756275545 |

]]>

I would like to save the estimate of the following regression as a Stata file:

Code:

webuse grunfeld xtfmb invest mvalue kstock, verbose est store FMB

So created a 187 x 2 matrix with city names and gini coefficients, which I then created a variable for (gini1 - city names) (gini2 - gini coefficients)

I have many many more observations. What is a good way for my to have the gini coefficients populate all of the observations based on their respective city names. Currently the only method I have is copying the value of the Gini coefficient and trying:

gen gini3 = .

recode gini3 . = "gini coefficient city 101" if city==101

recode gini3 . = "gini coefficient city 102" if city==102

I attempted to do a carryforward, but because the observations are all currently attached to city 101 (first 187 rows), the carryforward doesn't work.

Suggestions?

]]>

Code:

```
--------------------------------------------------------------------------------
```***** (1) Spatial Panel Data Regression Models:**
spregxt Spatial Panel Regression Models: Econometric Toolkit
gs2slsxt Generalized Spatial Panel 2SLS Regression
gs2slsarxt Generalized Spatial Panel Autoregressive 2SLS Regression
spglsxt Spatial Panel Autoregressive Generalized Least Squares Regression
spgmmxt Spatial Panel Autoregressive Generalized Method of Moments Regression
spmstarxt (m-STAR) Spatial Lag Panel Models
spmstardxt (m-STAR) Spatial Durbin Panel Models
spmstardhxt (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Panel
spmstarhxt (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Panel Models
spregdhp Spatial Panel Han-Philips Linear Dynamic Regression: Lag & Durbin
spregdpd Spatial Panel Arellano-Bond Linear Dynamic Regression: Lag & Durbin
spregfext Spatial Panel Fixed Effects Regression: Lag & Durbin Models
spregrext Spatial Panel Random Effects Regression: Lag & Durbin Models
spregsacxt MLE Spatial AutoCorrelation Panel Regression (SAC)
spregsarxt MLE Spatial Lag Panel Regression (SAR)
spregsdmxt MLE Spatial Durbin Panel Regression (SDM)
spregsemxt MLE Spatial Error Panel Regression (SEM)
--------------------------------------------------------------------------------
***** (2) Spatial Cross Section Regression Models:**
spregcs Spatial Cross Section Regression Models: Econometric Toolkit
gs2sls Generalized Spatial 2SLS Cross Sections Regression
gs2slsar Generalized Spatial Autoregressive 2SLS Cross Sections Regression
gs3sls Generalized Spatial Autoregressive 3SLS Regression
gs3slsar Generalized Spatial Autoregressive 3SLS Cross Sections Regression
gsp3sls Generalized Spatial 3SLS Cross Sections Regression
spautoreg Spatial Cross Section Regression Models
spgmm Spatial Autoregressive GMM Cross Sections Regression
spmstar (m-STAR) Spatial Lag Cross Sections Models
spmstard (m-STAR) Spatial Durbin Cross Sections Models
spmstardh (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Cross Sections Models
spmstarh (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Cross Sections
spregsac MLE Spatial AutoCorrelation Cross Sections Regression (SAC)
spregsar MLE Spatial Lag Cross Sections Regression (SAR)
spregsdm MLE Spatial Durbin Cross Sections Regression (SDM)
spregsem MLE Spatial Error Cross Sections Regression (SEM)
--------------------------------------------------------------------------------
***** (3) Tobit Spatial Regression Models:
*** (3-1) Tobit Spatial Panel Data Regression Models:**
sptobitgmmxt Tobit Spatial GMM Panel Regression
sptobitmstarxt Tobit (m-STAR) Spatial Lag Panel Models
sptobitmstardxt Tobit (m-STAR) Spatial Durbin Panel Models
sptobitmstardhxt Tobit (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Panel
sptobitmstarhxt Tobit (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Panel
sptobitsacxt Tobit MLE Spatial AutoCorrelation (SAC) Panel Regression
sptobitsarxt Tobit MLE Spatial Lag Panel Regression
sptobitsdmxt Tobit MLE Spatial Panel Durbin Regression
sptobitsemxt Tobit MLE Spatial Error Panel Regression
spxttobit Tobit Spatial Panel Autoregressive GLS Regression
--------------------------------------------------------------
***** (3-2) Tobit Spatial Cross Section Regression Models:**
sptobitgmm Tobit Spatial GMM Cross Sections Regression
sptobitmstar Tobit (m-STAR) Spatial Lag Cross Sections Models
sptobitmstard Tobit (m-STAR) Spatial Durbin Cross Sections Models
sptobitmstardh Tobit (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity CS
sptobitmstarh Tobit (m-STAR) Spatial Lag Multiplicative Heteroscedasticity CS
sptobitsac Tobit MLE AutoCorrelation (SAC) Cross Sections Regression
sptobitsar Tobit MLE Spatial Lag Cross Sections Regression
sptobitsdm Tobit MLE Spatial Durbin Cross Sections Regression
sptobitsem Tobit MLE Spatial Error Cross Sections Regression
--------------------------------------------------------------------------------
***** (4) Spatial Weight Matrix:**
spcs2xt Convert Cross Section to Panel Spatial Weight Matrix
spweight Cross Section and Panel Spatial Weight Matrix
spweightcs Cross Section Spatial Weight Matrix
spweightxt Panel Spatial Weight Matrix
--------------------------------------------------------------------------------

For more information:

http://ideas.repec.org/f/psh494.html

http://econpapers.repec.org/RAS/psh494.htm]]>

I am running a Fama MacBeth 2 stage regression (1st: time series of each stock on the factors, record the coefficient for the cross sectional regression. Cross sectional regression for each period, then average all of them). All details are available here:

http://www.jasonhsu.org/uploads/1/0/...ma_macbeth.pdf

I would like to record the beta for the time series and cross sectional regression. I have used the following code:

Code:

webuse grunfeld, clear xtfmb invest mvalue kstock, verbose est store FMB

I need to conduct a series of regression analyses with negative weights. (I know this is unusual but it is conceptually sound.) The Stata manual says that negative weights are allowed when specified in the "svyset" function with the iweights option. (Syntax svyset id [iweights = w])

This worked with the svy:regress and svy:logistic commands, but when I tried svy:poisson or svy:glm, I got an error for "negative weights encountered". Is there a way to model count data with negative weights?

]]>

I've got two different political economy data sets that I need to merge, but they lack a common code, except for country name. Even though these data sets (which are time-series cross-sectional) are both from the UN, they used different approaches to coding.

The FDI data has only the country name, no codes or abbreviations.

The WDI data has both country name and a country code.

To add insult to injury, there are subtle difference in the naming of certain countries (e.g., the FDI data calls Bolivia, "Bolivia (Plurinational State of)" while the WDI data calls Bolivia, "Bolivia") and certain countries may be missing from one list, but appear on another.

I know this is not an uncommon problem when dealing with political economy data. And the brute force approach of adding consistent codes to one data set is of course available -- but is there a way to speed up this process? For instance, can I have Stata match by the first 5 letters of the country name and then return a table of mismatches? Or is there another approach you have used to speed up the process of merging these kind of data sets?

Thanks!

-nick

]]>

I have a question on using substring to remove the last 5 characters from a variable. Suppose I have a list of addresses that all (because of improper database management) contain the zipcode in the address line. So, "123 John Lane 11224" I was wondering if there was a method to remove the last five characters of these entries. That is, so I would end up with "123 John Lane"

Any help would be appreciated. All the best. ]]>

I am trying to make a number of graphs using -catplot- and I am wondering if there is any way to show the sample size automatically?

For example, the following code produces the following plot

Code:

sysuse auto.dta, clear set scheme burd5 gen PriceLow = 1 if price <= 5006.5 replace PriceLow = 0 if PriceLow != 1 label define PriceLow 0 "High price" 1 "Low price" label values PriceLow PriceLow catplot rep78, asyvars stack percent(foreign PriceLow) over(PriceLow) /// over(foreign) blabel(bar, pos(center) format(%2.0f)) legend(pos(bottom) col(5))

What I need is something like the plot below, which I've edited manually.

Array

I need to create several hundred plots, so doing this manually is something I would really like to avoid if possible.

Thanks in advance,

Dominic.]]>

For example the variable V341 allegedly displays strings yet when I double click any of it's cell a numeric value appears. I wish to have the var. displayed in it's

Thanks for any suggestion..

Best,

Anat]]>