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

problem of bootstrap command for xtdpdsys but no problem for xtreg

$
0
0
Hello,Dear expert

I write commands as follow:


xtset stock year

gen y=ln_innovK
gen x=DifG
gen w=cgbl


program abzj,rclass
tempname a b
xtdpdsys w x age tq size debt year1-year12 , endogenous(x,lag(0,1)) twostep
scalar `a'=_b[x]
xtdpdsys y w x age tq size debt year1-year12, endogenous(x,lag(0,1)) twostep
scalar `b'=_b[w]
return scalar ab=`b'*`a'
end



set seed 11111
bootstrap ab=r(ab) ,reps(1000) nodrop :abzj

------------------------------------------------------------
Then I got this error:

"insufficient observations to compute bootstrap standard errors
no results will be saved"

but if I change the "xtdpdsys"to "xtreg" as follows , It will be ok.



program abzj,rclass
tempname a b
xtregw x age tq size debt year1-year12 , fe
scalar `a'=_b[x]
xtreg y w x age tq size debt year1-year12, fe
scalar `b'=_b[w]
return scalar ab=`b'*`a'
end


Then I change the regression command with xtscc ,it will also have the same error.
my data as follows:

xtdes

stock: 4, 16, ..., 603366 n = 1098
year: 2003, 2004, ..., 2014 T = 12
Delta(year) = 1 unit
Span(year) = 12 periods
(stock*year uniquely identifies each observation)

Distribution of T_i: min 5% 25% 50% 75% 95% max
1 1 4 6 11 12 12

Freq. Percent Cum. | Pattern
---------------------------+--------------
245 22.31 22.31 | 111111111111
104 9.47 31.79 | .......11111
96 8.74 40.53 | ........1111
41 3.73 44.26 | .........111
34 3.10 47.36 | ......111111
33 3.01 50.36 | ....11111111
30 2.73 53.10 | .1..........
29 2.64 55.74 | ...111111111
28 2.55 58.29 | .11111111111
458 41.71 100.00 | (other patterns)
---------------------------+--------------
1098 100.00 | XXXXXXXXXXXX


I also find the same problem using other panel data.

So does it mean that command "xtreg“ only can be used in this suitiation?

I am willing to provide the data through email to you to test.
My email is lijian1981112@163.com
Pleaes contact with me ,if you need the data to test it

Thank you for your help.


Combine marginsplot - problem with plot options

$
0
0
I am trying to combine two (hopefully more) marginsplot using combomarginsplot. My code is the following:

Code:
xtreg yvar1 c.xvar##c.xvar 
margins, at(xvar = (-14.5(2)33.3)) saving(file1, replace)

xtreg yvar2 c.xvar##c.xvar 
margins, at(xvar = (-14.5(2)33.3)) saving(file2, replace)

combomarginsplot file1 file2, recast(line) recastci(rarea) plotopts(lcolor(dknavy)) ci1opts(color(ltblue)) ///
    xlabel(#3, nogrid)ylabel(, nogrid) graphregion(color(white)) labels("YVAR1" "YVAR2")
I would like to specify the line color and CI color for each of the marginsplot but it seems that I can only specify the following once
Code:
plotopts(lcolor(dknavy)) ci1opts(color(ltblue))
Is it possible to specify the colors for the second plot and its CI as well?

Thank you!

JSONIO Updated on SSC

$
0
0
For anyone needing to work with JSON data in either direction (e.g., reading/writing), the most current version of jsonio is now available. You can see examples of how to use jsonio on the project website : https://wbuchanan.github.io/StataJSON. The syntax has changed slightly since the first version released on SSC.

marginsplot error: "variable _pw0 not found" and "_term not labeled"

$
0
0
Dear All, I tried to use marginsplot after the following regression and got error messages I do not understand.
Code:
probit y i.v##i.x1 i.x2 x3 i.t, cl(id)
margins v, dydx(x1) pwcompare(pveffects) mcompare(bonferroni)
marginsplot
The above gives the following error message: variable _pw0 not found. Issuing the command
Code:
marginsplot, horizontal unique xline(0) recast(scatter) yscale(reverse)
after
Code:
margins v, dydx(x1) pwcompare(pveffects) mcompare(bonferroni)
gives: _term not labeled.

I wonder why? Can anyone help please?

Here is the data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id v t y x1 x2 x3)
20010 1 1 1 0 1 40
20010 1 2 0 0 1 75
20010 1 3 0 0 1 52
20012 1 2 0 0 1 51
20012 1 3 0 1 1 48
20022 1 2 0 0 1 60
20022 1 3 0 0 0 64
20030 1 1 1 0 1 30
20030 1 2 1 0 1 45
20030 1 3 1 0 1 48
20042 1 2 0 0 1 65
20042 1 3 1 0 1 70
20052 1 2 1 0 1 35
20052 1 3 1 0 1 45
20060 1 1 1 0 1 45
20060 1 2 1 0 1 50
20060 1 3 1 0 1 69
20062 1 2 0 0 1 61
20062 1 3 1 0 1 67
20070 1 1 0 0 1 49
20070 1 2 1 0 1 62
20070 1 3 0 1 1 53
20072 1 2 0 0 0 29
20072 1 3 0 0 1 31
20080 1 1 0 0 1 36
20080 1 2 1 0 1 28
20080 1 3 0 0 1 40
20082 1 2 1 0 1 40
20082 1 3 1 0 1 48
20092 1 2 0 0 1 29
20092 1 3 0 0 1 58
20102 1 2 1 0 1 47
20102 1 3 1 0 1 50
20110 1 1 1 1 1 35
20110 1 2 0 0 1 37
20122 1 2 1 0 1 63
20122 1 3 1 1 1 65
20130 1 1 0 1 0 32
20130 1 2 1 1 1 60
20130 1 3 1 1 1 70
20132 1 2 0 0 1 33
20132 1 3 1 0 1 45
20140 1 1 0 0 0 32
20140 1 2 0 0 1 40
20140 1 3 0 0 0 48
20142 1 2 1 0 0 35
20142 1 3 0 0 1 40
20150 1 1 1 1 1 27
20150 1 2 1 1 1 32
20150 1 3 0 0 1 30
20152 1 2 0 0 1 78
20152 1 3 0 0 1 51
20160 1 1 0 0 1 45
20160 1 2 1 0 1 55
20160 1 3 0 0 1 48
20162 1 2 1 0 1 46
20162 1 3 1 0 1 51
20170 1 1 1 0 1 49
20170 1 2 0 0 1 47
20170 1 3 0 0 1 58
20172 1 2 1 1 1 62
20172 1 3 1 1 1 67
20180 1 1 1 0 1 40
20180 1 2 0 0 0 65
20180 1 3 0 0 1 43
20182 1 2 1 0 1 45
20182 1 3 1 0 1 65
20192 1 2 1 0 1 37
20192 1 3 0 0 1 41
20200 1 1 0 0 1 25
20200 1 2 0 1 1 31
20200 1 3 0 0 1 36
20202 1 2 1 0 1 26
20202 1 3 1 0 1 32
20210 1 1 1 0 0 53
20210 1 2 0 0 0 61
20210 1 3 1 1 1 35
20212 1 2 0 0 0 45
20212 1 3 0 0 1 52
20220 1 1 0 0 1 25
20220 1 2 1 0 1 25
20220 1 3 0 0 1 40
20222 1 2 1 0 1 45
20222 1 3 0 0 1 40
20230 1 1 1 0 0 72
20230 1 2 0 0 0 77
20230 1 3 1 0 1 45
20232 1 2 1 0 1 45
20232 1 3 0 0 1 47
20240 1 1 0 0 0 75
20240 1 2 1 0 0 40
20250 1 1 0 0 0 38
20250 1 2 1 0 1 45
20250 1 3 0 0 1 29
20260 1 1 1 0 0 45
20260 1 2 1 1 1 59
20260 1 3 0 0 1 48
20262 1 2 1 0 1 35
20262 1 3 0 0 1 39
20270 1 1 0 0 0 51
end
label values t year
label def year 1 "Afrint1", modify
label def year 2 "Afrint2", modify
label def year 3 "Afrint3", modify
label values x1 nfwe
label def nfwe 0 "no", modify
label def nfwe 1 "yes", modify
label values x2 fertd
label def fertd 0 "no", modify
label def fertd 1 "yes", modify
Fred

Help in Granger casuality - VECM model

$
0
0
Hello guys. Is there an option to do Granger casuality test after doing a VECM model?

I see such option on VAR diagnostics and tests but not VEC. Please tell me If I am doing VECM model properly:

-lag order selection for VEC/VAR model for variables D.lfw20 D.lw20 (which is ln(fw20 and w20 - these are spot and futures for index market prices). Working on those variables because later im doing dcc-garch

-the AIC, SBIC, HQIC criteria says 4 is best fit
-vector error-correction model
-number of cointegrating equations(rank) - 1
-maximum lag 4 as criterias sasys
-depended variables are ones listed above (D.lfw20, D.lw20)
-trend constant (default)

How to test Granger Casuality in this model? If its gonna be vecm dcc-garch it cant be Granger casuality test from var model, can it?


PPML regressors excluded to ensure that the estimates exist

$
0
0
Hello everyone

I am currently running a ppml estimation, based on the theoretical model from the paper Beine, M., & Parsons, C. (2015). Climatic factors as determinants of international migration. The Scandinavian Journal of Economics, 117(2), 723-767.

I am trying to replicate their estimation, but using a different kind of shock (not climate shocks for me).

I have 47,643 observations, with bilateral panel data. More precisely, i have country of origin of migrants, country of destination, and year.
I need to control for country of origin et country of destination*year.

In that way, my command is as follow:

xi i.countryO
xi i.countryD*i.year

set matsize 2000
ppml migrantsflows GDPratio Network CW1 DependencyRatioOrigin Violence dist contig comlang_ethno _IcountryD_* _IcouXyea_*

The problem is, for every command that i tried, stata post "Number of regressors excluded to ensure that the estimates exist: x", for example with this regression "x" is 324.

Stata excludes many of my variables created by my fixed effects. I really don't understand why, i tried to find a particular pattern about this exclusion but didn't find any.
Do you have any idea about what is going on there?

NB: I know that my true model should be: ppml migrantsflows_log GDPratio_log Network_log CW1_log DependencyRatioOrigin_log Violence_log dist contig comlang_ethno _IcountryD_* _IcouXyea_*
But i have some issues with that regression. As I am using for my migrantsflows variable the difference between the ratio of emigrants from country O to countryD on the total natives in countryO, through time, I have only values <1, so my log variable is <0, and stata then post "no observations" (i guess it's because of this <0 flows issue).

Thank you in advance, i'm deeply lost with PPML!

Killian


Estimate Cofficient==0 after using xtdcce2 to estimate &quot;Common Correlatioin Estimation&quot;

$
0
0
Hi all,

I have an issue of getting the estimated coefficient when using xtdcce2, which is written by Jan Ditzen (2016). This comment is supposed to give me the estimate coefficients estimated by Common Correlation Estimation (CCE), which is proposed by Hashem Pesaran (2016). However, "xtdcce2" yield one of the coefficients (i.e., lmetrostock) to be "zero" and its standard error is also zero. I don't understand how that is the case.The following is the result from using this code:


Dynamic Common Correlated Effects - Mean Group

Panel Variable (i): fips Number of obs = 1494
Time Variable (t): year Number of groups = 146

Obs per group:
min = 1
avg = 11
max = 11
Degrees of freedom per country:
in mean group estimation = 5.2328767 F( 730, 34)= 0.57
with cross-sectional averages = 5.2328767 Prob > F = 0.99
Number of R-squared = 0.96
cross sectional lags = 0 Adj. R-squared = 0.96
variables in mean group regression = 730 Root MSE = 0.06
variables partialled out = 730
CD Statistic = 8.11
p-value = 0.0000
------------------------------------------------------------------------------------------
logcntemp| Coef. Std. Err. z P>|z| [95% Conf. Interval]
------------------------+-----------------------------------------------------------------
Mean Group Estimates: |
lmicrostock| 97.2162 35.0357 2.77 0.006 28.54753 165.8849
lownstock| .592534 .201532 2.94 0.003 .1975388 .9875295
lmetrostock| 0 0 . . 0 0
reduc| .00111 .001099 1.01 0.313 -.0010447 .0032649
_cons| 3.91515 1.63263 2.40 0.016 .7152482 7.11505
------------------------------------------------------------------------------------------
Mean Group Variables: lmicrostock lownstock lmetrostock reduc _cons
Cross Sectional Averaged Variables: logcntemp lmicrostock lownstock lmetrostock reduc




Thank you so much for your help! I really appreciate it.



Oudom

Coefficients plot

$
0
0
I want to plot regression coefficients using variables tot, newYCC and TM8. newYCC contains numbers from 1 to 7, representing the different time and TM8 is a dummy which represents the time different from 1 to 7. I want to use the second variable coefficient as yline in order to compare how the variable tot behaves during newYCC and TM8.
I've been using the command below but it actually doesn't work to plot the second's variable coefficient. These commands works just if I leave the second regression out.

quietly reg tot i.newYCC , nocons
quietly eststo c1: margins,at(newYCC=(1 2 3 4 5 6 7)) post

quietly reg totdev TM8 , nocons
quietly eststo c2: margins,at(TM8=(1)) post

coefplot c1 c2 , vertical yline(`a')recast(line) title("Terms of trade") lwidth(*2) ciopts(recast(rline) lpattern(dash))xlabel(1 "t-3" 2 "t-2" 3 "t-1" 4 "t" 5 "t+1" 6 "t+2" 7 "t+3")


input float year double tot float newYCC byte TM8
1974 103.132 . 1
1975 100.262 . 1
1976 99.2711 1 0
1977 99.5796 2 0
1978 100.738 3 0
1979 100.646 4 0
1980 96.1591 5 0
1981 91.7276 3 0
1982 92.5663 4 0
1983 91.1926 4 0
1984 91.6308 4 0
1985 92.9575 4 0
1986 96.9068 5 0
1987 97.8541 4 0
1988 98.7667 5 0
1989 97.7916 4 0
1990 98.0709 5 0
1991 98.2167 6 0
1992 100.408 7 0
1993 102.646 . 1
1994 101.052 . 1
1995 100 . 1
1996 99.4396 . 1
1997 98.5263 . 1
1998 99.7306 . 1
1999 98.92 . 1
2000 96.5638 . 1
2001 96.5245 . 1
2002 97.7203 . 1
2003 97.8623 . 1
end







Smart way to identify strange observations?

$
0
0
Hi, I am using Stata 13 and I have some sales data from a few stores. I scaled the sales data by store size and plotted it over time. I just wanted to get a feel for the data. It looks a bit funny (see the graph below).
Array


There are a few stores that do not have any (what seems like) seasonal fluctuation over time. I wonder if there is any smart way to identify these stores systematically? My initial idea was to identify them by variance. Here is what I did:

Code:
gen year_month = mofd(Date)
    format year_month %tm
    

        
*scale monthly sales by size
gen monthly_sales_by_size = monthly_sales/Size
        
        

        
*Some graphs to get a feel for the data
line monthly_sales_by_size year_month
    
    
*get variance by store
bysort Store: egen sales_variance = sd(monthly_sales_by_size)
sum sales_variance
    
drop if sales_variance <0.005
line monthly_sales_by_size year_month, legend(size(medsmall))
But that is such a crude way of doing it. Any idaes? I think it is a very interesting problem

Thank you in advance! /R

Coding an overall categorical variable from several mutually nonexclusive variables

$
0
0
I'm currently working with a dataset of 233 observations and 300 variables. This data originates from a survey with a great deal of multiple choice questions, which is the reason why there are so relatively many variables. Each possible answer for each multiple choice questions appears as a binary variable in my dataset saying whether that answer was chosen or not. I have provided an example that I asses demonstrates the problem in a fair, although much smaller scaled, manner.

My respondents have, in a multiple choice question, been asked what sodas they've consumed over the last year. For each soda they crossed off, they've been asked to which degree, on an ordinal scale from 1-5, they liked it and similarly how often they buy that soda.

The data, therefore, looks something like this.

Code:
input byte(Cola Fanta Cola_Citrus) float(Like_Cola Like_Fanta Like_ColaCitrus Buy_Cola Buy_Fanta Buy_ColaCitrus)
1 1 1 1 2 3 1 3 1
. . 1 . . 4 . . 3
1 . . 2 1 . 5 . .
1 1 . 3 3 . 2 3 .
1 . . 4 5 . 1 . .
. . 1 . . 2 . . 1
. 1 . . . . . 1 .
. 1 1 . . 1 . 1 1
. . . . . . . . .
1 1 . 5 4 . 5 3 .
end
label values Cola Cola
label def Cola 1 "Cola", modify
label values Fanta Fanta
label def Fanta 1 ".", modify
label values Cola_Citrus Cola_Citrus
label def Cola_Citrus 1 "Cola Citrus", modify
label values Like_Cola ordinal
label values Like_Fanta ordinal
label values Like_ColaCitrus ordinal
label values Buy_Cola ordinal
label values Buy_Fanta ordinal
label values Buy_ColaCitrus ordinal
label def ordinal 1 "Often", modify
label def ordinal 2 "Somehow Often", modify
label def ordinal 3 "Neither", modify
label def ordinal 4 "Rarely", modify
label def ordinal 5 "Never", modify
I'm aware that I can use the mrtab command in order to gain an overview of the answers, but I desire a new variable, as I wish to make a twoway table with other variables such as the "Like_var".

Thus, I wish to make a overall "category" for sodas. This could be "Cola" and "Orange sodas". But the Cola Citrus would have to figure ind both (!). Now, I can code individual binary variables on whether you drink Cola or Orange.

Code:
gen Cola2 =.
recode  Cola2 (.=1) if Cola==1 | Cola_Citrus ==1

gen Orange=.
recode vurdering (.=1) if Fanta==1 | Cola_Citrus==1

*Attempting to make overall category variable
gen Category_Var =.
recode Category_Var (.=1) if Cola2==1
recode kategorier (.=2) if Orange==1

tab Category_var
Upon tabulating the new category variable, and within the process of making it, there is no error message, but the second value of the variable, "orange", does not have all the observations that it should. I assume that each respondent can only appear once in each variable. And as you see several respondents enjoy sodas from both categories. Therefore, my question is:

"How may I code a variable that allow for each respondent to figure more than once, or alternatively, how would you go about analyzing the question of whether there are difference between the categories in regards to how often they are consumed?"

This is even more complicated by the fact that I am not allowed do use regression, but should stick to two, or perhaps, threeway tables.

Additionally, how may I produce one collected "how often do you buy soda"-variable, when this too dispersed over three variables? (I also would want to analyse the relationship between how good a soda is rated and how often it is bought).

Hopeful regards

Three way error component model with one delete Jackknife resampling

$
0
0
Dear Stata users,

I want to run a three way error component model using Stata. However, I couldn't find the specific code for this model. Furthermore, would someone let me know if I can use one delete Jackknife resampling technique with the three error component model?

Many thanks,

RO

Estimation on sub-population using foreach

$
0
0
Hello,

I would lile to perform estimation on sub-population (defined by year and region) and to create new variables which contain the estimation results for each group. So using the foreach command I write this code, but the result are not what I want. When I perform the estimation using this code, it generates a variables containing the result of the whole population and not only the sub-population.


Code:
gen group = 1 if region ==1 & year ==0
replace group = 2 if region ==2 & year ==0
replace group = 3 if region ==3 & year ==0
replace group = 4 if region ==4 & year ==0
replace group = 11 if region ==1 & year ==1
replace group = 21 if region ==2 & year ==1
replace group = 31 if region ==3 & year ==1
replace group = 41 if region ==4 & year ==1
gen a = 1
gen b = 1
preserve

bys year region : gen id = _n
keep if id < 30

levelsof group, local(level)
qui foreach k of local level {
quietly nlsur (wmrktst = {alpha}*wM + ({alpha}*{gamma})*T - {gamma}*stfamh) (wmrktot = {alpha}*wM + ({alpha}*{gamma})*T - {gamma}*otfamh)
mat list e(b)
mat def E = e(b)
replace a = E[1,2] if group == `k'
replace b = E[1,1] if group == `k'
}
I just start using the foreach command so I'm not really skilled with it.

Kind regards,

Sam

Running a Difference-in-Difference Regression on STATA

$
0
0
Good Afternoon,

I'm doing research on the effects of the economic crisis on mortality rates in several provinces and so I have panel data on mortality rates and unemployment rates for different provinces for 14 years by quarter. My dependent variable is mortalityrate and my main independent variable is unemploymentrate. I'm trying to do a difference in difference regression to see the difference in pre-crisis and post-crisis mortality rates. The only STATA work I've done for difference in difference has been for impact evaluation where there was a treatment and control group so I wasn't sure how to apply DID to this particular research.

I've generated a precrisis variable: year<=2008
and a postcrisis variable: year>2009

I then made interaction terms Unemploymentrate*precrisis and Unemploymentrate*postcrisis

My first question is should I make two interaction terms one for precrisis and one for post or if only one time period is necessary?

2nd- do I need to create a dummy treatment variable or can I interact with the original unemploymentrate variable?

My 3rd question is can someone recommend a good method for DID?
I've seen "xtreg" with DID for controlling for fixed effects (In my regression I want to control for fixed effects for year and province)
I've also seen some examples with "xi: reg" and others that just use a regular regression.

Does this regression look okay?
xtreg mortalityrate unemploymentrate unemploymentrate*precrisis unemploymentrate*postcrisis dummyyear* dummyquarter* dummyprovince*, cluster(province)
My knowledge of STATA is basic so I'm not familiar with the nuances in the different commands.

Thank you in advance for any assistance!


Categorical Dummy Variable Coding

$
0
0
Hi,

Say I am trying to see the effects of being from a different ethnicity on wages.

In my initial dataset ethnicities are coded from 1-4; white as 1, black as 2, indian as 3, and other as 4.

If I drop all missing values for ethnicity, and then create dummies manually using the code:

gen black = (race==2)
gen indian = (race==3)
gen other = (race==4)

And then run a regression of wage against these, would the interpretation of the coefficient of e.g. being Indian be compared to the base group of being white, or being indian compared to white, black or other?

Similarly, if I include age in the regression, would the interpretation for that coefficient relate to someone white?

I understand these questions might seem very basic but I want to check I have coded my dummies correctly to interpret them against the base group of only white rather than the base group of all other races.

Finally, if I included other categorical dummies in the equation, such as married and divorced with never married as the based group, would the coefficient on "Indian" be compared to a never married white individual or a white individual with the same marital status?

Problem replicating a seed

$
0
0
Hi all,

I am having a problem that might be just a mistake on understading how set seet works in the new Stata 14. I needed to select randomly three evaluations and create an average score per project so in my do file I set a seed, create a random number and selected the three evaluations with the largest random numbers per project. However when I run the do file, each time I get a different result. Why does that happen if each time the do file runs the seed is set at the same number?

The do file is the following:

clear all
set more off

set seed 988

gen random=runiform()
by iddelemprendimiento: egen r1=max(random)
gen ev1=1 if random==r1
by iddelemprendimiento: egen r2=max(random) if ev1==.
gen ev2=1 if random==r2
by iddelemprendimiento: egen r3=max(random) if (ev1==. & ev2==.)
gen ev3=1 if random==r3
gen evaluaciones=1 if ev1==1 | ev2==1 | ev3==1

collapse (mean) score if evaluaciones==1, by(iddelemprendimiento)



Matrix colnames and/or rownames from matrix or from value labels

$
0
0
Dear all,

I have successfully generated a matrix after a tabulate command, but unsuccessfully set the right column and row names and would love a bit of help.

I found online the following strategy to name columns and rows in a matrix:
Code:
    tab age Grade if Enrolled==1 & inrange(age,5,35) [iw=wt_hh], matcell(T1)
    decode age, gen(age_s)
    levelsof age_s, local(agelabels)
    matrownames T1 = `agelabels'
    decode Grade, generate(Grade_s)
    levelsof Grade_s, local(Gradelabels)
    mat colnames T1 = `Gradelabels'
However, I have two problems with this: (1) my age variable is not labeled, and (2) decode results in an alphabetical order that does not match the results matrix order. While the matrix has the following column names after tabulating:
Code:
"Primary 1" "Primary 2" "Primary 3" "Primary 4" "Primary 5" "Primary 6" "JSS 1" "JSS 2" "JSS 3" "SSS 1" "SSS 2" "SSS 3" "SSS 4"
Using the code above leads to the following column names, which means the resulting matrix would show "JSS 1" when it should be saying "Primary 1":
Code:
"JSS 1" "JSS 2" "JSS 3" "Primary 1" "Primary 2" "Primary 3" "Primary 4" "Primary 5" "Primary 6" "SSS 1" "SSS 2" "SSS 3" "SSS 4"'
To solve problem (1) I would have liked to set the rownames from a matrix already generated, something like the following:
Code:
    tab age Grade if Enrolled==1 & inrange(age,5,35) [iw=wt_hh], matcell(T1) matrow(rows)
    mat T1 = T1
    mat rownames T1 = `rows'
But I failed, so simply did the following, which works well enough for my purposes:
Code:
    tab age Grade if Enrolled==1 & inrange(age,5,35) [iw=wt_hh], matcell(T1) matrow(rows)
    mat T1 = rows, T1
However, I have not been able to fix problem (2). I have played with defining the local myself, but I also failed at that:
Code:
local labels ""
        levelsof Grade, local(dvs)
        foreach level in `dvs' {
            local varlabelname: value label Grade
            local varName: label `varlabelname' `level'
            local labels "`labels'" " " "`varName'"
            }
        di "`labels'"
Any ideas on how to do this without having to manually add the column names?

I am using Stata 13 by the way.

Thank you all very much!

IVREG2 vs VAR?

$
0
0
Hi Folks,

Any thoughts out there regarding using ivreg2 instead of var? It seems I have a fairly robust model when I use ivreg2 (with one lag of the dependent variable). Yet, the diagnostics for VAR (varsoc) suggest I need four lags. This paper is helpful, but a bit outdated. http://fmwww.bc.edu/ec-p/wp598.pdf

Thanks for directing me to some resources I might use to bring myself up to speed.

Cheers,
Steve

mi impute, when the imputed variable is the depvar

$
0
0
Hi,
I was wondering if I can use the mi estimation commands with a variable that has non-missing information. This variable with non-missing information has a list of plausible values and I want to use the EM algorithm in a GLM regression. This is my dependent variable of the GLM regression. I am not sure how to approach this subject since the information on the stata guide has as an example something much simpler: a variable with missing information that is a independent variable.
Does anyone know how can I approach this issue?

Thank you in advance for all of the help and attention,

Marta

Estimating the GARCH(1,1) model on panel data.

$
0
0
Hello everyone, I am trying to run a GARCH regression on a panel dataset.

I have an unbalanced panel dataset with gaps, consisting of securities and daily returns. I am trying to find out whether it is possible to run a panel regression of the GARCH(1,1) model and whether this is different to a multivariate GARCH regression. The GARCH model can be found under: Statistics --> Time series --> ARCH/GARCH or Multivariate Time series --> Multivariate GARCH. Both these options have inputs on dependent and independent variables. I am not sure what to fill in as GARCH regresses squared returns on its lags.

Could somebody please shed some light on whether a GARCH panel regression is possible and whether its different to a multivariate GARCH regression. Appreciate any feedback. Thank you.

estout does not display estadd scalar (Pseudo-R2)

$
0
0
Dear statlist,
I try to calculate a pseudo R2 for a mixed effect model and also display it in output (following this thread):

Code:
sysuse auto, clear
eststo clear

* Regular model
eststo: mixed price c.mpg##c.mpg || foreign:
scalar llu = e(ll)
di llu

* Constant only model
qui mixed price || foreign:
scalar llr = e(ll)
di llr

* Computation of the pseudo r2
estadd scalar pr2 = 1 - llu/llr
*di "Pseudo-R2: " pr2

ereturn list
estout, stat(pr2)
In ereturn list I can see e(pr2) = .0235342435927753. However, in estout the cell for pr2 is empty.

I have read similar posts on the forum and updated all my addons. The problem remains. Any help would be appreciated. Thank you.
Viewing all 65266 articles
Browse latest View live


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