Now that we're done with data handling, we're skipping the part about statistical analysis commands (regressions and the like). The next four steps will deal with automation of the analyses. This step is actually a preface to the next three steps which deal with automation. As you know, Stata can run each command separately in the command window. It is also possible to save all the commands in a ".do" file and rerun all of them whenever you like. Since programs tend to run the same commands again and again, we would like to automate some of the commands. It will also help us organize our analysis and report the results in a neat table instead of with the regular text output of Stata. To do that, we will go through steps 5-8.
Don't worry if you don't understand why we're doing what we're doing in this chapter. That will be clearer in the following chapter.
Don't worry if you don't understand why we're doing what we're doing in this chapter. That will be clearer in the following chapter.
The most basic statistical command in Stata is probably summarize. I'm relying on the fact that the reader is familiar with this command. If this is not the case, I think a more basic tutorial will fit you before going through this one.
So, let's say that I run this command (su is an abbreviation for summarize)
Now, what can you do if you want to use one of the statistics, for example, to calculate something with it? Suppose we want to calculate how much is 2 standard deviations. We see how much is one standard deviation (.409255) so we can manually calculate 2 * .409255:
But what happens if we're in a program, or if we want to use a more precise measure of standard error (Stata saves more than 6 figures after the dot)? In a program, we could not write "di 2*.409255". We can, but it will be bad coding. We would have to first run the program, get the standard deviation and then write it in the code. Moreover, if we just slightly change the data in the future, we will need to fix the code itself.
The solution is rather simple. Many commands keep their calculations for later use as scalars, vectors or macros. To see which calculations the summarize command saved, lets run "return list":
See, the command "return list" lists the scalars that the summarize command saves. Summarize, specifically, saves the calculations for the last variable specified (in our case it was just one). Now, we can run in our code, if we want to calculated generally 2 standard deviation of the variable we can simply run two commands:
This way, we didn't use the actual s.d in our command, but rather the r(sd) word. Stata replaced r(sd) with the value saved by the summarize command.
This trick can be done with other commands. Actually with all programs that are in the rclass category. I don't know where the rclass word came from, but I do know that it means that the scalars will be saved in r(something) command.
Another class of commands is the eclass commands. The command regress is one of them. If we will run reg, we can then look for saved values with "ereturn list":
We got the scalars (numbers) that are related to the regression (root MSE, number of observations, F-statistic, R-squared etc.) but also macros (which I personally never use) and most importantly: matrices. One is e(b) which is actually a vector of the coefficients (a matrix of 1 row and 2 columns) , and the other is e(V) which is the coefficients covariance matrix. Let's take a look at them:
And we see, indeed, the coefficients from the regression in e(b). Compare the output of the matrix list e(b) command and the output from the reg command. The e(V) matrix is a bit less self-evident. Remember that the covariance between a variable and itself is its variance. So the coefficient's standard error is actually the square-root of the value it has in the diagonal.
There is, however, a shorter way to reach the coefficient and the standard error. Instead of using the matrices, you can simply refer to the coefficient's value with the _b[] ... thing (I don't know how to call it). In order to get the value of the coefficient of x, put x between the brackets: _b[x] has the coefficient of x from the last regression. So now you can have your program calculate the "effect" of having 3 more rooms and not just one (or just save that number in order to report it in a table later). Also, in order to get the standard error, use _b[]'s brother, which is _se[]. That is:
As long as you didn't run another eclass command, the calculations from the last program will be available for you to use. Once you run the next eclass command (for example, another regression), the saved output will be replaced by the new command's output. The same goes for the rclass commands, but separately. That is, if you run an rclass command, it will not "step on" the eclass command's results, but only the last rclass command's results.
In order to put the results aside for later use (before running the next eclass or rclass command), we will learn how to use macros - in the next chapter.
(Go on to Step #6)
14 comments:
Hi Stata man,
Not sure if this fits in this section, but I have a question about storing log likelihoods to calculate BIC statistics using mi estimate. I'm trying to do
mi estimate, post: regress y x1 x2
mi estimate, cmdok: estat ic
But I receive the error: likelihood information not found in last estimation results
an error occurred when mi estimate executed estat on m=1
I'm not sure if this is the way to go about it, but how do I get a BIC statistics for regressions using multiple imputation? Any advice or suggestions would be most appreciated!
very good information and Inspiring & Interesting.
success always
http://tokoobatbiusasli.blogspot.com
Nice, thanks for an article, a very helpful info, will use it in my work!
You need to check out this service MyPaperHelper , it might help you too!
Thanks for your informative blog!!! Keep on updating your with such awesome information.
R Programming Online Training
awesome post presented by you..your writing style is fabulous and keep update with your blogs.i hope it may help a lot thanks a lot.
C and C++ Training Institute in chennai | C and C++ Training Institute in anna nagar | C and C++ Training Institute in omr | C and C++ Training Institute in porur | C and C++ Training Institute in tambaram | C and C++ Training Institute in velachery
wesome post presented by you..your writing style is fabulous and keep update with your blogs.
AWS training in Chennai
AWS Online Training in Chennai
AWS training in Bangalore
AWS training in Hyderabad
AWS training in Coimbatore
AWS training
Nice Blog!
Facing error while using QuickBooks get instant solution with our QuickBooks experts.Dial +1-855-533-6333 QuickBooks for Mac Support Phone Number.
Nice Blog!
Facing error while using QuickBooks get instant solution with our QuickBooks experts.Dial +1-855-533-6333 QuickBooks Enterprise Support Phone Number Georgia.
DR ISIKOLO has done it again for me after helping me to get my husband back. i want to let the world know about DR ISIKOLO the Great spell caster that brought back my estranded husband to me when i thought all hope was lost. so i contacted him and complied with all he told me to do and indeed, i got the result in 48 hours as he assured me. DR ISIKOLO used his powerful spell to put a smile on my face by bring back my man with his spell, at first i thought i was dreaming when my husband came back to me on her knees begging me to forgive her and accept her back and even since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about DR ISIKOLO because he is a great man. Do you have problems in your relationship? have your partner broke up with you and you still love and want him or her back? Do you have problem with your finance ? or do you need help of any kind then contact DR ISIKOLO today for i give you 100% guarantee that he will help you just as he helped me. DR ISIKOLO email address is: isikolosolutionhome@gmail.com.com or his WhatsApp/Viber him on: +2348133261196.
Website: https://isikololovetemple.com
I thought the physicians said there is no pills or another way for PENIS ENLARGEMENT !!! I am telling you today that Dr Aziba has the product for PENIS ENLARGEMENT and it worked perfectly for me from 3:0 to 11:00 and still counting. Contact Dr Aziba for help to Enlarge your penis. Email him via: Priestazibasolutioncenter@gmail.com and WhatsApp Him on +2348100368288.
*DOCTOR AZIBA ALSO STATES THAT HE HAS THE CURE FOR THE FOLLOWING AND MORE..
*LOW SPERM COUNT CURE.
*HERPES & HEPATITIS CURE.
*PROSTRATE CANCER CURE.
*AUTISM SPECTRUM DISORDER CURE.
*CANCER CURE.
Contact Dr Aziba for help to Enlarge your penis.
Email him via: Priestazibasolutioncenter@gmail.com
WhatsApp Him on +2348100368288.
Recently, there has been a noticeable increase in professional resume services, as those who are perhaps not the best wordsmiths, or who simply don’t have the time or resources to create a professional resume, are hiring executive resume services instead. So find top resume writing services review here
I feel so happy writing this review about Ghost Champion Wizard your can as well hire him today!
My Credit Score was on the poor side and I couldn’t get a house, a car or even a truck for my new business. I Couldn’t get approved for any type of loan until I read a comment about a private programmer online on how he helped some people fix their credit score in the space of three days. I gave it a try and reached out to him and to my greatest surprise he came through. He increased My Credit score and he also topped up my Credit Balance to $280,000 USD. He did it perfectly well and removed all The negative items I had on my credit Score. a lot more, Email: (GHOSTCHAMPIONWIZARD (at) Gmail dot com)
Removing Bad Records from Both Public and Private internet Databases
FOR RECOVERY OF STOLEN BITCOIN / CRYPTOCURRENCY, RECOVERY OF LOST FUNDS FROM SCAMMER.
I want to tell the world about a great man called Dr. Robinson buckler cured my husband and I from Herpes simplex with herbal medicine. My husband and I have was suffering from Herpes simplex for the past four (4) years. We have tried so many solutions with no result. One fateful day while browsing through the internet I saw a testimony of a client who got cured from herpes by Dr. Robinson buckler through herbal medicine so I decided to give a try. A try that changed our life for good. I contacted Dr. Robinson buckler and he sent some herbal medicine to us, which we took for 14 days. It was a great surprise when we went for a test and the test result came out negative., Dr. Robinson buckler brought joy into my family again. His result is 100% guaranteed. certainly the best online. YESS! SO.MUCH.YES. I love this, it’s exactly what i prayed for!.. it’s unbelievable! ....Thank you!! Very well!.. You contact him on his email. [R.buckler11@gmail. com].....
Post a Comment