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

to change the format of date variable

$
0
0
hello,

I am trying to change the format of my date variable

currently, my date variable is arranged as


date
1947 - Q1
1947 - Q2
1947 - Q3
1947 - Q4
1948 - Q1


but I would like to change the format (I am just playing with it now), but when I use the command

format date %tq

it displays an error message,

"string %fmt required for string variables"


My date variable is a string variable. What can I do in this case?


Thanks a lot

Replicating Blundell and Bond (1998) using -xtdpd-

$
0
0
Dear all,

Using xtdpd, I'm trying to replicate Table 4 of Blundell and Bond (1998) "Initial conditions and moment restrictions in dynamic panel data models" - Journal of Econometrics 87, 115-143. I have searched for past threads on this topic, but I cannot find any (although several people tried to replicate what xtdpd does by using gmm).

So far, I have been successful the third column, no other column has been replicated.

The third column is exactly replicated as follows.
Code:
webuse abdata, clear

*** Blundel and Bond (1998), Exact replication of "1976-1984 GMM DIF" - third column of Table 4 ***
xtdpd L(0/1).n L(0/1).(w k) yr1978-yr1984, div(yr1978-yr1984) dgmmiv(n) dgmmiv(w k, lag(2 .)) noconstant
The results are exactly the same as the third column of Table 4, which is great.

However, I cannot replicate the fourth column, but the closest replication is as follows:
Code:
webuse abdata, clear

*** Blundel and Bond (1998), Close replication of "1976-1984 GMM SYS" - fourth column of Table 4 ***
xtdpd L(0/1).n L(0/1).(w k) yr1978-yr1984, div(yr1978-yr1984) dgmmiv(n) dgmmiv(w k, lag(2 .)) lgmmiv(n w k, lag(1)) hascons
The results are different from the fourth column of Table 4, despite the success regarding the third column above.

In my understanding, this code utilizes the same orthogonal conditions as stated in footnotes of Table 4 (except for the constant term for the level equation, which is not clear whether or not being included; here I included it because it gives me closer estimates, but not sure if this is correct either). I have tried xtdpdsys as well, but I cannot do what I would like to do using its syntax (e.g., it includes other orthogonal conditions that I don't want to include).

As I've been spending so much time on this, I really appreciate it if anyone could tell me how to replicate the fourth column (as well as the first and the second columns).

Best Regards,
Futoshi

--
Futoshi Narita (Mr.)
Economist
Developing Markets Strategy Unit
Strategy, Policy, and Review Department
International Monetary Fund
TEL: 202-623-7143
Email: fnarita@imf.org





Unusual error using "uselabel" command

$
0
0
Hi Stata listers

Bit of an odd ball error that I can't resolve. The write labels to dataset command "uselabel" works fine most of the time. I have several more or less structurally identical datasets that I am pulling the labels into a single dataset (for reasons of cross dataset label conformity checks). Problem is in two of the datasets i get:

>uselabel
>value label FILTER_ not found
>r(111);

to be cheeky I then created _FILTER

>label define FILTER_ 1 "dummy" 2 "dummy2"

which resulted in:

>uselabel
>$ invalid name
>r(198)

Nothing has preceded this command except the opening of the data-set.

Any help appreciated.

Darren

creating LaTex formatted tables in Mac OS X

$
0
0
I am seeking to create a table created in Stata, and output to LaTex format.
Below is my Stata code, and prior to running this I have specified the directory containing the top.tex and bot.tex files.

HTML Code:
sysuse cancer, clear
label var died "Patient died"
la def ny  0 ”No” 1 ”Yes”, modify
la val died ny
recode studytime (min/10 = 1 "10 or less months") ///
            (11/20 = 2 "11 to 20 months") ///
            (21/30 = 3 "21 to 30 months") ///
            (31/max = 4 "31 or more months") ///
            , gen(stime)
la var stime "To died or exp. end"
tabout stime died using table1.txt, ///
    cells(freq col cum) format(0 1) clab(No. Col_% Cum_%) ///
    replace ///
    style(tex) bt  cl1(2-10) cl2(2-4 5-7 8-10) font(bold) ///
    topf(top.tex) botf(bot.tex) topstr(14cm) botstr(cancer.dta)
The Stata viewer produces what looks like a correctly formatted set of LaTex code.
However, the final command
HTML Code:
texify table1.txt
returns the following error code:
/bin/bash: pdflatex: command not found

I would very much appreciate assistance or tips appropriate for someone without any LaTex experience.

Fractional Model

$
0
0
I faced econometric problem in my estimation strategy. My explanatory variable is a proportion (i.e. the percentage of alternative sources of finance in total finance) and at the same time, it is endogenous variable. I am using a panel data with T = 2 and N= 1492. I got the plausible instrument variable to control endogeneity in 2 stage regression. May I get your advise on the possible estimation strategy in my situation. Thanks very Much,

multivariate probit model mvprobit: predict, xb vs predict, p

$
0
0
Hello Statalist,

I am using a mvprobit model and would like to obtain predicted probabilities post-estimation (I would use predict, p after probit). However, that option is unavailable after mvprobit. Only predict, xb is available. How would I obtain the predicted probabilities by hand? Thanks!

I illustrate below with some sample code:

Code:
use http://www.stata-press.com/data/r7/school.dta, clear

mvprobit (private = years logptax loginc) (vote = years logptax loginc)

mvppred ,xb

when you finish laughing at the noob, please lend him a hand . . .

$
0
0
trying to run an IV estimation with xtivreg2 . . . the generic syntax guidance is baffling. i haven't figured out whether to enclose my RH variables in parents, brackets, or ? then, how do i specify my instruments list? a real simple example using, say, y and x1, x2, x3, and x4 as the instrument would be of great help to me. panel data and want to run a FE model. kind thanks, larry

r(691) using graph export

$
0
0
I am creating a report and I need to periodically run my do-file to update a set of graphs.

Unfortunately, I have not been able to store my graphs as pdf. According to Stata, I am not able to store these graphs as pdf due to r(691) error.

Is there a way to bypass this error and store the graphs or any other function to save them as pdf with replace.

Any help would be greatly appreciated.

Concatinate sequential string variable values into a single string?

$
0
0
I have a long text file of multiple string variables which I need to incorporate into an -If- command. This file is updated and changes on occasion, and I need to modify my -If- command every time it gets updated. I am looking to create a do file which will merge all of the string variable entries into a single exported text string for me, which I can then cut and paste into the If statement.

Example:

Input file:
String1
String2
String3
String4
String5
Desired Output:
"String1","String2","String3","String4","Sting 5"

Seems simple, racking my brain on how to do it. Ideas?

Rolling regression output

$
0
0
Hi

I'm preforming rolling regressions using STATA 13 and the following command:
rolling _b _se r2=e(r2), window(36) saving (betas, replace) keep(t): regress var1 var2 var3 var4...

This gives me columns for the betas, standard error and coefficients for each of my independent variables. It also gives me a column with an R^2 value for the entire model. I'm interested to know how I can also make a column for the p-value of each variable. I've looked everywhere, through tons of documentation and all over the internet without really any luck.

Any help whatsoever would be greatly appreciated.

Separation e Quasi-Complete Separation in Logistic Regression

$
0
0
Hello, Statalists.

When I try to run the following logistic regression:

logistic eletri presmae metrop area logrenpcdef nmorad refsexo refraca ncrian medescresp difescresp
Stata returns me the following result, which is related to the fact that my database has the problem of separation or quasi-separation:

note: area != 0 predicts success perfectly
area dropped and 470 obs not used

note: refsexo != 1 predicts success perfectly
refsexo dropped and 21 obs not used

note: refraca != 0 predicts success perfectly
refraca dropped and 17 obs not used

note: metrop != 0 predicts failure perfectly
metrop dropped and 2 obs not used

outcome = logrenpcdef <= 6.828236 predicts data perfectly
r(2000);
Interpreting this result I know that the variable "logrenpcdef " being responsible for separation, but do not know what is meant by the message in relation to other variables, which are binary.


Thanks in advance

Segmentation fault error

$
0
0
Hi all, I am currently running code that reads in multiple datasets, merging them into one dataset. I keep encountering a "segmentation fault" error. I've done some google searches and understand this relates to me accessing some form of memory I don't have access to.

Has anyone else seen this error before? What did you come up with for a solution? Is this simply a case of my data being too big too handle?

Note: I've previously run this code without error, so I don't believe it's a problem with syntax.

a doubt on string variables

$
0
0
Hi,

I'm doing a database, working on excel right now to store the data (maybe this is part of the problem). I'll work on the database with stata afterwards.

Here you can see the type of variables i got, once i put the file in stata:
Array

Some of the variables are dummies, with only 0 and 1s.

When I put in stata, that I try to do something, it tells me that there is a type mismatch problem.

How can I change the variable type so that stata can do the operations ?

thanks

confidence interval for cox proportional hazard model hazard rates

$
0
0
Hello Statalist, let me start by saying I am not a statistician. I am a person interested in doing some statistical analysis for work. I have had a handful of undergrad and a couple of graduate level statistics courses, but those were about 10 years ago, so I'm (a little) out of it. Any help or guidance here would be very appreciated.

I have been using stata to build cox proportional hazards models, and I believe I have a good understanding of the model itself, however I am trying to build a confidence interval for the final hazard rates the model produces. I have seen the basic output provides confidence intervals for the coefficients, and I am able to get a covariance matrix of the various covariates, but I am struggling to find the way I would put a confidence interval around my lambda(t|x).

I believe that this model is heavily used in epidemiological studies, where they likely only care about the relative hazard, but I care about the hazard rates themselves, not just the relative hazard. I have found through googling ways to get a confidence interval for the exp(X*B) portion (http://www.public.iastate.edu/~kkoeh...oxph.4page.pdf , page 318), but I want it for the full lambda0(t)*exp(X*B).

Apologies if I butchered notation or terminology.

Thank you in advance for any assistance!

Logit and probit modelleling (binary responses)

$
0
0
I have some basic questions about logit and probit models that I can't seem to find the answers to in any theoretical discussion.

1. When running binary probit and logit models, should I base significance on coefficients and standard errors (typically given by probit) or marginal effects and standard errors (typically given by dprobit)?

2. Further, I have variables that are significant when using a binary logit model, but not when running the same regression with a binary probit model. Is this unusual?

Winsorize in cross-section

$
0
0
Hi guys,

I am very new to Stata and have to do a winsorizing on stocks characteristics in each cross-section (month). I have to winsorize at the 0.5 and 99.5 % -tiles.

Now, I tried using winsor2 variable, replace cuts(0.5, 99.5). However, this variable cannot be combined by "by" and thus does not allow for cross-sectional winsorizingj. by month_id: winsor2 does not work.

I also tried :

bys month_id: summarize marketcap,de
bys month_id: replace marketcap = r(p1) if marketcap < r(p1) & marketcap !=.
bys month_id: replace marketcap = r(p99) if marketcap > r(p99) & marketcap !=.

However, here, we can only winsorize at the 1 and 99 % -tiles. I need to winterize at 0.5% and 99.5% though.

I appreciate ny help provided !

Best, BAT

Plot three graphs into one diagram

$
0
0
Dear all,


Could someone tell me how it is possible with Stata to put three graphs into the same diagram? So far, I only achieved to create three independent diagrams that were simply plotted next to each other. However, I Want three different graphs in the same diagram.

The x-axis will be the same for all graphs (a time variable) and the y-axis as well.

I hope you could help me out on this!

Best
Bata

Post-estimation from xtgee model to calculate mean differences in cumulative exposure

$
0
0
Hello,

I am using xtgee to identify the association between independent variables of interest and monthly medication dosing. A simplified version of my code is:

Code:
xtset id Month
xtgee MonthlyDose i.treatment##i.Month, robust
where MonthlyDose is a time-varying variable that is equal to the sum of an individual's monthly dose, and treatment is the binary treatment vs. no treatment indicator variable.

I then use
Code:
margins r.treatment@Month
to calculate the mean between-group differences for each month, and
Code:
marginsplot
to visualize this relationship over time.

My next goal is to calculate the mean difference in cumulative medication exposure between the two groups at various time points, as well as 95% confidence intervals and the P value. For example, the mean difference in cumulative exposure between both groups at month 6. Can this be done using the margins command, or another post-estimation command?

My apologies if there's an easy solution that I'm not aware of.

Thank you,
Matt

Abnormal returns

$
0
0
Hi,

I try to regress abnormal returns on my portfolio and I have a few questions. I use monthly data over a 7 year period, for 84 total observations. The alpha variable has a coefficient of 0.000781 and a std dev of 0.002032. This yields a t-value of 0.39 when months are considered. If I want to see the variable and t-variable of the coefficient over the period of a year (abnormal return over a year), I multiply the 0.000781 coefficient by 12 and for a value of 0.0094. I then multiply the std dev coefficient of 0.002032 by the square root of 12, for a std dev of 0.007 on yearly basis. Now my T-value is 1.34. I still look up the t-table at 83 degrees of freedom or should I divide this by 12 now that I have converted it from monthly to yearly? Is this the correct method?

However, I wonder how to calculate the P-value? Surely, I look it up in the table but I wonder how to calculate it myself?

Thanks in advance

Error with xtbcfe

$
0
0
Hello Stata Users,

I am trying to run xtbcfe but experiencing some difficulty. I keep getting the following error message, which I do not understand. I also installed xtbcfe moremata estout and distinct.

bcfe_ub(): 3499 mm_repeat() not found
<istmt>: - function returned error

Thank you in advance for your help.
Viewing all 72776 articles
Browse latest View live


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