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

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

Plain time series forecasting in panel data set

$
0
0
Hey,

I have a large panel data set (58 cross-sections, up to 120 time periods) and I'd like to forecast an indicator. As one option (the other one being the xtpmg command for panels with large N and T) I'd like to use a simple time series model for each cross-section separately. Estimating the model is no problem, I just restrict the observations with the if, but the command forecast doesn't allow me to solve the forecast model, since the "command may not be used with panel data". Is it possible to use the forecast command in this setting for a single cross-section? If yes, how?

Thanks in advance!

Best,
Thomas

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


How to Create Maps in Stata

$
0
0
Hi All,

I am trying to use the data attached to create 2 maps in Stata. Data is comprised of 2 variables, student zip codes (HOMEZIP) and student types (StudentType). I would like to "map" zip codes as dots onto the state of Texas to see whether student locations cluster. I would like to do this for 2 student types, gtex students in gtex.dta and TCEDH students in tcedh.dta. What are the commands necessary to construct these 2 maps (again, just zip-code-based dots mapped onto the state of Texas)? Here are links to my data (I was not able to upload them into Statalist):

https://drive.google.com/file/d/0Bz-...ew?usp=sharing

https://drive.google.com/file/d/0Bz-...ew?usp=sharing

Thanks in advance,

Adam


Source of Stata's &quot;school&quot; dataset

$
0
0
Does anyone know the source the dataset that is loaded by typing
Code:
webuse school
I tried typing "notes", but none were provided. I am interested in definitions of variables as well as the original source (if possible).

year, quarter, month, and week: Creating a date? Sample Data provided.

$
0
0
Dear Statalist participants

I have year, quarter, month, week in my data and I want to create a Stata date variable on a weekly basis and sort my data accordingly.

the quarter runs from 1 to 4 , But the month variable runs from 1 to 3 (i.e. during the quarter) and the week variable runs from 1 to 4 (i.e. during the month).

I need:
1- to create a date variable
2- to sort my data weekly using the date variable in order to run weekly regressions

Another related question: in order to run my analysis on a weekly basis, would it be easier if the month variable runs from 1 to 12 and the the week variable runs from 1 to 48 ( weeks are stylized so there are 48 weeks indeed for each given year). Or it does not make a difference?

I upload a sample using dataex for you
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int year byte(quarter month week) float earnings
1987 1 1 1   1.7705997
1987 1 1 2    .4728113
1987 1 1 3    .3941394
1987 1 1 4   .11440884
1987 1 2 1     .160652
1987 1 2 2    .3961538
1987 1 2 3   .45841575
1987 1 2 4    .5288332
1987 1 3 1    .8589164
1987 1 3 2    .8497481
1987 1 3 3    .8618858
1987 1 3 4     .961287
1987 2 1 1    1.345534
1987 2 1 2   1.1195575
1987 2 1 3    .3546848
1987 2 1 4    .4636721
1987 2 2 1    .7540874
1987 2 2 2    .8403442
1987 2 2 3    .8561469
1987 2 2 4    .8706375
1987 2 3 1    1.383695
1987 2 3 2   1.3878306
1987 2 3 3   1.3569516
1987 2 3 4   1.2848142
1987 3 1 1    1.087582
1987 3 1 2    .7876818
1987 3 1 3     .200033
1987 3 1 4   .16993275
1987 3 2 1    .2436485
1987 3 2 2    .2782035
1987 3 2 3   .32997075
1987 3 2 4    .3608698
1987 3 3 1    .5761423
1987 3 3 2    .6065645
1987 3 3 3    .6020274
1987 3 3 4    .6339163
1987 4 1 1   1.3598517
1987 4 1 2   .56407243
1987 4 1 3    .3157399
1987 4 1 4   .22502215
1987 4 2 1    .3535852
1987 4 2 2    .3888265
1987 4 2 3     .425247
1987 4 2 4    .4753116
1987 4 3 1    .7817153
1987 4 3 2    .7864803
1987 4 3 3    .7770564
1987 4 3 4     .810554
1988 1 1 1   1.9881122
1988 1 1 2    .9616702
1988 1 1 3    .9560576
1988 1 1 4  -.02433528
1988 1 2 1   .06566841
1988 1 2 2    .1756358
1988 1 2 3    .2455934
1988 1 2 4   .29687575
1988 1 3 1    .4343888
1988 1 3 2    .4354226
1988 1 3 3    .4378992
1988 1 3 4    .4880208
1988 2 1 1   2.0682137
1988 2 1 2    .7863678
1988 2 1 3   .16332495
1988 2 1 4    .1944389
1988 2 2 1    .3070929
1988 2 2 2    .4097694
1988 2 2 3    .4642496
1988 2 2 4    .4707479
1988 2 3 1     .755556
1988 2 3 2    .7392501
1988 2 3 3    .7286718
1988 2 3 4    .7465883
1988 3 1 1   1.2585707
1988 3 1 2    .4756329
1988 3 1 3   .17472464
1988 3 1 4  -.10320017
1988 3 2 1   -.1050039
1988 3 2 2  -.06223335
1988 3 2 3   -.0396569
1988 3 2 4 -.001310848
1988 3 3 1  .010440214
1988 3 3 2   .03693339
1988 3 3 3   .03542653
1988 3 3 4   .07352171
1988 4 1 1   1.9921095
1988 4 1 2   1.0118054
1988 4 1 3   -.1854238
1988 4 1 4   .08538733
1988 4 2 1   .20397782
1988 4 2 2    .2374128
1988 4 2 3   .28562233
1988 4 2 4   .28901428
1988 4 3 1   .47351405
1988 4 3 2    .4622011
1988 4 3 3    .4750741
1988 4 3 4      .48286
1989 1 1 1   2.0214815
1989 1 1 2   1.0627728
1989 1 1 3    .6280478
1989 1 1 4  -.03181221
end


Thanks
Mike





survival analysis with overlapping records probable error

$
0
0
Dear Stata team,
hi again,
I am trying to run the survival analysis. I have multiple records per subject. the participant come to the clinic and the specimen is taken to measure the outcome (it takes many days for the outcome to be detected) and some times the participant may come to the next visit when the second sample is collected from him before the results of the first sample shows up.
these overlapping between the visit2 and the outcome of visit1 should be independent meaning that it doesn't matter if they result of visit1 comes before sampling in visit2. what matters is the duration that we observe for each sampling to be detected.
is there a way where I can get rid of this overlapping issue? does it affect the analysis?

I have these variables:
date of sampling
date of detection
detection result (0 for positive and 1 for negative)

I used the following
stset date of detection, id(id) failure(detection result==1) time0(date of sampling)

any help on this ?

thank you very much

best regards
Umama

Transforming Time Series Data

$
0
0
I have a Time Series on the price of coffee and 450 observations. Is there any particular reason I see articles log transforming the data?

Thanks in advance

New package descgen on SSC

$
0
0
Thanks once again to Kit Baum, a new package descgen is now downloadable from SSC. In Stata, use the ssc command to do this.

The descgen package is described as below on my website. It is designed to be used with the existing SSC package xdir to create meta-datasets, with 1 observation for each of a list of Stata dataset files and data on an assortment of Stata dataset attributes. Meta-datasets can be very useful in documenting big databases concisely.

Best wishes

Roger

---------------------------------------------------------------------------
package descgen from http://www.imperial.ac.uk/nhli/r.newson/stata10
---------------------------------------------------------------------------

TITLE
descgen: Add Stata dataset attribute variables to a xdir resultsset

DESCRIPTION/AUTHOR(S)
descgen is intended for use in output datasets (or resultssets)
produced by the xdir package, which have one observation for each
of a list of files, and data on directory names and file names.
It inputs the file name variable and (optionally) the directory
name variable, and generates a list of new variables, containing,
in each observation, Stata dataset attributes describing the
Stata dataset stored in the corresponding file. These attributes
include numbers of variables and observations and sizes of an
observation or of the dataset, and (optionally) lists of
variables in the dataset. If the corresponding file is not a
Stata dataset, then these dataset attribute variables will have
missing values.

Author: Roger Newson
Distribution-Date: 02march2017
Stata-Version: 10

INSTALLATION FILES (click here to install)
descgen.ado
descgen.sthlp
---------------------------------------------------------------------------
(click here to return to the previous screen)

suest: equations not found

$
0
0
Dear all,
can someone give me some suggestion on this problem?

The dependent variable is intention_2, which is binary.
And the independent variables are wifeage-a continuous variable, and i.wifeedu1- a categorical variable.

I am trying to compare the coefficients of the variable "wifeage" in model "TEST1" and "wifeage" in model "TEST2". Therefore, I wrote the code as following:

logit intention_2 wifeage whkpr i.wifeedu1 if actchi_3==0

estimates store TEST1

logit intention_2 wifeage whkpr i.wifeedu1 if actchi_3==2

estimates store TEST2

suest TEST1 TEST2

test [TEST1_mean = TEST2_mean]

However, the stata always shows "equation TEST1_mean not found".

Can anyone tell me which part of code is wrong?

I am waiting online for your wisdom.

The least tedious method for calculating many autocorrelations?

$
0
0
Hi!

Lets say that I have time series data of returns for one stock over a period of 30 years and want to calculate the first autocorrelation (in yearly stock returns) figure by running an AR(1)-regression. Then I could create a new variable (which I will name "persistence in stock returns" ) using the coefficient value from the regression. This is the first autocorrelation figure.

Now lets assume that I have data for 1000 stocks instead. For each stock, I want to calculate this "persistence/autocorrelation measure" from above. The thing is that I want to store this data nicely in a variable because later, I'm gonna use this as the dependent variable in a cross sectional regression...

So, how do I do this? Do I really have to run 1000 regressions??

/Alex
Viewing all 65064 articles
Browse latest View live


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