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

One sided meta analysis

$
0
0
I have extracted this data from studies of either treatment (group) 1 or 2.
I want to run a meta-analysis comparing the means, but obviously each study only has one patient group.
Am I best running a separate meta-analysis for each group, or is there a way to compare them within Stata?
Thanks

Array

Testing statistical difference for 4 variables

$
0
0
I shoul perform a test for whether the means are statistically different from zero for the excess stock returns and the three factor returns (Mkt_RF (this is called ‘the excess market return’), SMB, HML). Is it possible to do it in stata? if yes, what command should I use? Thanks in advance

How to recreate longitudinal analyses from SAS in STATA using xtgee only using SAS output???

$
0
0
Hello all,

I have been trying to recreate SAS output in Stata but keep getting discrepancies. Unfortunately, the biostatistician only gave me the output and not the SAS code so I am trying to recreate the analyses in Stata by using the output.

First, I tried to check skewness and kurtosis and there was quite a discrepancy but I soon learned that is because SAS and Stata use different formulas.

Now, I am trying to create GEE analyses but I am not getting the same results.

This is what I am using to decipher the SAS analyses:
Distribution Normal Link Function Identity Observations Used 1375
GEE Model Information: Correlation Structure AR(1)
Subject Effect SBA (55 levels) Number of Clusters 55
Correlation Matrix / Cluster Size 25 (years)
tm=years; tm5=(tm-5)*(tm>=5); tm10=(tm-10)*(tm>=10); tm19=(tm-19)*(tm>=19);

Dependent Variable sallfd = sqrt(All_food) Algorithm converged.
GEE Fit Criteria

I have tried the following:
xtset SBA year
xtgee sAllfd tm tm5 tm10 tm19 i.Gcode Gcode#c.tm Gcode#c.tm5 Gcode#c.tm10 Gcode#c.tm19, family(gaussian) link(identity) corr(ar1)


Would this be incorrect since xtgee provides fit population-averaged panel-data models by using GEE?

Any help is most welcomed.

groups command, export/copy table to excel

$
0
0
the groups function is a very useful command, however the output seems to be not very transferable - is there a way to export the results to excel? Copy Table does not work for -groups- ouput
Either with the same function as "copy Table" for other output, or putexcel?
Thanks

mi predict problem

$
0
0
Dear all,

I am having problems trying to get the baseline survivor function after mi predict.
I am using the following code:
mi predict basesurv using miest, basesurv

and get the following error:
option basesurv not allowed r(198)

Is there a way to calculate predicted probabilities after mi predict command? I can only calculate XB after mi predict, but I would like to calculate 10-year risks for each person in my dataset. Therefore I first need baseline survivor values.. Any suggestions are very welcome..

Thanks!

Please help: translate R survey design code into Stata

$
0
0
Dear all,
Let me start by saying that I know very little to nothing of survey design, so this may be really simple, but I have no way of knowing.
Someone shared with me a code to run a model. The code is in R, which I don't "speak", but for the most part I've been able to "translate" it into Stata to continue working with my dataset.
However, there's a piece that has to do with survey design, where I am completely lost.

The R code reads like this:

# create a survey design object with SIPP design information
z <-
svrepdesign (
data = y ,
repweights = "repwgt[1-9]" ,
type = "Fay" ,
combined.weights = T ,
rho =(1 - 1 / sqrt( 4 )) ,
weights =~wpfinwgt
)

What would this look like in Stata?
I was looking into svyset but wasn't finding all the options. Since it uses replicate weights, thought it would be BRR, but it also says Fay, so I'm very confused, to say the least.
Anyone?

Thanks in advance!

Problem with mi commands and using value labels in expressions

$
0
0
Hi

I am trying to use value labels in expressions with the mi commands. Unfortunately, when I run the following command:

mi estimate: regress income age if country == "CH":country

I obtain the error:

command prefix regress income age if country == "CH": not allowed.

country denotes also the name of the value label of the variable country. Is there a work around so that I can use the value labels in expressions with the mi commands?

Best,
Konrad

Fama and French (2015) Time Series Apprach

$
0
0
I am comparing results of Fama and Frech (2015) Time series approach and Fama and Macbeth (1973) two steps approach. The results of Fama and Macbeth (1973) can be computed by using asreg or xtfmb comand. Can someone please explain that how to test procedure of Fama and Frech (2015). I know the equations from the paper but unable to apply these equations here in stata. Thanks for your help

what package does near/far matching in Stata?

$
0
0
Hi,

I am looking to use a near-far propensity score matching technique in stata but I have not been able to find any way to do that. Does anyone have any recommendations?

Thanks

Variance of Fixed effect residuals

$
0
0
Hi all, I am performing the following fixed effect regression on an unbalanced panel model:
Code:
quietly xtreg tasso_crescita_sales_prod L.log_sales L.dummy_2 L2.dummy_2 L3.dummy_2 mean_gr_rate_atc2 recalls_sales ageprodcat1 ageprodcat2 ageprodcat3 ageprodcat4 newmolfirm newmolmarket i.Year, fe vce(cluster idpr)
I would like to compute the variance of all the residuals and store It into a variable.
Code:
e(sigma_e) // or e(sigma_u)
do not seem to do what I want...specifically: I constructed a variable consisting of the residuals of the estimation (variable av_it):

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(idproduct Year av_it)
  8 2004          .
  8 2015          .
 22 2004          .
 22 2005          .
 22 2006          .
 22 2007          0
 22 2008          .
 22 2009          .
 22 2010          .
 22 2011          .
 41 2004          .
 41 2005          .
 41 2006          .
 41 2007    .303154
 41 2008 -.14690971
 41 2009 .006593704
 41 2010   .2429447
 41 2011  -.1774826
 41 2012  -.8590889
 41 2013  .12342644
 41 2014  .50736046
 41 2015          .
 44 2005          .
 44 2006          .
 44 2007          .
 44 2008  -.9983988
 44 2009  .12073898
 44 2010  -.5993109
 44 2011          .
 44 2012 -1.4308786
 44 2013    1.45887
 44 2014  1.4698343
 44 2015 -.02085495
 62 2004          .
 62 2005          .
 62 2006          .
 62 2007          .
 62 2008          .
 62 2009          .
 62 2010          .
 62 2011          .
 62 2012          .
 62 2013          .
 62 2014          .
 62 2015          0
 99 2004          .
 99 2005          .
 99 2006          .
 99 2007          .
 99 2008          .
 99 2009          .
 99 2010          .
107 2004          .
107 2005          .
107 2006          .
107 2007          .
107 2008          .
107 2009   2.132491
107 2010          .
107 2011          .
107 2012          .
107 2013          .
107 2014          .
107 2015  -2.132491
108 2004          .
108 2005          .
108 2006          .
108 2007          .
108 2008          .
108 2009          .
108 2010          .
108 2011          .
108 2012          .
108 2013          .
108 2014          .
108 2015          .
114 2004          .
114 2005          .
114 2006          .
114 2007  -.7792645
114 2008  .26324368
114 2009   .1756668
114 2010   .4246168
114 2011  -.0842619
114 2012          .
114 2013          .
114 2014          .
114 2015          .
130 2004          .
130 2005          .
130 2006          .
130 2007   .6940765
130 2008  -.6289883
130 2009   .6858149
130 2010          .
130 2011  -.4151192
130 2012   -.335784
130 2013          .
130 2014          .
130 2015          .
end
What I would like to do is to compute Var(av_it) and then average it over time.

quantile regression, loop-foreach

$
0
0
Dear Clyde Schechter

There is a slight twist in my qreg variables, which is giving me troubles while running them in a loop.. mentioned below is the code that I am using, where XtsysCFI is the dependant variable and all others are independant vars. Please note that XtsysCFI and XIFI belong to different panels. or in a way it is a cross panel sort of regression. that i want to see the effect of XIFI(one set of panel type) on XtsysCFI(other set of panel type). next to the codes is my data example.

program define one_id
qreg XtsysCFI XIFI L_Tbills L_MktR L_EV L_TEDSp L_Inf, q(0.99)
foreach v of varlist XIFI L_Tbills L_MktR L_EV L_TEDSp L_Inf {
gen coeff_`v' = _b[`v']
gen se_`v' = _se[`v']
gen t_`v' = coeff_`v'/se_`v'
gen p_`v' = 2*t(e(df_r), -abs( t_`v'))
}
gen constant_term = _b[_cons]
gen se_constant = _se[_cons]
predict V
exit
end
runby one_id, by(FI) status


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long FI float(Time_Period XtsysCFI XIFI L_Prices L_Tbills L_MktR L_EV L_Inf L_TEDSp)
1 480            .         .        .       .       .     .      .        .
1 481    .14411725         . .0672038 -16.535       .     .      .  -2.3525
1 482    .15156017         . .0835295 -11.625     8.9     . -11.95 -1.34125
1 483    .21712346         . .0798496   -.134   3.516     .  18.21    -1.15
1 484     .3422176         . .0781215  -4.167  -5.058     .   8.68   -.6275
1 485   .002527645         . .0903209    .982 -21.281     .  -1.03   -.3375
1 486   .015975993         . .0657473    .278  -1.041     .  32.81  -.45062
1 487   -.04165486         .  .074969    .139   2.221     .  -2.35  -.50812
1 488     .8570709         . .0736191   2.075  -2.384     . -11.04      -.7
1 489  .0031250215         . .0654767  10.298   3.017     .     14 -1.32875
1 490     .2175392         . .0733345  35.135   -5.01     .   -9.7    -4.24
1 491    .25854942         . .0745745   -.727 -15.387     .  18.64   -4.205
1 492   -.01926262         .   .07685    .366  16.674     .  -6.65 -4.56125
1 493    .02069786         . .0745791       0  -3.098     .  -7.52 -5.53875
1 494     .3173947         . .0580505       0  -2.664     .   -1.5  -5.9075
1 495     .2068724         . .0498555   5.383  -7.193     .  -9.13 -6.67125
1 496      .426964         . .0479043   -.087   3.169     .   -5.5 -7.20375
1 497    -.0753018         . .0466443     .52    .769     .  -9.11    -7.61
1 498    .10299566         . .0375243  11.034   -.815     . -29.81 -9.04375
1 499   -.21613307         . .0303341 -10.093 -10.609     .  -1.59    -7.91
1 500     .2027448         . .0321417  -9.585   2.375     .  33.47  -7.0075
1 501    -.3093559         .  .031865    .287 -10.462     . -25.98    -7.91
1 502   -.16420217         . .0308261      -2  21.554     .   2.45    -8.09
1 503   -.08708863         . .0338145 -19.728  -3.465     . -22.71 -6.22812
1 504    -.2005374         . .0336571  -3.995  -6.471  9.25  -8.76    -6.05
1 505 -.0002454049         . .0279009 -19.924  24.111 10.75  12.99    -4.47
1 506   -.10337656         .   .03609     .63   8.615 10.89   21.5    -4.49
1 507  -.003704032         . .0309914    .782   5.624   9.9  37.04    -4.41
1 508    .01020024         . .0282982    .155   1.637  9.89    -.3    -4.53
1 509    .12938884         .  .033633    -.31 -13.247 10.34 -12.05    -4.53
2 510            .  .3849556        .       .       .     .      .        .
1 510   .032016464         .   .04408  -2.333   6.221 10.39     25    -4.42
1 511   -.06109645         . .0330991   1.911    .983 10.38  15.89    -4.58
2 511            . -.0415979 .3431187    2.82   -1.17     . 257.58    -.996
1 512    .09693163         . .0316686       0   9.949 10.48 -10.64    -4.59
2 512            . -.2283536 .3281123    2.78   -1.41     . -24.58    -.974
2 513            .         0 .3296109    2.82   -8.78     . -73.03    -1.03
1 513    .14152934         . .0351229   -.469   2.212   9.8   1.32    -4.58
1 514   -.05514001         . .0334291   -.471  12.106  9.52   -9.4    -4.65
2 514            .         0   .32543    2.58    3.64     .     25    -.894
2 515            .         0   .32543       0    8.26     .   -430    1.425
1 515   -.04051322         . .0434067 -24.921    .321  9.46 -12.68    -3.34
1 516     .3020173         .   .04959  -9.244  16.703   9.9  12.54    -2.94
2 516            . -.4291332   .32543    2.04    5.97     .   6.06     -.66
1 517    .15097298         .  .058837 -11.111  -5.962  9.84   3.23    -2.49
2 517            . -.3982469 .3976787    2.28    5.04     .    4.3     -.93
2 518            . -.3725341 .4287735       0    3.45     .  87.64     1.34
1 518 -.0082018105         . .0553855 -16.927  -5.905 10.02   3.69    -1.85
2 519            . -.3876064 .4756424     2.3   10.55     .  81.82   -1.021
1 519    -.0747935         . .0612581 -34.483  12.394 10.23 -37.26     -.81
2 520            . -.0865148 .5084478    2.39   18.44     .    300    -1.08
1 520   -.20991796         . .0718027 -21.531   6.649 10.21      0     -.33
1 521   -.06638288         . .0797373   9.756   6.555  9.74  25.33     -.52
2 521            . -.1282595 .5422959    2.38    7.81     .    450     -1.1
2 522            .   .357486 .5570995    2.25   -3.98     . 304.55   -1.134
1 522   -.16017137         .   .12406  -7.778   9.341  9.79 -32.75     -.54
2 523            . -.5621945 .5407044     2.2    3.07     .   5.62   -1.086
1 523    -.1714864         . .1145765 -27.108  14.499  9.41 -26.94      -.1
1 524    -.0406557         . .1088409       0  12.598  8.86  24.82     -.07
2 524            .  .0264065 .5507024       0    6.29     .  45.74     1.14
1 525 -.0044194986         . .1100355       0 -10.237  9.29  23.86     -.05
2 525            . -.0222192 .5858518    2.37   10.04     .   -7.3    -1.21
1 526   .037139542         . .1140039       0  -6.311  9.28  61.01     -.04
2 526            . -.0933437 .6098683    2.37     .64     . -30.71   -1.201
2 527            . -.4315497 .6122505       0    3.02     .   -100    1.172
1 527    -.1508766         .  .091113   37.19   7.323  8.26  20.23     -.49
1 528   -.19442508         . .0838474  -1.205   9.452  8.29   28.2     -.49
2 528            . -.2398862 .6069409    2.46    5.77     .      .   -1.308
2 529            .  -.126793 .7043023    2.18    7.03     . -66.67    -1.05
1 529    -.0772997         . .1004205       0   7.944  8.32  -4.81     -.51
2 530            . -.0273112  .790715       0    1.55     .  34.48     1.12
1 530   -.14642256         .  .105205   2.439    -.02  8.35 -16.31     -.56
2 531            . -.4355585 .7682244     1.7   -5.35     .      0     -.59
1 531   .008173214         . .1129339   3.571   5.355  7.38   23.9     -.63
1 532    .16021617         . .1099791   5.747   6.147  7.38  12.17     -.66
2 532            .  .1995203 .7063832     .91    2.05 6.052 174.36      .27
1 533   -.13840793         . .1099219  13.043   1.233  7.37  17.53     -.77
2 533            .  .0047507 .6672567       0    4.49 5.918  -27.1    1.315
1 534   -.21261966         . .1230468       0  -4.058  7.54  20.03     -.47
2 534            .  -.368475 .6758518      .6    3.23 5.818    -50     1.01
1 535  -.066786736         . .1174582  22.596    .203  7.58  10.41     -.85
2 535            . -.3785119 .7043523     2.4    4.01 5.696 -25.64      -.7
2 536            . -.4216251  .704395       0    3.89 4.906 165.52      1.8
1 536   -.12084915         .   .11671   2.745   1.057  7.41   -.96     -.82
2 537            . -.1181883 .7933378    2.66    2.68 4.904 112.99     -.64
1 537   .017371073         . .1027805  14.504  -2.433  7.49   -2.6     -.98
1 538   -.19863896         . .0998014   6.333   2.172  6.92  -3.33    -1.02
2 538            . -.1018165 .8354295    2.66    1.04 4.859  23.78     -.49
1 539   -.10281584         . .1004495  16.928   4.323  6.62   6.44    -1.32
2 539            . -.2933779 .8149614       0    3.83 4.904  48.77     2.41
1 540    -.2062522         . .0903648   1.877  11.051  6.45 -20.41    -1.24
2 540            . -.1129385 .8334031     .87     .67 4.902 -13.91    1.694
2 541            .  .0463896 .8346148    1.99    1.51 4.959  19.23      .76
1 541   -.17810403         . .0934748  31.579   8.164  6.25  15.47    -2.25
1 542  -.000890707         .  .099512      -6  20.228  7.12  16.92    -1.78
2 542            .  .1280549 .8160575       0    3.54 4.772    2.9     2.92
2 543            . -.1688652  .939693       0   15.47 3.459  18.18     3.12
3 543            .  .3437548        .       .       .     .      .        .
1 543  -.021723453         . .0927309  14.894  -6.112  7.47   3.02    -2.28
1 544     .1960406         . .0965819  24.074  -8.956  7.88   8.29    -3.49
end
format %tm Time_Period
label values FI FI
label def FI 1 "786 PA Equity", modify
label def FI 2 "AAYAN KK Equity", modify
label def FI 3 "AAYANRE KK Equity", modify
Could you please assist me how to loop the panels for qreg while the variables belong to different panel ids?

Thanking in anticipation

Summation with restrictions

$
0
0
Hello,

I'm working with a dataset which includes information about 5 countries. In this case, I only want to work with 3 variables. The data looks like this:

reporter partner aux
Belgium Israel .0097238
Belgium Italy .0004703
Belgium Japan .0017738
Belgium Mexico .0038083

Israel Belgium .0058587
Israel Italy .0009222
Israel Japan .0017172
Israel Mexico .0051594


Where aux is the respective distance between each pair of countries by the GDP of each partner (say aux=Dij / GDPj).
So, I want to generate a new variable which shows the sum of these aux values for each combination of countries BUT without considering its respective aux value. Also it must be by reporter.
For example, the new variable should show in the first row (Belgium-Israel) the sum of .0004703+.0017738+.0038083 (these are the aux values of the other combination for Belgium, with italy, Japan and Mexico). Then, in the second row (Belgium-Italy) the sum of .0097238+.0017738+.0038083. Also, I want the same for Israel.

I hope you understand what I want.

Thanks!!



Generating a new variable

$
0
0
I am working with play-by-play data on the NFL.

In my dataset, I have a variable named GameID, a unique identifier for every game, a variable named Quarter, for the quarter that a play takes place in, a variable called Yards, the Yards gained in a play, and finally Run, a dummy variable that equals 1 if the play was a run.

I wish to create a new variable that gives the average yards per rush in each quarter for a given game. Help on how I can create such a variable would be greatly appreciated.

Thanks in advance

longitudinal population survey data

$
0
0
Hello,

I have a longitudinal population survey data. This is actually my first time working with such a huge dataset, and I am having a really bad time in setting it up. I am describing the dataset below. I would be really grateful if anyone can point to the right direction.

It is a population survey. The strata are the districts. Primary sample units are individuals. The time period is from 1980 to 2019. The variables include both continuous and categorical variables. The categorical variables represent demographic characteristics of the sample primary sample units. What I am interested in is finding out the patterns in one of the continuous and one of the categorical variables, given the others, through time.

I have tried to setup the data with svy. Since the survey was with replacement, there is no FPC. However, this was not fruitful; most commands were still reporting repeating time values or too many values. Furthermore, I am not sure whether I should subset the dataset because I cannot figure what the variables would represent then.

I am sure that I am lacking some basics for data like this. If anyone can point to the right resource, that would be very helpful too.

Thank you.

Analyzing two time points with regression

$
0
0
I am analyzing data with the mental health component score (measured 0-100) for 4500 individuals. This score was measured at baseline and then 30 days following an intervention.
I would like to use regression to see the average change in score over time.

I used the following codes to reshape my data:

rename preop_mcs test1
rename x30d_mcs test2
reshape long test, i(sampleid) j(time)
xtset sampleid
xtreg test

I then conducted a mixed effects regression with the following code:

meglm test time || sampleid:

Then I added covariates:

meglm test time age sex smoking race bmi || sampleid:

I've noticed no matter how many or which covariates I've added the coefficient for time does not change. Because I know age is significantly associated with the score from my previous analysis, I'd expect to see at least a little change. This makes me think something is wrong with my coding and/or approach.

I appreciate any guidance with the above coding and how to proceed with a regression.


Attrition and OLS estimatos

$
0
0
How can I prove that the attrition bias affects or does not affect my OLS estimator?
Can I do it with a balance table between the group of which I have information and with the one of which I lost information? How would you interpret that balance table? (I have complete data of both groups in other variables)

Help with Stata's Graphs

$
0
0
Hi

I'm trying to build a Graph on Stata but the variability of my Data is very high.
I need to build a Graph of Brazilian's Inflation from 1980 to 2012 but, in the middle of this period, we had very high values if we compare with the data average. My objective is, only in the graphic view, to limit the higher values to 100 (Eg.: where the inflation was 300, converter this value to 100 on this graph). Is possible to do It?

Thanks!

Reg without constant term

$
0
0
Hi,

I know that when I estimate a regression with fixed effects the constant term should not be included.
However, when I run the regression os Stata, it estimates the constant term.

How can I run my regression without a constant term?
or what is the interpretation of the constant term in the presence of the fixed effects?

Thanks!




Scatter of a local

$
0
0
Hi, is it not possible to create a scatter of a local variable? I'm evaluating the difference in the probabilities of Y btn men and women for a range of other variables. Through some loops I get a list of that, but when trying to plot it, I can't. Is not possible to make a scatter of a local?

This code is working (with it I get the mentioned list):

quietly {

logit pmvotegrp lrself male retnat income age edulevel

local maleA=0
local incomeA=3
local lrselfA=5
local edulevelA=3
local retnatA=3

local maleB=1
local incomeB=3
local lrselfB=5
local edulevelB=3
local retnatB=3

capture drop predA
capture drop predB

foreach nn of numlist 1/100 {

local ageA=`nn'
local ageB=`nn'


# delimit ;
local sysA=_b[_cons]+
_b[lrself]*`lrselfA'+
_b[male]*`maleA'+
_b[retnat]*`retnatA'+
_b[income]*`incomeA'+
_b[age]*`ageA'+
_b[edulevel]*`edulevelA';

local sysB=_b[_cons]+
_b[lrself]*`lrselfB'+
_b[male]*`maleB'+
_b[retnat]*`retnatB'+
_b[income]*`incomeB'+
_b[age]*`ageB'+
_b[edulevel]*`edulevelB';

local predA=exp(`sysA')/(1+exp(`sysA'));
local predB=exp(`sysB')/(1+exp(`sysB'));

# delimit cr

local diffBA=`predB'-`predA'

noisily: display in r "Case `nn' (Age `ageB'): `diffBA' "

}
}

When changing the noisily part for what follows, I get nothing:

noisily: twoway scatter `diffBA' age, msize(small) mcolor(red)
, name(dd_age, replace) legend(off)
title("Probability of voting PM's party, diff btn men and women", size(vsmall))
xtitle("Age") ytitle("Diff prob men and women")
nodraw
xlabel(0(1)100,grid angle(45) labsize(vsmall))
ylabel(1(0.001)1,grid labsize(vsmall))

Even if just coding scatter `diffBA' age, I get nothing. Any advice?

Fixed Effect troubles

$
0
0
Hello, I'm a first-time poster and newbie to the world of Stata. I am trying to estimate a fixed effects model with city as the entity variable and year as the time variable in a panel data set I have. I am typing "xtreg city year, fe" and getting an error message "must specify panelvar; use xtset."

I then entered the command "xtset city year", then "xtreg city year, fe" and got a different error message. This time it says "the panel variable city may not be included as an independent variable."

I have no idea what this means or how to fix it. I would appreciate any tips. Thank you very much for your time.
Viewing all 72839 articles
Browse latest View live


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