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

reg with an unbalanced panel

$
0
0
Goodmorning,

i have a panel data UNBALANCED of 57 banks divided in quarterly from 2002 to 2015. for example the first bank has 56 observations (thus from 2002q1 to 2015q4) but others have less observations (for example from 2006q4 to 2012q4).
To do quantile regressions i set these codes:


forvalues i = 1/57 {
qreg Xi Returnlag Volatilitylag LiquiditySpreadlag CreditSpreadlag YieldSlopelag Tbilllag if IDBanks ==`i', quantile(.50)
predict var5 if IDBanks ==`i'
}

Then, to do OLS regressione i set these codes:
reg var5 ERVlag BETAlag Leveragelag MarketToBookValuelag Sizelag MaturityMismatchlag var5lag

the results are very strange in the second one. the codes are right for you? someone could you help me?
thank you so much for the possible answers.

Location of -preference set- file(s)?

$
0
0
I'm facing down needing to reimage my hard drive for the third time in a year. It's getting pretty annoying to have to re-tweak my various configurations each time. I know about porting over .ado files, and I've got Sublime Text set up to run as my .do file editor, so that saves me some pain. But I'd really love to be able to just re-load my saved preferences for the other GUI elements.

I see that (at least as of Stata 15 Nov 21) it's possible to save a -preference set- and load a -preference set-...but I cannot find the location of the file(s) in which those preferences are recorded.

Can someone point me to the right location? The goal would be to back that up so I can easily restore it once I've wiped the hard drive and reinstalled Stata.Array

Linear regression, use Stata to estimate and predict

Complicated Reshape from Wide to Long

$
0
0
Here peacescale is the variable I want, and the time periods are in YYYYMMDD format. What I want to do is have each row correspond to the value of peacescale for each dyad year. So, for example, dyad 2020 has a peacescale value of 0.75 for 1920-1987 and 1 from 1987-2015. So, I'd want the data to look something like this:

Dyad Year Peacescale
2020 1920 0.75
2020 1921 0.75
...
2020 1987 1
...


Thanks!


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long(dyad begperiod1 endperiod1) float peacescale1 long(begperiod2 endperiod2) float peacescale2 long(begperiod3 endperiod3) float peacescale3
2020 19200110 19871002 .75 19871003 20159999   1        .        .   .
2031 19730710 20159999  .5        .        .   .        .        .   .
2040 19020520 19590113  .5 19590114 20141216   0 20141217 20159999 .25
2041 19009999 19150909   0 19150910 19610529  .5 19610530 19640115 .25
2042 19009999 19160504 .25 19160505 20159999  .5        .        .   .
2051 19620806 20159999  .5        .        .   .        .        .   .
2052 19620831 20159999  .5        .        .   .        .        .   .
2053 19661130 20159999  .5        .        .   .        .        .   .
2054 19781103 20159999  .5        .        .   .        .        .   .
2055 19740207 20159999  .5        .        .   .        .        .   .
2056 19790222 20159999  .5        .        .   .        .        .   .
2057 19791027 20159999  .5        .        .   .        .        .   .
2058 19811101 20159999  .5        .        .   .        .        .   .
2060 19830919 20159999  .5        .        .   .        .        .   .
2070 19940101 20159999 .75        .        .   .        .        .   .
2071 19009999 19230923   0 19230924 19931231  .5 19940101 20159999 .75
2080 19810921 20159999  .5        .        .   .        .        .   .
2090 19009999 20159999  .5        .        .   .        .        .   .
2091 19009999 20159999  .5        .        .   .        .        .   .
2092 19009999 20159999  .5        .        .   .        .        .   .
2093 19000101 19090102  .5 19090103 19260923   0 19260924 19330101  -9
2094 19200101 20159999  .5        .        .   .        .        .   .
2095 19031103 19870928  .5 19870929 19891222 .25 19891223  2015999  .5
2100 19009999 20159999  .5        .        .   .        .        .   .
2101 19009999 20020513  .5 20020514 20159999 .25        .        .   .
2110 19660526 20159999  .5        .        .   .        .        .   .
2115 19751125 20159999  .5        .        .   .        .        .   .
2130 19009999 19520815  .5 19520816 19821209 .25 19821210 19851011  -9
2135 19009999 19520824  .5 19520825 20001112 .25 20001113 20159999  .5
2140 19009999 20159999  .5        .        .   .        .        .   .
2145 19009999 20159999  .5        .        .   .        .        .   .
2150 19009999 20159999  .5        .        .   .        .        .   .
2155 19009999 20159999  .5        .        .   .        .        .   .
2160 19009999 20159999  .5        .        .   .        .        .   .
2165 19009999 20159999  .5        .        .   .        .        .   .
2200 19009999 19020631  .5 19020701 19031020 .25 19031021 19411206  .5
2205 19221206 20159999  .5        .        .   .        .        .   .
2210 19170417 20159999  .5        .        .   .        .        .   .
2211 19170417 20159999  .5        .        .   .        .        .   .
2212 19201115 20159999  .5        .        .   .        .        .   .
2220 19009999 20159999  .5        .        .   .        .        .   .
2221 19930528 20159999  .5        .        .   .        .        .   .
2223 19900918 20159999  .5        .        .   .        .        .   .
2225 19170417 20159999  .5        .        .   .        .        .   .
2230 19009999 20159999  .5        .        .   .        .        .   .
2232 19930728 20159999  .5        .        .   .        .        .   .
2235 19170417 20159999  .5        .        .   .        .        .   .
2255 19009999 19150209  .5 19150210 19210702   0 19210703 19391023  .5
2265 19491007 19901002 .25        .        .   .        .        .   .
2290 19170417 20159999  .5        .        .   .        .        .   .
2300 19009999 19171206  .5 19171207 19181112 .25        .        .   .
2305 19190910 20159999  .5        .        .   .        .        .   .
2310 19170417 20159999  .5        .        .   .        .        .   .
2315 19181028 19451130  .5 19451201 19480224  -9 19480225 19891226 .25
2316 19930101 20159999  .5        .        .   .        .        .   .
2317 19930101 20159999  .5        .        .   .        .        .   .
2325 19009999 19411210  .5 19411211 19430903   0 19430904 20159999  .5
2331 19920302 20159999  .5        .        .   .        .        .   .
2338 19640921 20159999  .5        .        .   .        .        .   .
2339 19170417 20159999  .5        .        .   .        .        .   .
2341 20060612 20159999  .5        .        .   .        .        .   .
2343 19930408 20159999  .5        .        .   .        .        .   .
2344 19920115 20159999  .5        .        .   .        .        .   .
2345 19009999 19920522  .5 19920523 20010119   0 20010120 20159999  .5
2346 19920407 20159999  .5        .        .   .        .        .   .
2349 19920115 20159999  .5        .        .   .        .        .   .
2350 19170417 20159999  .5        .        .   .        .        .   .
2352 19600816 20159999  .5        .        .   .        .        .   .
2355 19401213 19440908   0 19440909 19511124  -9 19511125 19891107 .25
2359 19911226 20159999  .5        .        .   .        .        .   .
2360 19009999 19401212  .5 19401213 19440823   0 19440824 19511124  -9
2365 19009999 19170103  .5 19170104 19230701   0 19230702 19410930 .25
2366 19180224 19400616  .5 19910906 20159999  .5        .        .   .
2367 19181118 19400616  .5 19910906 20159999  .5        .        .   .
2368 19180216 19400615  .5 19910906 20159999  .5        .        .   .
2369 19911226 20159999  .5        .        .   .        .        .   .
2370 19911226 20159999  .5        .        .   .        .        .   .
2371 19911226 20159999  .5        .        .   .        .        .   .
2372 19911226 20159999  .5        .        .   .        .        .   .
2373 19911226 20159999  .5        .        .   .        .        .   .
2375 19171206 20159999  .5        .        .   .        .        .   .
2380 19170417 20159999  .5        .        .   .        .        .   .
2385 19170417 20159999  .5        .        .   .        .        .   .
2390 19170417 20159999  .5        .        .   .        .        .   .
2395 19440617 20159999  .5        .        .   .        .        .   .
2402 19750705 20159999  .5        .        .   .        .        .   .
2403 19750712 20159999  .5        .        .   .        .        .   .
2404 19740910 20159999  .5        .        .   .        .        .   .
2411 19681012 20159999  .5        .        .   .        .        .   .
2420 19650218 20159999  .5        .        .   .        .        .   .
2432 19600620 20159999  .5        .        .   .        .        .   .
2433 19600820 20159999  .5        .        .   .        .        .   .
2434 19600801 20159999  .5        .        .   .        .        .   .
2435 19601128 20159999  .5        .        .   .        .        .   .
2436 19601013 20159999  .5        .        .   .        .        .   .
2437 19600807 20159999  .5        .        .   .        .        .   .
2438 19581002 20159999  .5        .        .   .        .        .   .
2439 19600805 20159999  .5        .        .   .        .        .   .
2450 19200630 20159999  .5        .        .   .        .        .   .
2451 19610427 20159999  .5        .        .   .        .        .   .
end

Heckman selection marginal effects

$
0
0
HI guys!!

Hello again!

I am master student who is writing using, HECKMAN 2step Gravity model

I have 170 import countries, 156 export countries 7year 15000 panel data!

Command :
heckman log_value log_dis_ij ban regionalization language log_REM_i log_REM_j log_gdp_i log_gdp_j, select(value_select = log_dis_ij ban regionalization language log_REM_i log_REM_j log_gdp_i log_gdp_j fot) twostep


I got result , and now I hope to get marginal effect!

Command:
margins, dydx(*) predict(psel)


However, I got only selection equation margianl effect!


If any statlist comment how to get marginal effect of outcome equation, it would be very appreciated!!

SIncerley

diff package single t-test not showing after category

$
0
0
Hi everyone! I'm trying to balance test my covariates using the "test" addon in the "diff" package but, as you can see in the attached picture, the "After" portion of the t-test comes out blank. I don't know why it's blank. As you can see, from my tabulation of the "post1" variable, there are 436 observations in the "after" period that are not being evaluated. Any ideas what I'm doing wrong? Thank you!

Array

Bug in extended function r(scalars)??

$
0
0
Hi
It is probably me doing something wrong

But when do the code:
Code:
. sysuse auto
(1978 Automobile Data)

. quietly regress price mpg

. display "`:r(scalars)'"
level

. regress price mpg

      Source |       SS           df       MS      Number of obs   =        74
-------------+----------------------------------   F(1, 72)        =     20.26
       Model |   139449474         1   139449474   Prob > F        =    0.0000
    Residual |   495615923        72  6883554.48   R-squared       =    0.2196
-------------+----------------------------------   Adj R-squared   =    0.2087
       Total |   635065396        73  8699525.97   Root MSE        =    2623.7

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         mpg |   -238.894     53.077    -4.50    0.00     -344.701    -133.088
       _cons |  11253.061   1170.813     9.61    0.00     8919.088   13587.033
------------------------------------------------------------------------------

. display "`:r(scalars)'"
PT_has_legend PT_has_cnotes PT_k_ctitles level
When quietly is before the regress command I the right value: level
On the other hand without quietly as prefix command I get some strange PT_ values.

Does anyone know why?

saving the rngstate of each replication in a monte carlo simulation

$
0
0

Hello,

Using Stata 14, I am simulating an r-class program and would like to save the rngstate of each replication of the simulation. Any help would be greatly appreciated!


Jessica

Only one (of 4) categories appearing in regression results with i. specification

$
0
0
Hello,
I am facing a puzzle where I have a categorical independent variable in my regression (role_impbins) that takes values 0 to 3 for the 4 categories. I am using i.role_impbins in my regression and I expect STATA to leave out the category coded as 0 as the reference group, but the categories coded as 2 and 3 are also not appearing in my results. I have checked and there are no missing values for this variable nor for any of the other variables in the regression. However, there are a small number of observations for the categories 2 and 3.

Here is a tab of the role_impbins variable:

Role | Freq. Percent Cum.
--------------------+-----------------------------------
Household | 262 72.78 72.78
Cluster Leader | 54 15.00 87.78
Health Volunteer | 26 7.22 95.00
Health Professional | 18 5.00 100.00
--------------------+-----------------------------------
Total | 360 100.00


And the regression I am running results as follows:
svy: reg nkbehav_pct edu_respondent_highestyr edu2 respondent_age age2 i.role_impbins
(running regress on estimation sample)

Survey: Linear regression

Number of strata = 3 Number of obs = 259
Number of PSUs = 30 Population size = 66,132.386
Design df = 27
F( 5, 23) = 14.27
Prob > F = 0.0000
R-squared = 0.1239

------------------------------------------------------------------------------------------
| Linearized
nkbehav_pct | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------------------+----------------------------------------------------------------
edu_respondent_highestyr | .0170928 .0063014 2.71 0.011 .0041634 .0300222
edu2 | -.0008234 .0005671 -1.45 0.158 -.0019871 .0003402
respondent_age | .0116763 .0036573 3.19 0.004 .0041722 .0191804
age2 | -.0001412 .000046 -3.07 0.005 -.0002357 -.0000468
|
role_impbins |
Cluster Leader | .0161535 .016133 1.00 0.326 -.0169486 .0492555
_cons | .299051 .0730634 4.09 0.000 .1491373 .4489648
------------------------------------------------------------------------------------------


Does anyone have any idea what might be going wrong and what I should do to investigate or fix this problem?

Thanks so much,
Kate

How to split my data

$
0
0
Hello,

I'm new to stata list so I apologise for any errors in my post. I'm currently running a regression model on Natural Resources Rents (dependent) and rent seeking behavior (independent), using a panel-data approach of 49 countries beteween 1994-2014 with multitude of control variables. I have used a xtabond2 command and two step robust small orthogonal.

I have ran my model i.e. 1994-2014 but now want to split my data into groups of years (4 groups of 6 years). How could I to split that?

Any help on this would greatly appreciated.
Thanks!

Binary Y, endogenous X and continuous instrument Z

$
0
0
Hi all,

I have binary Y, endogenous X and continuous instrument Z plus controls. I am following Angrist and Pischke's, mostly harmless econometrics and using ivreg2. But I get the coefficient of 5 for X. Is that even possible, how do I interpret it? Should I be using other methods?

Thanks,
Laxman

looping on multiple files

$
0
0
Hi statalist community!

I am stuck with this problem for more than two weeks and have studied the web meanwhile. I have multiple stata files (all in R2 folder) I need to make changes on and merge with a master file. At fist step my code to make changes, does not work:

Code:
local dir "C:\Users\Paper 2\Data\cdrdist\R2"
local data: dir "`dir'" files "*.dta"
local data `data'

foreach file of local data {
drop _all

use "`dir'/`data'", clear
duplicates drop FQmetainstanceID,force
seva,replace
}
I'd appreciate if you could take a look at my code. I think I need to read more about local directory macros.

regards,

Command for heteroskedasticity test after Tobit

$
0
0
Dear Statalist members

As I am new to STATA and find it friendly when I get the commands right. I am wondering if you could help in providing a command that tests for heteroskedasticity after Tobit.

I have checked the archives but I do not find a helpful source within my reach eg:
https://www.stata.com/statalist/arch.../msg00989.html

Elsewhere, others have proposed this way https://www.researchgate.net/post/ho...ow_to_solve_it

For the latter I have failed to follow where to search. Any help will be highly appreciated!

Cheers!
Penjani

Problem Importing CSV Files

$
0
0
I'm running into an issue with the CSV import function via import wizard in Stata 15. When I open the wizard (by going to File-->Import-->Tex File (.csv)), the wizard opens properly. But, when I click on the "Browse" button to find the CSV file, stata just closes entirely, without asking to save any open do files or data.

Are there any fixes for this?

Dropping observations in panel dataset if respondent hasn't answered

$
0
0
Hi everyone. I have a panel dataset with varying numbers of respondents in each year for 2006, 2007, 2008 and 2010. I want to drop the respondent if they do not appear in the 2010 and in some year (could be any). My panel variable is named "pid" and the year variable is "year".
Array

I would expect to have fewer than 8000 respondents who have answered in both 2006 (or 2007 or 2008) and 2010. I have checked other threads which ask for similar things but I was not able to drop the required observations.

Any help in the right direction would be much appreciated. Thanks.

Display Shea partial R2 in a table

$
0
0
I want to replicate 2SLS table of Burnside and Dollars "Aid, policies and growth". So, I have run a ivreg2 and I have stored the estimate. But I haven't succeed to display Shea partial R2. In fact, I have use the esttab to store the stat but in my esttab does not display it. Can you help me ?
Sincerely and thanks for you

Partial correlation using 2SLS

$
0
0
Hello,

In a homework we are asking to compute the partial correlation coefficient of (Aid/GPD)*policy (the variable name is "edapolicy") for an OLS and a 2SLS regression. I managed to do the OLS one using pcorr but I didn't find how to compute the 2SLS.

Here is my OLS reg : reg gdpg lgdp ethnf100 assas ethnfassas icrge m2_1 ssa easia policy eda edapolicy
And my 2SLS reg : ivreg2 gdpg ///
lgdp (eda = lpop arms_1 egypt frz centam ///
arms_pol lgdp_pol lpop_pol lgdp2_pol lpop2_pol) ///
assas m2_1 icrge ssa easia policy ///
ethnfassas year2-year7, endog(eda)

For me, knowing that the partial correlation is "the degree of association between two random variables, with the effect of a set of controlling random variables removed", there should be any difference between the 2 partial correlations. But if it's asked it should be because there is one.

How could I compute it ?

Sincerely and thanks you

Display Shea partial R2 in a table

$
0
0
Dear all, I want to display a Shea partial R2 after running an ivreg2 on Stata 15. But in my table, the stats doesn't display
Code:
  eststo IV2_Table4 :
       quietly ivreg2 gdpg
       lgdp (eda edapolicy eda2policy = lpop arms_1 egypt frz centam
       arms_pol lgdp_pol lpop_pol lgdp2_pol lpop2_pol)
       assas m2_1 icrge ssa easia policy
       ethnfassas year2-year7, first endog(eda edapolicy eda2policy)
mat first = e(first)
scalar shea2=first[2,1]
estadd scalar partr2_2=shea2
scalar shea3=first[2,2]
scalar shea4=first[2,3]
estadd scalar partr2_3=shea3
estadd scalar partr2_4=shea4
esttab IV2_Table4,
         label legend
         cells("b(fmt(2) star)" se(par fmt(2)))
         varwidth(35) modelwidth(15 10)
         mtitles("2SLS")
         stats(N r2 prs prs1 partr2_4 pr3,
         fmt(%9.0f %9.2f %9.3f %9.3f %9.3f %9.3f)
         labels("Observations" "R2" "Shea partial R2 Aid/GDP" "Shea partial R2 (Aid/GDP)xpolicy"
         "Shea partial R2 (Aid/GDP)xpolicy" "Hausman test"))
         title("TABLE 4—GROWTH REGRESSIONS: USING ALL COUNTRIES AND THE POLICY INDEX")
         drop(year2 year3 year4 year5 year6 year7 _cons)
Thank you for your help

difference vce (robust) vce (cluster ID)

$
0
0
Hi forum members,

I am doing a fixed effect panel regression and wanted avoid heteroskedasticity and autocorrelation.

Does
Code:
vce (robust
already suffice? or do i need to apply
Code:
 vce (cluster ID)
?
or are they intercangeable?
Lot of confusing info on this topic...

thank you,
best

Estimating LA-AIDS model

$
0
0
Hello statalist users

I am estimating a demand system for LA-AIDS model on 13 food groups but so far am faced with a challenge in estimating the price equation for the composite food groups where the dependent variable is multinomial (a unit value) using OLS in order to assess the demand related price effect. How can I go on estimating the prices (p1 to p13) and expenditure shares (w1 to w13) since dividing expenditure by quantity will generate constant price that undermines disparities in prices cross a cross sectional dataset am using.
I read a paper that used price equation estimation of this form but i can not figure out to estimate the prices. This equation is of a form
V = hhdsize + percapita_montlhly_expenditure + Education_ level _hhd + Urban _residence + region
Where categorical variables are Urban(rural, urban), region (west, East, south, north).
could any one know about how to proceed from this point in order to obtain the parameters .

Your response is highly appreciated
Viewing all 65514 articles
Browse latest View live


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