Quantcast
Channel: Statalist
Viewing all 72762 articles
Browse latest View live

Rainfall data

$
0
0
Hi all,

I am working with monthly rainfall data over years 1993-2010, for seven district. Each district have certain number of grids with information on longitude and latitude, monthly rainfall, area in sqkm. My problem concerns when creating district variable; whenever two districts share the same values for longitude and latitude, only information for one of the two districts is kept with my current coding.


Ex.
gen district = .
/*district 1 */
replace district =1 if a==77.25 & b==17.25
replace district =1 if a==77.25 & b==17.50
replace district =1 if a==77.25 & b==17.75

/*district 2*/
replace district=2 if a==77.25 & b==17.25
replace district=2 if a==77.25 & b==17.50
replace district=2 if a==77.50& b==17.25

Evidently for district 1, only one case will be kept because the first two cases will be overwritten by the "replace" command in district 2. How can I keep all information for each district despite the overlap.

Thanks !


time series probit regression analysis

$
0
0
Hi,

I am attempting to use STATA to run a probit regression on time series using the xtprobit function however I am not getting the expected results.

I am trying to measure what causes football clubs to go insolvent I am regressing insolvency events against residuals from a fixed effects regression which represent shocks to a clubs league position caused by factors other than wages and another set of residuals which represent shocks to clubs revenue caused by factors other than league position.
I am also using the division in which the club were in at the date of the insolvency event as a dummy variable.
The results are not as expected in particular presence in the lower tiers of English football is being shown as insignificant (with the highest tier being the base group) - I don't understand this because almost all insolvency events took place in the lower tiers so would expect this to return significant results.

Therefore I wanted to check with people that I have my data in my STATA data set laid out in the right way. I have a database that consists of the clubs that participated in the football league in every season from the 1996/97 season to the 2014/15, for every season a club has competed in the football league (the top 4 divisions) there is a seperate entry. It also includes which league they were in in that season. I also have column named insolvency event and if the club had an insolvency event in that season there is a 1 in the column and a 0 if not

Any help for me on this matter would be much appreciated,

Thankyou

Replicating the values of a variable to fill specific gaps

$
0
0
Dear Statalisters,

I am working with a dataset originating from two different datasets, one with a series of variables regarding the household quality of a number of families, the other certain aspects of the quality of life of its members.

I need to work with both, but, logically, the number of observations is considerably greater in the "individual" dataset.

To fill the gaps in the "household" dataset, I would like to replicate the values of the "household" dataset's variables so that it features the same value each time the same family code is present in the "individual" dataset.

To further make myself clear: if person #1, #2 and #3 are all members of family #1, in which I have a corresponding value of 1000 for variable X, I would like for each member of family #1 to feature the value 1000 in variable X.

I think that some sort of use of the "by/bysort" command is what I need, but I am not sure.

I checked if this question was previously asked, but I don't think so, if that should be the case, please redirect me to the thread.

I thank in advance for any contribution!

Tommaso Bechini

Test

$
0
0
This is a test before submitting a post.

Thank you.

Xtabond

$
0
0
Hello All,

I have a panel dataset and I am using the Arellano-Bond "Xtabond" function.

The dataset includes a binary variable which I need to exclude from first differencing. Thus I have used the xtabond option - diffvars(varlist)

When I run the regression I get the following error:

xtabond mutual_funds__holdings topexecutivescaled ,diffvars(soedummy)
diffvars() may not be specified when performing system estimation

It would be very much appreciated if you could provide advise on how to resolve the error.

Kindest regards,

Elaine

Bootstrap Loop impacting program

$
0
0
Hi and thank you in advance,

I would like run a loop over a program in bootstrap but it seems not working because I miss the variables in the program. May I ask your help?

*Programma per combinare indici e 80/20ratio bootstrap
capture program drop cosa
program define cosa, rclass
ineqdeco `x' if aa==`i'
return scalar gini = r(gini)
return scalar theil =r(ge1)
qui sumdist `x' if aa==`i', ngp(5)
return scalar r(sh5)
return scalar r(sh1)
scalar k = (r(sh5)/r(sh1))
return scalar R8020=k
qui sum `x' if aa==`i'
return scalar Q25 = r(p25)
return scalar Q50 = r(p50)
return scalar Q75 = r(p75)
end

* Bootstrap GINI, THEIL, 75/25 ratio
local redditi "Ii II IIf IIp"
foreach x of local redditi {
foreach i in 2011 2012 2013 2014 {
bootstrap gini`x'`i' = r(gini`x'`i') theil`x'`i'=r(theil`x'`i') R8020`x'`i'=r(R8020) Q25`x'`i' = r(Q25) Q50`x'`i' = r(Q50) Q75`x'`i' = r(Q75), reps(10) saving(C:\Prova`x'`i'.dta, replace): cosa
}
}

How to fix autocorrelation in panel data?

$
0
0
I have panel data and the command xtserial dependentvar independentvar indicates autocorrelation. How can I fix this? I know one way to fix autocorrelation is to use lags but the xtserial says that "factor variables and time-series operators are not allowed". Also, when I try to use the Cochrane-Orcutt method the transformed Durbin-Watson statistic given is smaller than the original, in my case it becomes 0. These are the only two options my textbook gives to use.
Thanks

How can I create and permanently install a program without sharing it publicly?

$
0
0
Hi everyone,

I want to share a user-written program within my organization, but I don't want to share it publicly. How can I make it easy for people to install the program? I don't want people to have to look at the do file unless they want to. I know they can run a do file to install the program, then it will be usable. However, it seems that they have to install the program again every time they open Stata. Is there a way around that?

I am aware it is possible to host a command on our own server. Can we do that in such a way that nobody else can access it?

Thanks,

Kris

AICc adjusted or corrected Akaike information criterion

$
0
0
Does STATA calculate AICc, and how do I do it? I am comparing models run with meqrlogit for one question, and glm for another. I have compared AIC between models with estat ic, however I would like to use AICc. Is there an option to do that in STATA?

Thank you.

Setting y axis range using another graph's axis range

$
0
0
Dear Statalisters,

I have two dataset (let's call it A and B) with same variables, but with slightly different values in them. Each dataset contains y1, y2,... y15, and x1. I have plotted 30 graphs, 15 from each dataset, using:

Code:
foreach num of numlist 1/15{
twoway scatter y`num' x1
graph export graph`num'
}
I want to compare graphs from dataset A with graphs from dataset B. For instance, I'd like to compare graph1 from dataset A with graph1 from dataset B. However, they have different range for y-axis, as their values are different, and I want them to have the same range.

As an example, if y1 from dataset A ranges from [0 1] and y1 from dataset B ranges from [0.5 2], then I'd like graph1 from both dataset to have the y-axis range of [0 2].

I was wondering if there is any way that I can automatically set y-axis range such that the smaller minimum axis range will be the minimum axis range for both graph, and greater maximum axis range will be the maximum axis range for both graphs. I can do it manually by comparing two graphs, and using yscale(range()), but I thought that it would be nice to do this automatically, especially since I have 30 graphs in total, and I might have to do the same thing over and over again in the future. However, I do not know how I can do this. I've tried searching for macro that may store the y-axis limit when I run twoway scatter, but I couldn't find one.

Any help would be appreciated!

Regards,
Hee Sung

estout / esttab: Lining up factor variables in table when mixing regular regressions and margins

$
0
0
Hi all,

As a training exercise, I've replicated all of the results from Helpman, Melitz, and Rubinstein (2004 QJE), and I am trying to learn how to automate creation of one of their tables, as I figure it may be useful for me to know later. Specifically, what I'm interested in getting is all of the Probit marginal effects reported in Columns 2, 4, and 6 in the lower half of the table (the VARIABLE=1 rows) to be properly lined up with their counterparts in Columns 1, 3, and 5. My esttab command and results are shown below. Let me know if you need anything else as far as my code goes. I appreciate your help!

(On another note, I can't quite figure out why the "noconstant" option isn't being obeyed here.)

Code:
. // Make a pretty table:
. esttab est1 est3 est4 est6 est7 est9, ///
>     drop(*expcode* *impcode* *year* 0.*) ///
>     label stats(N r2 r2_p) b se noconstant

--------------------------------------------------------------------------------------------------------------------
                              (1)             (2)             (3)             (4)             (5)             (6)   
                     Log of Bil~e                    Log of Bil~e                    Log of Bil~e                   
--------------------------------------------------------------------------------------------------------------------
Distance (Log)             -1.176***       -0.263***       -1.201***       -0.246***       -1.200***       -0.246***
                         (0.0311)        (0.0117)        (0.0243)       (0.00850)        (0.0243)       (0.00848)   

Land Border                 0.458**                         0.366**                         0.364**                 
                          (0.147)                         (0.131)                         (0.131)                   

Island                     -0.391**                        -0.381***                       -0.378***                
                          (0.121)                        (0.0961)                        (0.0962)                   

Landlock                   -0.561**                        -0.582***                       -0.581***                
                          (0.188)                         (0.148)                         (0.147)                   

Legal                       0.486***                        0.406***                        0.407***                
                         (0.0500)                        (0.0401)                        (0.0401)                   

Language                    0.176**                         0.207***                        0.203***                
                         (0.0610)                        (0.0475)                        (0.0474)                   

Colonial Ties               1.299***                        1.321***                        1.326***                
                          (0.120)                         (0.110)                         (0.110)                   

Currency Union              1.364***                        1.395***                        1.409***                
                          (0.255)                         (0.187)                         (0.187)                   

FTA                         0.759***                        0.996***                        0.976***                
                          (0.222)                         (0.213)                         (0.214)                   

Religion                    0.102           0.104***      -0.0180          0.0989***      -0.0384          0.0976***
                         (0.0964)        (0.0250)        (0.0764)        (0.0159)        (0.0767)        (0.0159)   

Land Border=1                              -0.148**                        -0.146***                       -0.146***
                                         (0.0472)                        (0.0321)                        (0.0321)   

Island=1                                   -0.136***                       -0.140***                       -0.140***
                                         (0.0320)                        (0.0216)                        (0.0216)   

Landlock=1                                -0.0717                         -0.0868**                       -0.0872** 
                                         (0.0451)                        (0.0279)                        (0.0279)   

Legal=1                                    0.0384**                        0.0285**                        0.0283** 
                                         (0.0135)                       (0.00881)                       (0.00882)   

Language=1                                  0.113***                        0.109***                        0.108***
                                         (0.0164)                        (0.0105)                        (0.0106)   

Colonial Ties=1                             0.128                           0.114                           0.116   
                                          (0.117)                        (0.0818)                        (0.0824)   

Currency Union=1                            0.190***                        0.206***                        0.206***
                                         (0.0515)                        (0.0257)                        (0.0257)   

FTA=1                                       0.494***                        0.497***                        0.495***
                                         (0.0204)                        (0.0179)                        (0.0182)   

WTO (none)                                                                                -0.0681                   
                                                                                         (0.0576)                   

WTO (both)                                                                                  0.303***                
                                                                                         (0.0422)                   

WTO (none)=1                                                                                              -0.0565***
                                                                                                         (0.0129)   

WTO (both)=1                                                                                               0.0932***
                                                                                                         (0.0125)   

Constant                    13.63***                        14.03***                        13.75***                
                          (0.471)                         (0.362)                         (0.362)                   
--------------------------------------------------------------------------------------------------------------------
N                           11146           24649          110697          248060          110697          248060   
r2                          0.709                           0.682                           0.682                   
r2_p                                                                                                                
--------------------------------------------------------------------------------------------------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001

reporting summary statistics: panel data, between and within variation

$
0
0
Hello,

I am working on a panel dataset an dwanted to report my summary statistics and export them in a paper-like format into word. I know how to export a basic table using outreg2 (with the variable name, standard deviation, min, max, and number of obs), but because I have a panel dataset I wanted to report the statistics with the within and bbetween variation (so the normal stata command would be xtsum ......).

Could you please advice me on how I could do that and whether it is possible to do with outreg2?

Thank you,

Aleksandra

Additional information in graph bar

$
0
0
Hello everyone,
I’m trying to do a graph with the following Syntax:
graph bar Var1 Var2 Var3 Var4, over(Var5, options)

The graph bar automatically uses means, which is fine. But how can I add another barlabel or textbox which shows the number of observations, standard deviation and median for each bar/variable1-4?
Does anybody know how to do this in STATA?

Problem with Chrome browser and Statalist

$
0
0
I think there was a thread on this a while back but I can't find it. In any event, this annoying problem persists.

Whenever I open a thread in Statalist I immediately get sent to the bottom of the page. This does not happen when I use Safari on my iPad. Granted, a few keystrokes can get me to the right place, but this all adds up after a while! I haven't seen this behavior in any other forums. Is there some sort of easy fix I can do on my end? If not, will this ever be fixed on the Statalist end?

OS is Win7, browser is Google Chrome.

transformation: a good or not so good idea?

$
0
0
I have a dependent variable on likert scale 0-9, and the predictors are mostly continuous variables. The potential predictors are around 50. Should I do transformation for Y into normal distribution for further pursuit of linear regression, or do ordinal logistic regression? I fear over the latter is that it has too many (10) levels.

Modifying vector in loop

$
0
0
Hello statalist,

I'd like to do the following in a loop (jj is defined earlier as a scalar and is an integer under 50, ADDV is a 1326 by 50 matrix but I only want to subtract column j, kk is a vector with one column and number of rows jj):

for(j = 1; j <= jj; j++) {
maxindex(v,1,ww=.,null=.)
kk[j]=lookupcol[ww]
kk[jj-j]=lookuprow[ww]
v=v-ADDV[.,j]
}

This returns "<istmt>: 3301 subscript invalid" I assume due to the v replacement. I want each iteration to keep subtracting the next vector from the current v vector, thus keeping v updated through the loop.

Intention of doing this is to remove the vector of values associated with the first maximum index value. I can't just do the second max because there are a vector of values associated with a certain maximum that I want to remove before calculating the next maximum.

Anyone have a way of doing this?

Thanks.

Neal

what's the keyboard to run do-file in MAC?

$
0
0
I can't use ctrl(command)+d to run do-file in my Mac. It's weird. It's time-consuming to click button every time, especially I prefer to run do file line by line.

Does anyone know the relevant keyboard?
Thanks!

Country-specific time trends

$
0
0
Hello,

I am working on a panel dataset (24 countries, over 30 years) and I am trying to estimate a two-ways fixed effects model and include as controls country-specific time trends. I was trying to find out what would be the best way to do that?

When I was searching trhough past posts, I saw someone suggesting using:

gen t=_N +1979

and then include t in the regression.

But I wasn't sure if that was appropriate? Is there a better way to do that given my data?

Thank you for your help in advance,

Aleksandra

Can sem ( Coarsened Exact Matching) command create matched pairs ?

$
0
0
Hi, I was using the command cem, which is written by Gray King of Harvard to perform Coarsened Exact Matching, an alternative matching method to PSM. What I want is to create "1-to-1" matched pairs year by year. This can be done in psmatch2 by merging (command generated) _id variable. It's kind of like transfer from the long format to wide format.
But in cem command help file, I could not find an equivalent item. The command tutorial does mention an argument named k2k, which can be used to make sure sample size balance between treatment and control group. but I still cannot how to do it with cem command. Can someone help me? Thanks in advance

xtline with color changed at a given point of time

$
0
0
Hello,
Suppose I have a dataset with person ID, day, and calories. I have another variable called ``treated'' which equals 1 if a person got some treatment and 0 otherwise.
I am thinking of having an xtline graph by ID, but for each line, I want it to be of a different color for different values of ``treated''.
Here is what I did:

clear all
sysuse xtline1.dta,clear
keep if person<3
*creating variable ``treated''
bysort person:gen temp=_n
drop if temp>100
gen treated=0
replace treated=1 if person==1 & temp>50
replace treated=1 if person==2 & temp>70
drop temp

xtset person day, daily
xtline calories,overlay

And here is what I got: (see g1.png in the attachment)

And here is what I want: (see g2).

I searched online but got answer yet. Any suggestions will be appreciated.
Thanks!
Marco


Viewing all 72762 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>