Re: [julia-users] inverse function error?

2015-06-18 Thread Stefan Karpinski
I think these sample programs may be too big for people to review for you.
If you can pare the problem down to an example that can be posted in an
email, you've more likely to get help.

On Thu, Jun 18, 2015 at 11:11 AM, SG davidhe...@gmail.com wrote:


 Hi All,

 I am a novice to Julia.

 While I am running the attached julia program, I found inverse function
 throws an error?
 However it worked well in Matlab. Can you help me? Many thanks.






Re: [julia-users] inverse function error?

2015-06-18 Thread SG
Thank you, I will cut it down and post it again soon. 

On Thursday, June 18, 2015 at 7:01:16 PM UTC+2, Stefan Karpinski wrote:

 I think these sample programs may be too big for people to review for you. 
 If you can pare the problem down to an example that can be posted in an 
 email, you've more likely to get help.

 On Thu, Jun 18, 2015 at 11:11 AM, SG david...@gmail.com javascript: 
 wrote:


 Hi All, 

 I am a novice to Julia. 

 While I am running the attached julia program, I found inverse function 
 throws an error? 
 However it worked well in Matlab. Can you help me? Many thanks.






[julia-users] inverse function error?

2015-06-18 Thread SG

Hi All, 

I am a novice to Julia. 

While I am running the attached julia program, I found inverse function 
throws an error? 
However it worked well in Matlab. Can you help me? Many thanks.





lag0.jl
Description: Binary data


example1_rev.jl
Description: Binary data
,Inflation
1948Q1,8.4685373161
1948Q2,8.626617999
1948Q3,8.1440129595
1948Q4,4.4294955046
1949Q1,1.3741439494
1949Q2,-0.3184571541
1949Q3,-2.8268277883
1949Q4,-2.1455778394
1950Q1,-1.5009188995
1950Q2,-0.6299318267
1950Q3,2.0302448585
1950Q4,4.2713747474
1951Q1,8.564404428
1951Q2,8.7766211618
1951Q3,6.9045371469
1951Q4,6.3692528033
1952Q1,2.7671832034
1952Q2,2.0598341129
1952Q3,2.7888499122
1952Q4,1.4347768223
1953Q1,0.7667805208
1953Q2,0.8770681093
1953Q3,0.6602463501
1953Q4,0.7214528994
1954Q1,1.2444018028
1954Q2,0.7085627515
1954Q3,-0.0123336831
1954Q4,-0.4969998158
1955Q1,-0.5953695298
1955Q2,-0.5714233563
1955Q3,-0.2364186471
1955Q4,0.3730423224
1956Q1,0.2484968957
1956Q2,1.040558176
1956Q3,1.9967798064
1956Q4,2.5486824224
1957Q1,3.3554485678
1957Q2,3.5488653853
1957Q3,3.4066871969
1957Q4,3.0386359058
1958Q1,3.3975891895
1958Q2,3.2201907795
1958Q3,2.2739125577
1958Q4,1.8952735282
1959Q1,0.8897593789
1959Q2,0.3908295391
1959Q3,0.9636745953
1959Q4,1.4633757762
1960Q1,1.3815336814
1960Q2,1.8085289491
1960Q3,1.34917
1960Q4,1.3863407274
1961Q1,1.4968691888
1961Q2,0.864190176
1961Q3,1.1981665564
1961Q4,0.7027192621
1962Q1,0.8895298851
1962Q2,1.2989361249
1962Q3,1.1946215824
1962Q4,1.2920615567
1963Q1,1.221584666
1963Q2,1.0313480132
1963Q3,1.354969964
1963Q4,1.3836785439
1964Q1,1.4765561298
1964Q2,1.4524194909
1964Q3,1.0684906821
1964Q4,1.2581594652
1965Q1,1.157197342
1965Q2,1.6324043283
1965Q3,1.703064599
1965Q4,1.7686541391
1966Q1,2.3887137264
1966Q2,2.6535371839
1966Q3,3.2186943786
1966Q4,3.5076144993
1967Q1,2.8310334073
1967Q2,2.5340383051
1967Q3,2.672638161
1967Q4,2.9458895144
1968Q1,3.6726867275
1968Q2,4.0377204539
1968Q3,4.3802871796
1968Q4,4.5222348525
1969Q1,4.7574355
1969Q2,5.3559726984
1969Q3,5.3763448222
1969Q4,5.6684644048
1970Q1,6.0407947626
1970Q2,5.8632002691
1970Q3,5.5302092572
1970Q4,5.4489164258
1971Q1,4.7005603833
1971Q2,4.2233004328
1971Q3,4.1815198972
1971Q4,3.4749468134
1972Q1,3.4455972037
1972Q2,3.1754981977
1972Q3,2.98506
1972Q4,3.2787469318
1973Q1,4.0286153005
1973Q2,5.4564162653
1973Q3,6.6084819515
1973Q4,8.0814045156
1974Q1,9.4520220295
1974Q2,10.0246264954
1974Q3,10.8470764802
1974Q4,11.3737145296
1975Q1,10.5601514536
1975Q2,9.1141496524
1975Q3,8.3267392554
1975Q4,7.1247742578
1976Q1,6.1488752919
1976Q2,5.8409562021
1976Q3,5.4391873832
1976Q4,5.0576493324
1977Q1,5.733809
1977Q2,6.5760365936
1977Q3,6.3669012945
1977Q4,6.3852914369
1978Q1,6.2751809522
1978Q2,6.7903858502
1978Q3,7.7169677907
1978Q4,8.5529998348
1979Q1,9.3313407219
1979Q2,10.2132068221
1979Q3,11.0842550124
1979Q4,11.9014257111
1980Q1,13.2844092033
1980Q2,13.4766019843
1980Q3,12.1654819882
1980Q4,11.8132704287
1981Q1,10.6746823258
1981Q2,9.4171278325
1981Q3,10.30302151
1981Q4,9.1541895741
1982Q1,7.3098690177
1982Q2,6.6771299249
1982Q3,5.6560736325
1982Q4,4.3480718817
1983Q1,3.5310773748
1983Q2,3.2497960238
1983Q3,2.4948193598
1983Q4,3.1821722843
1984Q1,4.5215635323
1984Q2,4.3107790453
1984Q3,4.2060230683
1984Q4,4.0705025706
1985Q1,3.5759934668
1985Q2,3.54349422
1985Q3,3.2976804042
1985Q4,3.4528651509
1986Q1,3.058567226
1986Q2,1.6644878559
1986Q3,1.654370283
1986Q4,1.3370400136
1987Q1,2.0178919924
1987Q2,3.6323170112
1987Q3,4.0782275688
1987Q4,4.3112877934
1988Q1,3.8890809076
1988Q2,3.9028252838
1988Q3,4.058790281
1988Q4,4.2160791481
1989Q1,4.5681260458
1989Q2,5.0313056536
1989Q3,4.5990354229
1989Q4,4.5233928496
1990Q1,5.1005116806
1990Q2,4.4815042225
1990Q3,5.4133001112
1990Q4,6.0875081174
1991Q1,5.1260346684
1991Q2,4.7330124911
1991Q3,3.78131252
1991Q4,2.9221047693
1992Q1,2.8525314661
1992Q2,3.0273903908
1992Q3,3.0284841559
1992Q4,3.0745233897
1993Q1,3.1239548982
1993Q2,3.0772639328
1993Q3,2.7783312856
1993Q4,2.7316126201
1994Q1,2.5077516493
1994Q2,2.3545871958
1994Q3,2.81495371
1994Q4,2.5700338975
1995Q1,2.8007430975
1995Q2,3.0484651896
1995Q3,2.6293397742
1995Q4,2.5925391998
1996Q1,2.7458230803
1996Q2,2.7878699172
1996Q3,2.8587881621
1996Q4,3.1800786598
1997Q1,2.9026082931
1997Q2,2.2757823107
1997Q3,2.2006234312
1997Q4,1.8733431887
1998Q1,1.4717383596
1998Q2,1.5708506016
1998Q3,1.5837577681
1998Q4,1.5142017533
1999Q1,1.6731628715
1999Q2,2.0904993849
1999Q3,2.3190134699
1999Q4,2.5860252639
2000Q1,3.2050130283
2000Q2,3.2402290638
2000Q3,3.410158438
2000Q4,3.3855468266
2001Q1,3.3536803016
2001Q2,3.270881533
2001Q3,2.6431185838
2001Q4,1.8576460055
2002Q1,1.224139831
2002Q2,1.3091217531
2002Q3,1.5639915525
2002Q4,2.2284239903
2003Q1,2.9326897095
2003Q2,1.986090497
2003Q3,2.1923532887
2003Q4,1.9820538821
2004Q1,1.8018327826
2004Q2,2.7472637382
2004Q3,2.6400614392
2004Q4,3.3287737866
2005Q1,2.9896677256
2005Q2,2.8815648068
2005Q3,3.7453038493
2005Q4,3.6087353121
2006Q1,3.6081283299
2006Q2,3.8654355154
2006Q3,3.2888060986
2006Q4,1.9297385143

Re: [julia-users] inverse function error?

2015-06-18 Thread SG


#= This line adds functions to take  
   an AR(2) model for US inflation  
=# 
 
using DataFrames 
 
function lag0(x,p) 
 R::Int32=size(x,1) 
 C::Int32=size(x,2) 
 
# Take the first R-p rows of matrix x 
 x1=x[1:(R-p),:] 
 return out=[zeros(p,C); x1] 
 
end 
 
 
#load inflation datatable 
#df=readtable(inflation.csv) 
 
df=DataFrame() 
df[:A]=1:8 
df[:B]=10:17 
 
##
# Way of converting DataArray to Array  #
##
Y=[df[i,2] for i in [1:size(df,1)]] 
 
##  type of (Y) is now Any  
 
 
T=size(Y,1) 
X=[ones(T,1) lag0(Y,1) lag0(Y,2)] 
inv(X'*X)

==

Hi All, 

I am posting again the issue. I found when I create an Array as shown 
above, the type of Array 
changed to Any which is not acceptable for the base Inverse function(an 
error occurred). 
I am wondering why Julia does not assume the type of original data, here in 
the example, Int64.

Many thanks, 






On Thursday, June 18, 2015 at 7:23:16 PM UTC+2, SG wrote:

 Thank you, I will cut it down and post it again soon. 

 On Thursday, June 18, 2015 at 7:01:16 PM UTC+2, Stefan Karpinski wrote:

 I think these sample programs may be too big for people to review for 
 you. If you can pare the problem down to an example that can be posted in 
 an email, you've more likely to get help.

 On Thu, Jun 18, 2015 at 11:11 AM, SG david...@gmail.com wrote:


 Hi All, 

 I am a novice to Julia. 

 While I am running the attached julia program, I found inverse 
 function throws an error? 
 However it worked well in Matlab. Can you help me? Many thanks.






Re: [julia-users] inverse function error?

2015-06-18 Thread Mauro
I don't know why Y does not get its type inferred correctly.  But you
can do:
eltype(df[2])[df[i,2] for i in 1:size(df,1)]

On Thu, 2015-06-18 at 20:21, SG davidhe...@gmail.com wrote:
 #= This line adds functions to take  
an AR(2) model for US inflation  
 =# 
  
 using DataFrames 
  
 function lag0(x,p) 
  R::Int32=size(x,1) 
  C::Int32=size(x,2) 
  
 # Take the first R-p rows of matrix x 
  x1=x[1:(R-p),:] 
  return out=[zeros(p,C); x1] 
  
 end 
  
  
 #load inflation datatable 
 #df=readtable(inflation.csv) 
  
 df=DataFrame() 
 df[:A]=1:8 
 df[:B]=10:17 
  
 ##
 # Way of converting DataArray to Array  #
 ##
 Y=[df[i,2] for i in [1:size(df,1)]] 
  
 ##  type of (Y) is now Any  
  
  
 T=size(Y,1) 
 X=[ones(T,1) lag0(Y,1) lag0(Y,2)] 
 inv(X'*X)

 ==

 Hi All, 

 I am posting again the issue. I found when I create an Array as shown 
 above, the type of Array 
 changed to Any which is not acceptable for the base Inverse function(an 
 error occurred). 
 I am wondering why Julia does not assume the type of original data, here in 
 the example, Int64.

 Many thanks, 






 On Thursday, June 18, 2015 at 7:23:16 PM UTC+2, SG wrote:

 Thank you, I will cut it down and post it again soon. 

 On Thursday, June 18, 2015 at 7:01:16 PM UTC+2, Stefan Karpinski wrote:

 I think these sample programs may be too big for people to review for 
 you. If you can pare the problem down to an example that can be posted in 
 an email, you've more likely to get help.

 On Thu, Jun 18, 2015 at 11:11 AM, SG david...@gmail.com wrote:


 Hi All, 

 I am a novice to Julia. 

 While I am running the attached julia program, I found inverse 
 function throws an error? 
 However it worked well in Matlab. Can you help me? Many thanks.








Re: [julia-users] inverse function error?

2015-06-18 Thread David P. Sanders


El jueves, 18 de junio de 2015, 22:18:48 (UTC+2), Mauro escribió:

 I don't know why Y does not get its type inferred correctly.  But you 


Array comprehensions in global scope never (?) have their types inferred.
You can try putting the array comprehension inside a 
function -- this may (or may not) help.

[Note that to avoid performance problems, you should in fact avoid as much
as possible having *anything* global -- everything should be in a function.]

David.
 

 can do: 
 eltype(df[2])[df[i,2] for i in 1:size(df,1)] 

 On Thu, 2015-06-18 at 20:21, SG david...@gmail.com javascript: wrote: 
  #= This line adds functions to take   
 an AR(2) model for US inflation   
  =# 

  using DataFrames 

  function lag0(x,p) 
   R::Int32=size(x,1) 
   C::Int32=size(x,2) 

  # Take the first R-p rows of matrix x 
   x1=x[1:(R-p),:] 
   return out=[zeros(p,C); x1] 

  end 


  #load inflation datatable 
  #df=readtable(inflation.csv) 

  df=DataFrame() 
  df[:A]=1:8 
  df[:B]=10:17 

  ## 
  # Way of converting DataArray to Array  # 
  ## 
  Y=[df[i,2] for i in [1:size(df,1)]] 

  ##  type of (Y) is now Any   


  T=size(Y,1) 
  X=[ones(T,1) lag0(Y,1) lag0(Y,2)] 
  inv(X'*X) 
  
  == 
  
  Hi All, 
  
  I am posting again the issue. I found when I create an Array as shown 
  above, the type of Array 
  changed to Any which is not acceptable for the base Inverse 
 function(an 
  error occurred). 
  I am wondering why Julia does not assume the type of original data, here 
 in 
  the example, Int64. 
  
  Many thanks, 
  
  
  
  
  
  
  On Thursday, June 18, 2015 at 7:23:16 PM UTC+2, SG wrote: 
  
  Thank you, I will cut it down and post it again soon. 
  
  On Thursday, June 18, 2015 at 7:01:16 PM UTC+2, Stefan Karpinski wrote: 
  
  I think these sample programs may be too big for people to review for 
  you. If you can pare the problem down to an example that can be posted 
 in 
  an email, you've more likely to get help. 
  
  On Thu, Jun 18, 2015 at 11:11 AM, SG david...@gmail.com wrote: 
  
  
  Hi All, 
  
  I am a novice to Julia. 
  
  While I am running the attached julia program, I found inverse 
  function throws an error? 
  However it worked well in Matlab. Can you help me? Many thanks.