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

Mac constantly getting an error when trying to create a directory or retrieve data

$
0
0
Hi,

I'm having trouble creating a directory for my do file or even retrieving the data I need to use. I believe the problem is with my Mac because before it was having an error even finding the pathway to my documents folder, so I had to change it to the desktop for it to half-way work.

These are my commands:

clear all
prog drop _all
capture log close
set more off

global datadir "/Users⁩/C/desktop/ProblemSets"
global logdir "/Users/C/desktop/ProblemSets"

log using "$logdir/Ps1 log_new.smcl", replace
use "$datadir/HIV Testing Data.dta", clear

This is the result that appears:

. clear all

. prog drop _all

. capture log close

. set more off

.
. global datadir "/Users⁩/C/desktop/ProblemSets"

. global logdir "/Users/C/desktop/ProblemSets"

.
. log using "$logdir/Ps1 log_new.smcl", replace
--------------------------------------------------------------------------------------------------------
name: <unnamed>
log: /Users/C/desktop/ProblemSets/Ps1 log_new.smcl
log type: smcl
opened on: 23 Sep 2019, 17:19:58

. use "$datadir/HIV Testing Data.dta", clear
file /Users⁩/C/desktop/ProblemSets/HIV Testing Data.dta not found
r(601);

end of do-file

Comparing matched cases and controls with a cluster variable

$
0
0
Hi, I have matched cases and controls and now all variables are shown twice for example BMI and BMI_ctrl. How do I do a paired ttest to see if the cases have a higher BMI than controls? The lack of one variable that defines cases and controls has thrown me. I also need to control for a cluster variable.

Thanks

Changing directories based on a condition.

$
0
0
Hello. I am having issues generating a correct command for the following condition. I have a do file that reads in data from a working directory. I generate a observation counter. I would like to change my current directory if my data_counter >250 observations. I think I need a if else statement.

Code:
*Identify what data we are working with daily vs cumulative data sets**
 gen data_counter = _n

if data_counter >=100 {
cd "/Users/wchin/Desktop/dive-project.git/cycle/short db/Stata data_sets/master" 
}
else{
cd "/Users/wchin/Desktop/dive-project.git/cycle/short db/Stata data_sets/daily"
}

Graphical display of multiple OLS regressions

$
0
0
Hi All,

I am running regression models with the same outcome and independent variables across 5 countries and I am trying to display this graphically in a way that the results are provided for the each country in the dataset and one result for all the countries combined, all in one graph. i have tried
HTML Code:
coefplot
but I want to combine all the regressions in one model

my regression models are

HTML Code:
reg foodsum empower_score ib4.ses_cat age_men age_women edulvl_women hh_size hungerscale study_loc start_month [pw=wmwght] if country=="MOZ", cluster(a02)
HTML Code:
reg foodsum empower_score ib4.ses_cat age_men age_women edulvl_women hh_size hungerscale study_loc start_month [pw=wmwght] if country=="RWA", cluster(a02)
HTML Code:
reg foodsum empower_score ib4.ses_cat age_men age_women edulvl_women hh_size hungerscale study_loc start_month [pw=wmwght] if country=="UGA"], cluster(a02)
HTML Code:
reg foodsum empower_score ib4.ses_cat age_men age_women edulvl_women hh_size hungerscale study_loc start_month [pw=wmwght], cluster(a02)]
I would most appreciate any advice on how this could be achieved

Many thanks!

Calculating difference between two times in minutes

$
0
0
I have two variables - bed time and wake time. bed time is formulated like: 21_30 and wake time is formulated like 06_30.

Can you advise how I can calculate the duration between those times in stata in minutes? i.e in that example the calculation should be 540 minutes.

Predict with oprobit: cross-section by fyear

$
0
0
Hi all,

I need to estimate equation (below) via ordered probit and cross-sectionally by fyear. And then, the highest fitted probability of each possible rating has to be generated.
Array


,where "i" is for firm and "t" is for fyear.

"CR" is the numerically transformed credit rating: dependent variable.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte ind int date_f long destr_gvkey int fyear float(IC Debt) byte CR
28 212 1078 2013   .19953124      6.858 17
28 213 1078 2013   .21894777   9.298006 17
28 214 1078 2013    .1949921  9.0503235 17
28 215 1078 2013   .18853165   6.224858 17
28 216 1078 2014   .16914694   8.147954 17
28 217 1078 2014   .17027125     6.1375 17
28 218 1078 2014   .11471515   8.325978 17
28 219 1078 2014   .10805573   6.100311 17
28 212 1209 2013  .031368762  10.418954 16
28 213 1209 2013  .023320094   10.00368 16
28 214 1209 2013   .02394333  10.273672 16
28 215 1209 2013   .02523235   9.781103 16
28 216 1209 2014   .02163526   10.29079 16
28 217 1209 2014   .01986862  10.333612 16
28 218 1209 2014  .018431772    9.45309 16
28 219 1209 2014   .01893234   8.553754 16
13 212 1380 2013  .010476887   4.198065 13
13 213 1380 2013  .017500242  3.5066504 13
13 214 1380 2013  .007661829  4.2382255 13
13 215 1380 2013   .04242878   5.580366 13
13 216 1380 2014  .031093087   3.666009 13
13 217 1380 2014   .05368752   4.610774 13
13 218 1380 2014   .10054912   4.098428 13
13 219 1380 2014   .06335217   5.056588 13
28 212 1602 2013    .4119094  13.890697 17
28 213 1602 2013    .4185136  12.276694 17
28 214 1602 2013    .3952482   13.42004 16
28 215 1602 2013   .29339886    17.1258 16
28 216 1602 2014   .29553458  16.157417 16
28 217 1602 2014    .3766215  13.760529 16
28 218 1602 2014    .3966796  14.376635 16
28 219 1602 2014    .3916301  13.602746 16
13 212 1678 2013 .0040134643  4.3254766 15
13 213 1678 2013  .002904499  4.4871793 15
13 214 1678 2013  .020767277  4.3473935 15
13 215 1678 2013  .030922985  4.3183837 15
13 216 1678 2014  .026881104  3.8941224 15
13 217 1678 2014  .021284595  4.1135206 15
13 218 1678 2014   .00957534  14.982167 15
13 219 1678 2014  .013743923  -7.952617 15
28 212 1794 2013   .03943116  16.838863 10
28 213 1794 2013   .03820096   13.19173 10
28 214 1794 2013   .03100584   14.02459 10
28 215 1794 2013   .02862343   4.942512 10
28 216 1794 2014   .02461821  15.459716 10
28 217 1794 2014   .04028553  21.612904 10
28 218 1794 2014   .04700643   12.70115 10
28 219 1794 2014     .127203  -61.88679 10
13 212 1860 2013  .033244185   9.227638 10
13 213 1860 2013   .03560679   7.853799 10
13 214 1860 2013   .06157583   9.488736 10
13 215 1860 2013   .02427223    8.02013 10
13 216 1860 2014  .032443028  12.039682 10
13 217 1860 2014  .014598052   13.51565 10
13 218 1860 2014  .029073395   11.47729 10
13 219 1860 2014  .017767018   9.906453 10
73 212 1878 2013     .486724   6.490861 13
73 213 1878 2013    .4730661   6.359761 13
73 214 1878 2013   .47680205   7.237634 13
73 215 1878 2013    .4933841   8.184211 13
73 216 1878 2014    .4559867   9.263027 13
73 217 1878 2014    .4053238   8.496018 13
73 218 1878 2014    .4014102  14.589844 13
73 219 1878 2014    .4123896     14.944 13
73 212 1891 2013   .03825292   1.044131 21
73 213 1891 2013    .0430483  .05906067 21
73 214 1891 2013   .04183358 .021473683 21
73 215 1891 2013   .05352345   .6868318 21
73 216 1891 2014     .057355   7.384876 21
73 217 1891 2014  .033651862  .02887921 19
73 218 1891 2014   .04628585 .018615386 19
73 219 1891 2014   .12529133   6.334492 19
13 212 1976 2013   .04054651   5.702127 16
13 213 1976 2013   .04106033   5.708139 16
13 214 1976 2013   .04872836  4.4941063 16
13 215 1976 2013   .05008234  4.2369437 16
13 216 1976 2014   .04301692   4.423379 16
13 217 1976 2014   .04112883   3.931838 16
13 218 1976 2014   .04221074  3.7146466 16
13 219 1976 2014   .06036008   2.830822 16
28 212 2086 2013    .1323457   6.405022 16
28 213 2086 2013    .2521578   9.295267 16
28 214 2086 2013     .094099    8.77638 16
28 215 2086 2013   .10564768    8.45572 16
28 216 2086 2014   .08111318  12.437768 15
28 217 2086 2014   .07280815 -25.546244 15
28 218 2086 2014   .08128937  35.646152 15
28 219 2086 2014   .11286028   42.88018 15
28 212 2316 2013   .11566952   39.87368  6
28 213 2316 2013   .09807305   38.60204  6
28 214 2316 2013   .10080414  36.757282  6
28 215 2316 2013   .13956735   51.69863  6
28 216 2316 2014  .072881356   35.66981  6
28 217 2316 2014   .04752137  34.648647  6
28 218 2316 2014   .04492395  34.232143  6
28 219 2316 2014  .066991016     -116.8  5
28 212 2403 2013  .070443295   8.055102 17
28 213 2403 2013   .07720953   6.823864 17
28 214 2403 2013   .07395935   6.233362 17
28 215 2403 2013   .11725228   6.609005 17
end
format %tq date_f

What I coded so far is below; however, I couldn't go further than that.

Code:
forvalues j = 1/`=_N' {
    capture quietly {
        oprobit CR IC Debt if ind==ind[`j'] & fyear== fyear[`j']  
           predict p1 p2 p3 p4 in `j'
      }
}
I can't go further than what I wrote above. Now, I have three problems.
First, I got error message from the above code: "is not a valid command name"
Code:
. forvalues j = 1/`=_N' {
  2.     capture quietly {
  3.         oprobit CR IC Debt if ind==ind[`j'] & fyear== fyear[`j']  
  4.            predict p1 p2 p3 p4 in `j'
  5.       }
  6. }
 is not a valid command name
Second, each industry-fyear has different outcomes.
For example, the combination of ind (13) and fyear (2013) has 4 outcomes: Pr (CR==10), Pr (CR==13), Pr (CR==15), and Pr (CR==16). These are outcomes that I individually execute the commands as follows:
Code:
oprobit CR IC Debt if ind==13 & fyear==2013
predict p1 p2 p3 p4
However, if I have different industry and fyear, I have 6 different outcomes: Pr (CR==5), Pr (CR==6), Pr (CR==10), Pr (CR==15), Pr (CR==15), and Pr (CR==17)
Code:
oprobit CR IC Debt if ind==28 & fyear==2014
predict p1 p2 p3 p4 p5 p6
And, I believe this happens because the dependent variables are different in each industry-fyear.

I need help to write the code that generates the outcomes for each industry-fyear.
Third, based on the past study, I need to divide each probability by the frequency of that rating in the population.
For example, if I run the following code:

Code:
oprobit CR IC Debt if ind==13 & fyear==2013
predict p1 p2 p3 p4 if ind==13 & fyear==2013
tab CR

The outcomes will be: p1=Pr(CR==10), p2=Pr(CR==13), p3=Pr(CR==15), and p4=Pr(CR==16)
And, each Pr needs to be divided by the frequency of CR in the population.
new_p1=Pr(CR==10)/16
new_p2=Pr(CR==13)/16
new_p3=Pr(CR==15)/12
new_p4=Pr(CR==16)/26
Hope what I wrote above makes sense to you all.
Any help will be greatly appreciated.

Thanks a lot.

logistic function (discounting models): error r(430) convergence not achieved

$
0
0
Hi,

I use the following commands (logistic function) and Stata indicates "error r(430) convergence not achieved".

nl (choice=1/(1+exp(-{m}*(reward-y*exp(-{r}*t))))), cluster(id) nolog iterate(100)
nl (choice=1/(1+exp(-{m}*(reward-y/(1+{r}*t))))), cluster(id) nolog iterate(100)
nl (choice=1/(1+exp(-{m}*(reward-{alpha}*y*exp(-{r}*t))))), cluster(id) nolog iterate(100) level(99)
nl (choice=1/(1+exp(-{m}*(reward-{alpha=1}*y*(1-(1-{theta=3})*{r}*t)^(1/(1-{theta=3})))))), cluster(id) nolog iterate(100) level(99)

In the analysis, each respondent represents a cluster in which 75 binary choices are observed.
In the estimation, 23,925 observations are obtained, which corresponds to 319 distinct units of observation. The data looks like below.

What could be possible solutions?

Thanks.

Array

Why Mundlak and Fixed effect regression coefficient are not exactly same

$
0
0
Dear Statalist,

I have any issue regarding comparing the fixed-effect model and mundlak effect in controlling the means of time-variant variables as additional regressors.
Here are the results. I am wondering why the coefficient of fixed and random effect is slightly different. Might it be due to missing data?

thanks and regards,

PHP Code:
 xtreg lremit $xlist0 i.yearvce(cluster pairidfe

note
comlang_off omitted because of collinearity
note
colony omitted because of collinearity
note
contig omitted because of collinearity

Fixed
-effects (withinregression               Number of obs      =      1102
Group variable
pairid                          Number of groups   =       271

R
-sq:  within  0.1197                         Obs per groupmin =         1
       between 
0.5477                                        avg =       4.1
       overall 
0.5723                                        max =         7

                                                F
(10,270)          =      5.71
corr
(u_iXb)  = 0.0948                         Prob F           =    0.0000

                               
(StdErradjusted for 271 clusters in pairid)
------------------------------------------------------------------------------
             |               
Robust
      lremit 
|      Coef.   StdErr.      t    P>|t|     [95ConfInterval]
-------------+----------------------------------------------------------------
       
lgdpc |   .4199601   .1413403     2.97   0.003      .141691    .6982293
   lgdpc_hos 
|   .2482984   .3412649     0.73   0.467    -.4235802    .9201771
      lcost2 
|  -.1912492   .0978837    -1.95   0.052    -.3839617    .0014632
     lmig_st 
|   .3740764   .1592843     2.35   0.020     .0604792    .6876735
 comlang_off 
|          0  (omitted)
      
colony |          0  (omitted)
      
contig |          0  (omitted)
             |
        
year |
       
2012  |   .0043988   .0190377     0.23   0.817    -.0330823      .04188
       2013  
|  -.0265595   .0471652    -0.56   0.574    -.1194178    .0662988
       2014  
|  -.0332107   .0542274    -0.61   0.541    -.1399731    .0735516
       2015  
|   .1402847    .055213     2.54   0.012     .0315819    .2489875
       2016  
|   .0661839   .0598106     1.11   0.269    -.0515705    .1839384
       2017  
|   .0920051   .0592864     1.55   0.122    -.0247174    .2087276
             
|
       
_cons |  -6.884898   5.217741    -1.32   0.188    -17.15753    3.387733
-------------+----------------------------------------------------------------
     
sigma_u |  1.2156288
     sigma_e 
|  .34090766
         rho 
|  .92708901   (fraction of variance due to u_i)
------------------------------------------------------------------------------ 
Mundlak Effect results

PHP Code:
 xtreg lremit $xlist0 $vlist0 i.yearvce(cluster pairid

Random-effects GLS regression                   Number of obs      =      1102
Group variable
pairid                          Number of groups   =       271

R
-sq:  within  0.1197                         Obs per groupmin =         1
       between 
0.6579                                        avg =       4.1
       overall 
0.6785                                        max =         7

                                                Wald chi2
(17)      =    847.77
corr
(u_iX)   = (assumed)                    Prob chi2        =    0.0000

                                 
(StdErradjusted for 271 clusters in pairid)
--------------------------------------------------------------------------------
               |               
Robust
        lremit 
|      Coef.   StdErr.      z    P>|z|     [95ConfInterval]
---------------+----------------------------------------------------------------
         
lgdpc |   .4439019   .1406352     3.16   0.002     .1682619    .7195418
     lgdpc_hos 
|   .2524156   .3360553     0.75   0.453    -.4062407    .9110718
        lcost2 
|  -.2028169   .0977656    -2.07   0.038    -.3944339   -.0111998
       lmig_st 
|   .3689689   .1583542     2.33   0.020     .0586004    .6793375
   comlang_off 
|   .0681932   .1503237     0.45   0.650    -.2264358    .3628223
        colony 
|   -.135961   .1806898    -0.75   0.452    -.4901066    .2181845
        contig 
|   .0056654   .3514274     0.02   0.987    -.6831196    .6944504
    lgdpc_mean 
|  -.1943218   .1454022    -1.34   0.181    -.4793049    .0906614
lgdpc_hos_mean 
|  -.0928574     .34678    -0.27   0.789    -.7725336    .5868189
   lcost2_mean 
|  -.3658746   .2326023    -1.57   0.116    -.8217667    .0900174
  lmig_st_mean 
|    .399029   .1679837     2.38   0.018     .0697869     .728271
               
|
          
year |
         
2012  |   .0038119   .0192994     0.20   0.843    -.0340142    .0416381
         2013  
|    -.02782   .0471031    -0.59   0.555    -.1201403    .0645004
         2014  
|  -.0348137   .0541059    -0.64   0.520    -.1408593    .0712318
         2015  
|   .1384236   .0552425     2.51   0.012     .0301503     .246697
         2016  
|   .0623224   .0595451     1.05   0.295    -.0543839    .1790286
         2017  
|    .089855   .0592783     1.52   0.130    -.0263284    .2060383
               
|
         
_cons |  -7.467168   .8463628    -8.82   0.000    -9.126009   -5.808328
---------------+----------------------------------------------------------------
       
sigma_u |  1.0303308
       sigma_e 
|  .34090766
           rho 
|  .90132614   (fraction of variance due to u_i)
------------------------------------------------------------------------------- 

Using a loop to append multiple waves of data

$
0
0
I want to create a loop to append multiple waves of panel data. Most vars appear in each wave, three additional vars only appear in 4 waves. Should I therefore create two separate loops to append the waves?

I understand when appending waves the vars names need to be the same. In the panel data I have, a prefix is added to each varname to reflect the wave (age in wave 1 is aage, year 2 is bage, year 3 is cage), and for appending the vars need to have the same name. So can we code the removal this prefix within the loop to append the waves? And if not, how would I go about coding this?

Using the source datafile I save the renaming vars to a temp datafile, then save the appending to a new datafile, right? Some clarity in the code on this would be appreciated.

Thank you in advance.

bysort command while regressing

$
0
0
I have 2 variables, investment and cash flow. I also generated a dummy variable called age, which has 3 levels 1 for young,2 for growth and 3 for mature.Now,I tried to regress investment on cash flow with bysort command. Stata displays an error command ,"not sorted ".I think the problem is with the lag operator. I have appended my commands. Can anyone help me what went wrong.

[bysort age : xtreg investment cashflows l.cashflows i.year,fe vce(robust)] .

Producing forest plot with reference category using preestimated values from regression analysis??

$
0
0
Dear Stata users,
I have regression estimates (i.e., effect sizes and 95%CIs). Now, I want to put them on the forest plot with reference category. I tried using admetan but it excludes the reference category (as it uses log form, SE is inestimable for reference category. I want to have forest plot as given below in the figure and appreciate if someone suggest any way of doing;

Array

Extreme Bound Analysis Results Interpretation

$
0
0
Hi All,

I got the following result after running an extreme bound analysis.

gfc, gfcf, infl, popgr, to, tot, llock are the variables that appear in all the regressions.
fdini is the variable of interest.
polity2, cor, ge, ps, rq, rl, va are other potential control variables.
gdppcgr is the dependent variable.

Can someone please help me in interpreting the following result?

I have gone through papers that report EBA results; but those result tables are different from the output that Stata gives. Thus I am unable to make much sense of the output.

For example: 1. The five columns in front of each combination of z variables.
2. The table at the end
3. Additionally, if someone can please explain the difference between le() and the 0.95 CI mentioned in the last table.

Code:
eba gdppcgr fdini polity2 cor ge ps rq rl va, x(gfc gfcf infl popgr to tot llock) detail type(3) le(0.15)
z1 z2 z3 1 4.6472645 .00320803 .15240717 .90371552
z1 z2 z4 1 3.0548062 -.00257979 -.12230341 .922524
z1 z2 z5 1 3.919754 .00126325 .06002498 .96183271
z1 z2 z6 1 6.1878181 -.00076388 -.03625275 .97693089
z1 z2 z7 1 3.6349709 -.00070261 -.03365616 .97858191
z1 z3 z4 1 2.3002324 .00368973 .17499878 .88970914
z1 z3 z5 1 5.5216174 .00479687 .22801675 .85728006
z1 z3 z6 1 5.6181717 .00470837 .22387925 .85978612
z1 z3 z7 1 3.1569164 .00162142 .07706948 .95103284
z1 z4 z5 1 2.0866983 .0030853 .14589109 .90777349
z1 z4 z6 1 3.1105747 .00127314 .06022497 .96170584
z1 z4 z7 1 2.2323534 -.00442695 -.21014918 .86813372
z1 z5 z6 1 4.5545945 .00357673 .1696774 .89299911
z1 z5 z7 1 2.7914491 -.0006536 -.0310681 .98022779
z1 z6 z7 1 3.8547575 -.00260347 -.12367798 .92166196
z2 z3 z4 1 4.8191953 .00221314 .10758012 .93177476
z2 z3 z5 1 6.8219852 .00381441 .18573088 .88309218
z2 z3 z6 1 7.0903535 .00264684 .12899079 .91833287
z2 z3 z7 1 4.6707268 .00344555 .16758468 .89429454
z2 z4 z5 1 4.038815 .00040825 .01985424 .98736206
z2 z4 z6 1 6.0524855 -.00058906 -.0286741 .9817505
z2 z4 z7 1 3.2560699 -.00147631 -.07204387 .95421455
z2 z5 z6 1 7.1446962 .00091743 .04468834 .97156943
z2 z5 z7 1 3.8615916 .00093359 .04548912 .97106068
z2 z6 z7 1 6.8034697 -.00276362 -.13459017 .91482905
z3 z4 z5 1 5.7203054 .00533139 .25922867 .8385243
z3 z4 z6 1 7.5384178 .00553112 .2688928 .83277299
z3 z4 z7 1 3.0974302 .00289881 .14055224 .91110399
z3 z5 z6 1 7.2717772 .006164 .30013074 .81437648
z3 z5 z7 1 5.7568231 .00437667 .21266793 .86659884
z3 z6 z7 1 7.1319551 .00368098 .17891625 .88729092
z4 z5 z6 1 6.7978168 .00376513 .18257896 .88503294
z4 z5 z7 1 2.9073579 .00042755 .02068883 .98683096
z4 z6 z7 1 4.8576789 -.0002627 -.01272858 .99189717
z5 z6 z7 1 6.1259589 .00178423 .0864996 .94506937

Result of EBA on fdini at .15 confidence level and maximum VIF = 10000

Dvar = gdppcgr
X    = [gfc gfcf infl popgr to tot llock]
Z    = [polity2 cor ge ps rq rl va]

        beta         t      p-val        .95 C.I.        VIF    Zs
-----|---------|---------|--------|---------|---------|-----------------------
 min    0.0053    0.2592   0.8385   -0.2560    0.2667     5.72  [z3 z4 z5]
 Max    0.0062    0.3001   0.8144   -0.2548    0.2671     7.27  [z3 z5 z6]
------------------------------------------------------------------------------
A total of 35 combinations of 3 regressors from the Z(nx7) vector were used.

.
Thanks,
Aman
Stata 14.0

Stata 15.0 crashes

$
0
0
Good morning,
I am using Stata 15.0 and every so often the program crashes. This has happened using different datasets, regardless of the computational difficulty of the command used.
I was wondering if anyone else has experienced the same problem
Thank you
Stefania

margins, pwcompare vs. margins, contrast

$
0
0
Dear members of Stata forum,

I am running a simple logit regression, where my outcome variable is 1 when individuals indicate they will vote in the election and zero otherwise. Individuals psychological health such as depression, locus of control, anxiety, etc. which are measured by continuous scores ranging from -5 till 5 are among my independent variable.

I have significant effects of the anxiety, and locus of control in the original regression, and I am calculating the marginal effects at different scores of anxiety/locus of control using the margin command.

I have two questions:

1- If I want to find out whether the average probability of voting at different scores of the anxiety/locus of control are different from each other, should I use the pwcompare or contrast option.
I particular:

Code:
logit vote anx loc dep $dem

margins, at(anx=(-5(1)5)) pwcompare(effects)
or

Code:
margins, at(anx=(-5(1)5)) contrast(effects)

2- When I use pairwise comparision, with bonferroni or other adjustment methods, all the comparisons become insignificant while the unadjusted p-values indicate significant difference between points. This I guess is due to large number of hypothesis being tested. But I am wondering wether adjustment is needed or not?

Thank you very much fro taking the time.
Emma

Estimating output for observations after the model development

$
0
0
Hello dear all,
Sorry if I'm asking a repetitious question. I'm new to STATA and I searched the forum before posting my question.
I have a dataset containing 153 observation. 123 of them are used to develop the model and the rest of them (30) is going to be used for model validation. I developed four count models (Poisson, NB, ZIP and ZINB).
After developing these models, I aim to validate these models using those 30 observations. How can I get output from STATA for my observations, after I calibrating the model?
I want to compare the predicted and actual values of the target variable to calculate RMSE, MAD and MAPE.
Thanks.

Combining t - statistics with table

$
0
0
Hello,

I have already created a table which contains alphas of 25 ( 5 x 5 ) portfolios. In the next step I am trying to implement t - statistics on the alphas in my table.
Unfortunately I am struggeling to find a solution to do the t - test and combine the results with my alphas in the table.

In the end, there should be the table with alphas and the associated t - statistics underneath.

I am looking forward to an answer!

Thank you in advance.

Sort by correlation coefficient

$
0
0
I am trying to find out which variable produces the highest correlation coefficient with var1 within subjects.

I have 10 variables (var1-var10) for 10 days (day) for 10 individuals (id) in long format. However, I recreated an example with 3 variables, for 5 days for 3 individuals in dataex:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id day) float(var1 var2 var3)
1 1   .7806329   .2003541   .9929246
1 2   .8852594   .7479552   .3049926
1 3    .573707  .22255337   .8362682
1 4   .2431343   .9553812   .1578373
1 5 .008077622   .8259419   .8112878
2 1   .4933739   .1188735  .36237845
2 2   .7138895  .55584866    .884728
2 3   .4031537   .3037445 .008933238
2 4   .1250264  .53452736   .7117536
2 5   .7928984   .3798434   .6441231
3 1  .25131217 .063004404   .9543635
3 2   .6858981   .6998435   .8498245
3 3   .9965313    .483217   .4657771
3 4   .9135284   .8579231  .13088849
3 5  .29056227  .25628337   .5243536
end
I want to find out, for each id, which of variables var2-var10 has the highest Pearson's correlation with var1.

The best I can do is:

Code:
local varlist "var2 var3"

foreach i in 1 2 3 {
    display _newline
    foreach a in `varlist' {
        qui pwcorr var1 `a' if id==`i'
        local `i'_`a'_r = r(rho)
        if r(rho) !=. & r(rho)!=0 { //in the actual dataset, var1 may not be available or may not vary. This is how I exclude them from the list. 
            display "`i'_`a'_r:" ``i'_`a'_r'
        }
    }    
}
which outputs:

Code:
1_var2_r:-.54861605
1_var3_r:.04435157


2_var2_r:-.05894353
2_var3_r:.25521847


3_var2_r:.79714705
3_var3_r:-.61136201
The next step is to sort these by absolute correlation coefficient within id so that I know which of var2-var3 correlates highest with var1 within each id. For this exercise, I do not care for the significance.

Just to remind you that the example data is much smaller (3 x 5 x 3) than the actual data (10 x 10 x 10), so in the latter case it makes more sense to sort the correlation coefficients.

Thanks so much.

generating positive and negative components of a variable

$
0
0
Dear members, I want to generate positive and negative components of a variable on stata for non-linear panel ARDL.

I am just stuck on this stage. I need stata command or code. please help.

Regards,
Rabiya gill

Filtering methods in Micro panels

$
0
0
Dear all
I have a micro panel(No: of firms=3000 and no: of years=8). My variable of interest is Cashflows(unscaled) & I am interested in finding trend and cycle components of cashflows. Since it is obvious there will be gaps in Cashflows due to missing data, I am unable to use filtering methods like HP/BK. Below gives the ts report and due to gaps, I am unable to proceed.

Panel variable: id
Time variable: year
---------------------------
Starting period = 2011
Ending period = 2018
Observations = 22256
Number of gaps = 5945
(Gap count includes panel changes).
In the above case, is there any way to do filtering rather than abandoning the study.

Problem with png2rtf

$
0
0
Hi all,

I am using png2rtf module to add a graph file to a word file. All its ok but I have a problem when I add also a table to the same word file: graph dissapear and only the table exist in the word file. I used append option in both. I am using asdoc to add a table to word file but I have the same Issue with estpost and esttab.

Example of my problem:


sysuse auto.dta, clear

cd "C:\Nueva carpeta"

hist mpg
graph export grafico.png, replace

png2rtf using graph.doc, g(grafico.png) append

*Here I add the table to the same word file but delete the graph.
asdoc sum mpg, save(graph.doc) append

*I had the same problem with command below
*estpost sum mpg
*esttab using graph.doc, cells("count mean sd ") noobs nonumber collabels(N Media D.S.) title(Estadistica descriptiva ) append
Do you know what its the problem?
Thanks in advance
Rodrigo
Viewing all 65507 articles
Browse latest View live


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