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

Analysis for two continuous variables (not normally distributed)

$
0
0
Dear Statlist,

I have two continuous variables, the dependent variable is not normally distributed while the independent variable is normally distributed. Apart from Spearman's correlation (I actually am not sure if this is suitable since the dependent variable is not ordinal), I'm wondering which method I can use for analyzing the relationship between this two variables? Thank you very much.

Yue

Is it possible to test coefficient estimates across two samples using GMM model?

$
0
0
Dear All,

I run the same GMM model in two different samples (firms which have high imported input vs low imported input). I would like to test the coefficient estimates (particularly for fx) across specifications. How can I do this?
Thank you in advance.
Have a great day!
Nazlı


xtdpd expshare l1.expshare fx dllabprod VIX Dolratetota lrsale col leverage2 lFGDP_s ipsectoralgrowth log_GDP if year>2001 & dummy_highimport==1, dgmmiv(Dolratetota lrsale dllabprod , lag(3 3)) div(lFGDP_s fx VIX ipsectoralgrowth log_GDP ) hascons twostep

xtdpd expshare l1.expshare fx dllabprod VIX Dolratetota lrsale col leverage2 lFGDP_s ipsectoralgrowth log_GDP if year>2001 & dummy_highimport==0, dgmmiv(Dolratetota lrsale dllabprod , lag(3 3)) div(lFGDP_s fx VIX ipsectoralgrowth log_GDP ) hascons twostep

How to get the quintile points in survey data?

$
0
0
I am using a survey data now and trying very hard to figure out the quintile points (20%, 40%, 60%, 80%) of a continuous variable.
I know the code to get the quartile points. But can someone let me know how to get the quintile points? Thanks!

importing multiple excel files using a loop

$
0
0
Hi statalists, I have the following code but I always get the error message

local dpto AMAZONAS ANCASH APURIMAC
foreach x in local dpto {
import excel using "Z:\HigherEducation_Inequality\INEI\`x'_t.xls" , sheet(`x') clear
keep A B C
keep if A=="18"|A=="19"
xpose,clear
drop in 1
rename v1 pob18
rename v2 pob19
gen Name=`x'
gen id=_n
gen Year=1998 if id==1
replace Year=1999 if id==2
drop id
save data_`x',replace
}

file Z:/HigherEducation_Inequality/INEI`x'_t.xls not found
r(601);


Does anyone has any thoughts about what am I doing wrong?

Page break in PDF output

$
0
0
I need to put page breaks in PDF strategically to keep certain lines of text together on the same page.
Is there any way to measure the 'fit' of the text, to determine whether the next line still fits the page or I need to move it to the next page?

Thank you, Sergiy

IVREG LIML yields zero cefficients and p-value=1.

$
0
0
I am using Stata to run "IVREG LIML" which is an IV with Limited Maximum Likelihood estimator. However, some of the coefficients are zeros with p-value equal 1. I wonder what causes this issue. I really appreciate it if anyone can help me with this problem.

Thank you!

Array

How to destring date variable formatted as year and week number

$
0
0
Dear Statalist,

I was just wondering if there is an easy way to destring a date variable formatted as "year and week number".
for example,

2008w34
2008w35
2008w36
2008w37
2008w38


Thanks so much for your help!

Yonatan

Issues with Hausman-Wu test

$
0
0
Hi everyone,

I am having issues with running a Hausman-Wu test. The output is as follows:

"hausman fe re

Note: the rank of the differenced variance matrix (8) does not equal the number of
coefficients being tested (9); be sure this is what you expect, or there may be
problems computing the test. Examine the output of your estimators for anything
unexpected and possibly consider scaling your variables so that the coefficients
are on a similar scale.

---- Coefficients ----
| (b) (B) (b-B) sqrt(diag(V_b-V_B))
| fe re Difference S.E.
-------------+----------------------------------------------------------------
Dependency | .0625601 .0869425 -.0243824 .
MilExpGDP | -.1617947 -.0907287 -.071066 .195339
Population | -8.84e-09 3.13e-08 -4.01e-08 3.77e-08
Secondary | -.0252826 -.0201809 -.0051017 .
Unemployment | .0036028 -.009116 .0127187 .0101393
TradeGDP | .0032786 .0063996 -.0031209 .0018899
GDPpc | -3.08e-06 -.0000964 .0000933 .0000417
Inflation | -.0016078 -.0028157 .001208 .
UrbanPop | .2251216 .1224237 .102698 .0358208
------------------------------------------------------------------------------
b = consistent under Ho and Ha; obtained from xtreg
B = inconsistent under Ha, efficient under Ho; obtained from xtreg

Test: Ho: difference in coefficients not systematic

chi2(8) = (b-B)'[(V_b-V_B)^(-1)](b-B)
= 33.87
Prob>chi2 = 0.0000
(V_b-V_B is not positive definite)"

I have already tried different syntaxes, and with sigmamore & sigmaless addition, but these have been to no avail.

Any guidance you could provide on the matter would be gratefully appreciated.

Yours,
Scott

dummy for panel data

$
0
0
Hi,
how to create dummy variable for panel data? I want to create a dummy for 130 districts for 3 years; 2010, 2012 and 2014. If the district has a cant then it should be 1 otherwise 0. How to do it for all 3 years?

How to recode data with multiple groups

$
0
0
Hi Everyone,

I am fairly new to stata and I am looking at cancer data. I have histology groupings for lung cancer. The groups all over the place so it is hard to include ranges but I included them where I could. The code works perfect but it just seems long and messy. I am looking for a way to make this code more efficient. I apologize in advance if this is an easy fix and Thanks in advance for any help!


recode HistologicTypeICDO3 (8051/8052 =0) (8070/8076=0) (8078 =0) (8083/8084 =0) (8090 =0) (8094 =0) (8120 =0) (8123 =0) (8002 =1) (8041/8045 =1) (8015 =2) (8050 =2) (8140/8141 =2) (8143/8145 =2) (8147 =2) (8190 =2) (8201 =2) (8211 =2) (8250/8255 =2) (8260 =2) (8290 =2) (8310 =2) (8320 =2) (8323 =2) (8333 =2) (8401 =2) (8440 =2) (8470/8471 =2) (8480/8481 =2) (8490 =2) (8503 =2) (8507 =2) (8550 =2) (8570/8572 =2) (8574 =2) (8576 =2) (8012/8014 =3) (8021 =3) (8034 =3) (8082 =3) (8003/8004 =4) (8022 =4) (8030/8033 =4) (8035 =4) (8200 =4) (8240/8241 =4) (8243/8246 =4) (8249 =4) (8430 =4) (8525 =4) (8560 =4) (8562 =4) (8575 =4) (8000/8001 =5) (8010 =5) (8005 =5) (8011 =5) (8020 =5) (8046 =5) (8095 =5) (8124 =5) (8130 =5) (8146 =5) (8160 =5) (8170 =5) (8230/8231 =5) (8247 =5) (8263 =5) (8312 =5) (8340/8341 =5) (8350 =5) (8370 =5) (8441 =5) (8460 =5) (8500/8501 =5) (8510 =5) (8524 =5) (8530 =5) (8551 =5) (8580/9999 =5) ,gen (Histologygroup)
label define Histologygroup 0 "Squamous Cell Carcinoma" 1 "Small Cell Carcinoma" 2 "Adenocarcinoma" 3 "Large Cell Carcinoma" 4 "Other Specified Carcinoma" 5 "Unspecified Carcinoma"
label values Histologygroup Histologygroup

Calandra

Simple loop question

$
0
0
Dear Listers,

I would like to ask you a very simple question regarding loop.

I want to make a variable for each of countries listed in my data. As there are many items, I would like to automate this process by using loop function.

Code:
global X 1 2 3 4 5 6 7 8 9 10 11 

foreach x of global X {

foreach y in 22.26    33.98    16.6    30.16    21.06    11.36    36.29    46.28    64.31    110.56    36.83 {



gen unit_physio_`x'= `y'

}
}

This is my code. In fact what I want is unit_physio_1 = 22.36, unit_physio_2=33.98, unit_physio_3=16.6

However, all of them are 22.26 after I run this code.

I would be happy if someone helps me with this problem.

Many thanks in advance.

Kind regards,

kim

a new variable based on two existing variables

$
0
0
Hi,

I'm using SHARE dataset where there is a dummy variable for people having played chess/cards in the previous year (ac035d10) and another one for people having played sudoku/puzzles in the previous year (ac035d9).
I want to generate a new dummy variable "edu_inf" (people involved in informal learning activities in the previous year) based on the two existing variables.
Obviously some people could have played both chess/cards and sudoku/puzzles in the previous year.
How can I generate in STATA this new variable?


How to solve autocorrelation and hetero ?

$
0
0
I using xtserial and xttest3
What should I do to deal with autocorrelation and hetero ?
My data have 9 countries and 10-40 quarters ( T > N )

Proportional odd assumption for ordered logit regression in panel data

$
0
0
Respected sir, I am using xtologit command for ordered logit regression for panel data. My dependent variable has three categories. I want to check proportional odds assumption. I have tried a lot but couldn't get right command. Please help me..
Thank you
Priya

Extracting a specific part of a string if the string contains an exact syntax

$
0
0
OK, so I'm not explaining this very well but here is what I want to do. I have data as shown below.

The incentive has a maximum of $6000.00, The incentive has a maximum of 5.00 Years
The incentive is 0.48 $/kWh
The incentive is 0.60 $/W, The system size has a minimum of 150.00 kW, The system size has a maximum of 200.00 kW
The incentive is 100.00 %
The incentive is 25.00 %, The incentive has a maximum of $1000.00
The system size has a maximum of 50.00 kW, The incentive is 1.05 $/W


What I want to do is extract, for example, if there is a section of the string that contains "The incentive is (NUMBER I WANT TO EXTRACT) $/kWh", I want to extract that number and generate a new variable with it.

So for example, for the sample data above, I want the following output

The incentive has a maximum of $6000.00, The incentive has a maximum of 5.00 Years .
The incentive is 0.48 $/kWh 0.48
The incentive is 0.60 $/W, The system size has a minimum of 150.00 kW, The system size has a maximum of 200.00 kW 0.60
The incentive is 100.00 % .
The incentive is 25.00 %, The incentive has a maximum of $1000.00 .
The system size has a maximum of 50.00 kW, The incentive is 1.05 $/W .


I've read string help, but I'm still struggling with this code.

Thank you so much for all the help in advance.

How does one put formatted date labels into excel with Putexcel?*

$
0
0
Hi there,

Here's my code:


local vars "date"

foreach pre in `vars'{
putexcel set "tabout/cleaningtest_`pre'.xls", replace
putexcel A1="`pre'" A3=("Sample/Patient Characteristic") B3=("Mean (SD)")
tab `pre', matrow(hnames)
local hlevels = rowsof(hnames)
forvalues i = 1/`hlevels' {
local hal`i' = hnames[`i',1]
local hal_lab`i' : label (`pre') `hal`i''
local x = `i' +2
excelcol `x'
putexcel `r(column)'3=("`hal_lab`i''"),

My aim is to put a series of dates in the colums in the excel spreadsheet. It works perfectly except it the dates are in numeric form and not formatted as they are displayed in Stata.

I am using Stata 14.2

Many thanks in advance.

Binscatter2 - faster, enhanced binned scatterplots in Stata

$
0
0
Hi all,

I wanted to make note of a program that I've had available on GitHub for a while now to generate binned scatterplots in Stata, like Michael Stepner's excellent -binscatter- package. Binscatter2 inherits all of the usage and syntax of binscatter, but runs substantially faster in large datasets by leveraging the functionality of -gtools-. Furthermore, binscatter2 offers a handful of new bells and whistles -- expanded options for saving, fit lines, plotting quantile intervals of the data, etc.

This project is still very much ongoing, and I hope to submit it to SSC very soon.

You can read more it here: https://github.com/mdroste/stata-binscatter2

creating a variable that takes a value of the difference of the last non-missing value and the first non-missing value in panel data

$
0
0
i have panel time series.
I want to create a variable that is the difference between the last non-missing value and the first non-missing value.so in this case for Austria, the value would be 1 - 0 = "1".
I want to know the simplest code. I have been creating a variable that is the last value, and another variable that's the first value, and blah blah but i need to do this for so many variables, so i would that'd be a one liner command or something?

thank you!


"Australia" 193 1960 .
"Australia" 193 1961 .
"Australia" 193 1962 .
"Australia" 193 1963 .
"Australia" 193 1964 .
"Australia" 193 1965 .
"Australia" 193 1966 .
"Australia" 193 1967 .
"Australia" 193 1968 .
"Australia" 193 1969 .
"Australia" 193 1970 .
"Australia" 193 1971 .
"Australia" 193 1972 .
"Australia" 193 1973 .
"Australia" 193 1974 .
"Australia" 193 1975 .
"Australia" 193 1976 .
"Australia" 193 1977 .
"Australia" 193 1978 .
"Australia" 193 1979 .
"Australia" 193 1980 .
"Australia" 193 1981 .
"Australia" 193 1982 .
"Australia" 193 1983 .
"Australia" 193 1984 .
"Australia" 193 1985 .
"Australia" 193 1986 .
"Australia" 193 1987 .
"Australia" 193 1988 .
"Australia" 193 1989 .
"Australia" 193 1990 0
"Australia" 193 1991 -1
"Australia" 193 1992 -1
"Australia" 193 1993 -1
"Australia" 193 1994 -1
"Australia" 193 1995 -1
"Australia" 193 1996 0
"Australia" 193 1997 0
"Australia" 193 1998 0
"Australia" 193 1999 0
"Australia" 193 2000 0
"Australia" 193 2001 1
"Australia" 193 2002 0
"Australia" 193 2003 0
"Australia" 193 2004 0
"Australia" 193 2005 1
"Australia" 193 2006 0
"Australia" 193 2007 0
"Australia" 193 2008 0
"Australia" 193 2009 0
"Australia" 193 2010 -1
"Australia" 193 2011 -1
"Australia" 193 2012 -1
"Australia" 193 2013 0
"Australia" 193 2014 1
"Australia" 193 2015 .
"Australia" 193 2016 .
"Australia" 193 2017 .
"Australia" 193 2018 .
"Australia" 193 2019 .
"Australia" 193 2020 .
"Australia" 193 2021 .
"Austria" 122 1960 .
"Austria" 122 1961 .
"Austria" 122 1962 .
"Austria" 122 1963 .
"Austria" 122 1964 .
"Austria" 122 1965 .
"Austria" 122 1966 .
"Austria" 122 1967 .
"Austria" 122 1968 .
"Austria" 122 1969 .
"Austria" 122 1970 .
"Austria" 122 1971 .
"Austria" 122 1972 .
"Austria" 122 1973 .
"Austria" 122 1974 .
"Austria" 122 1975 .
"Austria" 122 1976 .
"Austria" 122 1977 .
"Austria" 122 1978 .
"Austria" 122 1979 .
"Austria" 122 1980 .
"Austria" 122 1981 .
"Austria" 122 1982 .
"Austria" 122 1983 .
"Austria" 122 1984 .
"Austria" 122 1985 .
"Austria" 122 1986 .
"Austria" 122 1987 .
"Austria" 122 1988 .
"Austria" 122 1989 .
"Austria" 122 1990 0
"Austria" 122 1991 0
"Austria" 122 1992 0
"Austria" 122 1993 0
"Austria" 122 1994 0
"Austria" 122 1995 0
"Austria" 122 1996 0
"Austria" 122 1997 0

renaming using loop

$
0
0
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str43 Q2_8a1 double(Q2_8b1 Q2_8c1 Q2_8d1 Q2_8e1) str43 Q2_8a2    double(Q2_8b2    Q2_8c2    Q2_8d2    Q2_8e2)    str43    Q2_8a3    double(Q2_8b3    Q2_8c3    Q2_8d3    Q2_8e3)
"anil mongar"        24 1 10 1 "" . . . . "" . . . .
"Nir mala"           34 2 21 1 "" . . . . "" . . . .
"Suk mith lepcha"    64 2 21 1 "" . . . . "" . . . .
"pemba lepcha"       50 1  3 1 "" . . . . "" . . . .
"sangay tenzin"      77 1  8 1 "" . . . . "" . . . .
"Nar Badhur"         32 1  7 1 "" . . . . "" . . . .
"Pema Wangmo Lepcha" 29 2  5 1 "" . . . . "" . . . .
"neelam"             40 2 12 2 "" . . . . "" . . . .
"tandin bida"        43 2 10 1 "" . . . . "" . . . .
""                    . .  . . "" . . . . "" . . . .
"Durga"              31 1  8 1 "" . . . . "" . . . .
"nim dem"            23 2 12 1 "" . . . . "" . . . .
""                    . .  . . "" . . . . "" . . . .
"Namgay Dem"         32 2  8 1 "" . . . . "" . . . .
"kumari tamang"      41 1 21 1 "" . . . . "" . . . .
"Phuntsho wangdi"    48 1  9 1 "" . . . . "" . . . .
"Chungku"            27 2  2 1 "" . . . . "" . . . .
"Deoraj Gurung"      43 1 17 1 "" . . . . "" . . . .
""                    . .  . . "" . . . . "" . . . .
"ganga maya ghally"  45 2 21 1 "" . . . . "" . . . .
end
label values Q2_8c1 Q2_8c
label values Q2_8c2 Q2_8c
label values Q2_8c3 Q2_8c
label def Q2_8c 1 "Male", modify
label def Q2_8c 2 "Female", modify
label values Q2_8d1 Q2_8d
label values Q2_8d2 Q2_8d
label values Q2_8d3 Q2_8d
label def Q2_8d 2 "Grade 2", modify
label def Q2_8d 3 "Grade 3", modify
label def Q2_8d 5 "Grade 5", modify
label def Q2_8d 7 "Grade 7", modify
label def Q2_8d 8 "Grade 8", modify
label def Q2_8d 9 "Grade 9", modify
label def Q2_8d 10 "Grade 10", modify
label def Q2_8d 12 "Grade 12", modify
label def Q2_8d 17 "Bachelor's degree", modify
label def Q2_8d 21 "No education", modify
label values Q2_8e1 Q2_8e
label values Q2_8e2 Q2_8e
label values Q2_8e3 Q2_8e
label def Q2_8e 1 "Bhutanese", modify
label def Q2_8e 2 "Indian", modify
Dear All
How can i use loop to rename all variables from Q2_8a as name1,Q2_8b as age1 Q8_8c as sex1 Q8_8d as edu_level1 and Q8_8e nationaliy1 ajnd simultaneously name2, age2, sex2, edu2, nationality2

Question spmap

$
0
0
Hi,

I have a question about spmap. I'm just a beginner with STATA and I want to know how to use spmap for dummy variables.
In my example I want to map the dummy variable ethnicity (1= native & 0= not native) in de resort Paramaribo (capital of Suriname)

These are the steps (my do-file)

spmap mean_etn2 using "Paramaribo_ressort_coord.dta", id(Suriname_ressort_ID) ///
fcolor(Blues) osize(vvthin ..) ///
title("Ethnicity in Paramaribo(adm. level ressort)")

spmap mean_etn2 using "Paramaribo_ressort_coord.dta", id(Suriname_ressort_ID) ///
fcolor(Blues) osize(vvthin ..) ///
title("
Ethnicity
in Paramaribo(adm. level ressort)") ///
clmethod(custom) clbreak(0 1 2)

Now I want to know what the 0, 1 & 2 mean after clbreak and how I can label the legend.
Thanks in advance!
Viewing all 65071 articles
Browse latest View live


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