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

Factor analysis using custom correlation matrix

$
0
0
Hello!

I'm stuck!
I'm running a factor analysis using a polychoric correlation matrix. Everything is ok, but I cant compute scores by using predict function in the postestimation menu since I did not use the raw data. I was wondering how can I compute the scores in this case.

Thanks & Regards.

Creating a simple line chart

$
0
0
Hello,

I hope to ask if anyone can help me create simple line charts for my panel data. The panel data consist of firms (1992-2016, every two years) operating in 115 countries. There are other variables I hope to take into account (e.g. naics, entry mode, activity, parent name, etc.) when creating line charts. Also, the firm information is missing for some years (unbalanced).

Examples:
GE / 1992 / China / Shanghai subsidiary / Manufacturing
GE / 1994 / China / Shanghai subsidiary / Manufacturing
...
GE / 2016 / China / Shanghai subsidiary / Manufacturing
GE / 1992 / US / New York subsidiary / Service
GE / 1996 / US / New York subsidiary / Service
GE / 2000 / US / New York subsidiary / Service
...
Facebook / 2000 / Israel / Tel Aviv subsidiary / Sales
Facebook / 2002 / Israel / Tel Aviv subsidiary / Sales
...

Each of the subsidiaries has its own ID. So, the GE's Shanghai subsidiary in China will have its own ID and is also given the same parent id for GE's subsidiaries across all countries. Based on these types of information, I need line charts that show which countries the number of firms is growing generally across years, for example. Could you tell me which command I should use?

Also, there are simply too many countries (115) that it may be difficult to tell which country indicates which line. Do you have any suggestion on how to create a line chart that can more clearly show data? Or should I use other graphs than line charts?

Additionally, it is unbalanced so some years are missing - is there any way that the missing years can be also counted on the chart? For example, as an example above, GE's NY subsidiary for service is missing in 1994 but I hope it to be counted in the chart. Is it possible?

Lastly, I'm looking at not only the number of each subsidiaries in each country across years but also the number of parent firms in each country across years or the number of subsidiaries in the same naics category. In other words, if the unit of analysis is different than just the number of unique firm IDs, which command should I use?

I appreciate your help in advance!









CMP + eregress

$
0
0
Dear Statalists,

I am using Stata 15, the eregress package and the cmp package. The following is the problem that I am facing.

Let's say:

Y: Wage, continuous
T: Whether you are treated, binary
D: IV for T
X: control
Z: Whether you work

My data set looks like the following:
# Y T Z
1 15 1 1
2 14 1 0
3 16 1 missing
4 17 0 1
5 18 0 0
6 19 0 missing
7 88 missing 1
8 5 missing 0
9 missing 1 0

My naive regression is : reg Y on T, X

The problem is : wages are only observed when the individual is on the labor market or when the Z variable takes the value of 1. So I want to do a Heckman selection like the following:

outcome equation: reg Y on T, X
selection equation: reg Z on T, X

Now the problem is T is also endogenous to Z, therefore I want to use the IV - D variable in the outcome equation, but not in the selection equation. At the current stage, I have 2 ways to go.

Way one - cmp package

code:
cmp (wage = T X) (selectvar = T_endo X ) (T = IV) , ind(selectvar*$cmp_cont $cmp_probit $cmp_cont)
where selectvar is generated by the following command: gen selectvar = wage<. (this follows the logic of the example in the cmp manual) T_endo is the variable I created to replace T, in order not to be instrumented by the IV in the thrid equation.

My questions are :
(1) does my code make sense in terms of what I want and what I have? since in this way, I didn't use my Z variable.

Way two - eregress

code:
eregress Y, entreat(T = IV) select(selectvar = T_endo X)
where selectvar is generated by the following command: gen selectvar = wage<.

My questions are:
(1) The code gives me the error message : can't find initial value. Can anyone help me sovle this error?
(2) does my code make sense in terms of what I want and what I have?

What would be my next try? Thank you all for the time and effort reading my post. I appreciate it.

Best
Xu

Make margins postestimation run faster? Manual calculation for margins and 95% CI?

$
0
0
I am running mixed effects/multilevel analyses on a very complex, very large dataset and I've noticed that margins is taking a very, very long time to run and is keeping me from getting timely results.

My question for you all: do you know of a way of storing estimates and calculating margins later? do you know of a way of more quickly calculating predicted probabilities and their standard errors?

Thank you!

Need suggestion to improve coefficient values

$
0
0
I run fixed effect regression my dependent variable in index value 0 to 1 while independent variable are %. Problem is that coefficient values are very low. please suggest how can I improve coefficient values or run alternative method. I attached fixed effect results. Looking for your kind response.

Extracting two dates. HELP !

$
0
0
I have observations where the data was saved as csv files and now loaded into stata.
There is the 1) inclusion date =trial date and 2) echo_date= a date where we did an ultrasound of the heart (echocardiogram) on a subgroup of participants.
The trial date is not the same for all participant, it can be, but not always.
As the echo test should not be older than 1 year or 365 days from the trial_date. So I tried to change the format of the dates from strings to date, but then I am stuck.
I don't know how to extract them from each other.

generate echo_date = date(ek_echo_date, "YMD")
format %tdCCYY-NN-DD echo_date

generate trial_date = date(sp_date, "YMD")
format %tdCCYY-NN-DD trial_date

AND now to extract
drop if trial_date > 365 ... echo_date ?


My supervisor has a windows laptop while I use MAC, he has used the following commands, and it works for him

replace ek_echo_date = date("19apr2015","DMY") if sp_cpr1=="020843xxxx"
gen = (ek_echo_date-sp_date)
sort screen_echo_time


cpr is the personal id number and it is not xxxx we use in the command, it is actual numbers, but I had to hide here.
As I understand he puts one specific participant as the "start point" and then says if the date is 1 year older than that then we drop the echo, but I get "type mismatch"
Thank you very much in advance.
Best regards Lida

Difference-in-Differences reg vs xtreg

$
0
0
Dear all,

I read through many discussions concerning difference in differences analyses but have not quite found an answer.

I have data on several industries and years before and after a law was changed for some of these industries. Thus, I want to do a DID analysis.

Originally, I want to analyze all years prior and after the law was changed. From reading previous discussions I got the sense that this would be the appropriate DID command:

Code:
xtreg DepVar i.year i.treated##i.period, fe robust
where DepVar is the dependent variable, year the years, treated a dummy denoting which industry is in the treatment group and period a dummy for when the treatment was switched on.

In a second step I wand to focus just on the two years between which the change was implemented. However, I am wondering which of the following commands is correct:

Code:
xtreg DepVar i.treated##i.period, fe robust
or
Code:
reg DepVar i.treated##i.period, robust
or
Code:
reg DepVar i.treated##i.period i.industry, robust
where industry is a dummy denoting each industry?

They all give the same results but the standard errors are different. So I don´t know which one to trust.

I would really appreciate if someone could clear up my confusion!

Thanks a lot!

All the best
Leon

Graphing interaction term

$
0
0
Hello,
I have an interaction term that I would like to graph. I would like to replicate the graph below (attached). In my case instead of women/men it is son/no son and the x axis would be the different wealth quintiles.
I have tried to replicate it using:
Code:
xtreg M1  dbirthstat2 i.qwealth 0.sondum2#1.qwealth 0.sondum2#2.qwealth 0.sondum2#3.qwealth 0.sondum2#4.qwealth 0.sondum2#5.qwealth , re theta
margins qwealth#sondum2
marginsplot, recast(scatter)
But that doesn’t produce the graph I’m looking for. This is my data
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double Findid float sondum2 byte qwealth
601004802 0 3
601004802 0 3
601005902 1 1
601005902 1 1
601025702 1 2
601025702 1 3
601037702 1 1
601037702 1 1
601038302 1 1
601038302 1 1
601054402 1 2
601054402 0 2
601056302 0 4
601056302 0 4
601058302 1 1
601058302 0 1
601058602 1 2
601058602 1 2
601059402 0 3
601059402 0 2
601060202 1 2
601060202 0 2
601060302 1 2
601060302 1 1
601061202 0 2
601061202 0 2
601061302 0 1
601061302 0 1
601061602 1 1
601061602 1 1
601061802 1 1
601061802 0 1
601062002 1 3
601062002 1 2
601062302 1 2
601062302 0 1
601062802 1 3
601062802 0 2
601063102 0 4
601063102 0 4
601065402 0 1
601065402 0 1
601067002 0 1
601067002 0 1
601069302 1 1
601069302 0 1
601070202 1 3
601070202 0 3
601070802 0 3
601070802 0 1
601071402 1 2
601071402 1 1
601071502 0 2
601071502 0 1
601071602 0 2
601071602 0 1
601071702 0 4
601071702 0 2
601072002 1 2
601072002 0 1
601072702 1 3
601072702 1 4
601072902 1 3
601072902 0 2
601073102 0 2
601073102 0 1
601074202 0 2
601074202 0 3
601074502 1 3
601074502 1 2
601075502 0 2
601075502 0 2
601075902 0 1
601075902 0 3
601077402 1 1
601077402 0 2
601078802 0 2
601078802 0 1
601079402 0 2
601079402 0 1
601079502 1 2
601079502 0 2
601080302 1 3
601080302 0 4
601081102 1 3
601081102 1 1
601082202 0 2
601082202 0 2
601082402 0 1
601082402 0 1
601083402 0 2
601083402 0 2
601084002 0 1
601084002 0 3
601084502 0 1
601084502 0 1
601084902 1 2
601084902 1 1
601085202 1 2
601085202 0 2
end
label values sondum2 sondum
label def sondum 0 "Has sons", modify
label def sondum 1 "No son", modify
label values qwealth qwealth
label def qwealth 1 "Richest", modify
label def qwealth 2 "Rich", modify
label def qwealth 3 "Middle", modify
label def qwealth 4 "Poor", modify

Exporting Lincoln result using Outreg2

$
0
0
Hello,

i am trying to export my ITSA output tables to Microsoft Word using Outreg2 command, however; the post-intervention Trend (Lincoln) results are not being exported when i run the command outreg2 using myreg.doc, replace ctitle(Model 1) label and i really want them to be include. How can i do that?

Thanks.
Daughtry

vertical line overlaying an area plot

$
0
0
Hello, I am trying to add to an area plot three vertical lines overlaying them. I have tried with the xline option but it does not work with any of the options. Could anyone help? Thank you very much!!
This is the dataset:

year hous ba fa
1984 359.45 202.63 120.00
1985 349.58 197.03 117.81
1986 360.49 197.77 121.42
1987 382.94 200.97 124.70
1988 413.83 204.23 125.49
1989 435.12 201.19 128.57
1990 437.66 191.62 127.07
1991 451.60 188.36 124.82
1992 426.45 179.77 127.71
1993 435.00 192.97 137.17
1994 437.33 201.31 143.90
1995 435.18 203.68 147.81
1996 436.18 209.20 154.53
1997 442.92 220.21 163.00
1998 457.71 236.12 176.94
1999 479.38 247.72 186.01
2000 491.84 242.40 180.43
2001 510.23 235.66 173.61
2002 532.28 230.52 167.66
2003 569.33 235.92 168.65
2004 626.14 251.62 178.53
2005 677.88 266.91 188.00
2006 706.25 284.21 201.16
2007 727.35 293.74 206.34
2008 721.79 283.32 193.04
2009 685.89 275.83 191.17
2010 693.44 277.17 194.21
2011 698.54 282.62 201.07
2012 666.29 283.35 207.93
2013 650.72 289.40 218.79
2014 644.67 294.51 227.52
2015 629.20 288.76 223.98

and this is the line of the code:

twoway (area hous year, color("200 0 0")) (area ba year, color("146 195 51")) (area fa year, color("64 105 166")), title("{bf:Level and Composition of Household Wealth in Spain, 1984-2015}", size(medium) color(black)) subtitle(" ", margin(l+0 r+0 b-1 t-1)) xlabel(1984 1991 1998 2006 2014) xtitle("Year", height(4.5)) ylabel(, format(%9.0gc)) ytitle("as a % of national income (in %)", height(5)) legend(lab(1 "Housing") lab(2 "Unincorporated" "business assets") lab (3 "Financial assets") rows(1)) xline(1984(3)2015, lcolor(black) lpattern(dot) lwidth(thin)) xline(1991, lcolor(black) lwidth(thin)) xline(2006, lcolor(black) lwidth(thin)) xline(1998, lcolor(black) lwidth(thin)) graphregion(color(white)) text(845 1987.25 "1st Housing Boom", size(small)) text(845 1994.5 "1st Housing Bust", size(small)) text(845 2002 "2nd Housing Boom", size(small)) text(845 2011 "2nd Housing Bust", size(small)) graphregion(margin(l+0 r+3))

Pseudo likelihood?

$
0
0
Dear community,
In my probit model on public opinion I have applied weights, which resulted in pseudo likelihood instead of log likelihood. Could you tell me how to interpret this?

Calculate average with geometrically declining weights

$
0
0
Hello Everyone,

Could anyone help me to find a code to calculate the following equation? I am trying to calculate the average value of excess return with geometrically declining weights using 12 months. The equation is in the attached picture:
Array

Where : ϕ = 2 -1/3.


Best

How to find all user-written programs related to Text Mining / Content Analysis

$
0
0
Dear Forum Members,

I wish to find all avaliable adofiles related to Text Mining / Content Analysis.

I know there are some hand outs in the Web as well as Stata Meeting presentations, but it seems we don't have an updated rendition on this.

By typing "search content analysis" and "search text mining" in the Command Window I just got a few adofiles (3, to be precise).

I wonder whether there is some sort of browsing by theme somewhere in the Web.

Thanks in advance.

Panel data homogeneity test Hsiao

$
0
0
Hi everyone. I'm so glad that I found this forum. Well, I really need some help regarding panel data. I'm doing my research in the impact of governance in performance. I have a panel data of 240 obs(n=40/T=6). My Dependent variable is performance (calculated by ROA ( return on assets)). As for my independents variables I have like the capital structure ( the % of CEO capital,...) and board of directors (size of the board), its independance ( its a dummy variable it takes 0 when the board has not independant directors, 1 otherwise) the existence of audit comittee ( dumly variable 0/1).......
1-So my first question I read a lot about panel data but actually in some publucations I find that the first step is the specification model ( homogeniety test) or hsiao test, in others No?? They try just to specify if the model is fe or re? Can you please tell me is the Hsiao test (homogeniety test) the first test to do in regression panel data?
2-second, is the use of independant dummy variables (I have 5 of them) well have an impact in my models and its significance?

Thank you and sorry for my english because I'm not a native speaker and I do my research in frensh. Thank you for your insights

Error 301 for conditional fixed effects negative binomial regression, panel data

$
0
0
Hello,

Background

I have a couple of years' worth of panel data for dengue case counts at the province level in Vietnam (outcome = dengue case counts by province years, offset by provincial populations; n=189 (63 provinces x 3 years)). All my exposures and outcome are continuous variables.

I am fitting a conditional fixed effects negative binomial regression model to assess the strength of association between exposure socioeconomic variables and the dengue case counts by province-year.

I have three candidate univariate models taking mobility of population, case counts in the previous year and population density as exposures. The Hausman test suggested random effects model for population density. The models are:
xtnbreg rmorb mobility, fe exposure(avgpop)
xtnbreg rmorb prevyearcases, fe exposure(avgpop)
xtnbreg rmorb popdensity, re exposure(avgpop)


I used the command estat ic to obtain AIC and BIC numbers, in order to select a preferred model.

Issue:

Beyond this, I would like to plot residuals and test for heteroskedasticity.

However when I try the commands for these (rvfplot and xttest3 respectively), I get error 301 'last estimates not found'.

Can you help?

Full code below for info.

Polly

CODE:
import excel socioeconplusspaciotemporaltraining1415INTEGERS.xl sx, cellrange(B2:AH65) firstrow clear
reshape long rmorb pov clin mobil popdens hpres u1vac elec y1q1nmorb urban, i(provcode) j(year)
xtset provcode year
xtnbreg rmorb mobility, fe exposure(avgpop)
estat ic
ssc install xttest3

xttest3 / rvfplot both return error 301

Problems with Multilevel logistic model

$
0
0
Dear all,
I am currently working on a study looking at the link between weather shocks (precipitation and temperature) on internal migration (municipal level and across province movements) in South Africa. my outcome variables (migrants inflow and migrants outflow) are binary so I am using a logistic regression analysis. When I run a (three-level) multilevel model logistic model (this is because I have a clustered data (individual migrants and their control variables; weather data in addition to other socio-economic variables at the municipal levels and GDP at the Province level), my result never shows. I even left the STATA running overnight. Please see below my command:

melogit Mig_Outflow || Usual_Province: GDPGrowthRate || MN_CODE_2016: PrecOrig_sq OrigPrec AverageCrimeRate PovertyRate UnemploymentRate || id: EducLevel Race MarrDummy Male1

I would be very grateful if someone will be so kind to explain why this happens, and suggest some plausible solution to that?

Thank you.

How to create crisis dummy variable in panel countries

$
0
0
Time Period 1970 to 2018
Countries 33

I wanted to create crisis dummy variable 1 if below crisis year rest zero.

I would be grateful for your help.

Code:
 
Country Crisis year
Albania 1994
Algeria 1990
Angola
Argentina 1980, 1989, 1995, 2001
Armenia 1994
Australia
Austria 2008
Azerbaijan 1995
Bangladesh 1987
Barbados
Belarus 1995
Belgium 2008
Belize
Benin 1988
Bhutan
Bolivia 1986, 1994
Bosnia and Herzegovina 1992
Botswana
Brazil 1990, 1994
Brunei
Bulgaria 1996
Burkina Faso 1990
Burundi 1994
Cambodia
Cameroon 1987, 1995
Canada
Cape Verde 1993
Central African Rep. 1976, 1995
Chad 1983, 1992
Chile 1976, 1981
China, P.R. 1998
Colombia 1982, 1998
Comoros

Creating portfolios sorted by returns and standard deviation.

$
0
0
Hello
I have sorted stocks by past returns and price standard deviation. And, I tried to create portfolios using xtile. what I want to do is that I create two portfoilios; the first is top 20% past 1month returns stocks and top 50% standard deviation; the second is that bottom past 1month 20% return stocks and bottom 50% standard deviation.
Since the process is double-sorting, I sorted stocks by returns and by SD and I cannot create portfolios when I have to double-sort.
I know if I have one sorting standard I could have used
egen portfolios = xtile(past_ret_1), nq(5)
But I cannot create portfolio with two sorting standards.

I have to create portfolios which
1. have top 20% 1month past returns and top 50% past 1 month volatility(standard deviation)
2. have bottom 20% past 1month returns and bottom 50% past 1 month volatility(standard deviation)

Could anyone help me?
I describe the variables which I need to code this.
permno is stock code,
date is date, prc is price of stock,
ast_ret_1 is past 1 month return,
volatility_1 is past 1 month volatility (standard deviation)
r1r is 5 quantiles of past_ret_1,
vol_grade1 is 2 quantiles of volatility_1

My dataex is below


. dataex

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double permno long date double(shrcd exchcd siccd prc ret) int mdate double volatility_1 float past_ret_1 double volatility_3 float past_ret_3 double volatility_6 float(past_ret_6 ri1 ri3 ri6) byte(r1r r3r r6r vol_grade1 vol_grade3 vol_grade6)
10001 18266 11 2 4925              10.25    -.004854387138038874 600                   .            .                  .            .                  .           .  -.025365876            0   .05951216 . . . . . .
10001 18294 11 2 4925  9.989999771118164    -.006958314683288336 601  .18640435354468468  -.025365876 .18640435354468468  -.025365876 .18640435354468468 -.025365876  .0010010239     .1811812   .20620625 2 2 3 1 1 1
10001 18322 11 2 4925                 10   -.0008392913150601089 602  .07973949391474112  .0010010239 .15942680476776733  -.024390243 .15942680476776733 -.024390243         .025         .137   .04350004 3 2 3 1 1 1
10001 18353 11 2 4925              10.25     .007866266183555126 603  .07564392234132054         .025 .13787852330894748            0 .13787852330894748           0    .15121953    .05951216   .07317073 4 3 3 1 1 1
10001 18385 11 2 4925 11.800000190734863      .03599647432565689 604  .40177915615148524    .15121953 .44905645667481014     .1811812 .40594366205503735   .15121953  -.036440704    .02118644  -.03898305 5 5 4 1 1 1
10001 18414 11 2 4925 11.369999885559082   -.0026315555442124605 605  .39753444140417754  -.036440704  .5543317709609373         .137  .5137325483141435   .10926828    -.0448549    -.0822339  -.10729994 2 5 4 1 1 1
10001 18444 11 2 4925 10.859999656677246                       0 606   .3195789827141747    -.0448549  .5530637553214912    .05951216  .7111912906637656   .05951216    .10957648   .012891376  -.03775321 2 4 4 1 1 1
10001 18476 11 2 4925 12.050000190734863     .028156990185379982 607  .38256143087180816    .10957648  .4674535510182806    .02118644  .7228745528019987   .20620625   -.13402487   -.05892117  -.10622405 5 3 5 1 1 1
10001 18506 11 2 4925   10.4350004196167      .00617106631398201 608   .6820635243785057   -.13402487  .5199689092052626    -.0822339  .6988548611401296   .04350004    .05414466  -.027312007   .05414466 1 2 3 2 1 1
10001 18536 11 2 4925                 11    -.010791356675326824 609  .23167174266670273    .05414466  .5051961032408528   .012891376  .5273756839519413   .07317073   .030909104   -.05000002   .06818182 4 3 4 1 1 1
10001 18567 11 2 4925  11.34000015258789    -.008732615038752556 610  .15765161420960289   .030909104 .45920004131705155   -.05892117 .47373630755060436  -.03898305   -.10493832   -.05026452 -.022045854 4 2 2 1 1 1
10001 18597 11 2 4925 10.149999618530273     .010956141166388988 611   .5875475317883132   -.10493832  .5126182310801831  -.027312007   .609981220237303  -.10729994    .02955667    .08374389    .1251232 1 2 2 2 1 1
10001 18630 11 2 4925 10.449999809265137   -.0066540539264678955 612  .12508096619524547    .02955667  .5297362400926223   -.05000002  .5926389438470832  -.03775321    .03062207    .12440193   .12057418 4 2 2 1 1 1
10001 18659 11 2 4925 10.770000457763672   -.0009275765623897314 613   .1578552469346256    .03062207  .3723881033701738   -.05026452  .5563828464510988  -.10622405   .021355575   .029712133   .04828222 4 2 2 1 1 1
10001 18687 11 2 4925                 11    .0018215354066342115 614  .07125262232538056   .021355575  .2324524127880026    .08374389 .41657432956710305   .05414466    .06818182    .03818183  -.00999997 4 4 4 1 1 1
10001 18718 11 2 4925              11.75    .0017050689784809947 615    .181595891063371    .06818182  .2560189479973279    .12440193  .4327399562258367   .06818182    -.0561702  -.003404252 -.065531954 5 5 4 1 1 1
10001 18749 11 2 4925  11.09000015258789     -.01246655359864235 616  .17742968647816745    -.0561702 .34554503303207285   .029712133  .5184807669582139 -.022045854    .02975653   .018034248 -.006311965 2 3 3 1 1 1
10001 18779 11 2 4925 11.420000076293945    -.006956514902412891 617  .10122221615745265    .02975653  .2562096761145746    .03818183 .43820764162425335    .1251232   .025394043   -.04640978  -.04991241 4 4 4 1 1 1
10001 18809 11 2 4925 11.710000038146973     .013852800242602825 618  .06950455926252143   .025394043 .18129218532038652  -.003404252 .35840022726152915   .12057418  -.035866786   -.06233992 -.023057256 4 3 4 1 1 1
10001 18840 11 2 4925 11.289999961853027     .009838967584073544 619  .22807671595986842  -.035866786 .18267390602016262   .018034248  .2969734976720698   .04828222   -.03542955  -.023914926  -.01416295 2 3 3 1 1 1
10001 18871 11 2 4925 10.890000343322754    -.008196649141609669 620   .1584367410581936   -.03542955 .26967476101129784   -.04640978 .26210378054041233  -.00999997   .008264389  -.003673091   .02387505 2 2 3 1 1 1
10001 18903 11 2 4925 10.979999542236328   -.0009099389426410198 621   .1362248386336823   .008264389 .36503089311441256   -.06233992  .3312659481663802 -.065531954   .003643071    .04189436   .04007291 3 2 2 1 1 1
10001 18932 11 2 4925 11.020000457763672    .0018182233907282352 622    .064879644634678   .003643071  .1754350624607524  -.023914926  .3031444882221424 -.006311965  -.015426503   .009990906  .014446435 3 2 3 1 1 1
10001 18962 11 2 4925 10.850000381469727    -.004587085917592049 623  .08011199628563465  -.015426503 .14098885706925854  -.003673091 .30494546040380033  -.04991241     .0543778     .0276497  -.05437789 2 3 2 1 1 1
10001 18995 11 2 4925   11.4399995803833    .0017512700287625194 624  .16471602550200323     .0543778  .1109390323861021    .04189436 .27715720948418837 -.023057256  -.027089104 -.0017482084   -.1171328 4 4 3 1 1 1
10001 19024 11 2 4925  11.13010025024414   -.0017846968257799745 625  .12695825733412597  -.027089104  .1505072818312588   .009990906 .17297727649822103  -.01416295  .0017878877   .004411454   -.0943478 2 3 3 1 1 1
10001 19053 11 2 4925 11.149999618530273   -.0009677049820311368 626   .0733472854133795  .0017878877  .1506023838790185     .0276497 .17794872754080054   .02387505    .02421529   -.07982057  -.10672642 3 3 3 1 1 1
10001 19085 11 2 4925 11.420000076293945    -.020583171397447586 627   .1590294799085855    .02421529 .14011209706522632 -.0017482084  .1718818116493562   .04007291  -.021085806   -.11558666  -.12872157 4 3 3 1 1 1
10001 19114 11 2 4925 11.179200172424316    -.022805705666542053 628  .17402728265658138  -.021085806 .15136438495279056   .004411454  .1767343709664558  .014446435   -.08222412   -.09832548   -.1027981 2 3 3 1 1 1
10001 19145 11 2 4925 10.260000228881836    -.016299143433570862 629   .2630426561283295   -.08222412 .25490894451350693   -.07982057 .21065142226993364  -.05437789  -.015594527  -.029239785  -.07602346 1 2 2 1 1 1
10001 19176 11 2 4925 10.100000381469727                       0 630    .262437261852884  -.015594527  .4555340676353445   -.11558666  .3951759012681891   -.1171328 -.0019802433   -.01485154  -.05148519 2 2 2 1 1 1
10001 19206 11 2 4925 10.079999923706055    -.006896521896123886 631  .06224752051650344 -.0019802433 .42426073529192365   -.09832548  .5055695043194937   -.0943478   -.01190475  -.004960336  -.02777775 3 2 2 1 1 1
10001 19240 11 2 4925  9.960000038146973    -.002003958448767662 632  .07820865732721459   -.01190475  .2119991506535575  -.029239785  .5751764591194123  -.10672642 -.0010040391   -.04819282  .003012021 3 2 2 1 1 1
10001 19267 11 2 4925  9.949999809265137    .0010060592321678996 633 .046484553045708754 -.0010040391 .10346999210154871   -.01485154   .524455669371931  -.12872157  .0080401935   -.03718592   .03919601 3 3 2 1 1 1
10001 19298 11 2 4925 10.029999732971191     .000898096477612853 634  .03227864172652164  .0080401935 .06351416957895344  -.004960336  .3920297684823155   -.1027981   -.05483551   -.02293116   .02392829 3 3 2 1 1 1
10001 19330 11 2 4925  9.479999542236328    -.004201776813715696 635   .4917846959868616   -.05483551 .37806184764038636   -.04819282 .34091790047554354  -.07602346   .010548564     .0537975   .08649796 2 2 2 1 1 1
10001 19360 11 2 4925  9.579999923706055       .0267952848225832 636  .12748062644580277   .010548564 .40215772419513063   -.03718592 .34743378822254384  -.05148519   .022964537    .07933196    .0960334 3 2 2 1 1 1
10001 19390 11 2 4925  9.800000190734863   -.0070921676233410835 637   .1730536192179159   .022964537  .3363810478802017   -.02293116 .32662120860743593  -.02777775    .01938771    .04795921   .06224486 4 2 2 1 1 1
10001 19418 11 2 4925  9.989999771118164    .0050302003510296345 638  .05680673034385046    .01938771 .25360936079801805     .0537975  .3271844424437017  .003012021   .035035074   .031031074     .016016 4 4 3 1 1 1
10001 19449 11 2 4925  10.34000015258789     .013725523836910725 639  .04287068869956355   .035035074 .18079184222215358    .07933196   .340254399421649   .03919601  -.006769796   .015473872 -.004835608 4 4 3 1 1 1
10001 19479 11 2 4925 10.270000457763672    -.005808273795992136 640  .14054930450066883  -.006769796 .13558691824147576    .04795921  .3700833577673592   .02392829   .002921103   .013631877 -.022395374 3 4 3 1 1 1
10001 19512 11 2 4925 10.300000190734863    .0019455698784440756 641  .12124643005719198   .002921103  .1874594287183265   .031031074 .35141358137286594   .08649796    .01941746  -.014563162  -.19708735 3 3 4 1 1 1
10001 19540 11 2 4925               10.5     .019417457282543182 642  .14604521823753902    .01941746 .17155749358700312   .015473872   .273556838331953    .0960334  -.008571443  -.020000003   -.2342857 4 3 4 1 1 1
10001 19571 11 2 4925  10.40999984741211    -.000959714874625206 643  .22069548057910818  -.008571443  .1684166689431317   .013631877 .22211684000340348   .06224486   -.02497601  -.035542738  -.11911622 3 3 4 1 1 1
10001 19604 11 2 4925 10.149999618530273    -.004901979584246874 644  .07947326195351662   -.02497601  .1584622601198413  -.014563162  .1841185037416441     .016016   .013793138    -.1852216 -.073891625 2 3 3 1 1 1
10001 19632 11 2 4925 10.289999961853027     .008823544718325138 645  .07089471348123667   .013793138 .14480615214672515  -.020000003  .1581658604218184 -.004835608   -.02429543    -.2186589   -.0281827 3 3 3 1 1 1
10001 19663 11 2 4925 10.039999961853027     .007021032273769379 646  .11058593465750331   -.02429543 .09025947741784955  -.035542738 .14096491287365762 -.022395374   -.17629477   -.08665337    .0846614 2 2 3 1 1 1
10001 19694 11 2 4925  8.270000457763672    -.036130473017692566 647    .623414004046124   -.17629477  .5098740407713392    -.1852216 .40667581431779926  -.19708735  -.027811425    .13663834   .25755733 1 1 1 2 1 1
10001 19725 11 2 4925  8.039999961853027    .0012453586095944047 648  .12027350435487831  -.027811425  .9765681054309964    -.2186589   .856076286427567   -.2342857    .14054728     .2437811   .29353228 2 1 1 1 1 1
10001 19757 11 2 4925  9.170000076293945                       0 649   .4675528098777736    .14054728  .7383673068649981   -.08665337  .8653969540244855  -.11911622    .02508174     .1875682    .3631407 5 2 2 1 1 1
10001 19785 11 2 4925  9.399999618530273     .004273500293493271 650  .23728124683069343    .02508174  .6891845208952013    .13663834  .8181591992611321 -.073891625    .06382983    .10638298    .1978724 4 5 2 1 1 1
10001 19814 11 2 4925                 10    -.005964256357401609 651  .16197478259265533    .06382983  .4120083692715949     .2437811  .7576223882289632   -.0281827    .08900003    .03999996         .17 5 5 2 1 1 1
10001 19844 11 2 4925 10.890000343322754   -.0009173647267743945 652  .44953050802713124    .08900003 .49894747190638905     .1875682  .8192106400636942    .0846614   -.04499548    .14784202   .04224059 5 5 4 1 1 1
10001 19876 11 2 4925 10.399999618530273    -.008579614572227001 653  .21985490386674195   -.04499548  .4790351795938581    .10638298  .9032507779990131   .25755733            0    .08269237   .09615385 2 4 5 1 1 1
10001 19905 11 2 4925 10.399999618530273    -.013282764703035355 654  .10365692927007192            0  .3015330210211246    .03999996  .6213321839858031   .29353228     .2019231    .12500003   .05961547 3 4 5 1 1 1
10001 19936 11 2 4925               12.5    -.030256038531661034 655  1.1404454300559521     .2019231  .7784783317600383    .14784202  .7770261287362366    .3631407   -.09919998   -.09199997  -.22800003 5 5 5 2 1 1
10001 19968 11 2 4925 11.260000228881836   -.0017730057006701827 656  .44702663991570357   -.09919998  .8851793244193881    .08269237  .8292865455040823    .1978724    .03907634   .012433338  -.10301952 1 4 5 1 1 1
10001 19997 11 2 4925 11.699999809265137    -.009314191527664661 657  .23346458803456374    .03907634  .7332278930742997    .12500003  .7541634327784786         .17   -.02991448    -.0581196  -.14957266 4 5 4 1 1 1
10001 20030 11 2 4925 11.350000381469727                       0 658  .14059028685323144   -.02991448  .3149031876679924   -.09199997  .6998235946019506   .04224059   .004405219    -.1497798  -.11101323 2 2 3 1 1 1
10001 20058 11 2 4925 11.399999618530273    -.008695685304701328 659  .09963676818455106   .004405219  .1929267962598497   .012433338  .6556062320346671   .09615385   -.03333326   -.11403503  -.12280699 3 3 4 1 1 1
10001 20090 11 2 4925 11.020000457763672                       0 660   .2737379653773335   -.03333326 .20405005636093954    -.0581196  .5456458673348294   .05961547    -.1243195   -.09709624  -.08620697 2 2 4 1 1 1
10001 20121 11 2 4925  9.649999618530273    -.010256449691951275 661   .4097300989645378    -.1243195  .4793438075213596    -.1497798 .48788475439816464  -.22800003     .0466322    .04559591  .013471515 1 1 1 1 1 1
10001 20149 11 2 4925 10.100000381469727                       0 662   .2446505058044584     .0466322  .6408768982377454   -.11403503  .6438900723449399  -.10301952   -.01485154  -.009901027  -.12871289 4 2 2 1 1 1
10001 20179 11 2 4925  9.949999809265137   -.0010040390770882368 663  .09795740644721498   -.01485154  .3840516538847445   -.09709624  .6957564225942188  -.14957266   .014070387    .01206029   -.1065326 2 2 2 1 1 1
10001 20209 11 2 4925  10.09000015258789     .001986142946407199 664  .06637716411991972   .014070387   .154285966169348    .04559591  .6503682985108398  -.11101323  -.008919737   -.03072353  -.12586723 3 4 2 1 1 1
10001 20240 11 2 4925                 10                       0 665   .0581172805442231  -.008919737   .107328667474757  -.009901027  .5381612061583212  -.12280699    .00699997   -.11999998  -.12700005 3 3 2 1 1 1
10001 20270 11 2 4925 10.069999694824219     -.02233014442026615 666  .16794321933282605    .00699997  .1206459891277396    .01206029  .2823565798780028  -.08620697   -.02879841   -.11717968  -.25322738 3 3 2 1 1 1
10001 20303 11 2 4925  9.779999732971191    -.024925224483013153 667   .1212776976858375   -.02879841 .13294903934247845   -.03072353  .1554382674821914  .013471515   -.10020445   -.09815951  -.13905928 2 2 3 1 1 1
10001 20332 11 2 4925  8.800000190734863    -.012345640920102596 668  .34786478479449284   -.10020445 .46126758551671454   -.11999998   .356839508408627  -.12871289    .01022729  -.007954619  -.05681818 1 2 2 1 1 1
10001 20362 11 2 4925  8.890000343322754    -.005592755973339081 669  .23358382474387235    .01022729  .5509337361041263   -.11717968  .5345813159474855   -.1065326  -.007874088   -.15410577   -.1226097 3 2 2 1 1 1
10001 20394 11 2 4925  8.819999694824219                       0 670  .18473612181984753  -.007874088  .2974306907681954   -.09815951  .5721746581352123  -.12586723    -.0102041   -.04535143  -.21655327 3 2 2 1 1 1
10001 20423 11 2 4925  8.729999542236328   -.0011441910173743963 671  .11627884176868694    -.0102041 .21259853951346633  -.007954619  .5713980810324415  -.12700005   -.13860248   -.04925537  -.18556695 3 3 2 1 1 1
10001 20457 11 2 4925  7.519999980926514     .009395996108651161 672   .5579679723619297   -.13860248  .6512967430482997   -.15410577  .7329853960190996  -.25322738    .11968087    .03723407  -.05851065 1 1 1 1 1 1
10001 20485 11 2 4925  8.420000076293945      .01201927661895752 673  .27671314614485903    .11968087  .5680918456949471   -.04535143  .6159062690213537  -.13905928  -.014251768   -.17933494  -.15083136 5 2 2 1 1 1
10001 20514 11 2 4925  8.300000190734863       .0559796504676342 674   .2349002451136125  -.014251768  .4202801443741118   -.04925537   .561834561666733  -.05681818   -.06024096    -.1433735  -.10361447 2 2 2 1 1 1
10001 20545 11 2 4925  7.800000190734863   -.0012803779682144523 675  .13742525924620014   -.06024096 .22447660547009565    .03723407  .5332888965346905   -.1226097    -.1141026   -.09230772  -.03333336 2 4 2 1 1 1
10001 20576 11 2 4925  6.909999847412109     -.05342470481991768 676   .2633846021305704    -.1141026 .39412138769836946   -.17933494  .5052049115736454  -.21655327     .0289436    .03473231    .7872649 1 1 1 1 1 1
10001 20606 11 2 4925  7.110000133514404    -.004201643168926239 677  .09567675569586913     .0289436 .48335545823210324    -.1433735  .5042947253178054  -.18556695  -.004219439    .04641349    .7510548 4 1 1 1 1 1
10001 20636 11 2 4925  7.079999923706055      .01287555880844593 678  .05673900789326746  -.004219439  .2530382865060027   -.09230772  .5272738438726049  -.05851065    .00988703    .06497176    .7796611 3 2 2 1 1 1
10001 20667 11 2 4925  7.150000095367432     .007042280398309231 679 .048782661566319226    .00988703 .10762584669607418    .03473231  .5020461587462266  -.15083136    .04055943     .7272727    .7692307 3 4 2 1 1 1
10001 20698 11 2 4925  7.440000057220459     .010869554243981838 680   .1220978336810731    .04055943 .17764848751005802    .04641349 .39596763716385475  -.10361447   .013440847     .6733871    .7002687 4 4 2 1 1 1
10001 20730 11 2 4925  7.539999961853027    -.016949167475104332 681   .1715364726753886   .013440847 .23925850670954377    .06497176  .2817927559295505  -.03333336     .6379311     .6710876    .6777188 3 4 2 1 1 1
10001 20759 11 2 4925 12.350000381469727                       0 682   2.115515531436557     .6379311 2.1413539866430558     .7272727 1.7401421430669661    .7872649    .00809712   .024291435  .012145718 5 5 5 2 2 2
10001 20789 11 2 4925 12.449999809265137    -.004000015091150999 683   .0970518319368766    .00809712   2.39688207556103     .6733871 2.3624398394939847    .7510548    .01204824   .016064242  .016064242 3 5 5 1 2 2
10001 20822 11 2 4925 12.600000381469727     .003984078764915466 684  .07054213004398015    .01204824 1.3418394719060822     .6710876  2.550009684547101    .7796611   .003968193   .003968193   .02380946 3 5 5 1 2 2
10001 20851 11 2 4925 12.649999618530273                       0 685  .04757363708671314   .003968193 .09452372153657818   .024291435  2.458981151214114    .7692307            0  -.011857677    .0316206 3 3 5 1 1 2
10001 20879 11 2 4925 12.649999618530273                       0 686 .039366089860446346            0  .0711081492552561   .016064242  2.013523405989526    .7002687            0            0           . 3 3 5 1 1 2
10001 20912 11 2 4925 12.649999618530273    -.003937022760510445 687   .0473913086863199            0 .04519681973146688   .003968193  .9858898764953599    .6777188  -.011857677   .019762846           . 3 3 5 1 1 1
10001 20940 11 2 4925               12.5                       0 688 .041696421737767955  -.011857677 .05335704570218714  -.011857677 .08043606477525421  .012145718    .01199997    .04400001           . 3 3 3 1 1 1
10001 20971 11 2 4925 12.649999618530273    -.003937022760510445 689 .052265164265786236    .01199997 .05701883729893278            0 .06425233168020862  .016064242   .019762846            .           . 3 3 3 1 1 1
10001 21003 11 2 4925 12.899999618530273    -.001934280269779265 690  .10233207953408884   .019762846 .10971372377365043   .019762846 .08449748919907539   .02380946   .011627952            .           . 4 3 3 1 1 1
10001 21032 11 2 4925 13.050000190734863     .007722037378698587 691  .05897991367034467   .011627952 .14225035481618584    .04400001 .13428686175196708    .0316206            .            .           . 3 4 3 1 1 1
10002 18266 11 3 6020 3.0999999046325684      .08013938367366791 600                   .            .                  .            .                  .           .     .2451613     .5644838   .21290326 . . . . . .
10002 18294 11 3 6020  3.859999895095825    -.015306168235838413 601   .4296841825364234     .2451613  .4296841825364234     .2451613  .4296841825364234    .2451613    .17875656     .4145078   -.1554404 5 5 5 1 1 1
10002 18322 11 3 6020  4.550000190734863     .004415006842464209 602  .36717583363251327    .17875656  .7387044837153376     .4677421  .7387044837153376    .4677421    .06591199   -.03736265  -.31428576 5 5 5 1 1 1
10002 18353 11 3 6020  4.849899768829346 -.000020646557459258474 603  .10538855626183742    .06591199  .7850850067661307     .5644838  .7850850067661307    .5644838    .12579647   -.22472624  -.36905915 5 5 5 1 1 1
10002 18385 11 3 6020  5.460000038146973     -.11793214827775955 604   .3809403276799246    .12579647   .589193584993965     .4145078  .9486795247042981    .7612904    -.1978022    -.4029304   -.4578755 5 5 5 1 1 1
10002 18414 11 3 6020  4.380000114440918    -.011286617256700993 605  .46236515967535524    -.1978022 .47578619431157226   -.03736265  .8975770443956432    .4129033   -.14155254   -.28767127   -.4200914 1 2 5 1 1 1
10002 18444 11 3 6020  3.759999990463257     .016216199845075607 606  .33242027453540607   -.14155254   .681697207867179   -.22472624  .8364520181489538   .21290326   -.13297872    -.1861702   -.3005319 1 1 5 1 1 1
10002 18476 11 3 6020  3.259999990463257     .061889272183179855 607    .229305905784321   -.13297872  .7488768581626191    -.4029304  .7608379566539603   -.1554404   -.04294482   -.09202453  -.20858897 1 1 2 1 1 1
end
format %d date
format %tm mdate
------------------ copy up to and including the previous line ------------------

Run a loop only on string variables (without specifying them)

$
0
0
Hi!

I am using a rather big data set in terms of variables. I have crop specific variables for 18 crops. Every crop has 44 variables (so basically 44 variables that repeat themselves for 18 different crops giving a total of 792 variables). Some of these variables are string and some are numeric. All of them should be numeric so in need to destring them. (obs I cannot use destring codes because some cells include non numeric values which I first need to eliminate)

I´m using the following loop:
foreach v of varlist example1 example2 example3 {
egen `v'_n = sieve(`v'), char(0123456789.,)
replace `v'_n= subinstr(`v'_n, ",", ".",.)
destring `v'_n, replace
local x : variable label `v'
label variable `v'_n "`x'"
} Which works just fine when I test it on string variables. When I include the numeric variables, I get error messages. However I don’t want to manually check which of the 792 variables are strings so I was wondering how can I alter my code so the loop would run only for string variables?
I found on statalist [https://www.stata.com/statalist/arch.../msg00953.html] the following code:

qui ds *, has(type string)
foreach x of varlist `=r(varlist)' {
do string things
}

So when I alter it in the following manner
qui ds *, has(type string)
foreach v of varlist `=r(example1 – example44)' {
egen `v'_n = sieve(`v'), char(0123456789.,)
replace `v'_n= subinstr(`v'_n, ",", ".",.)
destring `v'_n, replace
local x : variable label `v'
label variable `v'_n "`x'"
}
I get: invalid name varlist required
r(100);

what am I doing wrong?

thank you in advance

regression on continuous outcome variable paired match case control study

$
0
0
re
We have done a cross-sectional survey of disease X in cattle. Seropositives were matched to seronegatives on region, village, farm, species, breed and age within 2 years. Now, we want to know the milk production (noted in questionnaire) (continuous independent variable) predicted by a model depending on test result (positive or negative), last calve months (continuous independent variable) and parity (number of times a cow has calved....1,2,3 etc) .............can we do a analysis keeping the matching pairs in mind.....
I have tried this command: xtmixed b_milk_kg i.elisa c_last_calve_months e_parity || c_village : || d_farm_id : || a_species :

BUT THIS NOT TAKE ACCOUNT THE MATCHING PAIRS.....
CAN U HELP
Viewing all 72904 articles
Browse latest View live


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