Quantcast
Channel: Statistics Help @ Talk Stats Forum - Stata
Viewing all 800 articles
Browse latest View live

Agency IDs organization

$
0
0
I would like to locate/organize my valid agency IDs (agencyid).

agencyid

CA0006
TN0106
NY0009
LA0035
TN0105
TN01o
CA0017
cA0006
La0035

The correct structure of the agency ID should be the state letters = 4 numbers ex,. (NY1111)The first thing I wanted to do is to make the first two letter of my agencyid variable upper case and maybe code as 9 (invalid ids) the ids that do not have the correct structure (NY1111) such as id TN01o. How can I do this?? thank you!

Thank you!

Panel data - dropping values after a missing one

$
0
0
Dear fellow talkstatters,

I am working with paneldata for my thesis. In order to get a balanced sample, I already deleted all the firms who missed data in the first three years.

The second step is to drop firms with missing values for managerial ownership for a year, which is done with the 'drop if missing(var)' -command. However, I want also to drop all the consecutive observations for the firm after the missing value. Does anyone know whether that is possible?

Kind regards,

Gijs

excluding unbalanced data from a subgroup

$
0
0
Hello all,

I am using an unbalanced data set with 24 years of firmdata. What I would like to do is to create a subgroup of this dataset. I would like this subgroup to have 10 years of firmdata, but only for firms that have a balanced dataset. For example, most firms have data from 1989 to 1998 but I want to exclude those firms that have some years missing.
The database is way to large to inspect the data. Is there a way to do this? And if so can it be done by using conditions, for example:

.....if inrange(year,1989,1998) & !missing(year)

effect sizes for xtmixed and logit

$
0
0
Hi,

I have a few questions regarding effect sizes for regressions- I have a relatively small sample size so am trying to support findings with effect sizes where possible.

Firstly, is it possible to compute effect sizes for interaction effects in longitudinal mixed effects regression? I am using xtmixed in Stata 12

xtmixed ghq time ft3_prep_bin || id:, robust
xi: xtmixed ghq i.time*ft3_prep_bin || id:, robust

(data is in long format for analysis over 2 time points)

Secondly, would it also be possible (and perhaps a similar process) to compute effect sizes for a similar mixed effects model interaction effect, which is not longitudinal? (data in wide format again- analysis at t2)

xtmixed fghq_tot group sex || id:, robust
xi: xtmixed fghq_tot i.group*sex || id:, robust
(interaction of 2 binary measures on a continuous measure)

Finally, is it possible to compute effect sizes for logistic regressions? Using logit and xi:logit for interaction terms? Or are odds ratios here typically enough?

Many thanks,

jmem

Foreach in regression analysis

$
0
0
Hi everyone,
I have almost no experience with Stata but I am trying to get into it :).

I have a simple table with column A including the variable "Year" and Columns B to AK including the variables "Ind_10" to "Ind_99" (the industries are not continuous). The Ind_* variables include industry sales for a given year in the respective cells.

I want stata to run a regression regressing Ind_* on Year for each industry.

Therefore I tried the following code:
foreach var of varlist Ind_10-Ind_99 {
reg Ind_* Year
}

This gives me some weired results that I cannot interpret.
Do you know what to do here?

Thanks a lot in advance!

A little help interpretting this piece of code

$
0
0
Hey I'm relatively new to Stata. I want to understand the following piece of code written by someone else. From what I gather it's ranking workers per industry and dropping those who make up less than 75% of the wage bill of that industry. Is this right?



Spoiler:

Calculate two different values for one variable with help of dummy

$
0
0
Hello!

Urgent help needed! Im trying to find out if membership in monetary union has changed government consumption. Data example

Country.,,,,,,,, Year.,,,,,,,,,,,,Gc.,,,,,,,,,,,,,, Demu(dummy 1=member Emu 0=not)
Fin. ,,,,,,,,,,,,,,,,99.,,,,,,,,,,,,,,0.4,,,,,,,,,,,,,,, 1
Fin. ,,,,,,,,,,,,,,,, 00.,,,,,,,,,,,,,,0.6,,,,,,,,,,,,,,, 1
Fin.,,,,,,,,,,,,,,,, 01.,,,,,,,,,,,, 0.4.,,,,,,,,,,,,,,,1

Swe.,,,,,,,,,,,,,,, 99.,,,,,,,,,,,,,,0.2.,,,,,,,,,,,,,,0
Swe.,,,,,,,,,,,,,,,,00.,,,,,,,,,,,,,,0.25,,,,,,,,,,,,,,,0
Swe.,,,,,,,,,,,,,,, 01.,,,,,,,,,,,,,,,0.4.,,,,,,,,,,,,,,,0

Ive runned regressions on how EMU has affected grotwth, but now i would like to find out if EMU has affected on Gc, has Emu increased Gc?

Any advice?

-Joonas

Difficulty in importing Excel files

$
0
0
I have a folder of Excel files named from 1 to 368, and I want to change their format to .dta. I thought it would be so easy but after one day of effort it is not working yet. My code is:
set more off
fs
foreach name in `r(files)'{
import excel using "D:\Users\n11094\Desktop\Rahavard Returns\New folder\"`name', sheet("Sheet1"), clear
keep A G
drop in 1
save `name'
}
The error message I recieve is "invalid 1" and Stata even doesnt change the format of the first file.
Anyone has an idea what is wrong?!

Stata to R conversion mlogit

$
0
0
I know R fairly well but have very little experience with STATA. I am trying to convert the below mlogit command in Stata so it is usable in R. Can anyone help me?

mlogit conflict lc1 lc2 ltsc0 ltsc1 ltsc2 loi loic1 loic2 lois0 let letc1 letc2 lets0 lli limc1 limc2 lims0 lyo lyoc1 lyoc2 lyos0 llpo lpoc1 lpoc2 lpos0 led ledc1 ledc2 leds0 llin ledn lyon lnc1 lnc1c1 lnc1c2 lnc1ts0 r4 r6 r7 if year >= 1970 & year <= 2009,baseoutcome(0) cons(107/110 115/120 145/156 99/100)

RESET Test

$
0
0
How do you do a reset test? with one term and with two terms

need some help with interaction of two variables

$
0
0
Hi everyone!
I will try to explain what my question is so that you can hopefully help me to find an answer.
Ok, I have, among much other information, data on mother education and mother employment status (once discrete and the other categorical)
Lets say, I want to predict children achievement (continuous variable) on the interaction of mother education and mother job. That is, even if the mother is more educated, it is well possible that she spends her time out of the home because she has a job and, as a consequence, the child may not receive the support needed.
How would you go about it?


Would you use a simple if condition, that is, if mother is educated BUT she works full time or would you build a dummy for that or would you build an interaction variable?
In this last case, how would you go about it? I mean would if I let mother education interact with her job, how would I then explain the results? As there are plenty of values for both mother education and her job..


any help would be really much appreciated!

thanks!

Export multiple graphs to one file

$
0
0
Hello everyone,

I am trying to create (line) graphs for a couple of different industries. Then I want to have all those graphs exported to one single .pdf-file. Does anyone know how to do this?

I currently tried to achieve this with the following code:
Code:

foreach var of varlist Ind_10-Ind_99 {
quietly: graph twoway line `var' Year if Year>1995
graph export Life_Cycle_Graphs.pdf
}

There are a couple of issues:
1. If I do not use the "graph export" command, Stata creates all the graphs but (to my knowledge) doesn't store them
2. The code as presented above stops after the first graph created, because the filename already exists.

I guess, it would be easiest if something as ",append" would exist as an option for the "graph export" command, but I don't know how to achieve this.

Any help is highly appreciated.

Generating Dummy Variable from excel file into STATA

$
0
0
Hi all :)

I am currently doing a research thesis titled "The Effects of Free Trade Agreements (FTA) on Indonesia's Trade". I have a panel data that consist of indonesia and its partner trade data from 1980 to 2011. In short, I have to create dummy variables of FTA that signed by Indonesia and its partner country.

I am new learner in STATA. My file is in excel file. I already importing it to STATA. I already construct the dummy variables on excel. Actually, there are 14 dummy variable : AANZFTA, AIFTA, AJFTA, AKFTA, AFTA, JIFTA, ACFTA, NAFTA, SAFTA, PAFTA, KUSFTA, SUSFTA, EUOCT, TPSEP. But each FTA has a branch of 3 dummy variables. For example, AANZFTA has AANZFTA1, AANZFTA21, and AANZFTA22. The meaning for that variables are :
FTA1jt : country j must be a member of that FTA at time t. Note that if at time t, that FTA is not yet signed, FTA1it would be zero for country j at time t.
FTA21jt : Country j must not be a member of that FTA at time t and must not be a member of any other FTA.
FTA22jt : Country j must not be a member of that FTA at time t and must be a member of at least one of Indonesia other FTAs.

How can I make stata read my dummy variable that i already construct on excel as dummy variables on stata? Or, if it is not possible, how do i construct/generate all of those dummy variables on stata? :confused::confused::confused:

Here I attached my excel files. I really need your help. It is such a big relief for me. Thank you very much. :wave::wave::wave:
Attached Files

Problems with graphing dinamic correlation after"mgarch dcc"

$
0
0
Hi everybody, I have some problems after having done the command "mgarch dcc.." and "predict H*, variance".
I need to estimate and then graph the correlation so I generate a new variable with the one I have from the garch model. (Es. I want correlation between stocks returns of Italy and Germany so: Cov(Italy,Germany)/[sqrt(Italy,Italy)*sqrt(Germany,Germany)]

and the i plot this new variable and that's what I've got: (see attached doc)

The graphs has a strange path in the first part of the distribution, can anybody suggest me an explanation, please?:confused:

XX
Attached Files

Zip Code analysis

$
0
0
I have a sizeble number of zipcodes in my dataset (zip codes from all over the USA) but I only want to use zipcodes of chicago. I found a list of zipcodes that constitute the chicago area (the list it is pretty long 90 zipcodes). I was thinking to create a variable that 1=chicago zip codes and 0 =other zipcodes. I heard that there is a command to deal with zipcodes. Any advices?

Thank you!

Basic understanding of a command

$
0
0
Hi Guys,

I have just started to learn stata and am working on a research project with an Econ professor where I need to understand his codes before moving forward with writing mine. so pardon me for a few basic questions.In a program I saw this:

by country: replace gov_domestic`endyear'=gov_domestic`endyear'[_N]/1000

I am confused what is the use of [_N] here in the line .. as it seems that result is same as what one would get without using [_N]

Also, another line that I saw was:

replace aggr_lcperc`endyear'=aggr_emdev_[_n+2] if category==.5

now again here what is the purpose of [_n+2]?

Can someone please throw some light on this.

Thanks a ton,
Sumit.

creating a variable for consequtive years

$
0
0
Hallo guys,

I want your help in my problem.I have a panel dataset and I want to construct a dummy variable which equals to one if net income is negative for the last two years, and zero otherwise.My data cover a six-year period, so the first year obviously the dummy is zero but the following years will be either one or zero.
Next to that a similar question about a second-not dummy but normal variable that equals to (net income t - net income t-1) / (net income t + net income t+1)

Thank you in advance for your help. It really will help me a lot for my thesis!!!

Graph in panel data

$
0
0
Dear Talk Stats members,

I am still a bit inexperienced with Stata and therefore my question. I have a panel data set of more than 100 countries over time. The dataset includes variables as inflation, but also whether a country is developed or developing (using a dummy). What I want is to create a graph with on the y-axis the inflation rate and on the x-axis the years. The graph should only show two lines. The first line should show the average inflation rate of developed countries over the years and the second line should show the average inflation rate of developing countries over the years. It is most likely that the inflation rate of developed countries is over the years lowers than the inflation rate of the developing countries.

It should be possible right? I can do it all by hand but that is a waste of time I think. I hope you people can help me out.

Thanks a lot!

Substring Merge

$
0
0
Hi,

I have two datasets that i would like to merge but the key string variable only matches partially
For example, in dataset1: the value is "Apple" and in dataset2: the value is "TreeApple321". I would like to merge another column in dataset1 to dataset2.

Please note that it's impossible to clean dataset2 before merging (can't just parse out Apple)

Please see the attached to see the sample.

Thanks!!
Attached Images
 

Why can't I use univar function in STATA 12?

$
0
0
I want to generate a summary ( mean and median only ) for var1 by other two variables ( var2 and var3) . I don't know why I can't use Univar function even I took off the " by (var2 var3). The error message is as "unrecognized command: Univar" .
Thanks.
Anna
Viewing all 800 articles
Browse latest View live


Latest Images