UNPKG

1.29 kBMarkdownView Raw
1## Regression Models
2
3## Instance Functionality
4
5### ols( endog, exog )
6
7What's the `endog`, `exog`?
8
9Please see:
10
11http://statsmodels.sourceforge.net/stable/endog_exog.html
12
13`ols` use ordinary least square(OLS) method to estimate linear model and return
14a `model`object.
15
16`model` object attribute is vrey like to `statsmodels` result object attribute
17(nobs,coef,...).
18
19The following example is compared by `statsmodels`. They take same result
20exactly.
21
22 var A=[[1,2,3],
23 [1,1,0],
24 [1,-2,3],
25 [1,3,4],
26 [1,-10,2],
27 [1,4,4],
28 [1,10,2],
29 [1,3,2],
30 [1,4,-1]];
31 var b=[1,-2,3,4,-5,6,7,-8,9];
32 var model=jStat.models.ols(b,A);
33
34 // coefficient estimated
35 model.coef // -> [0.662197222856431, 0.5855663255775336, 0.013512111085743017]
36
37 // R2
38 model.R2 // -> 0.309
39
40 // t test P-value
41 model.t.p // -> [0.8377444317889267, 0.15296736158442314, 0.9909627983826583]
42
43 // f test P-value
44 model.f.pvalue // -> 0.3306363671859872
45
46The adjusted R^2 provided by jStat is the formula variously called the 'Wherry Formula',
47'Ezekiel Formula', 'Wherry/McNemar Formula', or the 'Cohen/Cohen Formula', and is the same
48as the adjusted R^2 value provided by R's `summary.lm` method on a linear model.