Re: regression function
"Michael Creel" <[email protected]> Fri, 7 Sep 2007 09:21:45 +0200
| Newsgroups | gmane.comp.gnu.octave.sources |
|---|---|
| Message-ID | <[email protected]> |
--===============0400525194== Content-Type: multipart/alternative; boundary="----=_Part_135_16542015.1189149706235" ------=_Part_135_16542015.1189149706235 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/7/07, Ghassen El Montasser <[email protected]> wrote: > > hi, > I would like to contribute with the function"regression". This function > like ols functions produces "beta","sigma" "residus" but besides my function > produces the statistics of Student of estimated coefficients and the > associated p values(bilateral or one sided tests). The statistics of Student > and the p-values are very interesting for the significativity decision of > the parameters.I believe with the function "regression" , we shall have > richer output. > That sounds like a good idea to me. The following gives an idea of what I'd like to see in such a function. Cheers, M # Calculates ordinary LS estimator using the Huber-White heteroscedastic # consistent variance estimator. function [b, varb, e, ess] = mc_ols(y, x, names, silent, regularvc) k = columns(x); if nargin < 5 regularvc = 0; endif if nargin < 4 silent = 0; endif if (nargin < 3) || (rows(names) != k) names = 1:k; names = names'; endif [b, sigsq, e] = ols(y,x); xx_inv = inv(x'*x); n = rows(x); ess = e' * e; # Ordinary or het. consistent variance estimate if regularvc varb = xx_inv*sigsq; else varb = HetConsistentVariance(x,e); endif seb = sqrt(diag(varb)); t = b ./ seb; tss = y - mean(y); tss = tss' * tss; rsq = 1 - ess / tss; labels = str2mat("estimate","st.err.", "t-stat.", "p-value"); if !silent printf("\n*********************************************************\n"); printf("OLS estimation results\n"); printf("Observations %d\n",n); printf("R-squared %f\n",rsq); printf("Sigma-squared %f\n",sigsq); p = 2 - 2*t_cdf(abs(t), n - k); results = [b, seb, t, p]; if regularvc printf("\nResults (Ordinary var-cov estimator)\n\n"); else printf("\nResults (Het. consistent var-cov estimator)\n\n"); endif prettyprint(results, names, labels); printf("\n*********************************************************\n"); endif endfunction ------=_Part_135_16542015.1189149706235 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline <br><br><div><span class="gmail_quote">On 9/7/07, <b class="gmail_sendername">Ghassen El Montasser</b> <<a href="mailto:[email protected]">[email protected]</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div>hi,</div> <div>I would like to contribute with the function"regression". This function like ols functions produces "beta","sigma" "residus" but besides my function produces the statistics of Student of estimated coefficients and the associated p values(bilateral or one sided tests). The statistics of Student and the p-values are very interesting for the significativity decision of the parameters.I believe with the function "regression" , we shall have richer output.</div> </blockquote></div><br><br>That sounds like a good idea to me. The following gives an idea of what I'd like to see in such a function. Cheers, M<br><br># Calculates ordinary LS estimator using the Huber-White heteroscedastic <br># consistent variance estimator.<br><br>function [b, varb, e, ess] = mc_ols(y, x, names, silent, regularvc)<br> k = columns(x);<br><br> if nargin < 5 regularvc = 0; endif<br> if nargin < 4 silent = 0; endif <br> if (nargin < 3) || (rows(names) != k)<br> names = 1:k;<br> names = names';<br> endif<br><br> [b, sigsq, e] = ols(y,x);<br><br> xx_inv = inv(x'*x);<br> n = rows(x);<br><br> ess = e' * e; <br><br> # Ordinary or het. consistent variance estimate<br> if regularvc<br> varb = xx_inv*sigsq;<br> else<br> varb = HetConsistentVariance(x,e);<br> endif<br><br> seb = sqrt(diag(varb));<br> t = b ./ seb;<br><br> tss = y - mean(y);<br> tss = tss' * tss;<br> rsq = 1 - ess / tss;<br><br> labels = str2mat("estimate","st.err.", "t-stat.", "p-value");<br> if !silent<br> printf("\n*********************************************************\n");<br> printf("OLS estimation results\n");<br> printf("Observations %d\n",n);<br> printf("R-squared %f\n",rsq);<br> printf("Sigma-squared %f\n",sigsq);<br> p = 2 - 2*t_cdf(abs(t), n - k);<br> results = [b, seb, t, p];<br> if regularvc<br> printf("\nResults (Ordinary var-cov estimator)\n\n"); <br> else<br> printf("\nResults (Het. consistent var-cov estimator)\n\n");<br> endif<br> prettyprint(results, names, labels);<br> printf("\n*********************************************************\n"); <br> endif<br>endfunction<br><br> ------=_Part_135_16542015.1189149706235-- --===============0400525194== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Octave-sources mailing list [email protected] https://www.cae.wisc.edu/mailman/listinfo/octave-sources --===============0400525194==--