Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: undefined independent variable x
Replies: 2   Last Post: May 20, 2013 11:09 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: undefined independent variable x
Posted: May 20, 2013 11:06 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"Kam Hoi " <lkhbhjs@hotmail.com> wrote in message
news:knd7h7$cq3$1@newscl01ah.mathworks.com...
> When i type the followings
> function [b, CI, R, Yhat_CI, e]=OSL_robust (X, Y, significance)
> b=inv(X'*X)*(X'*Y)
> cov=inv(X'*X)*(X'*diag(e^2)*X)*inv(X'*X)
> se=(diag(cov))^0.5
> t=b./se
> p=2*(1-cdf('norm',abs(t),0,1))
> R2c=1-(((e'*e)/T)/var(Y,1))
> R2u=1-((e'*e)/Y'*Y)
> AR2c=1-((1/T-K-1)*e'*e)*(var(Y))
> AR2u=1-((1/T-K)*e'*e)/((Y'*Y)/T)
> CIU=(b+1.96*se)
> CIL=(b+1.96*se)
> Yhat=Xb
> Yhat_CI=[X*CIU,X*CIL]
> e=Y-Yhat
>
>
> It comes out that ??? Input argument "X" is undefined.


You ran this code by pressing the green triangle in the Editor or by just
typing:

OSL_robust

didn't you? That calls this function with 0 input arguments, so X is indeed
undefined when MATLAB tries to execute the second line. Call it with three
input arguments, like the functions on this documentation page are being
called with input arguments:

http://www.mathworks.com/help/matlab/learn_matlab/calling-functions.html

BTW, do NOT use inversion to solve the normal equations. Use the backslash
operator instead.

http://www.mathworks.com/help/matlab/math/systems-of-linear-equations.html
http://www.mathworks.com/help/matlab/ref/inv.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.