-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoedit_vs_ado.do
70 lines (63 loc) · 1.45 KB
/
doedit_vs_ado.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// command, harmful
clear
// command, harmless
regress
// constant
c(pi)
// string
"this is a string"
// quoted string is the same
`"this is a quoted string"'
// macro is (badly) called variable name
`this'
// a matrix is an underlined version
matrix aMatrix
// a function is slightly different from a command
normal()
// a command needing a subcommand has grey behind it and doesn't care about
// the harmful/harmless split
import
// a subcommand highlights differently
import excel
// obsolete commands are garish
display in green
// nothing special for numbers or operators (which include parens)
display 4 + (2*9)^14/2
// there are also mata highlights which could be better
mata:
transmorphic vector aFunction(real matrix X, string scalar i, pointer p)
{
pointer scalar foo
complex rowvector bleen
numeric colvector foobar
real matrix ohno
&foo
}
end
// in the Do-file Editor:
// Plain, Keyword, Comment, Function, Macro, String, Compound String, Number, Operator
input x freq
0 2041
1 79
2 22
3 13
4 5
6 1
7 1
8 1
10 1
13 1
end
expand freq
nbreg x, irr
local mu = exp(_b[_cons])
local size = 1/e(alpha)
local prob = `size'/(`size'+`mu')
local scale = (1-`prob')/`prob'
* indirectly via -rgamma- and -rpoisson-:
gen double xg = rgamma(`size',`scale')
replace xg = 1e-6 if xg< 1e-6
gen double xnb = rpoisson(xg)
nbreg xnb, irr
di "size = " 1/e(alpha) ", prob = " ///
1/e(alpha)/(1/e(alpha)+exp(_b[_cons]))