Question: least square estimation

I'm trying to do a least square estimation

 

with(plots);

q := array([892., 1012., 1060., 987., 680., 739., 809., 1275., 946., 874., 720., 1096.]);

p := array([1.23, 1.15, 1.10, 1.20, 1.35, 1.25, 1.28, .99, 1.22, 1.25, 1.30, 1.05])

lnx := array([seq([ln(p[t])], t = 1 .. 12)]);

lny := array([seq([ln(p[t])], t = 1 .. 12)]);

pointplot({seq([ln(p[t]), ln(q[t])], t = 1 .. 12)}, symbol = circle, axesfont = [TIMES, 14], labels = [x = ln(p), y = ln(q)])

 

 

linear := CurveFitting:-LeastSquares({[lnx[i], lny[i]],i=1..12 }, k);

 

which gives me an error :

Error, array defined with 2 indices, used with 1 indices

ideally I would also like to plot the dataset & the estimation line..

any ideas?

thanks, Adam

 

Please Wait...