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

test difference in marginal effects for a dummy variable, different computations

$
0
0
Dear Talk Stats readers,

I have a Stata problem.

I would like to test whether the difference between the marginal effects of a dummy varaible, obtained first by computing the difference and then by taking the derivative, is statistically significant. I want to implement this test in order to justify the utilization of the derivative. The model I am suing is the probit model; my vars are y x1 x2 x3, where x1 and x2 are the dummy variables. Below you can read the syntax I am using.

1) First, I generate an identical dummy var, but with a different name. gen x1bis = x1

2) Second, I regress the probit model, compute the marginal effect of x1 computing the difference, and I store the estimate probit y i.x1 i.x2 x3, cluster(id) margins, dydx(x1) atmeans post matrix list e(b) est store mfx1 estimate query

3) Third, I regress the probit model, compute the marginal effect of x1bis taking the derivatie, and I store the estimate probit y i.x1bis i.x2 x3, cluster(id) margins, dydx(x1bis) cont atmeans post matrix list e(b) est store mfx2 estimate query

4) Eventually, I test the difference lincom _b[1.x1] - _b[1.x1bis]

Stata returns these results: Coef. = 0 and Std. Err. = (omitted), while z, P|z| and CI = .

As you see, I control with "estimate query" what I have actually stored and the corresponding values: _b[1.x1] and _b[1.x1bis] corresponds to the estimates of the marginal effects computed in the two different ways, and their value is not the same.

Is there a syntax or (worse) a methodological problem in what I am doing? Do you have any suggestion concerning a possible correction, or even concerning a different way to implement this test?

Thank you very much!

Validation of survival data / models

$
0
0
Hello,

I'm currently analysing a couple of survival data with parametric survival analysis (AFT and PH) in STATA. I'm investigating different parameters and different distribution function. To chose the best available model I'm using an information criterion such as AIC or BIC. So far so good. Now I want to validate these models or rather the choice (--> goodness-of-fit vs. prediction error/forcasting quality).

I was thinking about splitting the data. on one data set I create the model and test it on the other one. But I don't know how I could do this or rather what to compare exactly... Do you have ideas how I could set this up or any other ideas???

thanks for your help
best regards
Olaf

xtlogit fixed effects model

$
0
0
Hi;
I am trying to estimate a conditional probability model with panel data and fixed effects, therefore I am using the xtlogit, fe command. After the estimation I want to compte the probabitities of some hypothetical cases given the parameters but to do so I need to get the fixed effects for each case. How an I supposed to do this?, the model does not give me an estimation of those fixed effects. Is it correct to estimate the fixed effects first say by xtreg, fe and then introduce the into xtlogit, fe?

thanks

Logit: (un)conditional fixed effect and clustering

$
0
0
Dear all,

I have a pseudo-panel data with observations of activities of firms over years: about 570 firms, over 10 years and activities within a firm vary in numbers (all together I have more than 60,000 observations of activities, unequally distributed across firms).

The dependent variable is dichotomous, so I run simple logit regression with robust standard errors clustered at the firm level. Year dummies are included. The results are fine.

I read that I could also run fixed effect logit: both conditional and unconditional.

My syntax:
- For simple logit
logit y x1 x2 x1x2 ..., robust cluster (firmid)

- For conditional fixed effect:
clogit y x1 x2 x1x2 ..., group(firmid)

- For unconditional fixed effect:
logit y x1 x2 x1x2 ... i.firmid, robust cluster (firmid)

In the second and third models, observations without within-group variance are dropped.

I heard that the simple logit with robust standard error might be a comprise because of complications of both fixed effect models. I appreciate if someone can explain the
difference between "conditional", "unconditional" fixed effect and simple logit with clustered standard error
.

Thanks a lot for your comments.

Unit roots and analysing indifferences

$
0
0
I have a dataset with cpi inflation, money growth, government debt, real interest rate, and real exchange rate.

I do Dicky-Fuller tests for unit roots, and it turns out:
CPI is a unit root. Which I am quite suprised about.
Real Interest rate is a unit root
Real exchange rate is a unit root
The money supply growth rate is a unit root

When I Dicky-Fuller test the variable central government debt, the test statistic is positive, while the critical values for the test are negative, what does this mean?

I took a natural log of central government debt, which should tell me the proportional change from year to year (right?)

I know that if my data has a unit root, I should analyse the differences, but how do I do this in Stata?

Urgent:Help in defining sampling weights

$
0
0
Urgent:Help in defining sampling weights
Hi everyone,

I want to do a repeated cross sectional analysis for four waves : In each wave I have different respondents and different weights.

In order to set the survey design I used:
svyset id [pw=weights for wave i]
where id is the code of each respondent and i=1,2,3,4

Placing the "[pw=weights for wave i]" at the end of commands like tab, sum,etc leads to the following message "pw is not allowed".

Because I want to create some descriptive statistics that denote the trend of the mean of different variables, is there a way not to define the survey design for each wave separately?I want to make Stata understand automatically that from respondents of different wave, different weights should be selected. However, I do not want to create a pooled data set.


I would appreciate your immediate help as it is very important to have the descriptive statistics ready by Wednesday.

Thank you all
Marianna

How do I estimate a Cox model with a time-varying variable?

$
0
0
Hi,
I'm trying to estimate a Cox model with a time-varying variable, that has been recorded at different times. In particular, I would like to ascertain whether the variations of the variable at different time predict an increased risk of the response variable. I already set _st, _d, _t and _t0.
The different values of the variable at different times of follow-up have been recorded in different columns for each observation (e.g. baseline value= 300; 1-h value= 210; 6-h value= 100 etc). Please also note that the time intervals between two different measures are not equal (e.g. 1 h, 6 h, 24 h, 1 month etc).
How should I proceed? I'm afraid I need to put the data in different rows for each patients, but i'm completely stuck!!!
Thank you very much in advance, have a nice day!!!

Time-Varying Coefficient Model

$
0
0
I would like to estime a Time-Varying coefficient model, presented in Chow (1984). This model can be modeled in a state space representation using the Kalman Filter
I regress the yield bond spread (Y_t) on several independent variables (X_t). The betas follow a random walk path:

Y_t=X_t*b_t+e_t COV(e_t)=R (Diagonal)
b_t=b_(t-1) + n_t COV(n_t)=V (Unstructured)

Although, I use sparse data, where the number of observation varies from one time to the other (n_t), so the dimension of the R matrix varies.
Could this model be estimated in stata?

Thanks

Simulations

$
0
0
Hello All,

I am a beginners user in Stata and I am working on an assignment that requires me to run a simulation for a regression function.

I have to graph four different assumptions: 1. where all of the assumption are met, 2. where E[u/x] does not equal to zero, 3. where cov(x,u) does not equal to zero, 4. where the correlation of x1 and x2 varies.

Can someone explain to me how to run these simulations in Stata and ultimately how to graph these simulation. In addition, I need to compare for bias and efficiency.

Thanks in advance for your help.

Fixed effects vs Random Effects Panel data

$
0
0
Having conducted both fixed and random effects regressions, I get significant p values at the 5% level for my coefficients under fe, but very insignificant p values under re. Is that possible or have I conducted one/both of the tests incorrectly? For the record conducting a Hausman test led to it saying the fe model was more appropriate to my data set.
Therefore can I just ignore the insignificant outcomes from the re model?
I am using stata 12 if that helps

ARIMA Problem

$
0
0
Hi All,

I have an AR (1) model. From the residuals, I can observe some serial auto-correlation. How do I add an MA term at a particular lag to the model in order to get rid of the auto-correlation. E.g adding an MA term at lag 8. Do I just run an ARIMA model (arima y, arima(1,0,8)) ? I'm a bit confused on how to represent the lag in the moving average in stata.

Thanks in Advance

Windows7

Looking for a stata tutor via SKYPE

$
0
0
Hello. I have an assignment due for my Biostats calss (on logistics and conditional logistics regression) on Wednesday. I'm struggling with it quite a bit and would definitely need some help, not have it solved for me, but help. I'm willing to pay money as I would pay to a regular, real life tutor. While the assignment is difficult for me, I'm pretty sure its fairly easy as this is the first class assignment... If this sounds interesting, perhaps you could respond here or shoot me an email?

Best,

JohnDurr :wave:

Error "could not create varbasic.vrf" using varbasic

$
0
0
Dear Community,

I am using STATA 11.2 on Windows 7.

When I run the following do file:

Code:

use http://www.principlesofeconometrics.com/poe4/data/stata/fred.dta, clear
gen date = q(1960q1) + _n - 1
format %tq date
tsset date

* [...]

* Cointegration Test: Case 2
reg c y
predict ehat, res
reg D.ehat L.ehat D.L.ehat, noconst
di _b[L.ehat]/_se[L.ehat]

reg D.c D.L.c D.L.y
reg D.y D.L.c D.L.y

varbasic D.c D.y, lags(1/1) step(12)

(Source: http://www.learneconometrics.com/cla...3/notes/var.do )

I receive just the "normal" varbasic output. But additionally an error message occurs:
Code:

could not create varbasic.vrf
r(603);

What's going wrong?

Thx in advance

Stata - Labelling Question text

$
0
0
Hello,

I have to do a stata exercises, but I am not really good at the programm.

I choose the Header "Stata - Labelling Question Text" because the header should be significant, but I am sure, that I will have further questions with my exercises.

Should I post them in this thread or should I open several ones for each problem?

The first problem I got is with labelling. My .dta contains several variables (one birthyear and several affections to political parties). My first task was to label the variables. I did this and this was no problem.

There stands I have to label the Question Text: "What is your attitude towards these political parties? State the attitude by using a scale from +10 to -10, where +10 means absolutely liking and -10 means absolutely disliking a party."

I can't find now such thing as a question Text. Where can I label it?

Thank you in advance

statanewbie

How to plot the estimated coefficients from an ARIMA regression

$
0
0
I am having trouble plotting the estimated coefficients from y regression. I have 150 observations, and I tried using the rolling command. " rolling, window(100) clear:regress y_break L.y_break" However, this only gives me 50 coefficients. Can someone please tell me what I am doing wrong here?

Thanks.

Help creating a variable

$
0
0
I have this big file with 8000 people (each person is one row) and 3500 variables, what I want to do is to generate a new variable that lists all the people that have answered 240,241,242 … 246 to a questions that are represented by the 3500 variables. Each variable is a question, 240-246 are possible answers. I want a variable that says how many times 240-246 is answered by each person. So if person number 1 has answered 240 – two times, 241 – ten times, etc. I want the new variable to tell me how many times 240-246 was answered. Alternatively to make it easier I can have a variable for each of the values. So one variable that tells me how many times 240 was answered by each person, then an other variable that tells me how many times 241 etc. Then at last a variable that sums the created variables, to give the total.

Any ideas on how to formulate this command? It is very important not to only create a dummy variable.

Constraints on Partial Derivative of Function

$
0
0
1)
Let's say I have the following function:

Y = b0 + b1(L) + b2(L)^2 + b3(L)*(K)

where b# are coefficients. I want to run a regression with the following constraint: dY/dL = 0.2

I could use the cnsreg command, but how would I define this constraint in Stata?

2)
I want to do the same thing but for a fixed effects regression using the xtreg command. To impose constraints I was thinking of using the LINEST package. Any other ideas for how to impose constraints on such a regression?

Adding Means of a variable

$
0
0
Hi,

I have 3 variables and I have to add the mean of the 3 variables up and divide by 3.
That is how I would do it:

generate newvariable = (mean)var1+(mean)var2+(mean)var3/3

I put mean in () because i dont know how to say to Stata that the programm has to add up the means.

How can I do this?

Adding a graph

$
0
0
Hi,
I have the following task:

Use new variable "var_graph" to create a stacked horizontal bar chart by the diferent groups in the variable 'age group'. This graphs should show the percantage of respondents in the different groups that gave positiv ratings compared to those that gave a negative rating on average.

How Can i do that?

I only know:
graph bar var_graph

Furthermore I have to:
-Add titles to the Graph and its axes
-Colour the bars
-change the legend

How can I do this?

Edit: Now I got this:

graph bar dint*, percent stack

But i still dont know how to change titles etc.

cumulative return in blocks

$
0
0
I would like to cumulate x by y, when y !=0. (0 can be treated as missing)

For example, -.0316535 -.0639327 -.0447331=?
-.010779 -.0078551 -.0615043 -.0923925 4=?
...

I've had many many attempts, but have yet to figure an efficient way to do it.:shakehead

Any help is greatly appreciated!


x y

0 0
-.0316535 1
-.0639327 2
-.0447331 3
0 0
-.0505651 1
0 0
0 0
-.010779 1
-.0078551 2
-.0615043 3
-.0923925 4
0 0
-.0251245 1
0 0
-.0186057 1
-.0463527 2
-.0119064 3
-.0122578 4
Viewing all 800 articles
Browse latest View live