Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: undefined independent variable x
Posted: May 20, 2013 11:06 AM
 Plain Text 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

Date Subject Author
5/20/13 Kam Hoi
5/20/13 Steven Lord
5/20/13 Curious

© The Math Forum at NCTM 1994-2018. All Rights Reserved.