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

Using stored estimates

$
0
0
Dear Statalist members,

I stored estimates from my regression

using code
reg y x
estimates save basemodel
(file basemodel.ster saved)

However when i type
estimates use basemodel it doesnt load anything.

Not sure how the .ster
works in stata.

Please help.

Best,

Bridget

Why no OR option in rologit

$
0
0
The Rank Ordered Logit command (rologit; superceded by cmrologit in Stata 16) does not have an -or- option to exponentiate coefficients. Why not? I've seen various sources that say it it is fine to exponentiate coefficients and treat them as odds ratios, but with rologit you have to do the exponentiation yourself. Is there some statistical reason that rologit won't do the exponentiation for you? Or is it just one of those things that Stata Corp never got around to programming?

Dropping duplicates based on two variables (id & year) with condition

$
0
0
Code:
     +--------------------------------------------------------+
     | year             id   date_in~e   date_fo~d   date_i~d |
     |--------------------------------------------------------|
  1. | 1990   ARP008791179   24mar2009   01jan1940          . |
  2. | 1990   ARP008791179           .           .          . |
  3. | 1990   ARP460221020           .   01jan1882          . |
  4. | 1990   ARP460221020           .           .          . |
  5. | 1990   ARP689251337           .   10jul1931          . |
     +--------------------------------------------------------+
I want to drop duplicates based on year and id. Although year and ids are duplicated, date_* variables are different in some cases. I want to keep ids by year that have more date_* info. For example, in observations 1 and 2 ids are the same but observation 1 has more date_* info.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double year str40 id long(date_inactive date_founded date_incorporated)
1990 "ARP008791179" 17980  -7305     .
1990 "ARP008791179"     .      .     .
1990 "ARP460221020"     . -28488     .
1990 "ARP460221020"     .      .     .
1990 "ARP689251337"     . -10402     .
1990 "ARP689251337"     .      .     .
1990 "ARPERE010103" 21326      .     .
1990 "ARPERE010103" 21326  -5113 -4428
1990 "AT0000609607"     .      .     .
1990 "AT0000609607"     . -33158     .
1991 "ARP008791179"     .      .     .
1991 "ARP008791179" 17980  -7305     .
1991 "ARP460221020"     .      .     .
1991 "ARP460221020"     . -28488     .
1991 "ARP646041201" 18401      .     .
1991 "ARP646041201" 18401      .     .
1991 "ARP689251337"     .      .     .
1991 "ARP689251337"     . -10402     .
1991 "ARP9028N1016"     .  11151 11151
1991 "ARP9028N1016"     .      .     .
1991 "ARP903251048"     .      .     .
1991 "ARP903251048" 20602      . 11269
1991 "ARP9897X1319"     .      .  6362
1991 "ARP9897X1319"     .      .     .
end
format %d date_inactive
format %d date_founded
format %d date_incorporated

Joint significance test reporting in Outreg2

$
0
0
Hello,

I am running a regression with several groups of dummies and I need to perform the joint significance test and I would like to report the pvalue of the test in the output table. Do you know how to do it?

To illustrate this is a part of the table
(1)
VARIABLES FIRST
age 0.0115
(0.0122)
agesq -6.92e-05
(0.000139)
head 0.183***
(0.0594)
primaryinc 0.108
(0.394)
primary 0.395
(0.379)
secondaryinc 0.473
(0.380)
secondary 0.511
(0.379)
universityinc 0.683*
(0.380)
university 0.627*
(0.379)

I would like to have a row at the end which says: "Education dummies" and report the pvalue of the joint test of primaryinc primary secondaryinc secondary universityin university... I am using outreg2 to produce this tables, if you know a way using this command would be useful but any solution would help.

Is this possible? Thanks!!

Difference-in-difference on matched data with binary outcome variable

$
0
0
Dear Statalisters,

I have a balanced data with three waves. I want to measure the impact of participation on a binary outcome variable. I match the pooled of the three waves based on the decision to participate. I understand how to go about applying the diff-in-diff estimator on the matched data using the -xtreg, fe- routine in Stata. This would account for the influence of time invariant unobservables in addition to the matching on observables. The corresponding routine -xtprobit- for a binary outcome does not seem to have a fixed effects option (-,fe-) equivalent. How can I apply the diff-in-diff estimator when the outcome variable is binary?

Help is very much appreciated!

Difference-in-difference on matched data with binary outcome variable

$
0
0
I have a balanced data with three waves. I want to measure the impact of participation on a binary outcome variable. I match the pooled of the three waves based on the decision to participate. I understand how to go about applying the diff-in-diff estimator on the matched data using the
Code:
-xtreg, fe-
routine in Stata. This would account for the influence of time invariant unobservables in addition to the matching on observables. The corresponding routine
Code:
-xtprobit-
for a binary outcome does not seem to have a fixed effects option (
Code:
-,fe-
) equivalent. How can I apply the diff-in-diff estimator when the outcome variable is binary?

Help is very much appreciated!

data merge: r(459);

$
0
0
Hi,
I have two panel data-set and what to merge the two data set. I use the following code but I receive the error "r(459); variable firmid does not uniquely identify observations in the master data". I double-checked for duplicate observation and no duplicate observation reported. I would be grateful if you help regarding the error.

Code: megre dataset1 with dataset2
merge 1:1 firmid using dataset2
or
merge m:1 firmid using dataset2

Kindly,
Mahmoud


Bootstrapping versus robust VCE option in xtpoission to deal with overdispersion

$
0
0
Hi everyone,

Does the bootstrapping option in xtpoission deal with overdispersion, or is vce(robust) the way to go? I have seen a few papers out there claiming that bootstrapping the Poission also deals with overdispersion, and I am not sure what to make of it.

Thanks in advance for any advice!

flat log likelihood encountered, cannot find uphill direction

$
0
0
I am working with a time series data, i try to forecast next day volatility with EGARCH (1,1) I got this error "flat log likelihood encountered, cannot find uphill direction" how can i correct it?

runiform(a,b) function for a stataSE 12

$
0
0
Hi Everyone,

I am trying to create a random element that its value is between A and B.
therefore I am trying to run the function runiform(a,b) but I am getting the error of :
invalid syntax
r(198);

I have looked online and I have found that stataSE 12 does not support this function.

Does anyone know a away around this issue?

Kind Regards

Interpreting log-log results with first difference

$
0
0
I have data that explores the relationship between Port activity (TEU) and industrial real estate vacancy/availability (avail). Availability is not a stationary variable, so I have taken the first difference to find it as stationary. My data are quarterly.

My model has the difference in log-availability as a function of the first lag in log-teu.

I've specified the following regression and with the following results


Code:
arima d.ln_avail l.ln_teu  l.ln_avail if tin(2002q1,), ar(1)
The coefficient on l1.ln_availability is b = -0.143

How do I interpret the coefficient in l1.ln_teu ? Is this a standard elasticity? ("A one percent increase in TEU is associated with a 0.143% decrease in availability in a subsequent quarter")?

Or is there a different interpretation given that the Y variable is a first difference?

Thanks!


Code:
clear

**SET YOUR WORKING DIRECTORY
cd "C:\yourdirectory"

use "baltportsindustrial.dta", clear

**set TS**
tsset qdate, quarterly

**check ac in Y variable***
ac avail
ac ln_avail
ac d.ln_avail


**regression**
arima d.ln_avail l.ln_teu l.ln_avail if tin(2002q1,), ar(1)

**tests for staionarity in residuals**
predict resid
dfuller resid, nocons lags(2)
dfuller resid, nocons

svylogitgof

$
0
0
Hi!

I am absolutely new to STATA and I hope that you could help me to solve this issue.

I run a logistic regression on the survey data:

svy: logistic f30_b_grupp i.f17_d i.f2_grupp i.f20_grupp i.f4_grupp i.fodland_grupp

But when I try to estimate the goodness of fit with svylogoitgof, I get the following mistake:


. svylogitgof
�lder invalid name
r(198);


I tried to google but it did not help. There is no a varaible ålder in the data set.

I will appreciate any help.

Thank you in advance.

Best regards,
Yuliya

-gsem- for dynamic multinomial logit model with random effects

$
0
0
Dear All,

I am trying to analyse, using panel data, the extent of state dependance to a previous situation, let's say a form of employment. To do that and following the litterature (bellow an example of references) I need to run a dynamic multinomial logit with random effect. In a previous discussion Pr.Stephan Jenkins suggested to use -gsem- routine. My concern is when I add a lagged dependant variable to capture the state depedance the model run for hours and some times days without convergence; and it converge easily when I don't add the lagged dependant variable.

Here an exemple using data of Pr. Natalia Sarkisian related to hours of work (The link to data: https://www.sarkisian.net/socy7706/datasets.html : hrs_hours_reshaped.dta)

Code:
*Create variable of hours of work with 4 classes (modalities)
recode rworkhours80 (0=0) (1/30=1) (31/50=2) (51/80=3), gen(rworkhours4)

*Generate lagged variables:

tab rworkhours4, gen(altern)

gen lag_altern1 = altern1[ _n-1]
replace lag_altern1 =. if wave==1
gen lag_altern2 = altern2[ _n-1]
replace lag_altern2 =. if wave==1
gen lag_altern3 = altern3[ _n-1]
replace lag_altern3 =. if wave==1
gen lag_altern4 = altern4[ _n-1]
replace lag_altern4 =. if wave==1

*Running the -gsem- command:
gsem (1.rworkhours4 <- lag_altern1 female age white M1[hhidpn]) (2.rworkhours4 <- lag_altern1 female age white M2[hhidpn]) (3.rworkhours4 <- lag_altern1 female age white M3[hhidpn]) if wave>1, mlogit
Listed 100 out of 54676 observations:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long hhidpn byte(wave female rworkhours80 rworkhours4 altern1 altern2 altern3 altern4) float(lag_altern1 lag_altern2 lag_altern3 lag_altern4)
10003020 1 0 40 2 0 0 1 0 . . . .
10003020 2 0 20 1 0 1 0 0 0 0 1 0
10003020 3 0 20 1 0 1 0 0 0 1 0 0
10003020 4 0  0 0 1 0 0 0 0 1 0 0
10004010 1 0  0 0 1 0 0 0 . . . .
10004010 2 0  0 0 1 0 0 0 1 0 0 0
10004010 3 0  0 0 1 0 0 0 1 0 0 0
10004010 4 0  0 0 1 0 0 0 1 0 0 0
10004010 5 0  0 0 1 0 0 0 1 0 0 0
10004010 6 0  0 0 1 0 0 0 1 0 0 0
10004010 7 0  0 0 1 0 0 0 1 0 0 0
10004010 8 0  0 0 1 0 0 0 1 0 0 0
10004010 9 0  0 0 1 0 0 0 1 0 0 0
10013010 1 0 55 3 0 0 0 1 . . . .
10013010 2 0  . . . . . . 0 0 0 1
10013010 3 0 40 2 0 0 1 0 . . . .
10013010 4 0 20 1 0 1 0 0 0 0 1 0
10013010 5 0  0 0 1 0 0 0 0 1 0 0
10013010 6 0  0 0 1 0 0 0 1 0 0 0
10013010 7 0  0 0 1 0 0 0 1 0 0 0
10013010 8 0  0 0 1 0 0 0 1 0 0 0
10013010 9 0  0 0 1 0 0 0 1 0 0 0
10038010 1 0 55 3 0 0 0 1 . . . .
10038010 2 0 50 2 0 0 1 0 0 0 0 1
10038010 3 0 50 2 0 0 1 0 0 0 1 0
10038010 4 0 40 2 0 0 1 0 0 0 1 0
10038010 5 0 40 2 0 0 1 0 0 0 1 0
10038010 6 0 30 1 0 1 0 0 0 0 1 0
10038010 7 0 30 1 0 1 0 0 0 1 0 0
10038010 8 0 20 1 0 1 0 0 0 1 0 0
10038010 9 0 20 1 0 1 0 0 0 1 0 0
10050010 1 1 45 2 0 0 1 0 . . . .
10050010 2 1 35 2 0 0 1 0 0 0 1 0
10050010 3 1 35 2 0 0 1 0 0 0 1 0
10050010 4 1 35 2 0 0 1 0 0 0 1 0
10050010 5 1 35 2 0 0 1 0 0 0 1 0
10050010 6 1 35 2 0 0 1 0 0 0 1 0
10050010 7 1 35 2 0 0 1 0 0 0 1 0
10050010 8 1 35 2 0 0 1 0 0 0 1 0
10050010 9 1 35 2 0 0 1 0 0 0 1 0
10075020 1 1 40 2 0 0 1 0 . . . .
10075020 2 1 45 2 0 0 1 0 0 0 1 0
10075020 3 1  0 0 1 0 0 0 0 0 1 0
10075020 4 1  0 0 1 0 0 0 1 0 0 0
10075020 5 1  0 0 1 0 0 0 1 0 0 0
10075020 6 1  0 0 1 0 0 0 1 0 0 0
10075020 7 1  0 0 1 0 0 0 1 0 0 0
10075020 8 1  0 0 1 0 0 0 1 0 0 0
10075020 9 1  0 0 1 0 0 0 1 0 0 0
10083020 1 1  0 0 1 0 0 0 . . . .
10083020 2 1  0 0 1 0 0 0 1 0 0 0
10083020 3 1  0 0 1 0 0 0 1 0 0 0
10083020 4 1  0 0 1 0 0 0 1 0 0 0
10083020 5 1  0 0 1 0 0 0 1 0 0 0
10083020 6 1  0 0 1 0 0 0 1 0 0 0
10083020 7 1  0 0 1 0 0 0 1 0 0 0
10083020 8 1  0 0 1 0 0 0 1 0 0 0
10083020 9 1  0 0 1 0 0 0 1 0 0 0
10090010 1 1  0 0 1 0 0 0 . . . .
10090010 2 1  0 0 1 0 0 0 1 0 0 0
10097010 1 0 45 2 0 0 1 0 . . . .
10097010 2 0  0 0 1 0 0 0 0 0 1 0
10097010 3 0  . . . . . . 1 0 0 0
10097010 4 0  . . . . . . . . . .
10097010 5 0  . . . . . . . . . .
10097010 6 0  . . . . . . . . . .
10097010 7 0  . . . . . . . . . .
10097010 8 0  . . . . . . . . . .
10097010 9 0  . . . . . . . . . .
10106010 1 0  0 0 1 0 0 0 . . . .
10106010 2 0  0 0 1 0 0 0 1 0 0 0
10106010 3 0  0 0 1 0 0 0 1 0 0 0
10106010 4 0  0 0 1 0 0 0 1 0 0 0
10106010 5 0  . . . . . . 1 0 0 0
10106010 6 0  0 0 1 0 0 0 . . . .
10106010 7 0  . . . . . . 1 0 0 0
10106010 8 0  . . . . . . . . . .
10106010 9 0  . . . . . . . . . .
10109020 1 1 30 1 0 1 0 0 . . . .
10124010 1 1  0 0 1 0 0 0 . . . .
10124010 2 1  0 0 1 0 0 0 1 0 0 0
10124010 4 1  0 0 1 0 0 0 1 0 0 0
10124010 5 1  0 0 1 0 0 0 1 0 0 0
10124010 6 1  0 0 1 0 0 0 1 0 0 0
10124010 7 1  8 1 0 1 0 0 1 0 0 0
10155010 1 1 40 2 0 0 1 0 . . . .
10155010 2 1 40 2 0 0 1 0 0 0 1 0
10155010 3 1 40 2 0 0 1 0 0 0 1 0
10155010 4 1 40 2 0 0 1 0 0 0 1 0
10237020 1 0 40 2 0 0 1 0 . . . .
10237020 2 0  . . . . . . 0 0 1 0
10237020 3 0  . . . . . . . . . .
10237020 4 0  . . . . . . . . . .
10237020 5 0  . . . . . . . . . .
10237020 6 0  . . . . . . . . . .
10237020 7 0  . . . . . . . . . .
10237020 8 0  . . . . . . . . . .
10237020 9 0  . . . . . . . . . .
10240010 1 0 40 2 0 0 1 0 . . . .
10240010 2 0  . . . . . . 0 0 1 0
end
Any help how to fix this issue and getting the impact of the lagged variable (state dependance)?
Thanks



I am using Stata 15.

Example of Rferences on state dependance:

Haan, P. and Uhlendorff, A. (2006), ‘Estimation of multinomial logit models with unobserverd heterogeneity using maximum simulated likelihood’, The Stata Journal 6(2), 229–245.
Ki-Dong Lee , Seo-Hyeong Lee & Jong-Il Choe (2017): State dependence, individual heterogeneity, and the choice of employment status: evidence from Korea, Applied Economics, DOI: 10.1080/00036846.2017.134344

mata function available in different ado-files

$
0
0
Dear all,

I am trying to execute a mata function in different but related ado-files, but I don't know how to do it efficiently. Right now, I have the same mata functions at the end of each ado-file. Let me explain.

I have an ado file called `xyz.ado` that executes several other subroutines depending on the needs of the user. For instance, it may execute routine `xyz_load.ado` or `xyz_create.ado` or `xyz_estimate.ado`. Each of these ado-files uses a mata function called `hello()`. My problem is that if I defined `hello()` as shown below, it is not accessible by any of the `xyz_SUBROUTINES.ado` adofiles,

Code:
program define xyz
        .
        xyz_load ...
        .
end

version 15
mata:
void hello() {
    printf("hello people\n")
}
end

The restrictions that I face are the following:

1. Each of the subroutnines `xyz_SUBROUTINES.ado` must remain as independent ado-files. That is, I cannot do the following,

Code:
program define xyz
        .
        .
        .
        xyz_load ...
        .
        .
        .
end
program define xyz_load
        .
        mata: hello()
        .
end

mata:
void hello() {
    printf("hello people\n")
}
end
2. the whole `xyz` package is used for several people in my team, so the mata function should available in all the subrountines each time the user executes `xyz`
3. all the files of the package `xyz` won't be placed in the same directory path in the computer of each of the members of my team. That is, some people may have it in c:/ado/plus/x, others in c:/ado/personal/x, and others in c:/onedrive/stata/ (the ones with the latter directory path structure have already included such a paths in searching directories of stata using adopath ++)

So, my questions are the following.

1. Is it possible to compile a mata library from a .mata file directly from within an ado-file?
2. When I placed the in `xyz.mata` with all my mata function in c:/ado/plus/x, and then execute `do xyz.mata` directly within my `xyz.ado` it does not read the version in c:/ado/plus/x but the one in my current directory. How do I make Stata to look for .mata file in the searching directories stored in the global macro S_ADO?


Thank you so much for your help.

Best,




Calculating citation half-life

$
0
0
Dear all,

Assume that you have the following problem. You have patent citations for firms in different years. The questions is to calculate the half-life of citations. That is, how many years will be needed until a firm cumulatively gets 50% of the citations from a specific year. I have prepared the following simplistic example:

Code:
 input id    year    value    half_value    time_until_half
1    1990    50    25    3
1    1991    2    1    1
1    1992    3    1.5    1
1    1993    25    12.5    1
1    1994    15    7.5    3
1    1995    5    2.5    3
1    1996    1    0.5    1
1    1997    1    0.5    1
1    1998    3    .    .
2    1990    8    4    2
2    1991    3    1.5    2
2    1992    1    0.5    1
2    1993    2    1    1
2    1994    12    6    4
2    1995    1    0.5    1
2    1996    2    1    1
2    1997    1    0.5    1
2    1998    3    .    .
end
In this example, we have two firms "1" and "2". Firm "1" starts with 50 citations in year 1990. Based on the citation data for the following years, one can find that 3 years will be needed until the half-value (25) is reached (by summing citations from the following years). In the same manner we can calculate half-life for the other citations. For example, in year 1991 firm "1" has 2 citation (half-value is 1), so it just needs one year to reach that value (in year 1993 it has 3 citations).

How would one calculate half-life in the way described above in Stata?

Thanks a lot

Command to list households with multiple heads/without heads in a survey data

$
0
0
Below is a extract data from a survey conducted for various households within a community, please what command can I use to list households with (1)multiple heads and (2)those with no head within a household? where 1=head of household in relationship HHNO=household number, HHSIZE= number of individuals in the household while (mno=position of each member in a household, 1=head,2=wife, 3=child, 4=grandchild, 5=non-relative)
input str39 hhmnsrrno byte(HHNO HHSIZE) int mno byte relationship
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/01" 2 6 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/02" 2 6 2 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/03" 2 6 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/04" 2 6 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/05" 2 6 5 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/002/06" 2 6 6 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/01" 3 6 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/02" 3 6 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/03" 3 6 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/04" 3 6 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/05" 3 6 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/003/06" 3 6 6 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/01" 4 7 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/02" 4 7 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/03" 4 7 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/04" 4 7 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/05" 4 7 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/06" 4 7 6 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/004/07" 4 7 7 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/01" 5 6 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/02" 5 6 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/03" 5 6 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/04" 5 6 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/05" 5 6 5 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/005/06" 5 6 6 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/006/01" 6 4 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/006/02" 6 4 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/006/03" 6 4 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/006/04" 6 4 4 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/007/01" 7 3 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/007/02" 7 3 2 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/007/03" 7 3 3 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/008/01" 8 1 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/01" 9 6 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/02" 9 6 2 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/03" 9 6 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/04" 9 6 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/05" 9 6 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/009/06" 9 6 6 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/01" 17 6 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/02" 17 6 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/03" 17 6 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/04" 17 6 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/05" 17 6 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/017/06" 17 6 6 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/01" 18 7 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/02" 18 7 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/03" 18 7 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/04" 18 7 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/05" 18 7 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/06" 18 7 6 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/018/07" 18 7 7 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/01" 19 7 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/02" 19 7 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/03" 19 7 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/04" 19 7 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/05" 19 7 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/06" 19 7 6 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/019/07" 19 7 7 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/01" 20 13 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/02" 20 13 2 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/03" 20 13 3 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/04" 20 13 4 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/05" 20 13 5 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/06" 20 13 6 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/07" 20 13 7 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/08" 20 13 8 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/09" 20 13 9 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/10" 20 13 10 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/11" 20 13 101 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/12" 20 13 102 5
"SS/CR/BEK/ABUAGBOR-UKUM/1/020/13" 20 13 103 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/021/01" 21 3 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/021/02" 21 3 2 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/021/03" 21 3 3 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/022/01" 22 2 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/022/02" 22 2 2 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/023/01" 23 5 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/023/02" 23 5 2 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/023/03" 23 5 3 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/023/04" 23 5 4 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/023/05" 23 5 5 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/024/01" 24 3 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/024/02" 24 3 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/024/03" 24 3 3 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/025/01" 25 4 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/025/02" 25 4 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/025/03" 25 4 3 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/025/04" 25 4 4 6
"SS/CR/BEK/ABUAGBOR-UKUM/1/026/01" 26 3 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/026/02" 26 3 2 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/026/03" 26 3 3 7
"SS/CR/BEK/ABUAGBOR-UKUM/1/027/01" 27 2 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/027/02" 27 2 2 2
"SS/CR/BEK/ABUAGBOR-UKUM/1/028/01" 28 4 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/028/02" 28 4 2 3
"SS/CR/BEK/ABUAGBOR-UKUM/1/028/03" 28 4 3 4
"SS/CR/BEK/ABUAGBOR-UKUM/1/028/04" 28 4 4 6
"SS/CR/BEK/ABUAGBOR-UKUM/1/029/01" 29 4 1 1
"SS/CR/BEK/ABUAGBOR-UKUM/1/029/02" 29 4 2 4

Deleting rows with NAs

$
0
0
Dear Statalists,
I would like to delete rows where are only 7 real values and the rest is NA, does anyone know how to do it? Will really appreciate the assistance. Below you will find the part of my whole dataset.


* Example generated by -dataex-. To install: ssc install dataex
clear
input str9 Market str10(var6 var7 var8 var9 var10 var11 var12 var13 var14 var16 var17 var18 var19 var20 var21 var22 var23)
"Argentina" "24" "24,71" "27,44" "24,62" "25,95" "28,2" "26,7" "NA" "24,81" "23,74" "25,33" "26" "25,15" "24,1" "22,92" "NA" "20,15"
"Argentina" "NA" "NA" "NA" "7,88" "NA" "14,05" "12,1" "NA" "9,43" "8,36" "8,64" "9,37" "8,85" "8,12" "8,23" "NA" "4,07"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,06" "0,08" "0,08" "0,08" "0,07" "0,07" "NA" "NA" "0,09" "0,12" "0,15" "0,18" "NA" "0,26" "0,27" "NA" "0,24"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "4,38" "4,98" "5,54" "5,76" "7,45" "8,55" "6,85" "NA" "5,2" "4,4" "5,16" "6,24" "5,84" "4,98" "5,1" "NA" "3,16"
"Argentina" "NA" "NA" "NA" "0,69" "NA" "1,09" "0,88" "NA" "0,94" "0,79" "0,78" "0,92" "0,89" "0,83" "0,73" "NA" "0,49"
"Argentina" "3,81" "4,08" "4,48" "4,69" "6,29" "7,2" "6,4" "NA" "5,48" "5,19" "6,34" "7,3" "6,68" "6,08" "5,6" "NA" "4,68"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "1,67"
"Argentina" "0,05" "0,06" "NA" "0,05" "0,07" "0,07" "NA" "NA" "NA" "NA" "NA" "0,05" "0,06" "NA" "NA" "0,04" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "0" "NA" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "2,53" "NA" "2,48" "2,48" "2,45" "2,19" "NA" "1,79"
"Argentina" "NA" "0,03" "0,04" "NA" "0,05" "0,05" "NA" "NA" "0,05" "0,05" "NA" "0,05" "0,06" "NA" "NA" "0,05" "NA"
"Argentina" "0,26" "0,26" "0,27" "0,24" "0,21" "0,29" "0,23" "NA" "0,21" "NA" "0,34" "0,61" "1" "1,35" "1,08" "NA" "0,83"
"Argentina" "0,06" "NA" "NA" "NA" "0,06" "NA" "NA" "NA" "NA" "NA" "NA" "0,09" "0,1" "0,1" "0,1" "0,1" "0,09"
"Argentina" "1,6" "1,84" "1,31" "1,08" "1,04" "1,42" "1,61" "NA" "1,3" "1,27" "1,23" "1,18" "1,54" "1,67" "1,45" "NA" "1,65"
"Argentina" "58,05" "67,97" "69,05" "60,27" "82,33" "130,9" "159,99" "NA" "98,21" "93,25" "103,38" "98,18" "90,89" "NA" "60,39" "54,53" "NA"
"Argentina" "0,65" "NA" "0,75" "NA" "0,69" "NA" "0,87" "NA" "NA" "0,63" "NA" "NA" "1,43" "NA" "1,38" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,38" "0,37" "NA" "0,35" "0,48" "0,51" "0,51" "NA" "NA" "0,46" "NA" "NA" "0,35" "NA" "NA" "0,37" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "2,76" "2,76" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "3,1" "2,76" "NA" "2,53" "2,64" "2,65" "3,24" "3,07" "2,95" "2,63" "NA" "2,2"
"Argentina" "0,05" "NA" "0,08" "0,06" "0,1" "0,14" "0,12" "NA" "0,15" "0,15" "0,15" "0,13" "0,15" "0,16" "0,14" "0,13" "NA"
"Argentina" "0,25" "0,33" "0,45" "0,47" "0,55" "0,76" "0,84" "NA" "0,73" "0,89" "0,94" "0,94" "0,89" "0,85" "0,87" "0,74" "NA"
"Argentina" "1,4" "NA" "NA" "NA" "1,5" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "1,25" "NA" "NA" "1,38" "NA"
"Argentina" "1,35" "1,22" "0,92" "0,71" "0,79" "1,06" "1,28" "NA" "1,51" "1,45" "1,32" "1,65" "2,23" "2,63" "2,83" "NA" "4,48"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,84" "0,9" "NA" "NA" "1,2" "1,63" "NA" "NA" "1,45" "1,53" "NA" "1,59" "1,96" "1,84" "1,59" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,97" "1,77" "1,85" "1,51" "1,84" "2,32" "2,24" "NA" "2,17" "2,29" "2,52" "2,67" "2,87" "2,76" "2,43" "NA" "1,71"
"Argentina" "NA" "0,11" "NA" "0,11" "0,1" "0,11" "NA" "0,1" "0,1" "0,09" "0,11" "0,11" "0,18" "0,18" "0,18" "0,13" "0,14"
"Argentina" "0,08" "0,08" "NA" "NA" "0,14" "0,2" "0,17" "NA" "0,19" "0,18" "0,18" "0,2" "0,2" "0,2" "NA" "0,23" "NA"
"Argentina" "1,53" "1,94" "2,16" "2,24" "3,02" "3,3" "3,01" "2,85" "2,73" "2,81" "2,73" "2,95" "2,73" "2,68" "2,41" "2,26" "1,76"
"Argentina" "0,53" "0,54" "0,59" "0,59" "0,76" "0,96" "1,04" "NA" "0,99" "1,02" "0,99" "1,02" "1,05" "1,05" "0,99" "0,85" "0,84"
"Argentina" "0,1" "0,12" "0,13" "0,12" "0,17" "0,23" "0,18" "NA" "0,19" "0,22" "0,2" "0,22" "0,25" "NA" "0,2" "NA" "0,16"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "1,05" "NA" "0,79"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,16" "0,16" "0,17" "0,16" "0,16" "0,17" "NA" "NA" "0,13" "NA" "NA" "0,13" "0,17" "0,2" "NA" "NA" "NA"
"Argentina" "1,38" "1,68" "1,99" "1,96" "2,26" "2,62" "2,19" "NA" "2,17" "2,31" "2,15" "2,39" "2,42" "2,23" "1,76" "1,42" "1,36"
"Argentina" "1,04" "1,03" "1,04" "0,93" "1,17" "1,79" "NA" "NA" "1,25" "NA" "1,79" "1,71" "1,71" "NA" "1,38" "NA" "0,99"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "25,27" "32,15" "30,17" "26,26" "35,13" "52,59" "58,44" "NA" "48,71" "43,42" "41,93" "39,15" "40,51" "41,1" "35,08" "NA" "23,37"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "0,14" "0,15" "NA" "0,16" "0,19" "0,18" "NA" "NA" "NA" "0,15" "0,15" "0,15" "NA" "0,15" "0,14" "NA"
"Argentina" "NA" "NA" "0,07" "NA" "0,08" "0,11" "0,1" "NA" "0,11" "NA" "0,09" "NA" "0,09" "NA" "0,09" "0,09" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,99" "1,11" "1,3" "1,33" "1,42" "1,65" "1,46" "NA" "1,11" "1,15" "1,24" "1,47" "1,41" "1,36" "1,19" "NA" "1,1"
"Argentina" "1,31" "1,07" "0,53" "0,62" "0,73" "1,11" "0,99" "NA" "0,83" "0,96" "0,97" "1,12" "1,5" "1,5" "1,29" "1,18" "1,18"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "1,82" "NA" "NA" "NA" "NA" "1,54" "NA" "NA" "NA" "1,65" "NA" "NA" "2"
"Argentina" "1,34" "1,51" "1,54" "0,97" "1,04" "1,16" "1,31" "NA" "1,05" "1,08" "0,92" "0,9" "1,06" "1,09" "0,97" "0,89" "0,84"
"Argentina" "93,98" "89,63" "94,81" "91,77" "116,61" "129,18" "154,74" "NA" "111,72" "97,72" "91,33" "99,58" "103,99" "102,94" "87,51" "NA" "85,02"
"Argentina" "4,27" "4,31" "3,89" "3,64" "NA" "5,62" "4,44" "NA" "NA" "NA" "4,74" "NA" "4,73" "4,6" "4,3" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "18536,34" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "1,53" "1,56" "1,73" "1,46" "1,66" "2,02" "1,77" "NA" "1,65" "1,45" "1,47" "1,6" "1,65" "1,54" "1,42" "NA" "1,07"
"Argentina" "0,35" "0,3" "NA" "0,23" "0,28" "0,41" "0,45" "NA" "0,49" "0,66" "0,65" "0,81" "0,99" "1,11" "1,24" "1,17" "1,24"
"Argentina" "2,53" "2,61" "2,62" "2,42" "2,92" "3,77" "3,27" "NA" "3,03" "2,92" "2,92" "3,09" "3,03" "3,15" "3,15" "2,76" "2,28"
"Argentina" "2,86" "3,22" "3,38" "3,74" "4,74" "5,11" "4,5" "NA" "3,68" "3,12" "3,63" "3,78" "3,68" "3,17" "3,2" "NA" "1,95"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "1,9" "2,14" "NA" "NA" "2,03" "2,86" "2,3" "NA" "1,84" "NA" "NA" "1,53" "1,68" "1,7" "1,55" "NA" "NA"
"Argentina" "2,65" "2,83" "3,7" "3,4" "4,16" "4,95" "4,2" "NA" "4,3" "NA" "NA" "3,3" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,75" "NA" "0,62" "NA" "0,65" "NA" "0,73" "NA" "NA" "1,37" "1,4" "1,65" "1,65" "NA" "1,55" "1,4" "NA"
"Argentina" "1,88" "1,91" "2,25" "NA" "1,56" "1,8" "1,72" "NA" "NA" "NA" "NA" "1,83" "1,65" "NA" "1,55" "NA" "NA"
"Argentina" "0,82" "1,16" "NA" "NA" "1,1" "1,99" "2,4" "NA" "1,95" "1,85" "1,84" "1,85" "2,26" "NA" "2,47" "2,15" "NA"
"Argentina" "NA" "NA" "NA" "NA" "5,01" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "5" "NA" "NA" "5" "NA"
"Argentina" "2,03" "2,32" "2,37" "2,12" "NA" "3,45" "2,98" "NA" "1,97" "NA" "1,83" "2,1" "NA" "2,03" "1,96" "NA" "1,42"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "3,63" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "3,59" "2,98" "NA" "NA" "NA" "6" "5,75" "NA" "5,8" "NA" "NA" "5,9" "6,2" "6,5" "NA" "NA" "NA"
"Argentina" "NA" "1,74" "NA" "1,26" "1,53" "1,92" "NA" "NA" "2,26" "2,4" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,71" "1,02" "NA" "0,83" "1,1" "1,48" "NA" "NA" "NA" "NA" "NA" "1,1" "NA" "1,55" "1,28" "NA" "NA"
"Argentina" "1,7" "1,48" "NA" "0,81" "1,02" "1,5" "1,21" "1,15" "1,21" "NA" "NA" "1,11" "1,79" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,84" "0,68" "NA" "NA" "0,25" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "0,26" "NA" "NA" "0,26" "NA"
"Argentina" "NA" "NA" "20890,16" "NA" "20941,05" "NA" "20902,8" "NA" "20909,67" "NA" "20925,87" "NA" "20898,67" "NA" "NA" "20898,66" "NA"
"Argentina" "2,97" "2,95" "3,92" "3,37" "4,53" "5,94" "6,08" "NA" "6,01" "NA" "5,61" "5,4" "5,27" "5,03" "NA" "4,66" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "50" "NA" "NA" "NA" "NA"
"Argentina" "NA" "NA" "NA" "NA" "2,53" "2,43" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "0,41" "NA" "NA" "0,42" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "0,36" "NA" "NA" "NA" "NA"
"Argentina" "0,38" "0,4" "0,52" "0,46" "0,55" "0,72" "0,94" "0,93" "0,84" "0,7" "0,64" "0,65" "0,75" "0,76" "0,64" "0,5" "0,4"
"Argentina" "19,45" "27,25" "24,23" "20,68" "28,07" "38,99" "53,61" "NA" "52,41" "36,61" "37,2" "35,94" "48,85" "54,22" "55,46" "31,67" "32,28"
"Argentina" "1,6" "1,34" "1,19" "0,75" "0,85" "1,28" "1,53" "1,39" "1,58" "1,64" "1,71" "2,04" "2,6" "3,2" "3,55" "NA" "4,78"
"Argentina" "NA" "3,58" "3,6" "3,6" "3,61" "3,6" "3,6" "3,6" "3,6" "3,61" "3" "3" "3" "3" "3" "2,5" "2,5"
"Argentina" "4,79" "5,57" "NA" "6,24" "8,02" "8,5" "8" "NA" "NA" "6,61" "NA" "7" "6,5" "6,5" "5,75" "NA" "4,5"
"Argentina" "0,8" "0,68" "NA" "NA" "0,68" "0,47" "0,65" "0,84" "0,74" "1,03" "1,03" "1,1" "1,52" "1,43" "1,3" "1,08" "1"
"Argentina" "0,65" "0,68" "0,54" "NA" "0,59" "0,86" "0,78" "NA" "NA" "1" "NA" "NA" "1,26" "1,35" "1,3" "NA" "NA"
"Argentina" "4,32" "4,28" "4,25" "3,65" "3,81" "5,6" "4,8" "NA" "4,45" "4,63" "4,41" "4,65" "4,9" "4,85" "4,95" "NA" "3,52"
"Argentina" "NA" "NA" "NA" "NA" "0,35" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "0,3" "0,6" "NA" "0,6" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "1,03"
"Argentina" "NA" "NA" "NA" "NA" "15,33" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "7,08" "NA" "7,3" "9" "NA"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
"Argentina" "3,27" "3,06" "3,17" "NA" "2,78" "3,37" "NA" "NA" "2,08" "NA" "NA" "1,61" "1,94" "2,98" "2,07" "1,79" "NA"
"Argentina" "1,32" "1,46" "1,66" "1,52" "1,68" "1,95" "1,93" "NA" "1,68" "1,6" "1,68" "1,9" "1,91" "1,82" "1,63" "NA" "1,46"
"Argentina" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA"
end
[/CODE]

ttest two group mean-comparasion test: How big should be the difference between the variances to considering unequal test?

$
0
0
I am testing the association of some antibodies with different symptoms. This is the same group of patients (with and without symptom). The n within each group is different and the variance ratio is high. In that case, what test should I consider the best one?


Code:
. swilk lmark4

                   Shapiro-Wilk W test for normal data

    Variable |    Obs       W           V         z       Prob>z
-------------+--------------------------------------------------
      lmark4 |     23    0.95818      1.094     0.182    0.42766

. ttest lmark4, by( petequia)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |      21    8.803805    .0744901    .3413564    8.648421    8.959188
       1 |       2    9.171853    .0337019    .0476617     8.74363    9.600076
---------+--------------------------------------------------------------------
combined |      23    8.835809    .0714076    .3424588    8.687719    8.983899
---------+--------------------------------------------------------------------
    diff |           -.3680485    .2466404               -.8809652    .1448683
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -1.4922
Ho: diff = 0                                     degrees of freedom =       21

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0753         Pr(|T| > |t|) = 0.1505          Pr(T > t) = 0.9247

. ttest lmark4, by( petequia) unequal

Two-sample t test with unequal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |      21    8.803805    .0744901    .3413564    8.648421    8.959188
       1 |       2    9.171853    .0337019    .0476617     8.74363    9.600076
---------+--------------------------------------------------------------------
combined |      23    8.835809    .0714076    .3424588    8.687719    8.983899
---------+--------------------------------------------------------------------
    diff |           -.3680485    .0817593               -.5415563   -.1945407
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -4.5016
Ho: diff = 0                     Satterthwaite's degrees of freedom =   15.792

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0002         Pr(|T| > |t|) = 0.0004          Pr(T > t) = 0.9998
Thank you!

Gabriel Ferreira
(Stata 10.1 SE)

Multilevel Modelling - Variance Partitioning

$
0
0
Dear Stata-listers,

I hope you are all doing well.

Before I ask my question, let me provide a brief background about my research. I think this might be useful when someone (kindly) writes a reply. I am a junior researcher in accounting and finance who has been using panel data-sets for a while and implementing pooled OLS and/or panel models including several identification strategies (difference-in-differences, regression discontinuity design, instrumental variables, etc.).

Recently, I started working on a project with a colleague that comes from a management/strategy background. Our project is in his field of research, where the use of multilevel modelling is quite common, unlike my field of research (finance). Before we start the main analysis, my colleague and I are trying to replicate a seminal paper. The idea of the paper is simple: Chief Executive Officers (CEOs) have gained an increased importance in determining the firm's performance over the years. The data-set used in this paper is a panel data where, in a given year, a CEO manages a firm that operates in some industry. Assuming that firm performance is measured using return on assets (ROA), i.e., the dependent variable, the paper finds that the percentage of the variance of ROA explained by CEOs has increased over time (the paper compares three intervals of time: 1950-1969, 1970-1989, and 1990-2009). I include below a sample of a similar data-set:


Firm_ID Year CEO Industry ROA
1 2003 Liang K7 0.06019
1 2004 Liang K7 0.069624
1 2005 Liang K7 0.077258
1 2006 Liang K7 0.069463
1 2007 Liang K7 0.075686
1 2008 Liang K7 0.048303
1 2009 Liang K7 0.054536
1 2010 Liang K7 0.052903
1 2011 Liang K7 0.047317
1 2012 Liang K7 0.048673
1 2013 Liang K7 0.04473
1 2014 Liang K7 0.040357
1 2015 Liang K7 0.047204
1 2016 Liang K7 0.04153
1 2017 Liang K7 0.039362
2 2003 Kexin C27 0.046562
2 2004 Kexin C27 -0.00105
2 2005 Kexin C27 -0.08607
2 2006 Kexin C27 0.021265
2 2007 Kexin C27 -0.04802
2 2008 Lufeng C27 -0.06058
2 2009 Lufeng C27 0.027213
2 2010 Xiao C27 0.095465






























The authors of the original paper mentions the following: "We use multilevel modeling (MLM), which has the advantage of explicitly accounting for the nested structure of the data. For the MLM analysis, we specified a four-level nested model: years, within CEOs, within firms, within industries. We used the Stata command xtmixed for the MLM analysis."


Before I wrote this post, I spent a couple of days searching and reading several resources. I got the general idea of the analysis and how it works (Stata's videos and blogs are very helpful). Yet I am not sure if the command I thought of does what the authors of the original paper described. My suggested code is included below:

Code:
xtset ID Year
mixed ROA control_variables || Industry: || Firm_ID: || CEO: || Year:, mle variance
estat ICC // to get the percentage of variance explained by Industry, Firm_ID, CEO, and Year.
Please let me know what you think. Any additional explanation about MLM or about coding is welcomed.

Thank you all.

Mostafa
(Stata 15.1 MP)

Finding second smallest value with time interval

$
0
0
Hi,

How can i find second lowest value within a group 30 days after first? My first lowest is 83.8517

Following is the example

input long id double event_DT float(val_D1 val_D2) int timediff
32581947 1676377020000 110.07737 103.66864 192
1 1686620040000 110.07737 110.07737 311
1 1687762740000 110.07737 110.07737 324
1 1.687068e+12 110.07737 103.66864 316
1 1.6876773e+12 110.07737 103.66864 323
1 1.6875861e+12 110.07737 98.54212 322
1 1.6865739e+12 110.07737 103.66864 310
1 1681825620000 110.07737 103.66864 255
1 1686815580000 110.07737 98.54212 313
1 1686898980000 110.07737 98.54212 314
1 1686778320000 110.07737 98.54212 313
1 1686660540000 110.07737 103.66864 311
1 1.6866363e+12 110.07737 110.07737 311
1 1686615240000 110.07737 110.07737 311
1 1686593580000 110.07737 103.66864 311
1 1686674820000 110.07737 118.46265 312
1 1.6867281e+12 110.07737 110.07737 312
1 1687510140000 110.07737 103.66864 321
1 1686672420000 110.07737 118.46265 312
1 1684237920000 110.07737 98.54212 283
1 1686981960000 110.07737 103.66864 315
1 1686710220000 110.07737 110.07737 312
1 1687672920000 110.07737 103.66864 323
1 1.6865712e+12 110.07737 103.66864 310
1 1664287740000 110.07737 103.66864 52
1 1.6868019e+12 110.07737 98.54212 313
1 1687591080000 110.07737 98.54212 322
1 1.6866423e+12 110.07737 110.07737 311
1 1686597660000 110.07737 103.66864 311
1 1686696180000 110.07737 110.07737 312
1 1.687161e+12 110.07737 103.66864 317
1 1686723780000 110.07737 110.07737 312
1 1686685020000 110.07737 118.46265 312
1 1.6597674e+12 110.07737 103.66864 0
1 1686679440000 110.07737 118.46265 312
1 1679397180000 110.07737 103.66864 227
1 1.6868139e+12 110.07737 98.54212 313
1 1.6890882e+12 110.07737 98.54212 339
1 1.6867755e+12 110.07737 98.54212 313
1 1687072140000 110.07737 103.66864 316
1 1.6873218e+12 110.07737 83.85127 319
1 1686735420000 110.07737 110.07737 312
1 1687416960000 110.07737 103.66864 320
1 1.686807e+12 110.07737 98.54212 313
1 1686759660000 110.07737 103.66864 313
1 1686662880000 110.07737 103.66864 311
1 1687757940000 110.07737 110.07737 324
1 1686740040000 110.07737 110.07737 312
1 1660830720000 110.07737 98.54212 12
1 1671545580000 110.07737 98.54212 136
1 1686692520000 110.07737 110.07737 312
1 1673965920000 110.07737 103.66864 164
1 1686713280000 110.07737 110.07737 312
1 1.6867557e+12 110.07737 103.66864 312
1 1686894840000 110.07737 98.54212 314
1 1686992280000 110.07737 103.66864 315
1 1.6871523e+12 110.07737 103.66864 317
1 1687411380000 110.07737 103.66864 320
1 1687507620000 110.07737 103.66864 321
1 1687319940000 110.07737 83.85127 319
1 1669039020000 110.07737 103.66864 107
1 1666707720000 110.07737 83.85127 80
end

Thnak you,
Priyanka
Viewing all 65444 articles
Browse latest View live


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