I am trying to use fairlie decomposition technique (I am using mvdcmp as it produces same results as fairlie). However, is the command suitable for panel data as well, and not just cross-sectional data? How can we add time component into the command?
↧
Fairlie decomposition for Panel data
↧
Fairlie decomposition for longitudinal/panel data
I am trying to use fairlie decomposition technique (I am using mvdcmp as it produces same results as fairlie).
However, is the command suitable for panel data as well, and not just cross-sectional data? How can we add time component into the command?
However, is the command suitable for panel data as well, and not just cross-sectional data? How can we add time component into the command?
↧
↧
Confidence interval for Chi-square test
Dear All,
Can someone please help me out, to find out the confidence interval for chi-square test or fisher exact test.
I tried "csi" command but it is only for 2x2 table.
In my data i have around 200 subjects and two categorical variables which is of 3x3 table.
please help me out in finding the CI for the 3x3 table.
Thanks a lot in advance![Smile]()
Can someone please help me out, to find out the confidence interval for chi-square test or fisher exact test.
I tried "csi" command but it is only for 2x2 table.
In my data i have around 200 subjects and two categorical variables which is of 3x3 table.
please help me out in finding the CI for the 3x3 table.
Thanks a lot in advance

↧
Censored Regression
Could anyone please specify the command for censored regression models in STATA.
↧
Problem with Counting observations across firm identifier
Dear Stata users,
Version 16.1
I have 4 variables - firm_id, type_product, type_airframe, and Application of each product.
Each firm can have 1 product or multiple products (firm 1 has 9 types of products). Each product can have 3 different types of the airframe, and can have multiple applications.
* I have 2 questions -
1. how can i create a variable "count" that shows different types of airframes sold by each firm. I have shown a count variable in the sample data
2. How can I create a variable "total_apps" that counts different applications (no repetition) across all the products per firm? OR
How many unique applications are there per firm_id?
I tried to split the variable Application using code
-
split Application, p(
"its a semicolon in the parenthesis"
Got stuck after that. Please see the example using dataex below.
Thanks
***
Version 16.1
I have 4 variables - firm_id, type_product, type_airframe, and Application of each product.
Each firm can have 1 product or multiple products (firm 1 has 9 types of products). Each product can have 3 different types of the airframe, and can have multiple applications.
* I have 2 questions -
1. how can i create a variable "count" that shows different types of airframes sold by each firm. I have shown a count variable in the sample data
2. How can I create a variable "total_apps" that counts different applications (no repetition) across all the products per firm? OR
How many unique applications are there per firm_id?
I tried to split the variable Application using code
-
split Application, p(

Got stuck after that. Please see the example using dataex below.
Thanks
***
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(firm_id type_product) long type_airframe float count str428 Application 1 1 1 2 "Disaster Response; Environmental Research or Monitoring; Firefighting; Hobby; Imaging; Inspection; Mining; Precision Agriculture; Research; Search & Rescue; Survey, Mapping" 1 2 2 2 "Education; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Research" 1 3 2 2 "Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Research; Search & Rescue; Survey, Mapping" 1 4 2 2 "Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Survey, Mapping" 1 5 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Mining; Precision Agriculture; Search & Rescue; Survey, Mapping" 1 6 2 2 "Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Precision Agriculture; Research; Survey, Mapping" 1 7 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Hobby; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Precision Agriculture; Search & Rescue; Survey, Mapping" 1 8 2 2 "Cable Services; Disaster Response; Environmental Research or Monitoring; Imaging; Inspection; Mining; Precision Agriculture; Survey, Mapping" 1 9 2 2 "Cable Services; Imaging; Inspection; Mining; Pipeline Services; Precision Agriculture; Survey, Mapping" 2 1 1 1 "Disaster Response; Environmental Research or Monitoring; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Prototype; Research; Survey, Mapping" 3 1 2 1 "Cable Services; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Pipeline Services; Precision Agriculture; Search & Rescue" 4 1 1 3 "Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Target Acquisition" 4 2 3 3 "Communications; Disaster Response; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Search & Rescue; Survey, Mapping" 4 3 2 3 "Attack, Weapons Delivery; Communications; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Logistics; Patrol, Security; Target Acquisition" 4 4 2 3 "Disaster Response; Firefighting; Imaging; Inspection; Intelligence, Surveillance, Reconnaissance; Observation; Patrol, Security; Search & Rescue; Target Acquisition" 4 5 3 3 "Communications; Disaster Response; Imaging; Intelligence, Surveillance, Reconnaissance; Patrol, Security; Search & Rescue; Survey, Mapping; Target Acquisition" 4 6 1 3 "Attack, Weapons Delivery; Target Acquisition" end label values type_airframe airframe1
↧
↧
Calculating date from day of year and year
Hi there,
I have a day-of-year variable (1 - 366), and year variable (4- digit, i.e. - 2012, etc) and I need to caclulate the specific date but cannot seem to find a way to get it. Any suggestions?
thanks
I have a day-of-year variable (1 - 366), and year variable (4- digit, i.e. - 2012, etc) and I need to caclulate the specific date but cannot seem to find a way to get it. Any suggestions?
thanks

↧
New version of kmest on SSC (AGAIN)
Thanks once again to Kit Baum, a new version of the kmest package (superseding yesterday's version) is now available for download from SSC. In Stata, use the ssc command to do this, or adoupdate if you already have an old version of kmest.
The kmest package is described as below on my website. The new version has been updated to Stata Version 16, and uses data frames.Users of Stata Versions 10 to 15 can still download the old Stata Version 10 version of kmest by typing, in Stata,
net from http://www.rogernewsonresources.org.uk/stata10
and selecting and installing kmest.
Best wishes
Roger
-------------------------------------------------------------------------------------------------
package kmest from http://www.rogernewsonresources.org.uk/stata16
-------------------------------------------------------------------------------------------------
TITLE
kmest: Compute Kaplan-Meier survival probabilities and/or percentiles as estimation results
DESCRIPTION/AUTHOR(S)
kmest is intended for use in a survival time dataset set up by stset.
It computes Kaplan-Meier survival probabilities (as computed by sts
generate) for a list of times (sorted in ascending order), and/or
Kaplan-meier percentiles for a list of percents (srted in ascending
order), and saves them as estimation results, without a variance
matrix. kmest is intended for use with the bootstrap prefix, or
possibly with the jackknife prefix, to create confidence intervals for
the Kaplan-Meier survival probabilities and/or percentiles, possibly
allowing for clustering and/or sampling-probability weighting.
Author: Roger Newson
Distribution-Date: 05march2020
Stata-Version: 16
INSTALLATION FILES (click here to install)
kmest.ado
kmest_p.ado
kmest.sthlp
-------------------------------------------------------------------------------------------------
(click here to return to the previous screen)
The kmest package is described as below on my website. The new version has been updated to Stata Version 16, and uses data frames.Users of Stata Versions 10 to 15 can still download the old Stata Version 10 version of kmest by typing, in Stata,
net from http://www.rogernewsonresources.org.uk/stata10
and selecting and installing kmest.
Best wishes
Roger
-------------------------------------------------------------------------------------------------
package kmest from http://www.rogernewsonresources.org.uk/stata16
-------------------------------------------------------------------------------------------------
TITLE
kmest: Compute Kaplan-Meier survival probabilities and/or percentiles as estimation results
DESCRIPTION/AUTHOR(S)
kmest is intended for use in a survival time dataset set up by stset.
It computes Kaplan-Meier survival probabilities (as computed by sts
generate) for a list of times (sorted in ascending order), and/or
Kaplan-meier percentiles for a list of percents (srted in ascending
order), and saves them as estimation results, without a variance
matrix. kmest is intended for use with the bootstrap prefix, or
possibly with the jackknife prefix, to create confidence intervals for
the Kaplan-Meier survival probabilities and/or percentiles, possibly
allowing for clustering and/or sampling-probability weighting.
Author: Roger Newson
Distribution-Date: 05march2020
Stata-Version: 16
INSTALLATION FILES (click here to install)
kmest.ado
kmest_p.ado
kmest.sthlp
-------------------------------------------------------------------------------------------------
(click here to return to the previous screen)
↧
PSM with psmatch2 and xtreg
Hello everyone,
I'm trying to do a difference in difference regression on matched data. However, I cannot find a proper post where there is a clear explanation on how to do a PSM with panel data.
Can you give me some tips? Is it possible with psmatch2? Is it necessary to reshape the data into long (but how?)?
kind regards
Pieter
I'm trying to do a difference in difference regression on matched data. However, I cannot find a proper post where there is a clear explanation on how to do a PSM with panel data.
Can you give me some tips? Is it possible with psmatch2? Is it necessary to reshape the data into long (but how?)?
kind regards
Pieter
↧
Panel data
Hello everyone!
My name is Tobi and i want to ask you to help me.
In my panel data a RE model was chosen as the best model than a FE model and Pooled regression model.
I've conducted tests on autocorrelation, heteroskedasticity and serial correlation.
and results showed I had these problems.
I decided to use robust standard errors but then my control variables became insignificant !
could someone please advise as to why that is happening ?
My name is Tobi and i want to ask you to help me.
In my panel data a RE model was chosen as the best model than a FE model and Pooled regression model.
I've conducted tests on autocorrelation, heteroskedasticity and serial correlation.
and results showed I had these problems.
I decided to use robust standard errors but then my control variables became insignificant !
could someone please advise as to why that is happening ?
↧
↧
Test for Poolability
Hello!
My name is Evgeny and i ask you to help me to understand what is the Poolability test in stata.
A professor from my university uses this method of estimation.
I've tried to ask her about her estimation, but she did not answer clear.
My name is Evgeny and i ask you to help me to understand what is the Poolability test in stata.
A professor from my university uses this method of estimation.
I've tried to ask her about her estimation, but she did not answer clear.
↧
Esttab with hypothesis testing in regression table
Hi All,
My dataset resembles the following:
In this table, I have a variable y, and x along with 3 lags, defined over the time variable, year. What I wish to do, is to run 3 regressions, all the while storing the estimates: i) y on x and its first lag, ii) y on x and its first and second lag, and iii) y on x, its first, second and third lag. Thereafter, I would like to produce this as a latex file (using the esttab command), but at the bottom of each column corresponding to the different regression, I wish to run a joint F-test of the sum of each of the coefficients that appear in that regression equalling 0. So, in principle, I wish to do something like this:
Something seem to be amiss here, as I am not getting the desired output. Any help on this is much appreciated.
My dataset resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(year y x lagx lag2x lag3x) 1999 2 1 . . . 2000 3 2 1 . . 2001 2 1 2 1 . 2002 3 3 1 2 1 2003 3 2 3 1 2 2004 2 43 2 3 1 2005 1 1 43 2 3 end
Code:
****First Regresion*** eststo: reg y x lagx esttab using "table1.tex", scalar(F) varwidth(25) keep(x lagx lag2x) star(+ 0.15 * 0.10 ** 0.05 *** 0.01) p label replace lincomest x+lagx esttab using table1.tex, append coeflabel((1) "beta1+beta2=0") /// f collabels(none) gaps plain nomtitles /// refcat((1) "\textit{Joint Hypothesis Tests}", nolabel) starlevel(* 0.10 ** 0.05 *** 0.01) /// cells( b(star fmt(3)) se(par fmt(3)) ) /// noobs ***Second Regression*** eststo: reg y x lagx lag2x esttab using "table1.tex", scalar(F) varwidth(25) keep(x lagx lag2x) star(+ 0.15 * 0.10 ** 0.05 *** 0.01) p label append lincomest x+lagx+lag2x esttab using table1.tex, append coeflabel((1) "beta1+beta2+beta3=0") /// f collabels(none) gaps plain nomtitles /// refcat((1) "\textit{Joint Hypothesis Tests}", nolabel) starlevel(* 0.10 ** 0.05 *** 0.01) /// cells( b(star fmt(3)) se(par fmt(3)) ) /// noobs ***Third Regression*** eststo: reg y x lagx lag2x lag3x esttab using "table1.tex", scalar(F) varwidth(25) keep(x lagx lag2x) star(+ 0.15 * 0.10 ** 0.05 *** 0.01) p label append lincomest x+lagx+lag2x+lag3x esttab using table1.tex, append coeflabel((1) "beta1+beta2+beta3+beta4=0") /// f collabels(none) gaps plain nomtitles /// refcat((1) "\textit{Joint Hypothesis Tests}", nolabel) starlevel(* 0.10 ** 0.05 *** 0.01) /// cells( b(star fmt(3)) se(par fmt(3)) ) /// noobs
↧
binary_mediation command
Hello,
Using Stata 16, I am trying to run an existing do-file again in which I used the binary_mediation command.
Unfortunately, the command is no longer working. The following error occurs:
binary_mediation, dv(REG) mv(IPC) iv(sz3) cv(rATT sz2 sz1)
command binary_mediation is unrecognized
r(199);
Also using help or search functions do not lead to any results.
Is the binary_mediation command still existing?
Or, if not, is there an alternative way of calculating binary mediation using Stata 16?
Many thanks in advance
Best regards
Marie
Using Stata 16, I am trying to run an existing do-file again in which I used the binary_mediation command.
Unfortunately, the command is no longer working. The following error occurs:
binary_mediation, dv(REG) mv(IPC) iv(sz3) cv(rATT sz2 sz1)
command binary_mediation is unrecognized
r(199);
Also using help or search functions do not lead to any results.
Is the binary_mediation command still existing?
Or, if not, is there an alternative way of calculating binary mediation using Stata 16?
Many thanks in advance
Best regards
Marie
↧
MLEAA Mixed Logit with Infered and Stated Attribute Non Attendance
Hi all.
I m looking for the routine to estimate mixed logit with both specific individual characteristics and inferred/stated attribute non-attendance.
I am dealing with DCE data. At the end of my design I asked respondant with Lickert scale on each attribute. I asked them too on some individual characteristics.
I used tow routines (mixlogit and eaalogit) to estimate separatly mixed logit and inferred attribute non-attendance.
I m looking for the routine meaalogit developped by HOLE (2013).
Thank you verry much for your help.
I m looking for the routine to estimate mixed logit with both specific individual characteristics and inferred/stated attribute non-attendance.
I am dealing with DCE data. At the end of my design I asked respondant with Lickert scale on each attribute. I asked them too on some individual characteristics.
I used tow routines (mixlogit and eaalogit) to estimate separatly mixed logit and inferred attribute non-attendance.
I m looking for the routine meaalogit developped by HOLE (2013).
Thank you verry much for your help.
↧
↧
Help with Quantile comparison
Good afternoon,
Thanks for the support and for welcoming me into this community.
As an assignment I am supposed to replicate the creation of a variable in Stata, which represents the probability a wife earns more than her husband, as per method used in the paper.
To fulfill the assigment we split the sample into 72 different groups based in demographic characterics. For each of those 72 different groups we have to find 10 quantiles of logarithmetic household income for the wife, and we have to find the average for each quantile.
The average of logarithmetic for the wage of the quantile is then compared to the logarithmetic of the individual salary of each man in the demographic function,
PrWifeEarnsMorei = 1/n SUM (1) if average quantile of wife salary > ln husband incomei
I have no idea in how I can replicate this variable.
I have done the quantiles and the individual husband for the salary but I have no idea in how to do the sum
. gen quant=.
forvalues i=1/72 {
capture drop xq
xtile xq=REND_MENS_TOT if GRUP_DEMO_WF==`i', nq(10)
replace quant=xq if GRUP_DEMO_WF==`i'
}
. egen SAL_MED_WIF_QUANT = mean(REND_MENS_TOT), by(quant)
. egen LN_SAL_MED_WIF_QUANT = log (SAL_MED_WIF_QUANT)
. egen LN_SAL_HOMEM = log (REND_MENS_TOT) if (SEXO==1 & ESTADO_CIVIL==1 & VIVE_C_CONJ==1 & IDADE_ANOS >=18 & IDADE_ANOS <= 65)
I then have to compare LN_SAL_HOMEM as husband income, for each demographic group (GRUP_DEMO) with the average logarithmetic income of each of the 10 different quantile. I then have to sum all of the quantiles that have a larger average income, and divide by the total number of quantiles (10 in this case), to form this new variable PrWifeEarnMore.
I am desperate as I have no idea in how I can accomplish this feat.
Thanks for the support and for welcoming me into this community.
As an assignment I am supposed to replicate the creation of a variable in Stata, which represents the probability a wife earns more than her husband, as per method used in the paper.
To fulfill the assigment we split the sample into 72 different groups based in demographic characterics. For each of those 72 different groups we have to find 10 quantiles of logarithmetic household income for the wife, and we have to find the average for each quantile.
The average of logarithmetic for the wage of the quantile is then compared to the logarithmetic of the individual salary of each man in the demographic function,
PrWifeEarnsMorei = 1/n SUM (1) if average quantile of wife salary > ln husband incomei
I have no idea in how I can replicate this variable.
I have done the quantiles and the individual husband for the salary but I have no idea in how to do the sum
. gen quant=.
forvalues i=1/72 {
capture drop xq
xtile xq=REND_MENS_TOT if GRUP_DEMO_WF==`i', nq(10)
replace quant=xq if GRUP_DEMO_WF==`i'
}
. egen SAL_MED_WIF_QUANT = mean(REND_MENS_TOT), by(quant)
. egen LN_SAL_MED_WIF_QUANT = log (SAL_MED_WIF_QUANT)
. egen LN_SAL_HOMEM = log (REND_MENS_TOT) if (SEXO==1 & ESTADO_CIVIL==1 & VIVE_C_CONJ==1 & IDADE_ANOS >=18 & IDADE_ANOS <= 65)
I then have to compare LN_SAL_HOMEM as husband income, for each demographic group (GRUP_DEMO) with the average logarithmetic income of each of the 10 different quantile. I then have to sum all of the quantiles that have a larger average income, and divide by the total number of quantiles (10 in this case), to form this new variable PrWifeEarnMore.
I am desperate as I have no idea in how I can accomplish this feat.
↧
bys (var1): asdoc tabstat (var2), replace
When using "asdoc tabstat (var1), stat(mean sd) by(var2), replace", not every option is displayed (i.e. the full range from 0 to 10) but only the both extremes (i.e. 0 and 10). How can I adjust this correctly.
Thank you very much!
Result in stata:
![]()
Result with asdoc:
Descriptive statistics - by( Q14_1)
Thank you very much!
Result in stata:
Result with asdoc:
Descriptive statistics - by( Q14_1)
Q14_6 | |
0. Fully oppose | 4.75 |
10. Fully in favour | 7.64 |
↧
Panel data interpretation
Hi , for my dissertation I am looking at how ESG scores leads to increases in Corporate financial performance.My data is composed of 50 firms in 8 years
1.) i Set my data to panel data
Array
2) I then ran fixed effects and random effects followed by the hausman test and got the following results
Array
The results suggest that random effects model is suitable , am i Correct ?
3.) my fixed effects results as follows
Array
4) Then to account for heteroskedasticity , i use clustered robust standard errors
Array
But now my ESG score variable has decreased significantly , I am not sure what implication this has on my hypothesis that ESG scores affect Tobinsq measure ?
are you able to advise thank you very much
1.) i Set my data to panel data
Array
2) I then ran fixed effects and random effects followed by the hausman test and got the following results
Array
The results suggest that random effects model is suitable , am i Correct ?
3.) my fixed effects results as follows
Array
4) Then to account for heteroskedasticity , i use clustered robust standard errors
Array
But now my ESG score variable has decreased significantly , I am not sure what implication this has on my hypothesis that ESG scores affect Tobinsq measure ?
are you able to advise thank you very much
↧
cnsreg does not allow me to test for heteroskedasticity or autocorrelation
Dear Stata users,
I encounter a problem when trying to run cnsreg with several restrictions. An example of my data is shown below.
The first couple of restrictions are linear as shown below. These linear restrictions are necessary since Fixed Effects are interpreted.
Another couple of restrictions is dropping the constant and enforcing to keep collinear variables. Both restrictions must be enforced since I must estimate each Fixed Effect. If a Fixed Effect were dropped, then results couldn't be interpreted.
An assumption in the error structure is homoskedasticity and correlation between observations. The tests I am using are described below in code format. However, when I run either test, the following problem appears: estat [test name] not valid. I must point out that the problem is not there when I try the reg command, but I am unable to enforce all my restrictions.
Could you help me figurate out what I am doing wrong?
Thanks!
I encounter a problem when trying to run cnsreg with several restrictions. An example of my data is shown below.
Code:
* Data Example clear input float dep_value double contiguity float(dist_1 dist_2 dist_3 dist_4 dist_5 dist_6) -12.979575 0 0 1 0 0 0 0 -2.756527 1 1 0 0 0 0 0 -2.5877166 1 1 0 0 0 0 0 -3.820597 0 1 0 0 0 0 0 -7.575688 0 0 0 0 0 1 0 . 0 0 1 0 0 0 0 -7.340847 0 0 1 0 0 0 0 -6.870379 0 1 0 0 0 0 0 end
Code:
constraint 1 EXPO_FE1 + EXPO_FE2 + EXPO_FE3 + EXPO_FE4 + EXPO_FE5 + EXPO_FE6 + EXPO_FE7 + EXPO_FE8 + EXPO_FE9 + EXPO_FE10 + EXPO_FE11 + EXPO_FE12 + EXPO_FE13 + EXPO_FE14 + EXPO_FE15 + EXPO_FE16 + EXPO_FE17 + EXPO_FE18 = 0 constraint 2 IMPO_FE1 + IMPO_FE2 + IMPO_FE3 + IMPO_FE4 + IMPO_FE5 + IMPO_FE6 + IMPO_FE7 + IMPO_FE8 + IMPO_FE9 + IMPO_FE10 + IMPO_FE11 + IMPO_FE12 + IMPO_FE13 + IMPO_FE14 + IMPO_FE15 + IMPO_FE16 + IMPO_FE17 + IMPO_FE18 = 0
Code:
cnsreg dep_value contiguity dist_* EXPO_FE* IMPO_FE*, constraints(1-2) nocons collinear
Code:
estat imtest, white estat hettest estat durbinalt
Could you help me figurate out what I am doing wrong?
Thanks!
↧
↧
Difference-in-Differences per country
Dear Stata community,
I'm working with a panel data set of countries in Stata where I want to test how a market reform impacted certain economic variables. I would like to run a difference-in-differences estimation for each country in the panel data (14 countries).
Currently, I use the following command:
where type refers to whether the observation is in the treatment or control group (binary) and period whether the observation is in the treatment or control period (binary). However, this command runs the estimation on all panels.
Is there a way to use a command that performs the difference-in-differences estimation for each of my country in the panel data? Of course, I'd also be open to use the "built-in" commands instead of the user-written diff command.
Many thanks!
Nick
I'm working with a panel data set of countries in Stata where I want to test how a market reform impacted certain economic variables. I would like to run a difference-in-differences estimation for each country in the panel data (14 countries).
Currently, I use the following command:
Code:
diff econ_var, t(type) p(period)
Is there a way to use a command that performs the difference-in-differences estimation for each of my country in the panel data? Of course, I'd also be open to use the "built-in" commands instead of the user-written diff command.
Many thanks!
Nick
↧
ttest with only one var and conditions
Dear all.
I cannot give you the data but my problem should be quite simple to understand.
I'm working with medical data and I have a variable for the diagnostics (categorical variable). I also have a variable for a reimbursement procedure (also a categorical variable).
Additionally, I have a value for total costs (let’s say in USD).
Each of my IDs have these three values.
I'm trying to see if the mean of my total costs for the diagnostics is equal to the mean of total costs for the corresponding reimbursement procedure.
In other terms I want the null hypothesis:
H0: mean(total costs for reimbursement code 1) = mean(total costs for diagnostic code 5).
Of course a command like that doesn't work on STATA, but it's to illustrate better:
ttest (total_costs if reim_code==1) == (total_costs if diag_code==5)
I tried many things but can't find anything that worked.
Thank you very much for your help.
Alejandro
I cannot give you the data but my problem should be quite simple to understand.
I'm working with medical data and I have a variable for the diagnostics (categorical variable). I also have a variable for a reimbursement procedure (also a categorical variable).
Additionally, I have a value for total costs (let’s say in USD).
Each of my IDs have these three values.
I'm trying to see if the mean of my total costs for the diagnostics is equal to the mean of total costs for the corresponding reimbursement procedure.
In other terms I want the null hypothesis:
H0: mean(total costs for reimbursement code 1) = mean(total costs for diagnostic code 5).
Of course a command like that doesn't work on STATA, but it's to illustrate better:
ttest (total_costs if reim_code==1) == (total_costs if diag_code==5)
I tried many things but can't find anything that worked.
Thank you very much for your help.
Alejandro
↧
Cannot add axis scale without smashing last catplot in graph combine
Array I am attempting to combine catplot graphs which have a common categorical response. When I include an axis on the last graphic (omitting ysc(off) in the last catplot code for q14_r1), it collapses the graphic and I am unable to adjust this.
If I do not include an axis in the last graphic (including ysc(off) in the last catplot code for q14_r1), I am unable to add one in the Stata graph editor. I have tried both grc1leg and gr combine. Please see my sample data and code below.
If I do not include an axis in the last graphic (including ysc(off) in the last catplot code for q14_r1), I am unable to add one in the Stata graph editor. I have tried both grc1leg and gr combine. Please see my sample data and code below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(q13_r3 q13_r2 q12_r1 q12_r2 q14_r1) 3 3 3 3 5 1 1 2 2 1 4 3 4 4 4 5 5 4 4 3 4 3 4 4 4 4 2 3 4 2 3 4 2 3 2 3 4 3 4 2 4 4 4 4 3 2 2 3 3 2 3 1 5 3 3 3 4 3 4 4 4 4 3 3 2 5 3 5 4 1 4 4 4 4 4 3 3 2 4 4 4 4 4 4 3 3 4 4 4 3 4 4 3 3 3 4 4 3 4 3 3 5 3 4 4 3 5 5 5 1 5 4 2 3 1 4 4 2 2 5 3 3 3 3 2 5 5 5 5 1 4 4 5 5 5 4 4 3 3 1 3 4 4 3 2 3 5 2 4 1 4 4 4 4 3 2 2 2 2 2 5 5 5 5 1 4 5 4 5 2 4 4 4 4 3 5 5 5 5 5 5 5 5 5 4 3 4 4 4 2 4 2 2 2 4 5 5 4 4 3 2 2 4 3 3 2 3 3 4 1 3 1 2 3 4 4 2 3 3 1 5 4 4 4 1 3 3 4 4 2 1 1 1 4 5 4 3 2 2 4 5 1 3 2 2 4 4 4 4 3 4 4 4 4 2 3 4 4 4 3 1 1 1 1 5 4 3 4 4 4 4 3 4 4 5 4 4 4 3 1 5 3 3 3 3 2 3 4 4 4 4 1 3 3 5 . . . . . 1 3 2 4 3 5 5 4 4 1 4 5 5 5 5 4 4 5 4 3 4 4 4 4 2 3 4 4 3 2 4 5 4 5 2 4 4 5 5 3 5 4 4 4 3 4 4 4 4 3 5 5 5 5 4 5 4 5 4 4 4 4 3 3 3 4 4 3 4 3 4 1 4 5 4 3 1 4 4 3 4 5 4 4 2 4 3 5 5 3 4 4 4 4 5 2 1 2 3 3 4 4 5 4 5 3 2 5 5 3 4 4 4 4 3 4 3 3 3 3 3 5 4 3 3 4 1 3 3 4 4 3 5 4 3 4 2 5 4 4 2 4 4 4 5 3 3 5 5 3 4 2 4 4 2 4 4 4 3 3 5 4 4 4 2 2 2 2 2 2 4 3 4 5 2 3 5 5 5 1 3 3 4 4 5 3 4 4 4 4 . . . . . 3 4 4 4 3 end label values q12_r1 agree_alt label values q12_r2 agree_alt label values q13_r2 agree_alt label values q13_r3 agree_alt label values q14_r1 agree_alt label def agree_alt 1 "Strongly Disagree", modify label def agree_alt 2 "Disagree", modify label def agree_alt 3 "Neutral", modify label def agree_alt 4 "Agree", modify label def agree_alt 5 "Strongly Agree", modify foreach j in q13_r3 q13_r2 q12_r1 q12_r2 { local label : var label `j' catplot `j', percent var1opts(label(labsize(small))) ysc(off) /// ytitle(" ", size(small)) stack graphregion(color(white)) /// title("`label'" , span size(medium) color(black)) /// blabel(bar, pos(inside) format(%4.1f) size(vsmall)) /// l1title("") intensity(25) asyvars /// bar(1, color(maroon) fintensity(inten70)) /// bar(2, color(maroon) fintensity(inten50)) /// bar(3, color(gray) fintensity(inten40)) /// bar(4, color(dkgreen) fintensity(inten50)) /// bar(5, color(dkgreen) fintensity(inten70)) /// legend(off) /// name(g`j', replace) } local x : var label q14_r1 catplot q14_r1, percent var1opts(label(labsize(small))) /// ytitle(" ", size(small)) stack graphregion(color(white)) /// title("`x'" , span size(medium) color(black)) /// blabel(bar, pos(inside) format(%4.1f) size(vsmall)) /// l1title("") intensity(25) asyvars /// bar(1, color(maroon) fintensity(inten70)) /// bar(2, color(maroon) fintensity(inten50)) /// bar(3, color(gray) fintensity(inten40)) /// bar(4, color(dkgreen) fintensity(inten50)) /// bar(5, color(dkgreen) fintensity(inten70)) /// legend(rows(1) stack size(vsmall) order() symplacement(center)) /// name(gq14_r1, replace) grc1leg gq13_r3 gq13_r2 gq12_r1 gq12_r2 gq14_r1, leg(gq14_r1) /// ycommon cols(1) graphregion(margin(large) color(white)) /// imargin(0 0 0 0) gr combine gq13_r3 gq13_r2 gq12_r1 gq12_r2 gq14_r1, colfirst /// cols(1) imargin() title("") /// graphregion(color(white))
↧